Added checkbox to Qt debugger menu to control trace logger auto start function on debugger open. Also added code to stop the trace logger on debugger close if it was the debugger who started it in the first place.

This commit is contained in:
harry 2023-02-20 18:36:07 -05:00
parent 25cdc5ade1
commit da05b56cba
5 changed files with 66 additions and 6 deletions

View File

@ -106,6 +106,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
QMenuBar *menuBar; QMenuBar *menuBar;
QSettings settings; QSettings settings;
std::string fontString; std::string fontString;
bool autoStartTraceLogger = false;
g_config->getOption("SDL.DebuggerCpuStatusFont", &fontString); g_config->getOption("SDL.DebuggerCpuStatusFont", &fontString);
@ -210,8 +211,19 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
connect( this, SIGNAL(rejected(void)), this, SLOT(deleteLater(void))); connect( this, SIGNAL(rejected(void)), this, SLOT(deleteLater(void)));
g_config->getOption("SDL.DebugAutoStartTraceLogger", &autoStartTraceLogger);
startedTraceLogger = false;
if (autoStartTraceLogger)
{
// Start Trace Logger for Step Back Function // Start Trace Logger for Step Back Function
if (!FCEUD_TraceLoggerRunning())
{
FCEUD_TraceLoggerStart(); FCEUD_TraceLoggerStart();
startedTraceLogger = true;
}
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
ConsoleDebugger::~ConsoleDebugger(void) ConsoleDebugger::~ConsoleDebugger(void)
@ -223,6 +235,12 @@ ConsoleDebugger::~ConsoleDebugger(void)
saveDisplayViews(); saveDisplayViews();
if (startedTraceLogger && FCEUD_TraceLoggerRunning() )
{
FCEUD_TraceLoggerStop();
startedTraceLogger = false;
}
if ( dbgWin == this ) if ( dbgWin == this )
{ {
dbgWin = NULL; dbgWin = NULL;
@ -822,18 +840,30 @@ QMenuBar *ConsoleDebugger::buildMenuBar(void)
optMenu->addAction(act); optMenu->addAction(act);
// Options -> Load .DEB // Options -> Load .FDB
g_config->getOption( "SDL.AutoLoadDebugFiles", &opt ); g_config->getOption( "SDL.AutoLoadDebugFiles", &opt );
act = new QAction(tr("&Load .DEB on ROM Load"), this); act = new QAction(tr("&Load .FDB on ROM Load"), this);
//act->setShortcut(QKeySequence( tr("F7") ) ); //act->setShortcut(QKeySequence( tr("F7") ) );
act->setStatusTip(tr("&Load .DEB on ROM Load")); act->setStatusTip(tr("&Load .FDB on ROM Load"));
act->setCheckable(true); act->setCheckable(true);
act->setChecked( opt ? true : false ); act->setChecked( opt ? true : false );
connect( act, SIGNAL(triggered(bool)), this, SLOT(debFileAutoLoadCB(bool)) ); connect( act, SIGNAL(triggered(bool)), this, SLOT(debFileAutoLoadCB(bool)) );
optMenu->addAction(act); optMenu->addAction(act);
// Options -> Auto Start Trace Logger
g_config->getOption( "SDL.DebugAutoStartTraceLogger", &opt );
act = new QAction(tr("Auto Start &Trace Logger on Debugger Open"), this);
//act->setShortcut(QKeySequence( tr("F7") ) );
act->setStatusTip(tr("Auto Start &Trace Logger on Debugger Open"));
act->setCheckable(true);
act->setChecked( opt ? true : false );
connect( act, SIGNAL(triggered(bool)), this, SLOT(autoStartTraceLoggerOnOpen(bool)) );
optMenu->addAction(act);
optMenu->addSeparator(); optMenu->addSeparator();
// Symbols // Symbols
@ -2656,6 +2686,13 @@ void ConsoleDebugger::debFileAutoLoadCB( bool value )
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ConsoleDebugger::autoStartTraceLoggerOnOpen( bool value )
{
int autoStartTraceLogger = value;
g_config->setOption("SDL.DebugAutoStartTraceLogger", autoStartTraceLogger);
}
//----------------------------------------------------------------------------
void ConsoleDebugger::changeAsmFontCB(void) void ConsoleDebugger::changeAsmFontCB(void)
{ {
bool ok = false; bool ok = false;

View File

@ -531,6 +531,7 @@ class ConsoleDebugger : public QDialog
int selBmAddrVal; int selBmAddrVal;
bool windowUpdateReq; bool windowUpdateReq;
bool startedTraceLogger;
private: private:
void setRegsFromEntry(void); void setRegsFromEntry(void);
@ -590,6 +591,7 @@ class ConsoleDebugger : public QDialog
void registerNameEnableCB(bool value); void registerNameEnableCB(bool value);
void autoOpenDebugCB( bool value ); void autoOpenDebugCB( bool value );
void debFileAutoLoadCB( bool value ); void debFileAutoLoadCB( bool value );
void autoStartTraceLoggerOnOpen(bool value);
void breakOnBadOpcodeCB(bool value); void breakOnBadOpcodeCB(bool value);
void breakOnNewCodeCB(bool value); void breakOnNewCodeCB(bool value);
void breakOnNewDataCB(bool value); void breakOnNewDataCB(bool value);

View File

@ -1291,6 +1291,25 @@ int FCEUD_TraceLoggerStart(void)
return logging; return logging;
} }
//---------------------------------------------------- //----------------------------------------------------
int FCEUD_TraceLoggerStop(void)
{
if (!logging)
{
return 0;
}
if (traceLogWindow)
{
traceLogWindow->toggleLoggingOnOff();
}
else
{
logging = 0;
msleep(1);
pushMsgToLogBuffer("Logging Finished");
}
return logging;
}
//----------------------------------------------------
int FCEUD_TraceLoggerRunning(void) int FCEUD_TraceLoggerRunning(void)
{ {
return logging; return logging;

View File

@ -200,9 +200,9 @@ protected:
private: private:
public slots: public slots:
void closeWindow(void); void closeWindow(void);
void toggleLoggingOnOff(void);
private slots: private slots:
void updatePeriodic(void); void updatePeriodic(void);
void toggleLoggingOnOff(void);
void autoUpdateStateChanged(int state); void autoUpdateStateChanged(int state);
void logToFileStateChanged(int state); void logToFileStateChanged(int state);
void logRegStateChanged(int state); void logRegStateChanged(int state);
@ -232,6 +232,7 @@ int initTraceLogBuffer(int maxRecs);
void openTraceLoggerWindow(QWidget *parent); void openTraceLoggerWindow(QWidget *parent);
int FCEUD_TraceLoggerStop(void);
int FCEUD_TraceLoggerStart(void); int FCEUD_TraceLoggerStart(void);
int FCEUD_TraceLoggerRunning(void); int FCEUD_TraceLoggerRunning(void);
int FCEUD_TraceLoggerBackUpInstruction(void); int FCEUD_TraceLoggerBackUpInstruction(void);

View File

@ -686,6 +686,7 @@ InitConfig()
config->addOption("SDL.DebuggerBreakOnBadOpcodes", 0); config->addOption("SDL.DebuggerBreakOnBadOpcodes", 0);
config->addOption("SDL.DebuggerBreakOnUnloggedCode", 0); config->addOption("SDL.DebuggerBreakOnUnloggedCode", 0);
config->addOption("SDL.DebuggerBreakOnUnloggedData", 0); config->addOption("SDL.DebuggerBreakOnUnloggedData", 0);
config->addOption("SDL.DebugAutoStartTraceLogger", 0);
// Code Data Logger Options // Code Data Logger Options
config->addOption("autoSaveCDL" , "SDL.AutoSaveCDL", 1); config->addOption("autoSaveCDL" , "SDL.AutoSaveCDL", 1);