KiCad PCB EDA Suite
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-2021 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 <wx/arrstr.h>
34 #include <wx/event.h>
35 #include <wx/string.h>
36 
37 #include <stdarg.h>
38 #include <map>
39 
50 
58 extern const wxChar* const traceFindItem;
59 
65 extern const wxChar* const traceFindReplace;
66 
72 extern const wxChar* const kicadTraceCoords;
73 
79 extern const wxChar* const kicadTraceKeyEvent;
80 
86 extern const wxChar* const kicadTraceToolStack;
87 
93 extern const wxChar* const kicadTraceCoroutineStack;
94 
100 extern const wxChar* const traceAutoSave;
101 
107 extern const wxChar* const traceSchLibMem;
108 
114 extern const wxChar* const traceSchLegacyPlugin;
115 
121 extern const wxChar* const traceKicadPcbPlugin;
122 
128 extern const wxChar* const traceGedaPcbPlugin;
129 
135 extern const wxChar* const tracePrinting;
136 
142 extern const wxChar* const tracePathsAndFiles;
143 
149 extern const wxChar* const traceLocale;
150 
156 extern const wxChar* const traceScreen;
157 
163 extern const wxChar* const traceDisplayLocation;
164 
171 extern const wxChar* const traceZoomScroll;
172 
178 extern const wxChar* const traceSymbolResolver;
179 
185 extern const wxChar* const traceSchSheetPaths;
186 
192 extern const wxChar* const traceEnvVars;
193 
199 extern const wxChar* const traceGalProfile;
200 
202 
209 extern wxString dump( const wxKeyEvent& aEvent );
210 
217 extern wxString dump( const wxArrayString& aArray );
218 
220 {
221 public:
223  m_globalTraceEnabled( false ),
224  m_printAllTraces (false )
225  {};
227 
228  static TRACE_MANAGER& Instance();
229 
230  WX_DEFINE_VARARG_FUNC_VOID( Trace, 2, (const wxString, const wxFormatString&), DoTrace,
231  DoTraceUtf8 )
232 
233  void DoTrace( const wxString aWhat, const wxChar* aFmt, ... )
234  {
235  va_list argptr;
236  va_start( argptr, aFmt );
237  traceV( aWhat, aFmt, argptr );
238  va_end( argptr );
239  }
240 
241 #if wxUSE_UNICODE_UTF8
242  void DoTraceUtf8( const wxString aWhat, const wxChar* aFmt, ... )
243  {
244  va_list argptr;
245  va_start( argptr, aFmt );
246  traceV( aWhat, aFmt, argptr );
247  va_end( argptr );
248  }
249 #endif
250 
251 private:
252  void traceV( const wxString& aWhat, const wxString& aFmt, va_list vargs );
253  void init();
254 
255  std::map<wxString, bool> m_enabledTraces;
258 };
259 
260 #define KI_TRACE( ... ) TRACE_MANAGER::Instance().Trace( __VA_ARGS__ )
261 
262 #endif // _TRACE_HELPERS_H_
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
const wxChar *const traceZoomScroll
Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives.
const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.
const wxChar *const traceSymbolResolver
Flag to enable debug output of symbol library resolver results.
bool m_globalTraceEnabled
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
va_end(argptr)
const wxChar *const traceGedaPcbPlugin
Flag to enable GEDA PCB plugin debug output.
traceV(aWhat, aFmt, argptr)
const wxChar *const traceScreen
Flag to enable debug output of BASE_SCREEN and it's derivatives.
const wxChar *const tracePrinting
Flag to enable print controller debug output.
const wxChar *const traceSchLegacyPlugin
Flag to enable legacy schematic plugin debug output.
const wxChar *const tracePathsAndFiles
Flag to enable path and file name debug output.
const wxChar *const traceDisplayLocation
Flag to enable debug output of display positioning logic.
const wxChar *const traceGalProfile
Flag to enable debug output of GAL performance profiling.
const wxChar va_start(argptr, aFmt)
wxString dump(const wxKeyEvent &aEvent)
Debug helper for printing wxKeyEvent information.
WX_DEFINE_VARARG_FUNC_VOID(Trace, 2,(const wxString, const wxFormatString &), DoTrace, DoTraceUtf8) void DoTrace(const wxString aWhat
std::map< wxString, bool > m_enabledTraces
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
const wxChar *const traceLocale
Flag to enable locale debug output.
const wxChar *const traceEnvVars
Flag to enable debug output of environment variable operations.
const wxChar *const traceSchLibMem
Flag to enable schematic library memory deletion debug output.
static TRACE_MANAGER & Instance()
const wxChar *const kicadTraceCoroutineStack
Flag to enable tracing of the coroutine call stack.
const wxChar *const traceFindItem
Flag to enable find debug tracing.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
const wxChar * aFmt
const wxChar *const kicadTraceCoords
Flag to enable draw panel coordinate debug tracing.