diff --git a/src/SeerMainWindow.cpp b/src/SeerMainWindow.cpp index 1bfc260..9f417d2 100644 --- a/src/SeerMainWindow.cpp +++ b/src/SeerMainWindow.cpp @@ -36,7 +36,7 @@ SeerMainWindow::SeerMainWindow(QWidget* parent) : QMainWindow(parent) { // Add status bar indicator. SeerRunStatusIndicator* runStatus = new SeerRunStatusIndicator(this); - statusBar()->addPermanentWidget(runStatus); + statusBar()->addPermanentWidget(runStatus->indicatorBox()); // Add progress spin widget. QWidget* spacerWidget = new QWidget(this); @@ -214,6 +214,7 @@ SeerMainWindow::SeerMainWindow(QWidget* parent) : QMainWindow(parent) { QObject::connect(helpToolButton, &QToolButton::clicked, this, &SeerMainWindow::handleHelpToolButtonClicked); + QObject::connect(gdbWidget, &SeerGdbWidget::sessionTerminated, runStatus, &SeerRunStatusIndicator::handleSessionTerminated); handleRecordSettingsChanged(); // diff --git a/src/SeerRunStatusIndicator.cpp b/src/SeerRunStatusIndicator.cpp index ee9dc3a..0505a71 100644 --- a/src/SeerRunStatusIndicator.cpp +++ b/src/SeerRunStatusIndicator.cpp @@ -5,46 +5,60 @@ #include "SeerRunStatusIndicator.h" #include #include +#include +#include SeerRunStatusIndicator::SeerRunStatusIndicator(QWidget* parent) : QLabel(parent) { - _runStatus = RunStatus::Idle; + // Create group box + _groupBox = new QGroupBox(); + _groupBox->setTitle(""); + _groupBox->setFlat(true); + _groupBox->setStyleSheet("QGroupBox { border: none; }"); + + _statusLabel = new QLabel("Status"); + _statusLabel->setAlignment(Qt::AlignCenter); + _statusLabel->setFixedSize(150, 25); + _statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); + + // Layout + auto *layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->addWidget(_statusLabel); + _groupBox->setLayout(layout); } SeerRunStatusIndicator::~SeerRunStatusIndicator() { } void SeerRunStatusIndicator::setRunStatus (SeerRunStatusIndicator::RunStatus status) { - - // If the status is already set, don't set it again. - if (status == _runStatus) { - return; - } - - // Change the status to the new status. - _runStatus = status; - if (status == RunStatus::Idle) { - QApplication::restoreOverrideCursor(); - setText("Idle"); + _statusLabel->setText("Session Terminated"); + _statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); }else if (status == RunStatus::Stopped) { - QApplication::restoreOverrideCursor(); - setText("Stopped"); + _statusLabel->setText("Stopped"); + _statusLabel->setStyleSheet("background-color: red; color: black; font-weight: bold;"); - }else if (status == RunStatus::Running) { - QApplication::setOverrideCursor(Qt::BusyCursor); - setText("Running"); + } + else if (status == RunStatus::Stop_By_Breakpoint) { + _statusLabel->setText("Stop by breakpoint"); + _statusLabel->setStyleSheet("background-color: yellow; color: black; font-weight: bold;"); + } + else if (status == RunStatus::Running) { + _statusLabel->setText("Running"); + _statusLabel->setStyleSheet("background-color: green; color: black; font-weight: bold;"); - }else{ - QApplication::restoreOverrideCursor(); - setText("Unknown"); + } + else { + _statusLabel->setText("Unknown"); } emit statusChanged(status); } -SeerRunStatusIndicator::RunStatus SeerRunStatusIndicator::runStatus () const { - return _runStatus; +QGroupBox* SeerRunStatusIndicator::indicatorBox() { + return _groupBox; } void SeerRunStatusIndicator::handleText (const QString& text) { @@ -56,9 +70,11 @@ void SeerRunStatusIndicator::handleText (const QString& text) { setRunStatus(SeerRunStatusIndicator::Running); }else if (text.startsWith("*stopped")) { - - //^connected,frame={level=\"0\",addr=\"0x00007f48351f80c1\",func=\"read\",args=[],from=\"/lib64/libc.so.6\",arch=\"i386:x86-64\"}" - setRunStatus(SeerRunStatusIndicator::Stopped); + if (text.startsWith("*stopped,reason=\"breakpoint-hit\"")) + setRunStatus(SeerRunStatusIndicator::Stop_By_Breakpoint); + else + //^connected,frame={level=\"0\",addr=\"0x00007f48351f80c1\",func=\"read\",args=[],from=\"/lib64/libc.so.6\",arch=\"i386:x86-64\"}" + setRunStatus(SeerRunStatusIndicator::Stopped); }else if (text.startsWith("=thread-exited")) { @@ -70,9 +86,21 @@ void SeerRunStatusIndicator::handleText (const QString& text) { //=thread-group-exited,id="i1" setRunStatus(SeerRunStatusIndicator::Stopped); - }else{ + } + else if (text.startsWith("^done,stack")) { + // When finish command is invoked + setRunStatus(SeerRunStatusIndicator::Stopped); + } + else{ // All other text is ignored by this widget. // qDebug() << text; } } +// handle when program stop/ killed +void SeerRunStatusIndicator::handleSessionTerminated() { + _statusLabel->setText("Session Terminated"); + _statusLabel->setStyleSheet("background-color: lightgray; color: black; font-weight: bold;"); + // also tell SeerProgressIndicator to stop spinning + setRunStatus(SeerRunStatusIndicator::Idle); +} \ No newline at end of file diff --git a/src/SeerRunStatusIndicator.h b/src/SeerRunStatusIndicator.h index 5309b70..da7adde 100644 --- a/src/SeerRunStatusIndicator.h +++ b/src/SeerRunStatusIndicator.h @@ -6,6 +6,9 @@ #include #include +#include +#include +#include class SeerRunStatusIndicator : public QLabel { @@ -15,7 +18,8 @@ class SeerRunStatusIndicator : public QLabel { enum RunStatus { Idle = 0, Stopped = 1, - Running = 2 + Stop_By_Breakpoint = 2, + Running = 3, }; explicit SeerRunStatusIndicator(QWidget* parent = 0); @@ -23,16 +27,20 @@ class SeerRunStatusIndicator : public QLabel { void setRunStatus (SeerRunStatusIndicator::RunStatus status); SeerRunStatusIndicator::RunStatus runStatus () const; + QGroupBox* indicatorBox (); signals: void statusChanged (SeerRunStatusIndicator::RunStatus status); public slots: void handleText (const QString& text); + void handleSessionTerminated (); protected: private: - SeerRunStatusIndicator::RunStatus _runStatus; + QGroupBox* _groupBox; + QLabel* _statusLabel; + QHBoxLayout* _layout; };