Skip to content

Commit

Permalink
Add a 'Recconect' and 'Reattach' toolbar button.
Browse files Browse the repository at this point in the history
Still needs more work.  Perhaps killGdb() should detach before
killing gdb process.
  • Loading branch information
epasveer committed Dec 9, 2023
1 parent 70840d2 commit 201dc89
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/SeerMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ SeerMainWindow::SeerMainWindow(QWidget* parent) : QMainWindow(parent) {

QObject::connect(actionGdbRun, &QAction::triggered, this, &SeerMainWindow::handleRunExecutable);
QObject::connect(actionGdbStart, &QAction::triggered, this, &SeerMainWindow::handleStartExecutable);
QObject::connect(actionGdbReattach, &QAction::triggered, this, &SeerMainWindow::handleAttachExecutable);
QObject::connect(actionGdbReconnect, &QAction::triggered, this, &SeerMainWindow::handleConnectExecutable);
QObject::connect(_styleMenuActionGroup, &QActionGroup::triggered, this, &SeerMainWindow::handleStyleMenuChanged);
QObject::connect(actionGdbContinue, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbContinue);
QObject::connect(actionGdbNext, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbNext);
Expand Down Expand Up @@ -391,8 +393,10 @@ QString SeerMainWindow::gdbArgumentsOverride () const {
void SeerMainWindow::launchExecutable (const QString& launchMode, const QString& breakMode) {

// Show all buttons by default. Turn some off depending on debug mode.
actionGdbRun->setVisible(true);
actionGdbStart->setVisible(true);
actionGdbRun->setVisible(false);
actionGdbStart->setVisible(false);
actionGdbReconnect->setVisible(false);
actionGdbReattach->setVisible(false);
actionGdbContinue->setVisible(true);
actionGdbNext->setVisible(true);
actionGdbNexti->setVisible(true);
Expand All @@ -402,34 +406,41 @@ void SeerMainWindow::launchExecutable (const QString& launchMode, const QString&

if (launchMode == "run") {

actionGdbRun->setVisible(true);
actionGdbStart->setVisible(true);

gdbWidget->handleGdbRunExecutable(breakMode);

}else if (launchMode == "start") {

actionGdbRun->setVisible(true);
actionGdbStart->setVisible(true);

gdbWidget->handleGdbRunExecutable(breakMode);

}else if (launchMode == "attach") {

actionGdbRun->setVisible(false);
actionGdbStart->setVisible(false);
actionGdbReattach->setVisible(true);

gdbWidget->handleGdbAttachExecutable();

}else if (launchMode == "connect") {

actionGdbRun->setVisible(false);
actionGdbStart->setVisible(false);
actionGdbReconnect->setVisible(true);

gdbWidget->handleGdbConnectExecutable();

}else if (launchMode == "rr") {

actionGdbRun->setVisible(true);
actionGdbStart->setVisible(true);

gdbWidget->handleGdbRRExecutable();

}else if (launchMode == "corefile") {

actionGdbRun->setVisible(false);
actionGdbStart->setVisible(false);
// Run/Start are already disabled.
// Disable the rest.
actionGdbContinue->setVisible(false);
actionGdbNext->setVisible(false);
actionGdbNexti->setVisible(false);
Expand Down Expand Up @@ -771,6 +782,18 @@ void SeerMainWindow::handleStartExecutable () {
}
}

void SeerMainWindow::handleAttachExecutable () {

gdbWidget->setNewExecutableFlag(false);
gdbWidget->handleGdbAttachExecutable();
}

void SeerMainWindow::handleConnectExecutable () {

gdbWidget->setNewExecutableFlag(true);
gdbWidget->handleGdbConnectExecutable();
}

void SeerMainWindow::handleStyleMenuChanged () {

QAction* action = _styleMenuActionGroup->checkedAction();
Expand Down Expand Up @@ -940,6 +963,9 @@ void SeerMainWindow::handleText (const QString& text) {
//^connected,frame={level=\"0\",addr=\"0x00007f48351f80c1\",func=\"read\",args=[],from=\"/lib64/libc.so.6\",arch=\"i386:x86-64\"}"
return;

}else if (text.startsWith("^connected")) {
//^connected
return;

}else if (text.startsWith("*stopped")) {

Expand Down
2 changes: 2 additions & 0 deletions src/SeerMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class SeerMainWindow : public QMainWindow, protected Ui::SeerMainWindowForm {
void handleHelpToolButtonClicked ();
void handleRunExecutable ();
void handleStartExecutable ();
void handleAttachExecutable ();
void handleConnectExecutable ();
void handleStyleMenuChanged ();
void handleShowMessage (QString message, int time);

Expand Down
26 changes: 26 additions & 0 deletions src/SeerMainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@
</attribute>
<addaction name="actionGdbRun"/>
<addaction name="actionGdbStart"/>
<addaction name="actionGdbReconnect"/>
<addaction name="actionGdbReattach"/>
<addaction name="actionGdbContinue"/>
<addaction name="actionGdbNext"/>
<addaction name="actionGdbStep"/>
Expand Down Expand Up @@ -676,6 +678,30 @@
<string>View the program's execution messages.</string>
</property>
</action>
<action name="actionGdbReconnect">
<property name="icon">
<iconset resource="resource.qrc">
<normaloff>:/seer/resources/RelaxLightIcons/debug-run.svg</normaloff>:/seer/resources/RelaxLightIcons/debug-run.svg</iconset>
</property>
<property name="text">
<string>Reconnect</string>
</property>
<property name="toolTip">
<string>Reconnect to a previously connected server.</string>
</property>
</action>
<action name="actionGdbReattach">
<property name="icon">
<iconset resource="resource.qrc">
<normaloff>:/seer/resources/RelaxLightIcons/debug-run.svg</normaloff>:/seer/resources/RelaxLightIcons/debug-run.svg</iconset>
</property>
<property name="text">
<string>Reattach</string>
</property>
<property name="toolTip">
<string>Reattach to a previosly attached pid.</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
1 change: 1 addition & 0 deletions tests/hellogdbserver/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hellogdbserver
10 changes: 10 additions & 0 deletions tests/hellogdbserver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: all
all: hellogdbserver

hellogdbserver: hellogdbserver.c
gcc -g -o hellogdbserver hellogdbserver.c -lm

.PHONY: clean
clean:
rm -f hellogdbserver hellogdbserver.o

142 changes: 142 additions & 0 deletions tests/hellogdbserver/hellogdbserver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/* Factored discrete Fourier transform, or FFT, and its inverse iFFT */

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#define q 15 /* for 2^3 points */
#define N (1<<q) /* N-point FFT, iFFT */

typedef float real;
typedef struct{real Re; real Im;} complex;

#ifndef PI
# define PI 3.14159265358979323846264338327950288
#endif


/* Print a vector of complexes as ordered pairs. */
static void print_vector( const char *title, complex *x, int n) {

int i;

printf("%s (dim=%d):", title, n);

for(i=0; i<(n<8?n:8); i++ ) {
printf(" %5.2f,%5.2f ", x[i].Re,x[i].Im);
}

putchar('\n');

return;
}

/*
fft(v,N):
[0] If N==1 then return.
[1] For k = 0 to N/2-1, let ve[k] = v[2*k]
[2] Compute fft(ve, N/2);
[3] For k = 0 to N/2-1, let vo[k] = v[2*k+1]
[4] Compute fft(vo, N/2);
[5] For m = 0 to N/2-1, do [6] through [9]
[6] Let w.re = cos(2*PI*m/N)
[7] Let w.im = -sin(2*PI*m/N)
[8] Let v[m] = ve[m] + w*vo[m]
[9] Let v[m+N/2] = ve[m] - w*vo[m]
*/
void fft( complex *v, int n, complex *tmp ) {

if(n>1) { /* otherwise, do nothing and return */
int k,m; complex z, w, *vo, *ve;
ve = tmp; vo = tmp+n/2;
for(k=0; k<n/2; k++) {
ve[k] = v[2*k];
vo[k] = v[2*k+1];
}
fft( ve, n/2, v ); /* FFT on even-indexed elements of v[] */
fft( vo, n/2, v ); /* FFT on odd-indexed elements of v[] */
for(m=0; m<n/2; m++) {
w.Re = cos(2*PI*m/(double)n);
w.Im = -sin(2*PI*m/(double)n);
z.Re = w.Re*vo[m].Re - w.Im*vo[m].Im; /* Re(w*vo[m]) */
z.Im = w.Re*vo[m].Im + w.Im*vo[m].Re; /* Im(w*vo[m]) */
v[ m ].Re = ve[m].Re + z.Re;
v[ m ].Im = ve[m].Im + z.Im;
v[m+n/2].Re = ve[m].Re - z.Re;
v[m+n/2].Im = ve[m].Im - z.Im;
}
}
return;
}

/*
ifft(v,N):
[0] If N==1 then return.
[1] For k = 0 to N/2-1, let ve[k] = v[2*k]
[2] Compute ifft(ve, N/2);
[3] For k = 0 to N/2-1, let vo[k] = v[2*k+1]
[4] Compute ifft(vo, N/2);
[5] For m = 0 to N/2-1, do [6] through [9]
[6] Let w.re = cos(2*PI*m/N)
[7] Let w.im = sin(2*PI*m/N)
[8] Let v[m] = ve[m] + w*vo[m]
[9] Let v[m+N/2] = ve[m] - w*vo[m]
*/
void ifft( complex *v, int n, complex *tmp ) {

if(n>1) { /* otherwise, do nothing and return */
int k,m; complex z, w, *vo, *ve;
ve = tmp; vo = tmp+n/2;
for(k=0; k<n/2; k++) {
ve[k] = v[2*k];
vo[k] = v[2*k+1];
}
ifft( ve, n/2, v ); /* FFT on even-indexed elements of v[] */
ifft( vo, n/2, v ); /* FFT on odd-indexed elements of v[] */
for(m=0; m<n/2; m++) {
w.Re = cos(2*PI*m/(double)n);
w.Im = sin(2*PI*m/(double)n);
z.Re = w.Re*vo[m].Re - w.Im*vo[m].Im; /* Re(w*vo[m]) */
z.Im = w.Re*vo[m].Im + w.Im*vo[m].Re; /* Im(w*vo[m]) */
v[ m ].Re = ve[m].Re + z.Re;
v[ m ].Im = ve[m].Im + z.Im;
v[m+n/2].Re = ve[m].Re - z.Re;
v[m+n/2].Im = ve[m].Im - z.Im;
}
}
return;
}

int main(void) {

complex v[N], v1[N], scratch[N];
int k;

for (int x=0; x<10000; x++) {
/* Fill v[] with a function of known FFT: */
for(k=0; k<N; k++) {
v[k].Re = 0.125 * cos(2*PI*k/(double)N);
v[k].Im = 0.125 * sin(2*PI*k/(double)N);
v1[k].Re = 0.3 * cos(2*PI*k/(double)N);
v1[k].Im = -0.3 * sin(2*PI*k/(double)N);
}

/* FFT, iFFT of v[]: */
print_vector("Orig", v, N);
fft( v, N, scratch );
print_vector(" FFT", v, N);
ifft( v, N, scratch );
print_vector("iFFT", v, N);

/* FFT, iFFT of v1[]: */
print_vector("Orig", v1, N);
fft( v1, N, scratch );
print_vector(" FFT", v1, N);
ifft( v1, N, scratch );
print_vector("iFFT", v1, N);
}

exit(EXIT_SUCCESS);
}

0 comments on commit 201dc89

Please sign in to comment.