From d411aa2f12859d9c9bd93dc5eba4c964a59812fa Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Mon, 28 May 2018 15:14:41 -0700 Subject: [PATCH] add pause button; do not display signal message to backtract in console on SIGINT (#202) --- examples/c/sleeper.c | 2 +- gdbgui/src/js/Actions.js | 35 +++++++++++++++ gdbgui/src/js/InferiorProgramInfo.jsx | 45 ++----------------- gdbgui/src/js/TopBar.jsx | 63 +-------------------------- gdbgui/src/js/process_gdb_response.js | 45 ++++++++++--------- 5 files changed, 66 insertions(+), 124 deletions(-) diff --git a/examples/c/sleeper.c b/examples/c/sleeper.c index 51148481..c3bb4c1b 100644 --- a/examples/c/sleeper.c +++ b/examples/c/sleeper.c @@ -2,7 +2,7 @@ #include #include -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 diff --git a/gdbgui/src/js/Actions.js b/gdbgui/src/js/Actions.js index 605e24d2..f2b905b8 100644 --- a/gdbgui/src/js/Actions.js +++ b/gdbgui/src/js/Actions.js @@ -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; diff --git a/gdbgui/src/js/InferiorProgramInfo.jsx b/gdbgui/src/js/InferiorProgramInfo.jsx index f03ed781..91188dc4 100644 --- a/gdbgui/src/js/InferiorProgramInfo.jsx +++ b/gdbgui/src/js/InferiorProgramInfo.jsx @@ -1,12 +1,11 @@ -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', @@ -14,42 +13,6 @@ class InferiorProgramInfo extends React.Component { }; 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 = {}; @@ -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 @@ -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 ) diff --git a/gdbgui/src/js/TopBar.jsx b/gdbgui/src/js/TopBar.jsx index bb773710..4860d699 100644 --- a/gdbgui/src/js/TopBar.jsx +++ b/gdbgui/src/js/TopBar.jsx @@ -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'; @@ -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; @@ -284,65 +283,7 @@ class TopBar extends React.Component { } /> - - - - - - -
- - -
+ ); } diff --git a/gdbgui/src/js/process_gdb_response.js b/gdbgui/src/js/process_gdb_response.js index e9ec0c5a..b18cde84 100644 --- a/gdbgui/src/js/process_gdb_response.js +++ b/gdbgui/src/js/process_gdb_response.js @@ -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);