diff --git a/src/SeerGdbWidget.cpp b/src/SeerGdbWidget.cpp index bb49456..20ac497 100644 --- a/src/SeerGdbWidget.cpp +++ b/src/SeerGdbWidget.cpp @@ -111,7 +111,8 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) { logsTabWidget->addTab(_seerOutputLog, "Seer output"); logsTabWidget->setCurrentIndex(0); - // Create the console. + // Create the console tab. + // Each RUN method will create and connect to the console's terminal. createConsole(); // Create editor options bar. @@ -1059,15 +1060,19 @@ void SeerGdbWidget::handleGdbRunExecutable (const QString& breakMode, bool loadS // This causes a new gdb each time. The same console, though. setNewExecutableFlag(true); - // Disconnect from the console and delete the old gdb if there is a new executable. + // Delete the old gdb if there is a new executable. if (newExecutableFlag() == true) { - console()->deleteTerminal(); killGdb(); } // If gdb isn't running, start it. if (isGdbRuning() == false) { + // Connect the terminal to the console. + console()->resetTerminal(); + console()->connectTerminal(); + + // Start gdb. bool f = startGdb(); if (f == false) { QMessageBox::critical(this, tr("Error"), tr("Can't start gdb.")); @@ -1090,8 +1095,6 @@ void SeerGdbWidget::handleGdbRunExecutable (const QString& breakMode, bool loadS } // Set the program's tty device for stdin and stdout. - console()->createTerminal(); - console()->connectTerminal(); handleGdbTerminalDeviceName(); setExecutableLaunchMode("run"); @@ -1200,9 +1203,8 @@ void SeerGdbWidget::handleGdbAttachExecutable (bool loadSessionBreakpoints) { // This causes a new gdb each time. The same console, though. setNewExecutableFlag(true); - // Disconnect from the console and delete the old gdb if there is a new executable. + // Delete the old gdb if there is a new executable. if (newExecutableFlag() == true) { - console()->deleteTerminal(); killGdb(); } @@ -1210,6 +1212,11 @@ void SeerGdbWidget::handleGdbAttachExecutable (bool loadSessionBreakpoints) { // No need to connect to the console in this mode. if (isGdbRuning() == false) { + // Connect the terminal to the console. + console()->resetTerminal(); + console()->connectTerminal(); + + // Start gdb. bool f = startGdb(); if (f == false) { QMessageBox::critical(this, tr("Error"), tr("Can't start gdb.")); @@ -1224,6 +1231,10 @@ void SeerGdbWidget::handleGdbAttachExecutable (bool loadSessionBreakpoints) { handleGdbSourceScripts(); } + // Set the program's tty device for stdin and stdout. + // Not really needed for 'attach' mode, but do it anyway. + handleGdbTerminalDeviceName(); + // No console for 'attach' mode but make sure it's reattached. setExecutableLaunchMode("attach"); saveLaunchMode(); @@ -1295,14 +1306,17 @@ void SeerGdbWidget::handleGdbConnectExecutable (bool loadSessionBreakpoints) { // Disconnect from the terminal and delete the old gdb if there is a new executable. if (newExecutableFlag() == true) { - console()->deleteTerminal(); killGdb(); } // If gdb isn't running, start it. - // No need to connect to the console in this mode. if (isGdbRuning() == false) { + // Connect the terminal to the console. + console()->resetTerminal(); + console()->connectTerminal(); + + // Start gdb. bool f = startGdb(); if (f == false) { QMessageBox::critical(this, tr("Error"), tr("Can't start gdb.")); @@ -1313,6 +1327,10 @@ void SeerGdbWidget::handleGdbConnectExecutable (bool loadSessionBreakpoints) { handleGdbSourceScripts(); } + // Set the program's tty device for stdin and stdout. + // Not really needed for 'connect' mode, but do it anyway. + handleGdbTerminalDeviceName(); + // No console for 'connect' mode but make sure it's reattached. setExecutableLaunchMode("connect"); saveLaunchMode(); @@ -1327,7 +1345,7 @@ void SeerGdbWidget::handleGdbConnectExecutable (bool loadSessionBreakpoints) { }else{ handleGdbCommand("-gdb-set debug remote 0"); } - handleGdbExecutablePreCommands(); // Run any 'pre' commands before program is loaded. + handleGdbExecutablePreCommands(); // Run any 'pre' commands before program is loaded. } // Connect to the remote gdbserver using the proper remote type. @@ -1402,13 +1420,17 @@ void SeerGdbWidget::handleGdbRRExecutable (bool loadSessionBreakpoints) { // Disconnect from the console and delete the old gdb, then reconnect. if (newExecutableFlag() == true) { - console()->deleteTerminal(); killGdb(); } // If gdb isn't running, start it. if (isGdbRuning() == false) { + // Connect the terminal to the console. + console()->resetTerminal(); + console()->connectTerminal(); + + // Start gdb. bool f = startGdbRR(); if (f == false) { QMessageBox::critical(this, tr("Error"), tr("Can't start gdb.")); @@ -1417,8 +1439,6 @@ void SeerGdbWidget::handleGdbRRExecutable (bool loadSessionBreakpoints) { } // Set the program's tty device for stdin and stdout. - console()->createTerminal(); - console()->connectTerminal(); handleGdbTerminalDeviceName(); // Set the launch mode. @@ -1512,7 +1532,6 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () { // Disconnect from the console and delete the old gdb. No need to reconnect. if (newExecutableFlag() == true) { - console()->deleteTerminal(); killGdb(); } @@ -1520,6 +1539,11 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () { // No need to connect to the console in this mode. if (isGdbRuning() == false) { + // Connect the terminal to the console. + console()->resetTerminal(); + console()->connectTerminal(); + + // Start gdb. bool f = startGdb(); if (f == false) { QMessageBox::critical(this, tr("Error"), tr("Can't start gdb.")); @@ -1534,6 +1558,10 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () { handleGdbSourceScripts(); } + // Set the program's tty device for stdin and stdout. + // Not really needed for 'core' mode, but do it anyway. + handleGdbTerminalDeviceName(); + // No console for 'core' mode but make sure it's reattached. setExecutableLaunchMode("corefile"); saveLaunchMode(); @@ -1561,7 +1589,7 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () { // Run any 'post' commands after program is loaded. handleGdbExecutablePostCommands(); - // This is needed for code mode to refresh the stack frame, for some reason. + // This is needed for 'core' mode to refresh the stack frame, for some reason. handleGdbStackListFrames(); // Set window titles with name of program. @@ -2100,7 +2128,7 @@ void SeerGdbWidget::handleGdbTerminalDeviceName () { if (_consoleWidget->terminalDeviceName() != "") { - handleGdbCommand(QString("-inferior-tty-set ") + _consoleWidget->terminalDeviceName()); + handleGdbCommand(QString("-inferior-tty-set ") + _consoleWidget->terminalDeviceName()); }else{ qWarning() << "Can't set TTY name because the name is blank."; diff --git a/tests/hellorr/README.rr b/tests/hellorr/README.rr index 99db88d..5e70d21 100644 --- a/tests/hellorr/README.rr +++ b/tests/hellorr/README.rr @@ -9,6 +9,7 @@ Record a RR session. Or... $ rr record -n --output-trace-dir=/path/to/rr/trace-directory hellorr arg1 arg2 + $ rr record -n --output-trace-dir=`pwd`/rr hellorr one two three Replay the RR session in Seer.