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;
QSettings settings;
std::string fontString;
bool autoStartTraceLogger = false;
g_config->getOption("SDL.DebuggerCpuStatusFont", &fontString);
@ -210,8 +211,19 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
connect( this, SIGNAL(rejected(void)), this, SLOT(deleteLater(void)));
// Start Trace Logger for Step Back Function
FCEUD_TraceLoggerStart();
g_config->getOption("SDL.DebugAutoStartTraceLogger", &autoStartTraceLogger);
startedTraceLogger = false;
if (autoStartTraceLogger)
{
// Start Trace Logger for Step Back Function
if (!FCEUD_TraceLoggerRunning())
{
FCEUD_TraceLoggerStart();
startedTraceLogger = true;
}
}
}
//----------------------------------------------------------------------------
ConsoleDebugger::~ConsoleDebugger(void)
@ -223,6 +235,12 @@ ConsoleDebugger::~ConsoleDebugger(void)
saveDisplayViews();
if (startedTraceLogger && FCEUD_TraceLoggerRunning() )
{
FCEUD_TraceLoggerStop();
startedTraceLogger = false;
}
if ( dbgWin == this )
{
dbgWin = NULL;
@ -822,18 +840,30 @@ QMenuBar *ConsoleDebugger::buildMenuBar(void)
optMenu->addAction(act);
// Options -> Load .DEB
// Options -> Load .FDB
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->setStatusTip(tr("&Load .DEB on ROM Load"));
act->setStatusTip(tr("&Load .FDB on ROM Load"));
act->setCheckable(true);
act->setChecked( opt ? true : false );
connect( act, SIGNAL(triggered(bool)), this, SLOT(debFileAutoLoadCB(bool)) );
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();
// 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)
{
bool ok = false;

View File

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

View File

@ -1291,6 +1291,25 @@ int FCEUD_TraceLoggerStart(void)
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)
{
return logging;

View File

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

View File

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