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

View File

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

View File

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

View File

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

View File

@ -506,7 +506,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<property name="iconSize">
<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
@ -3004,6 +3004,16 @@ void Settings::Debugger::setAutosaveWatches(bool newAutosaveWatches)
mAutosaveWatches = newAutosaveWatches;
}
bool Settings::Debugger::openCPUInfoWhenSignaled() const
{
return mOpenCPUInfoWhenSignaled;
}
void Settings::Debugger::setOpenCPUInfoWhenSignaled(bool newOpenCPUInfoWhenSignaled)
{
mOpenCPUInfoWhenSignaled = newOpenCPUInfoWhenSignaled;
}
bool Settings::Debugger::autosaveBreakpoints() const
{
return mAutosaveBreakpoints;
@ -3046,8 +3056,8 @@ void Settings::Debugger::setOnlyShowMono(bool onlyShowMono)
void Settings::Debugger::doSave()
{
saveValue("show_command_log", mShowCommandLog);
saveValue("show_annotations", mShowAnnotations);
saveValue("enable_debug_console", mEnableDebugConsole);
saveValue("show_detail_log", mShowDetailLog);
saveValue("font_name",mFontName);
saveValue("only_show_mono",mOnlyShowMono);
saveValue("font_size",mFontSize);
@ -3058,13 +3068,14 @@ void Settings::Debugger::doSave()
saveValue("skip_custom_lib", mSkipCustomLibraries);
saveValue("autosave_breakpoints",mAutosaveBreakpoints);
saveValue("autosave_watches",mAutosaveWatches);
saveValue("open_cpu_info_when_signaled",mOpenCPUInfoWhenSignaled);
}
void Settings::Debugger::doLoad()
{
mShowCommandLog = boolValue("show_command_log",true);
mShowAnnotations = boolValue("show_annotations",false);
mEnableDebugConsole = boolValue("enable_debug_console",true);
mShowDetailLog = boolValue("show_detail_log",false);
mFontName = stringValue("font_name","Consolas");
mOnlyShowMono = boolValue("only_show_mono",true);
mFontSize = intValue("font_size",12);
@ -3075,6 +3086,7 @@ void Settings::Debugger::doLoad()
mSkipCustomLibraries = boolValue("skip_custom_lib",false);
mAutosaveBreakpoints = boolValue("autosave_breakpoints",true);
mAutosaveWatches = boolValue("autosave_watches",true);
mOpenCPUInfoWhenSignaled = boolValue("open_cpu_info_when_signaled",true);
}
Settings::History::History(Settings *settings):_Base(settings, SETTING_HISTORY)

View File

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

View File

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

View File

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

View File

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

View File

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