2018-04-17 16:25:19 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Wayne Stambaugh <stambaughw@gmail.com>
|
2024-04-17 18:31:50 +00:00
|
|
|
* Copyright (C) 2018-2024 KiCad Developers, see change_log.txt for contributors.
|
2018-04-17 16:25:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file trace_helpers.h
|
|
|
|
* @brief wxLogTrace helper definitions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _TRACE_HELPERS_H_
|
|
|
|
#define _TRACE_HELPERS_H_
|
|
|
|
|
2023-09-23 12:15:05 +00:00
|
|
|
#include <kicommon.h>
|
2018-11-22 16:24:17 +00:00
|
|
|
#include <wx/arrstr.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
|
2021-11-28 20:50:49 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <map>
|
|
|
|
|
2018-04-17 16:25:19 +00:00
|
|
|
/**
|
|
|
|
* @defgroup trace_env_vars Trace Environment Variables
|
|
|
|
*
|
|
|
|
* wxWidgets provides trace control of debug messages using the WXTRACE environment variable.
|
|
|
|
* This section defines the strings passed to WXTRACE to for debug output control of various
|
|
|
|
* sections of the KiCad code. See the wxWidgets <a href="http://docs.wxwidgets.org/3.0/
|
|
|
|
* group__group__funcmacro__log.html#ga947e317db477914c12b13c4534867ec9"> wxLogTrace </a>
|
|
|
|
* documentation for more information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
///@{
|
|
|
|
/// \ingroup trace_env_vars
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable find debug tracing.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_FIND_ITEM" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceFindItem;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable find and replace debug tracing.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_FIND_REPLACE" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceFindReplace;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable draw panel coordinate debug tracing.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_COORDS" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const kicadTraceCoords;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable wxKeyEvent debug tracing.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_KEY_EVENTS" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const kicadTraceKeyEvent;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
2019-07-27 14:11:41 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable tracing of the tool handling stack.
|
|
|
|
*
|
|
|
|
* Use "KICAD_TOOL_STACK" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const kicadTraceToolStack;
|
2019-07-27 14:11:41 +00:00
|
|
|
|
2021-04-16 16:49:20 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable tracing of the coroutine call stack.
|
|
|
|
*
|
|
|
|
* Use "KICAD_COROUTINE_STACK" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const kicadTraceCoroutineStack;
|
2021-04-16 16:49:20 +00:00
|
|
|
|
2018-04-17 16:25:19 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable auto save feature debug tracing.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_AUTOSAVE" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceAutoSave;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable schematic library memory deletion debug output.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_SCH_LIB_MEM" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceSchLibMem;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
2022-12-15 14:57:53 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable legacy schematic plugin debug output.
|
|
|
|
*
|
|
|
|
* Use "KICAD_SCH_PLUGIN" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceSchPlugin;
|
2022-12-15 14:57:53 +00:00
|
|
|
|
2018-04-17 16:25:19 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable legacy schematic plugin debug output.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_SCH_LEGACY_PLUGIN" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceSchLegacyPlugin;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable GEDA PCB plugin debug output.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_PCB_PLUGIN" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceKicadPcbPlugin;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable GEDA PCB plugin debug output.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_GEDA_PLUGIN" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceGedaPcbPlugin;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flag to enable print controller debug output.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_PRINT" to enable.
|
2018-04-17 16:25:19 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const tracePrinting;
|
2018-04-17 16:25:19 +00:00
|
|
|
|
2018-04-30 19:17:34 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable path and file name debug output.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_PATHS_AND_FILES" to enable.
|
2018-04-30 19:17:34 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const tracePathsAndFiles;
|
2018-04-30 19:17:34 +00:00
|
|
|
|
2018-10-17 19:03:33 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable locale debug output.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_LOCALE" to enable.
|
2018-10-17 19:03:33 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceLocale;
|
2018-10-17 19:03:33 +00:00
|
|
|
|
2022-01-18 12:43:31 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable locale debug output.
|
|
|
|
*
|
|
|
|
* Use "KICAD_FONTS" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceFonts;
|
2022-01-18 12:43:31 +00:00
|
|
|
|
2018-10-17 19:03:33 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable debug output of #BASE_SCREEN and it's derivatives.
|
2018-11-26 16:25:12 +00:00
|
|
|
*
|
|
|
|
* Use "KICAD_SCREEN" to enable.
|
2018-10-17 19:03:33 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceScreen;
|
2018-10-17 19:03:33 +00:00
|
|
|
|
2020-04-17 23:32:29 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable debug output of display positioning logic.
|
|
|
|
*
|
|
|
|
* Use "KICAD_DISPLAY_LOCATION" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceDisplayLocation;
|
2020-04-17 23:32:29 +00:00
|
|
|
|
2018-11-22 16:24:17 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable debug output of zoom-scrolling calculations in
|
2018-11-26 16:25:12 +00:00
|
|
|
* #KIGFX::ZOOM_CONTROLLER and derivatives.
|
|
|
|
*
|
|
|
|
* Use "KICAD_ZOOM_SCROLL" to enable.
|
2018-11-22 16:24:17 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceZoomScroll;
|
2018-11-22 16:24:17 +00:00
|
|
|
|
2019-04-30 17:03:19 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable debug output of symbol library resolver results
|
|
|
|
*
|
|
|
|
* Use "KICAD_SYM_RESOLVE" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceSymbolResolver;
|
2019-04-30 17:03:19 +00:00
|
|
|
|
2020-04-26 20:53:29 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable debug output of schematic symbol sheet path manipulation code.
|
|
|
|
*
|
|
|
|
* Use "KICAD_SCH_SHEET_PATHS" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceSchSheetPaths;
|
2020-04-26 20:53:29 +00:00
|
|
|
|
2020-08-11 23:11:48 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable debug output of environment variable operations.
|
|
|
|
*
|
2020-09-21 11:05:31 +00:00
|
|
|
* Use "KICAD_ENV_VARS" to enable.
|
2020-08-11 23:11:48 +00:00
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceEnvVars;
|
2020-08-11 23:11:48 +00:00
|
|
|
|
2021-03-22 19:34:33 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable debug output of GAL performance profiling.
|
|
|
|
*
|
|
|
|
* Use "KICAD_GAL_PROFILE" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceGalProfile;
|
2021-03-22 19:34:33 +00:00
|
|
|
|
2022-09-12 18:01:48 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable KiCad2Step debug tracing.
|
|
|
|
*
|
|
|
|
* Use "KICAD2STEP" to enable.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API const wxChar* const traceKiCad2Step;
|
2022-09-12 18:01:48 +00:00
|
|
|
|
2024-04-17 18:31:50 +00:00
|
|
|
/**
|
|
|
|
* Flag to enable user interface profile tracing.
|
|
|
|
*
|
|
|
|
* Use "KICAD_UI_PROFILE" to enable.
|
|
|
|
*/
|
|
|
|
extern KICOMMON_API const wxChar* const traceUiProfile;
|
|
|
|
|
2018-04-17 16:25:19 +00:00
|
|
|
///@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Debug helper for printing wxKeyEvent information.
|
|
|
|
*
|
|
|
|
* @param aEvent is the wxKeyEvent to generate the print string from.
|
|
|
|
* @return the wxKeyEvent information.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API wxString dump( const wxKeyEvent& aEvent );
|
2018-04-17 16:25:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Debug helper for printing wxArrayString contents.
|
|
|
|
*
|
|
|
|
* @param aArray is the string array to output.
|
|
|
|
* @return the wxArrayString contents in a formatted string for debugging output.
|
|
|
|
*/
|
2023-09-23 12:15:05 +00:00
|
|
|
extern KICOMMON_API wxString dump( const wxArrayString& aArray );
|
2018-04-17 16:25:19 +00:00
|
|
|
|
2023-09-23 12:15:05 +00:00
|
|
|
class KICOMMON_API TRACE_MANAGER
|
2021-11-28 20:50:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-12-03 16:49:23 +00:00
|
|
|
TRACE_MANAGER() :
|
|
|
|
m_globalTraceEnabled( false ),
|
|
|
|
m_printAllTraces (false )
|
|
|
|
{};
|
2021-11-28 20:50:49 +00:00
|
|
|
~TRACE_MANAGER(){};
|
|
|
|
|
|
|
|
static TRACE_MANAGER& Instance();
|
|
|
|
|
|
|
|
WX_DEFINE_VARARG_FUNC_VOID( Trace, 2, (const wxString, const wxFormatString&), DoTrace,
|
|
|
|
DoTraceUtf8 )
|
|
|
|
|
|
|
|
void DoTrace( const wxString aWhat, const wxChar* aFmt, ... )
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
va_start( argptr, aFmt );
|
|
|
|
traceV( aWhat, aFmt, argptr );
|
|
|
|
va_end( argptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
#if wxUSE_UNICODE_UTF8
|
|
|
|
void DoTraceUtf8( const wxString aWhat, const wxChar* aFmt, ... )
|
|
|
|
{
|
|
|
|
va_list argptr;
|
2022-01-05 19:23:02 +00:00
|
|
|
va_start( argptr, aFmt );
|
2021-11-28 20:50:49 +00:00
|
|
|
traceV( aWhat, aFmt, argptr );
|
|
|
|
va_end( argptr );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-07-15 20:49:01 +00:00
|
|
|
bool IsTraceEnabled( const wxString& aWhat );
|
|
|
|
|
2021-11-28 20:50:49 +00:00
|
|
|
private:
|
|
|
|
void traceV( const wxString& aWhat, const wxString& aFmt, va_list vargs );
|
|
|
|
void init();
|
|
|
|
|
|
|
|
std::map<wxString, bool> m_enabledTraces;
|
|
|
|
bool m_globalTraceEnabled;
|
|
|
|
bool m_printAllTraces;
|
|
|
|
};
|
|
|
|
|
2022-07-15 20:49:01 +00:00
|
|
|
#define KI_TRACE( aWhat, ... ) \
|
|
|
|
if( TRACE_MANAGER::Instance().IsTraceEnabled( aWhat ) ) \
|
2022-07-17 17:42:32 +00:00
|
|
|
{ \
|
|
|
|
TRACE_MANAGER::Instance().Trace( aWhat, __VA_ARGS__ ); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
}
|
2021-11-28 20:50:49 +00:00
|
|
|
|
2018-04-17 16:25:19 +00:00
|
|
|
#endif // _TRACE_HELPERS_H_
|