Skip to content

Commit

Permalink
Merge pull request #291 from epasveer/286-auto-resize-of-output-windo…
Browse files Browse the repository at this point in the history
…w-makes-this-debugger-unusable-for-my-project

286 auto resize of output window makes this debugger unusable for my project
  • Loading branch information
epasveer authored Feb 2, 2025
2 parents 85b80a3 + 876512e commit 55341a6
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## [2.6beta] - 2025-XX-XX
* Starting version 2.6 development cycle.
* Fixed regression when adding commands to a watchpoint.
* Create console once per Seer session. Instead of constant create/destroy.
* Fixed regression when ignoring files to be opened in the
EditorManager.

Expand Down
55 changes: 33 additions & 22 deletions src/SeerConsoleWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ SeerConsoleWidget::SeerConsoleWidget (QWidget* parent) : QWidget(parent) {

wrapTextCheckBox->setCheckState(Qt::Unchecked); // No wrap

// Create psuedo terminal for console.
// Create psuedo terminal for console. Don't connect to it yet.
createConsole();
connectConsole();

// Connect things.
QObject::connect(clearButton, &QPushButton::clicked, this, &SeerConsoleWidget::handleClearButton);
Expand All @@ -71,12 +70,7 @@ SeerConsoleWidget::SeerConsoleWidget (QWidget* parent) : QWidget(parent) {
}

SeerConsoleWidget::~SeerConsoleWidget () {
disconnectConsole();
deleteConsole();
}

const QString& SeerConsoleWidget::ttyDeviceName () const {
return _ttyDeviceName;
deleteConsole(); // Will disconnect console first befor deleting.
}

void SeerConsoleWidget::handleText (const char* buffer, int count) {
Expand Down Expand Up @@ -246,10 +240,6 @@ void SeerConsoleWidget::handleStdinLineEdit () {

QString str = stdinLineEdit->text();

if (str == "") {
return;
}

stdinLineEdit->clear();

str += '\n';
Expand Down Expand Up @@ -353,38 +343,59 @@ void SeerConsoleWidget::createConsole () {
setScrollLines(0);
}

void SeerConsoleWidget::connectConsole () {
void SeerConsoleWidget::deleteConsole () {

disconnectConsole();

_ttyDeviceName = "";

if (_ptsFD < 0) {
return;
}

::close(_ptsFD); _ptsFD = -1;
}

void SeerConsoleWidget::connectConsole () {

if (isConsoleConnected()) {
qDebug() << "Console is already connected!";
return;
}

if (_ptsFD < 0) {
qDebug() << "Can't connect Console. No _ptsFD!";
return;
}

_ptsListener = new QSocketNotifier(_ptsFD, QSocketNotifier::Read);

QObject::connect(_ptsListener, &QSocketNotifier::activated, this, &SeerConsoleWidget::handleConsoleOutput);
}

void SeerConsoleWidget::disconnectConsole () {

if (_ptsListener) {
if (isConsoleConnected() == false) {
qDebug() << "Console is already disconnected!";
return;
}

QObject::disconnect(_ptsListener, &QSocketNotifier::activated, this, &SeerConsoleWidget::handleConsoleOutput);
QObject::disconnect(_ptsListener, &QSocketNotifier::activated, this, &SeerConsoleWidget::handleConsoleOutput);

delete _ptsListener; _ptsListener = 0;
}
delete _ptsListener; _ptsListener = 0;
}

void SeerConsoleWidget::deleteConsole () {
bool SeerConsoleWidget::isConsoleConnected () const {

if (_ptsFD < 0) {
return;
if (_ptsListener != nullptr) {
return true;
}

_ttyDeviceName = "";
return false;
}

::close(_ptsFD); _ptsFD = -1;
const QString& SeerConsoleWidget::ttyDeviceName () const {
return _ttyDeviceName;
}

void SeerConsoleWidget::setScrollLines (int count) {
Expand Down
7 changes: 4 additions & 3 deletions src/SeerConsoleWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ class SeerConsoleWidget : public QWidget, protected Ui::SeerConsoleWidgetForm {
explicit SeerConsoleWidget (QWidget* parent = 0);
~SeerConsoleWidget ();

const QString& ttyDeviceName () const;
void createConsole ();
void deleteConsole ();
void connectConsole ();
void disconnectConsole ();
bool isConsoleConnected () const;
const QString& ttyDeviceName () const;

void setScrollLines (int count);
int scrollLines () const;
Expand Down Expand Up @@ -46,8 +49,6 @@ class SeerConsoleWidget : public QWidget, protected Ui::SeerConsoleWidgetForm {

protected:
void handleText (const char* buffer, int count);
void createConsole ();
void deleteConsole ();
void writeSettings ();
void writeFontSettings ();
void writeSizeSettings ();
Expand Down
42 changes: 21 additions & 21 deletions src/SeerGdbWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) {
logsTabWidget->addTab(_seerOutputLog, "Seer output");
logsTabWidget->setCurrentIndex(0);

// Create the console.
createConsole();

// Create editor options bar.
QToolButton* breakpointsLoadToolButton = new QToolButton(logsTabWidget);
breakpointsLoadToolButton->setIcon(QIcon(":/seer/resources/RelaxLightIcons/document-open.svg"));
Expand Down Expand Up @@ -722,8 +725,8 @@ void SeerGdbWidget::writeLogsSettings () {

QString current = logsTabWidget->tabBar()->tabText(logsTabWidget->tabBar()->currentIndex());

//qDebug() << "Tabs" << tabs;
//qDebug() << "Current" << current;
qDebug() << "Tabs" << tabs;
qDebug() << "Current" << current;

QSettings settings;

Expand Down Expand Up @@ -916,11 +919,10 @@ void SeerGdbWidget::handleGdbRunExecutable (const QString& breakMode) {

_executableBreakMode = breakMode;

// Delete the old gdb and console if there is a new executable
// Disconnect from the console and delete the old gdb if there is a new executable.
if (newExecutableFlag() == true) {
killGdb();
disconnectConsole();
deleteConsole();
killGdb();
}

// If gdb isn't running, start it.
Expand All @@ -932,6 +934,9 @@ void SeerGdbWidget::handleGdbRunExecutable (const QString& breakMode) {
break;
}

// Connect to the console.
connectConsole();

if (gdbAsyncMode()) {
handleGdbCommand("-gdb-set mi-async on"); // Turn on async mode so the 'interrupt' can happen.
}
Expand Down Expand Up @@ -1057,14 +1062,14 @@ void SeerGdbWidget::handleGdbAttachExecutable () {
}


// Delete the old gdb and console if there is a new executable
// Disconnect from the console and delete the old gdb if there is a new executable.
if (newExecutableFlag() == true) {
killGdb();
disconnectConsole();
deleteConsole();
killGdb();
}

// If gdb isn't running, start it.
// No need to connect to the console in this mode.
if (isGdbRuning() == false) {

bool f = startGdb();
Expand Down Expand Up @@ -1134,14 +1139,14 @@ void SeerGdbWidget::handleGdbConnectExecutable () {

while (1) {

// Delete the old gdb and console if there is a new executable
// Disconnect from the console and delete the old gdb if there is a new executable.
if (newExecutableFlag() == true) {
killGdb();
disconnectConsole();
deleteConsole();
killGdb();
}

// If gdb isn't running, start it.
// No need to connect to the console in this mode.
if (isGdbRuning() == false) {

bool f = startGdb();
Expand Down Expand Up @@ -1228,13 +1233,10 @@ void SeerGdbWidget::handleGdbRRExecutable () {
}
}

// Delete the old gdb and console if there is a new executable
// Create a new console.
// Disconnect from the console and delete the old gdb, then reconnect.
if (newExecutableFlag() == true) {
killGdb();
disconnectConsole();
deleteConsole();
createConsole();
killGdb();
connectConsole();
}

Expand Down Expand Up @@ -1338,14 +1340,14 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () {

QApplication::setOverrideCursor(Qt::BusyCursor);

// Delete the old gdb and console if there is a new executable
// Disconnect from the console and delete the old gdb. No need to reconnect.
if (newExecutableFlag() == true) {
killGdb();
disconnectConsole();
deleteConsole();
killGdb();
}

// If gdb isn't running, start it.
// No need to connect to the console in this mode.
if (isGdbRuning() == false) {

bool f = startGdb();
Expand Down Expand Up @@ -3221,8 +3223,6 @@ void SeerGdbWidget::killGdb () {

void SeerGdbWidget::createConsole () {

deleteConsole(); // Delete old console, if any.

if (_consoleWidget == 0) {
_consoleWidget = new SeerConsoleWidget(0);

Expand Down
20 changes: 12 additions & 8 deletions src/SeerMemoryVisualizerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ void SeerMemoryVisualizerWidget::setVariableName (const QString& name) {
variableNameLineEdit->setText(name);
setVariableAddress("");

if (variableNameLineEdit->text() == "") {
return;
}

// Clear old contents.
QByteArray array;

memoryHexEditor->setData(new SeerHexWidget::DataStorageArray(array));
memoryAsmEditor->setData("");

// Do nothing if there's no variable name.
if (variableNameLineEdit->text() == "") {
return;
}

// Send signal to get variable address.
emit evaluateVariableExpression(_variableId, variableNameLineEdit->text());
}
Expand Down Expand Up @@ -165,8 +166,6 @@ void SeerMemoryVisualizerWidget::handleText (const QString& text) {

QApplication::setOverrideCursor(Qt::BusyCursor);

//qDebug() << text;

if (text.contains(QRegularExpression("^([0-9]+)\\^done,value="))) {

// 11^done,value="1"
Expand Down Expand Up @@ -221,8 +220,6 @@ void SeerMemoryVisualizerWidget::handleText (const QString& text) {

if (id_text.toInt() == _memoryId) {

//qDebug() << text;

QString memory_text = Seer::parseFirst(text, "memory=", '[', ']', false);

QStringList range_list = Seer::parse(memory_text, "", '{', '}', false);
Expand Down Expand Up @@ -275,9 +272,11 @@ void SeerMemoryVisualizerWidget::handleText (const QString& text) {
// Display the error message.
QString msg_text = Seer::parseFirst(text, "msg=", false);

/* XXX
if (msg_text != "") {
QMessageBox::warning(this, "Error.", Seer::filterEscapes(msg_text));
}
*/
}

if (id_text.toInt() == _memoryLengthId) {
Expand All @@ -297,6 +296,11 @@ void SeerMemoryVisualizerWidget::handleText (const QString& text) {
handleRefreshButton();
}

// End of program. Clear everything as it will be out of date.
}else if (text.startsWith("^error,msg=\"No registers.\"")) {
setVariableName("");
setMemoryLength("");

}else{
// Ignore anything else.
}
Expand Down
2 changes: 2 additions & 0 deletions tests/hellocurses/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
helloworld
triangle
13 changes: 13 additions & 0 deletions tests/hellocurses/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: all
all: helloworld triangle

helloworld: helloworld.cpp
g++ -g -o helloworld helloworld.cpp -lncurses

triangle: triangle.cpp
g++ -g -o triangle triangle.cpp -lncurses

.PHONY: clean
clean:
rm -f helloworld triangle

13 changes: 13 additions & 0 deletions tests/hellocurses/helloworld.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <ncurses.h>

int main() {

initscr(); /* Start curses mode */
printw("Hello World !!!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */

return 0;
}

Loading

0 comments on commit 55341a6

Please sign in to comment.