add "open cpu window when signaled" debug option

This commit is contained in:
Roy Qu 2021-11-25 10:18:21 +08:00
parent adf001124c
commit 3abbf66251
13 changed files with 365 additions and 334 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,6 @@ Debugger::Debugger(QObject *parent) : QObject(parent)
mWatchModel = new WatchModel(this); mWatchModel = new WatchModel(this);
mRegisterModel = new RegisterModel(this); mRegisterModel = new RegisterModel(this);
mExecuting = false; mExecuting = false;
mUseUTF8 = false;
mReader = nullptr; mReader = nullptr;
mCommandChanged = false; mCommandChanged = false;
mLeftPageIndexBackup = -1; mLeftPageIndexBackup = -1;
@ -401,16 +400,6 @@ void Debugger::notifyAfterProcessWatchVar()
mWatchModel->endUpdate(); mWatchModel->endUpdate();
} }
bool Debugger::useUTF8() const
{
return mUseUTF8;
}
void Debugger::setUseUTF8(bool useUTF8)
{
mUseUTF8 = useUTF8;
}
BacktraceModel* Debugger::backtraceModel() BacktraceModel* Debugger::backtraceModel()
{ {
return mBacktraceModel; return mBacktraceModel;
@ -486,8 +475,8 @@ void Debugger::syncFinishedParsing()
// show command output // show command output
if (pSettings->debugger().showCommandLog() ) { if (pSettings->debugger().enableDebugConsole() ) {
if (pSettings->debugger().showAnnotations()) { if (pSettings->debugger().showDetailLog()) {
for (const QString& line:mReader->fullOutput()) { for (const QString& line:mReader->fullOutput()) {
pMainWindow->addDebugOutput(line); pMainWindow->addDebugOutput(line);
} }
@ -506,6 +495,7 @@ void Debugger::syncFinishedParsing()
if (mReader->signalReceived()) { if (mReader->signalReceived()) {
SignalMessageDialog dialog(pMainWindow); SignalMessageDialog dialog(pMainWindow);
dialog.setOpenCPUInfo(pSettings->debugger().openCPUInfoWhenSignaled());
dialog.setMessage( dialog.setMessage(
tr("Signal \"%1\" Received: ").arg(mReader->signalName()) tr("Signal \"%1\" Received: ").arg(mReader->signalName())
+ "<br />" + "<br />"
@ -1119,9 +1109,9 @@ void DebugReader::runNextCmd()
} }
// if devDebugger.ShowCommandLog or pCmd^.ShowInConsole then begin // if devDebugger.ShowCommandLog or pCmd^.ShowInConsole then begin
if (pSettings->debugger().showCommandLog() ) { if (pSettings->debugger().enableDebugConsole() ) {
//update debug console //update debug console
if (!pSettings->debugger().showAnnotations()) { if (!pSettings->debugger().showDetailLog()) {
emit changeDebugConsoleLastLine(pCmd->command + ' ' + pCmd->params); emit changeDebugConsoleLastLine(pCmd->command + ' ' + pCmd->params);
} else { } else {
emit changeDebugConsoleLastLine(pCmd->command + ' ' + pCmd->params); emit changeDebugConsoleLastLine(pCmd->command + ' ' + pCmd->params);

View File

@ -205,9 +205,6 @@ public:
void notifyBeforeProcessWatchVar(); void notifyBeforeProcessWatchVar();
void notifyAfterProcessWatchVar(); void notifyAfterProcessWatchVar();
bool useUTF8() const;
void setUseUTF8(bool useUTF8);
BacktraceModel* backtraceModel(); BacktraceModel* backtraceModel();
BreakpointModel* breakpointModel(); BreakpointModel* breakpointModel();
bool executing() const; bool executing() const;
@ -247,7 +244,6 @@ private:
bool mExecuting; bool mExecuting;
bool mCommandChanged; bool mCommandChanged;
BreakpointModel *mBreakpointModel; BreakpointModel *mBreakpointModel;
bool mUseUTF8;
BacktraceModel *mBacktraceModel; BacktraceModel *mBacktraceModel;
WatchModel *mWatchModel; WatchModel *mWatchModel;
RegisterModel *mRegisterModel; RegisterModel *mRegisterModel;

View File

@ -49,6 +49,14 @@
#include <widgets/searchdialog.h> #include <widgets/searchdialog.h>
static int findTabIndex(QTabWidget* tabWidget , QWidget* w) {
for (int i=0;i<tabWidget->count();i++) {
if (w==tabWidget->widget(i))
return i;
}
return -1;
}
MainWindow* pMainWindow; MainWindow* pMainWindow;
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
@ -1056,6 +1064,18 @@ void MainWindow::updateDebuggerSettings()
ui->debugConsole->setFont(font); ui->debugConsole->setFont(font);
ui->txtMemoryView->setFont(font); ui->txtMemoryView->setFont(font);
ui->txtLocals->setFont(font); ui->txtLocals->setFont(font);
int idx = findTabIndex(ui->debugViews,ui->tabDebugConsole);
if (idx>=0) {
if (!pSettings->debugger().enableDebugConsole()) {
ui->debugViews->removeTab(idx);
}
} else {
if (pSettings->debugger().enableDebugConsole()) {
ui->debugViews->insertTab(0, ui->tabDebugConsole, tr("Debug Console"));
}
}
} }
void MainWindow::checkSyntaxInBack(Editor *e) void MainWindow::checkSyntaxInBack(Editor *e)
@ -1398,7 +1418,6 @@ void MainWindow::debug()
prepareDebugger(); prepareDebugger();
mDebugger->setUseUTF8(e->fileEncoding() == ENCODING_UTF8 || e->fileEncoding() == ENCODING_UTF8_BOM);
if (!mDebugger->start()) if (!mDebugger->start())
return; return;
mDebugger->sendCommand("-file-exec-and-symbols", QString("\"%1\"").arg(debugFile.filePath().replace('\\','/'))); mDebugger->sendCommand("-file-exec-and-symbols", QString("\"%1\"").arg(debugFile.filePath().replace('\\','/')));
@ -1556,7 +1575,7 @@ void MainWindow::prepareDebugger()
// Clear logs // Clear logs
ui->debugConsole->clear(); ui->debugConsole->clear();
if (!pSettings->debugger().showCommandLog()) { if (!pSettings->debugger().enableDebugConsole()) {
ui->debugConsole->addLine("(gdb) "); ui->debugConsole->addLine("(gdb) ");
} }
ui->txtEvalOutput->clear(); ui->txtEvalOutput->clear();
@ -1927,13 +1946,13 @@ void MainWindow::buildContextMenus()
ui->debugConsole->setContextMenuPolicy(Qt::CustomContextMenu); ui->debugConsole->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->debugConsole,&QWidget::customContextMenuRequested, connect(ui->debugConsole,&QWidget::customContextMenuRequested,
this, &MainWindow::onDebugConsoleContextMenu); this, &MainWindow::onDebugConsoleContextMenu);
mDebugConsole_ShowCommandLog = createActionFor( mDebugConsole_ShowDetailLog = createActionFor(
tr("Show debug logs in the debug console"), tr("Show detail debug logs"),
ui->debugConsole); ui->debugConsole);
mDebugConsole_ShowCommandLog->setCheckable(true); mDebugConsole_ShowDetailLog->setCheckable(true);
connect(mDebugConsole_ShowCommandLog, &QAction::toggled, connect(mDebugConsole_ShowDetailLog, &QAction::toggled,
[this]() { [this]() {
pSettings->debugger().setShowCommandLog(mDebugConsole_ShowCommandLog->isChecked()); pSettings->debugger().setShowDetailLog(mDebugConsole_ShowDetailLog->isChecked());
pSettings->debugger().save(); pSettings->debugger().save();
}); });
mDebugConsole_Copy=createActionFor( mDebugConsole_Copy=createActionFor(
@ -2615,16 +2634,16 @@ void MainWindow::onDebugConsoleContextMenu(const QPoint &pos)
{ {
QMenu menu(this); QMenu menu(this);
bool oldBlock = mDebugConsole_ShowCommandLog->blockSignals(true); bool oldBlock = mDebugConsole_ShowDetailLog->blockSignals(true);
mDebugConsole_ShowCommandLog->setChecked(pSettings->debugger().showCommandLog()); mDebugConsole_ShowDetailLog->setChecked(pSettings->debugger().showDetailLog());
mDebugConsole_ShowCommandLog->blockSignals(oldBlock); mDebugConsole_ShowDetailLog->blockSignals(oldBlock);
menu.addAction(mDebugConsole_Copy); menu.addAction(mDebugConsole_Copy);
menu.addAction(mDebugConsole_Paste); menu.addAction(mDebugConsole_Paste);
menu.addAction(mDebugConsole_SelectAll); menu.addAction(mDebugConsole_SelectAll);
menu.addAction(mDebugConsole_Clear); menu.addAction(mDebugConsole_Clear);
menu.addSeparator(); menu.addSeparator();
menu.addAction(mDebugConsole_ShowCommandLog); menu.addAction(mDebugConsole_ShowDetailLog);
menu.exec(ui->debugConsole->mapToGlobal(pos)); menu.exec(ui->debugConsole->mapToGlobal(pos));
} }
@ -3704,7 +3723,7 @@ void MainWindow::cleanUpCPUDialog()
void MainWindow::onDebugCommandInput(const QString& command) void MainWindow::onDebugCommandInput(const QString& command)
{ {
if (mDebugger->executing()) { if (mDebugger->executing()) {
mDebugger->sendCommand(command,""); mDebugger->sendCommand(command,"", DebugCommandSource::Console);
} }
} }
@ -4854,14 +4873,6 @@ void MainWindow::updateEditorHideTime(QTabWidget* tabWidget) {
} }
} }
static int findTabIndex(QTabWidget* tabWidget , QWidget* w) {
for (int i=0;i<tabWidget->count();i++) {
if (w==tabWidget->widget(i))
return i;
}
return -1;
}
void MainWindow::showHideInfosTab(QWidget *widget, bool show) void MainWindow::showHideInfosTab(QWidget *widget, bool show)
{ {
int idx = findTabIndex(ui->tabInfos,widget); int idx = findTabIndex(ui->tabInfos,widget);

View File

@ -633,7 +633,7 @@ private:
QWidget * mFilesViewToolbar; QWidget * mFilesViewToolbar;
//action for debug console //action for debug console
QAction * mDebugConsole_ShowCommandLog; QAction * mDebugConsole_ShowDetailLog;
QAction * mDebugConsole_Clear; QAction * mDebugConsole_Clear;
QAction * mDebugConsole_Copy; QAction * mDebugConsole_Copy;
QAction * mDebugConsole_Paste; QAction * mDebugConsole_Paste;

View File

@ -506,7 +506,7 @@
<enum>QTabWidget::South</enum> <enum>QTabWidget::South</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View File

@ -2924,24 +2924,24 @@ Settings::Debugger::Debugger(Settings *settings):_Base(settings, SETTING_DEBUGGE
} }
bool Settings::Debugger::showCommandLog() const bool Settings::Debugger::enableDebugConsole() const
{ {
return mShowCommandLog; return mEnableDebugConsole;
} }
void Settings::Debugger::setShowCommandLog(bool showCommandLog) void Settings::Debugger::setEnableDebugConsole(bool showCommandLog)
{ {
mShowCommandLog = showCommandLog; mEnableDebugConsole = showCommandLog;
} }
bool Settings::Debugger::showAnnotations() const bool Settings::Debugger::showDetailLog() const
{ {
return mShowAnnotations; return mShowDetailLog;
} }
void Settings::Debugger::setShowAnnotations(bool showAnnotations) void Settings::Debugger::setShowDetailLog(bool showAnnotations)
{ {
mShowAnnotations = showAnnotations; mShowDetailLog = showAnnotations;
} }
QString Settings::Debugger::fontName() const QString Settings::Debugger::fontName() const
@ -3004,6 +3004,16 @@ void Settings::Debugger::setAutosaveWatches(bool newAutosaveWatches)
mAutosaveWatches = newAutosaveWatches; mAutosaveWatches = newAutosaveWatches;
} }
bool Settings::Debugger::openCPUInfoWhenSignaled() const
{
return mOpenCPUInfoWhenSignaled;
}
void Settings::Debugger::setOpenCPUInfoWhenSignaled(bool newOpenCPUInfoWhenSignaled)
{
mOpenCPUInfoWhenSignaled = newOpenCPUInfoWhenSignaled;
}
bool Settings::Debugger::autosaveBreakpoints() const bool Settings::Debugger::autosaveBreakpoints() const
{ {
return mAutosaveBreakpoints; return mAutosaveBreakpoints;
@ -3046,8 +3056,8 @@ void Settings::Debugger::setOnlyShowMono(bool onlyShowMono)
void Settings::Debugger::doSave() void Settings::Debugger::doSave()
{ {
saveValue("show_command_log", mShowCommandLog); saveValue("enable_debug_console", mEnableDebugConsole);
saveValue("show_annotations", mShowAnnotations); saveValue("show_detail_log", mShowDetailLog);
saveValue("font_name",mFontName); saveValue("font_name",mFontName);
saveValue("only_show_mono",mOnlyShowMono); saveValue("only_show_mono",mOnlyShowMono);
saveValue("font_size",mFontSize); saveValue("font_size",mFontSize);
@ -3058,13 +3068,14 @@ void Settings::Debugger::doSave()
saveValue("skip_custom_lib", mSkipCustomLibraries); saveValue("skip_custom_lib", mSkipCustomLibraries);
saveValue("autosave_breakpoints",mAutosaveBreakpoints); saveValue("autosave_breakpoints",mAutosaveBreakpoints);
saveValue("autosave_watches",mAutosaveWatches); saveValue("autosave_watches",mAutosaveWatches);
saveValue("open_cpu_info_when_signaled",mOpenCPUInfoWhenSignaled);
} }
void Settings::Debugger::doLoad() void Settings::Debugger::doLoad()
{ {
mShowCommandLog = boolValue("show_command_log",true); mEnableDebugConsole = boolValue("enable_debug_console",true);
mShowAnnotations = boolValue("show_annotations",false); mShowDetailLog = boolValue("show_detail_log",false);
mFontName = stringValue("font_name","Consolas"); mFontName = stringValue("font_name","Consolas");
mOnlyShowMono = boolValue("only_show_mono",true); mOnlyShowMono = boolValue("only_show_mono",true);
mFontSize = intValue("font_size",12); mFontSize = intValue("font_size",12);
@ -3075,6 +3086,7 @@ void Settings::Debugger::doLoad()
mSkipCustomLibraries = boolValue("skip_custom_lib",false); mSkipCustomLibraries = boolValue("skip_custom_lib",false);
mAutosaveBreakpoints = boolValue("autosave_breakpoints",true); mAutosaveBreakpoints = boolValue("autosave_breakpoints",true);
mAutosaveWatches = boolValue("autosave_watches",true); mAutosaveWatches = boolValue("autosave_watches",true);
mOpenCPUInfoWhenSignaled = boolValue("open_cpu_info_when_signaled",true);
} }
Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY) Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY)

View File

@ -930,11 +930,11 @@ public:
class Debugger: public _Base { class Debugger: public _Base {
public: public:
explicit Debugger(Settings* settings); explicit Debugger(Settings* settings);
bool showCommandLog() const; bool enableDebugConsole() const;
void setShowCommandLog(bool showCommandLog); void setEnableDebugConsole(bool showCommandLog);
bool showAnnotations() const; bool showDetailLog() const;
void setShowAnnotations(bool showAnnotations); void setShowDetailLog(bool showAnnotations);
bool onlyShowMono() const; bool onlyShowMono() const;
void setOnlyShowMono(bool onlyShowMono); void setOnlyShowMono(bool onlyShowMono);
@ -964,9 +964,12 @@ public:
bool autosaveWatches() const; bool autosaveWatches() const;
void setAutosaveWatches(bool newAutosaveWatches); void setAutosaveWatches(bool newAutosaveWatches);
bool openCPUInfoWhenSignaled() const;
void setOpenCPUInfoWhenSignaled(bool newOpenCPUInfoWhenSignaled);
private: private:
bool mShowCommandLog; bool mEnableDebugConsole;
bool mShowAnnotations; bool mShowDetailLog;
QString mFontName; QString mFontName;
bool mOnlyShowMono; bool mOnlyShowMono;
int mFontSize; int mFontSize;
@ -977,6 +980,7 @@ public:
bool mSkipCustomLibraries; bool mSkipCustomLibraries;
bool mAutosaveBreakpoints; bool mAutosaveBreakpoints;
bool mAutosaveWatches; bool mAutosaveWatches;
bool mOpenCPUInfoWhenSignaled;
// _Base interface // _Base interface
protected: protected:

View File

@ -20,13 +20,14 @@ void DebugGeneralWidget::doLoad()
ui->chkOnlyMono->setChecked(pSettings->debugger().onlyShowMono()); ui->chkOnlyMono->setChecked(pSettings->debugger().onlyShowMono());
ui->cbFont->setCurrentFont(QFont(pSettings->debugger().fontName())); ui->cbFont->setCurrentFont(QFont(pSettings->debugger().fontName()));
ui->sbFontSize->setValue(pSettings->debugger().fontSize()); ui->sbFontSize->setValue(pSettings->debugger().fontSize());
ui->chkShowLog->setChecked(pSettings->debugger().showCommandLog()); ui->grpEnableDebugConsole->setChecked(pSettings->debugger().enableDebugConsole());
ui->chkShowFullAnnotation->setChecked(pSettings->debugger().showAnnotations()); ui->chkShowDetailLog->setChecked(pSettings->debugger().showDetailLog());
if (pSettings->debugger().useIntelStyle()) { if (pSettings->debugger().useIntelStyle()) {
ui->rbIntel->setChecked(true); ui->rbIntel->setChecked(true);
} else { } else {
ui->rbATT->setChecked(true); ui->rbATT->setChecked(true);
} }
ui->chkShowCPUWhenSignaled->setChecked(pSettings->debugger().openCPUInfoWhenSignaled());
ui->chkBlendMode->setChecked(pSettings->debugger().blendMode()); ui->chkBlendMode->setChecked(pSettings->debugger().blendMode());
ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries()); ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries());
ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries()); ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries());
@ -40,8 +41,9 @@ void DebugGeneralWidget::doSave()
pSettings->debugger().setOnlyShowMono(ui->chkOnlyMono->isChecked()); pSettings->debugger().setOnlyShowMono(ui->chkOnlyMono->isChecked());
pSettings->debugger().setFontName(ui->cbFont->currentFont().family()); pSettings->debugger().setFontName(ui->cbFont->currentFont().family());
pSettings->debugger().setFontSize(ui->sbFontSize->value()); pSettings->debugger().setFontSize(ui->sbFontSize->value());
pSettings->debugger().setShowCommandLog(ui->chkShowLog->isChecked()); pSettings->debugger().setEnableDebugConsole(ui->grpEnableDebugConsole->isChecked());
pSettings->debugger().setShowAnnotations(ui->chkShowFullAnnotation->isChecked()); pSettings->debugger().setShowDetailLog(ui->chkShowDetailLog->isChecked());
pSettings->debugger().setOpenCPUInfoWhenSignaled(ui->chkShowCPUWhenSignaled);
pSettings->debugger().setUseIntelStyle(ui->rbIntel->isChecked()); pSettings->debugger().setUseIntelStyle(ui->rbIntel->isChecked());
pSettings->debugger().setBlendMode(ui->chkBlendMode->isChecked()); pSettings->debugger().setBlendMode(ui->chkBlendMode->isChecked());
pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked()); pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked());

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>677</width> <width>704</width>
<height>563</height> <height>563</height>
</rect> </rect>
</property> </property>
@ -36,7 +36,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="grpEnableDebugConsole">
<property name="title"> <property name="title">
<string>Debug Console</string> <string>Debug Console</string>
</property> </property>
@ -143,16 +143,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="chkShowLog"> <widget class="QCheckBox" name="chkShowDetailLog">
<property name="text"> <property name="text">
<string>Show debug logs in the debug console</string> <string>Show detail debug logs</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkShowFullAnnotation">
<property name="text">
<string>Show full gdb annotations</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -182,6 +175,13 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="chkShowCPUWhenSignaled">
<property name="text">
<string>Show CPU Window when signal received</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">

View File

@ -22,3 +22,8 @@ bool SignalMessageDialog::openCPUInfo()
{ {
return ui->chkOpenCPUInfo->isChecked(); return ui->chkOpenCPUInfo->isChecked();
} }
void SignalMessageDialog::setOpenCPUInfo(bool value)
{
ui->chkOpenCPUInfo->setChecked(value);
}

View File

@ -16,6 +16,7 @@ public:
~SignalMessageDialog(); ~SignalMessageDialog();
void setMessage(const QString& message); void setMessage(const QString& message);
bool openCPUInfo(); bool openCPUInfo();
void setOpenCPUInfo(bool value);
private: private:
Ui::SignalMessageDialog *ui; Ui::SignalMessageDialog *ui;