Skip to content

Commit

Permalink
add pause button; do not display signal message to backtract in conso…
Browse files Browse the repository at this point in the history
…le on SIGINT (cs01#202)
  • Loading branch information
cs01 committed May 28, 2018
1 parent 779ed9f commit d411aa2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 124 deletions.
2 changes: 1 addition & 1 deletion examples/c/sleeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <string.h>
#include <unistd.h>

int main(int argc, char *argv) {
int main(int argc, char **argv) {
printf("entering\n");
while(1){
// while this loop is running, you cannot interact with
Expand Down
35 changes: 35 additions & 0 deletions gdbgui/src/js/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,41 @@ const Actions = {
);
Actions.show_modal('upgrade to pro for this feature', body);
},
send_signal(signal_name, pid) {
$.ajax({
beforeSend: function(xhr) {
xhr.setRequestHeader(
'x-csrftoken',
initial_data.csrf_token
); /* global initial_data */
},
url: '/send_signal_to_pid',
cache: false,
type: 'POST',
data: {signal_name: signal_name, pid: pid},
success: function(response) {
Actions.add_console_entries(
response.message,
constants.console_entry_type.GDBGUI_OUTPUT
);
},
error: function(response) {
if (response.responseJSON && response.responseJSON.message) {
Actions.add_console_entries(
_.escape(response.responseJSON.message),
constants.console_entry_type.STD_ERR
);
} else {
Actions.add_console_entries(
`${response.statusText} (${response.status} error)`,
constants.console_entry_type.STD_ERR
);
}
console.error(response);
},
complete: function() {},
});
},
};

export default Actions;
45 changes: 4 additions & 41 deletions gdbgui/src/js/InferiorProgramInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,18 @@
import Actions from './Actions.js';
import constants from './constants.js';
import React from 'react';

import Actions from './Actions.js';
import {store} from 'statorgfc';

class InferiorProgramInfo extends React.Component {
constructor() {
super();
this.send_signal = this.send_signal.bind(this);
this.get_choice = this.get_choice.bind(this);
this.state = {
selected_inferior_signal: 'SIGINT',
selected_gdb_signal: 'SIGINT',
};
store.connectComponentState(this, ['inferior_pid', 'gdb_pid']);
}
send_signal(signal_name, pid) {
$.ajax({
beforeSend: function(xhr) {
xhr.setRequestHeader(
'x-csrftoken',
initial_data.csrf_token
); /* global initial_data */
},
url: '/send_signal_to_pid',
cache: false,
type: 'POST',
data: {signal_name: signal_name, pid: pid},
success: function(response) {
Actions.add_console_entries(
response.message,
constants.console_entry_type.GDBGUI_OUTPUT
);
},
error: function(response) {
if (response.responseJSON && response.responseJSON.message) {
Actions.add_console_entries(
_.escape(response.responseJSON.message),
constants.console_entry_type.STD_ERR
);
} else {
Actions.add_console_entries(
`${response.statusText} (${response.status} error)`,
constants.console_entry_type.STD_ERR
);
}
console.error(response);
},
complete: function() {},
});
}

get_choice(s, signal_key) {
let onclick = function() {
let obj = {};
Expand Down Expand Up @@ -103,7 +66,7 @@ class InferiorProgramInfo extends React.Component {
type="button"
title={`Send signal to pid ${this.state.gdb_pid}`}
onClick={() =>
this.send_signal(this.state.selected_gdb_signal, this.state.gdb_pid)
Actions.send_signal(this.state.selected_gdb_signal, this.state.gdb_pid)
}>
send to gdb
</button>
Expand Down Expand Up @@ -139,7 +102,7 @@ class InferiorProgramInfo extends React.Component {
this.state.inferior_pid
}. Note: signal is sent to machine running the gdbgui, so if running gdbserver remotely this will not work.`}
onClick={() =>
this.send_signal(
Actions.send_signal(
this.state.selected_inferior_signal,
this.state.inferior_pid
)
Expand Down
63 changes: 2 additions & 61 deletions gdbgui/src/js/TopBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';

import {store} from 'statorgfc';
import BinaryLoader from './BinaryLoader.jsx';
import ControlButtons from './ControlButtons.jsx';
import Settings from './Settings.jsx';
import SourceCodeHeading from './SourceCodeHeading.jsx';
import ToolTipTourguide from './ToolTipTourguide.jsx';
Expand All @@ -17,8 +18,6 @@ let onkeyup_jump_to_line = e => {
}
};

let btn_class = 'btn btn-default btn-sm';

let click_shutdown_button = function() {
// no need to show confirmation before leaving, because we're about to prompt the user
window.onbeforeunload = () => null;
Expand Down Expand Up @@ -284,65 +283,7 @@ class TopBar extends React.Component {
</div>
}
/>
<button
id="run_button"
onClick={GdbApi.click_run_button}
type="button"
title="Start inferior program from the beginning (keyboard shortcut: r)"
className={btn_class}>
<span className="glyphicon glyphicon-repeat" />
</button>

<button
id="continue_button"
onClick={GdbApi.click_continue_button}
type="button"
title="Continue until breakpoint is hit or inferior program exits (keyboard shortcut: c)"
className={btn_class}>
<span className="glyphicon glyphicon-play" />
</button>
<button
id="next_button"
onClick={GdbApi.click_next_button}
type="button"
title="Step over next function call (keyboard shortcut: n or right arrow)"
className={btn_class}>
<span className="glyphicon glyphicon-step-forward" />
</button>
<button
id="step_button"
onClick={GdbApi.click_step_button}
type="button"
title="Step into next function call (keyboard shortcut: s or down arrow)"
className={btn_class}>
<span className="glyphicon glyphicon-arrow-down" />
</button>
<button
id="return_button"
onClick={GdbApi.click_return_button}
type="button"
title="Step out of current function (keyboard shortcut: u or up arrow)"
className={btn_class}>
<span className="glyphicon glyphicon-arrow-up" />
</button>
<div role="group" className="btn-group btn-group-xs">
<button
id="next_instruction_button"
onClick={GdbApi.click_next_instruction_button}
type="button"
title="Next Instruction: Execute one machine instruction, stepping over function calls (keyboard shortcut: m)"
className="btn btn-default">
NI
</button>
<button
id="step_instruction_button"
onClick={GdbApi.click_step_instruction_button}
type="button"
title="Step Instruction: Execute one machine instruction, stepping into function calls (keyboard shortcut: ,)"
className="btn btn-default">
SI
</button>
</div>
<ControlButtons />
</div>
);
}
Expand Down
45 changes: 24 additions & 21 deletions gdbgui/src/js/process_gdb_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,29 +293,32 @@ const process_gdb_response = function(response_array) {
}
Actions.inferior_program_paused(r.payload.frame);
} else if (r.payload.reason === 'signal-received') {
Actions.add_console_entries(
`gdbgui noticed a signal was recieved (${r.payload['signal-meaning']}, ${
r.payload['signal-name']
}).`,
constants.console_entry_type.GDBGUI_OUTPUT
);
Actions.add_console_entries(
'If the program exited due to a fault, you can attempt to re-enter the state of the program when the fault ',
constants.console_entry_type.GDBGUI_OUTPUT
);
Actions.add_console_entries(
'occurred by clicking the below button.',
constants.console_entry_type.GDBGUI_OUTPUT
);

Actions.add_console_entries(
'Re-Enter Program (backtrace)',
constants.console_entry_type.BACKTRACE_LINK
);
Actions.inferior_program_paused(r.payload.frame);

if (r.payload['signal-name'] !== 'SIGINT') {
Actions.add_console_entries(
`gdbgui noticed a signal was recieved (${r.payload['signal-meaning']}, ${
r.payload['signal-name']
}).`,
constants.console_entry_type.GDBGUI_OUTPUT
);
Actions.add_console_entries(
'If the program exited due to a fault, you can attempt to re-enter the state of the program when the fault ',
constants.console_entry_type.GDBGUI_OUTPUT
);
Actions.add_console_entries(
'occurred by clicking the below button.',
constants.console_entry_type.GDBGUI_OUTPUT
);

Actions.add_console_entries(
'Re-Enter Program (backtrace)',
constants.console_entry_type.BACKTRACE_LINK
);
}
} else {
console.log('TODO handle new reason for stopping. Notify developer of this.');
console.log(r);
console.warn('TODO handle new reason for stopping. Notify developer of this.');
console.warn(r);
}
} else {
Actions.inferior_program_paused(r.payload.frame);
Expand Down

0 comments on commit d411aa2

Please sign in to comment.