Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
debug.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2011 Bruce Guenter.
4 Copyright (C) 2011 Henrik Andersson.
5 Copyright (C) 2011 johannes hanika.
6 Copyright (C) 2011, 2014, 2016-2017 Tobias Ellinghaus.
7 Copyright (C) 2012 Richard Wonka.
8 Copyright (C) 2016 Roman Lebedev.
9 Copyright (C) 2018 Mario Lueder.
10 Copyright (C) 2020 Pascal Obry.
11 Copyright (C) 2022, 2026 Aurélien PIERRE.
12 Copyright (C) 2022 Martin Bařinka.
13 Copyright (C) 2023, 2025 Alynx Zhou.
14
15 darktable is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 darktable is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with darktable. If not, see <http://www.gnu.org/licenses/>.
27*/
28
39#ifndef DT_COMMON_DEBUG_H
40#define DT_COMMON_DEBUG_H
41
42/* Self-containment: DT_DEBUG_TRACE_WRAPPER expands to dt_vprint() and the
43 * dt_debug_thread_t enumeration, both from common/logging.h. */
44
45#include "common/logging.h"
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51// Use this to re-define a function to trace it, so you don't need to modify all
52// callers. `thread` should be `dt_debug_thread_t`. This requires verbose mode.
53//
54// Example:
55// void dt_dev_pixelpipe_update_history_main_real(dt_develop_t *dev);
56// #define dt_dev_pixelpipe_update_history_main(dev) DT_DEBUG_TRACE_WRAPPER(DT_DEBUG_DEV, dt_dev_pixelpipe_update_history_main_real, (dev))
57#define DT_DEBUG_TRACE_WRAPPER(thread, function, ...) \
58 do { \
59 dt_vprint((thread), "[debug_trace] %s is called from %s at %s:%d\n", \
60 #function, __FUNCTION__, __FILE__, __LINE__); \
61 function(__VA_ARGS__); \
62 } while (0)
63
64// Same, for a function taking no arguments. ISO C wants at least one argument for a
65// variadic macro's `...`, so DT_DEBUG_TRACE_WRAPPER cannot be handed an empty list
66// without relying on a GNU extension.
67#define DT_DEBUG_TRACE_WRAPPER_VOID(thread, function) \
68 do { \
69 dt_vprint((thread), "[debug_trace] %s is called from %s at %s:%d\n", \
70 #function, __FUNCTION__, __FILE__, __LINE__); \
71 function(); \
72 } while (0)
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif // DT_COMMON_DEBUG_H
79
80// clang-format off
81// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
82// vim: shiftwidth=2 expandtab tabstop=2 cindent
83// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
84// clang-format on