KiCad PCB EDA Suite
Loading...
Searching...
No Matches
trace_helpers.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018 Wayne Stambaugh <[email protected]>
5 * Copyright (C) 2018-2024 KiCad Developers, see change_log.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30#ifndef _TRACE_HELPERS_H_
31#define _TRACE_HELPERS_H_
32
33#include <kicommon.h>
34#include <wx/arrstr.h>
35#include <wx/event.h>
36#include <wx/string.h>
37
38#include <stdarg.h>
39#include <map>
40
53
59extern KICOMMON_API const wxChar* const traceFindItem;
60
66extern KICOMMON_API const wxChar* const traceFindReplace;
67
73extern KICOMMON_API const wxChar* const kicadTraceCoords;
74
80extern KICOMMON_API const wxChar* const kicadTraceKeyEvent;
81
87extern KICOMMON_API const wxChar* const kicadTraceToolStack;
88
94extern KICOMMON_API const wxChar* const kicadTraceCoroutineStack;
95
101extern KICOMMON_API const wxChar* const traceAutoSave;
102
108extern KICOMMON_API const wxChar* const traceSchLibMem;
109
115extern KICOMMON_API const wxChar* const traceSchPlugin;
116
122extern KICOMMON_API const wxChar* const traceSchLegacyPlugin;
123
129extern KICOMMON_API const wxChar* const traceKicadPcbPlugin;
130
136extern KICOMMON_API const wxChar* const traceGedaPcbPlugin;
137
143extern KICOMMON_API const wxChar* const tracePrinting;
144
150extern KICOMMON_API const wxChar* const tracePathsAndFiles;
151
157extern KICOMMON_API const wxChar* const traceLocale;
158
164extern KICOMMON_API const wxChar* const traceFonts;
165
171extern KICOMMON_API const wxChar* const traceScreen;
172
178extern KICOMMON_API const wxChar* const traceDisplayLocation;
179
186extern KICOMMON_API const wxChar* const traceZoomScroll;
187
193extern KICOMMON_API const wxChar* const traceSymbolResolver;
194
200extern KICOMMON_API const wxChar* const traceSchSheetPaths;
201
207extern KICOMMON_API const wxChar* const traceEnvVars;
208
214extern KICOMMON_API const wxChar* const traceGalProfile;
215
221extern KICOMMON_API const wxChar* const traceKiCad2Step;
222
228extern KICOMMON_API const wxChar* const traceUiProfile;
229
235extern KICOMMON_API const wxChar* const traceGit;
236
237/*
238 * Flag to enable Eagle I/O debug tracing.
239 *
240 * Use "KICAD_EAGLE_IO" to enable.
241 */
242extern KICOMMON_API const wxChar* const traceEagleIo;
243
244/*
245 * Flag to enable Design Block O debug tracing.
246 *
247 * Use "KICAD_EAGLE_IO" to enable.
248 */
249extern KICOMMON_API const wxChar* const traceDesignBlocks;
250
252
259extern KICOMMON_API wxString dump( const wxKeyEvent& aEvent );
260
267extern KICOMMON_API wxString dump( const wxArrayString& aArray );
268
270{
271public:
273 m_globalTraceEnabled( false ),
274 m_printAllTraces (false )
275 {};
277
278 static TRACE_MANAGER& Instance();
279
280 WX_DEFINE_VARARG_FUNC_VOID( Trace, 2, (const wxString, const wxFormatString&), DoTrace,
281 DoTraceUtf8 )
282
283 void DoTrace( const wxString aWhat, const wxChar* aFmt, ... )
284 {
285 va_list argptr;
286 va_start( argptr, aFmt );
287 traceV( aWhat, aFmt, argptr );
288 va_end( argptr );
289 }
290
291#if wxUSE_UNICODE_UTF8
292 void DoTraceUtf8( const wxString aWhat, const wxChar* aFmt, ... )
293 {
294 va_list argptr;
295 va_start( argptr, aFmt );
296 traceV( aWhat, aFmt, argptr );
297 va_end( argptr );
298 }
299#endif
300
301 bool IsTraceEnabled( const wxString& aWhat );
302
303private:
304 void traceV( const wxString& aWhat, const wxString& aFmt, va_list vargs );
305 void init();
306
307 std::map<wxString, bool> m_enabledTraces;
310};
311
312#define KI_TRACE( aWhat, ... ) \
313 if( TRACE_MANAGER::Instance().IsTraceEnabled( aWhat ) ) \
314 { \
315 TRACE_MANAGER::Instance().Trace( aWhat, __VA_ARGS__ ); \
316 } \
317 else \
318 { \
319 }
320
321#endif // _TRACE_HELPERS_H_
va_end(argptr)
traceV(aWhat, aFmt, argptr)
const wxChar va_start(argptr, aFmt)
WX_DEFINE_VARARG_FUNC_VOID(Trace, 2,(const wxString, const wxFormatString &), DoTrace, DoTraceUtf8) void DoTrace(const wxString aWhat
bool m_globalTraceEnabled
std::map< wxString, bool > m_enabledTraces
KICOMMON_API const wxChar *const traceSymbolResolver
Flag to enable debug output of symbol library resolver results.
KICOMMON_API const wxChar *const traceLocale
Flag to enable locale debug output.
KICOMMON_API const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
KICOMMON_API const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
KICOMMON_API const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
KICOMMON_API const wxChar *const traceUiProfile
Flag to enable user interface profile tracing.
KICOMMON_API const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
KICOMMON_API const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.
KICOMMON_API const wxChar *const traceFindItem
Flag to enable find debug tracing.
KICOMMON_API const wxChar *const kicadTraceCoroutineStack
Flag to enable tracing of the coroutine call stack.
KICOMMON_API const wxChar *const traceSchLibMem
Flag to enable schematic library memory deletion debug output.
KICOMMON_API const wxChar *const traceEagleIo
KICOMMON_API const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
KICOMMON_API const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
KICOMMON_API const wxChar *const traceSchPlugin
Flag to enable legacy schematic plugin debug output.
KICOMMON_API const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
KICOMMON_API const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
KICOMMON_API const wxChar *const tracePrinting
Flag to enable print controller debug output.
KICOMMON_API const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.
KICOMMON_API const wxChar *const traceZoomScroll
Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives.
KICOMMON_API const wxChar *const traceGedaPcbPlugin
Flag to enable GEDA PCB plugin debug output.
KICOMMON_API const wxChar *const traceScreen
Flag to enable debug output of BASE_SCREEN and it's derivatives.
KICOMMON_API const wxChar *const traceDesignBlocks
KICOMMON_API const wxChar *const traceFonts
Flag to enable locale debug output.
KICOMMON_API const wxChar *const traceGit
Flag to enable Git debugging output.
KICOMMON_API const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
KICOMMON_API const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
KICOMMON_API const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
#define KICOMMON_API
Definition: kicommon.h:28
KICOMMON_API wxString dump(const wxKeyEvent &aEvent)
Debug helper for printing wxKeyEvent information.