Skip to content

Commit

Permalink
Some more work after integration of PR debugger-always-enabled.
Browse files Browse the repository at this point in the history
- In the ask dialogs show debugger choice only if it is active.
- In logfunctions fatal() method check if debugger is active.
  • Loading branch information
vruppert committed Nov 29, 2024
1 parent 00bc229 commit 89f86ab
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bochs/gui/sdl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ int sdl2_ask_dialog(BxEvent *event)
i = 2;
}
#if BX_DEBUGGER || BX_GDBSTUB
if (mode == BX_LOG_DLG_ASK) {
if ((mode == BX_LOG_DLG_ASK) && (bx_dbg.debugger_active || BX_GDBSTUB)) {
buttondata[i].flags = 0;
buttondata[i].buttonid = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
buttondata[i].text = "Debugger";
Expand Down
1 change: 1 addition & 0 deletions bochs/gui/siminterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class bx_real_sim_c : public bx_simulator_interface_c {
virtual bool is_pci_device(const char *name);
virtual bool is_agp_device(const char *name);
#if BX_DEBUGGER
virtual bool debugger_active() {return bx_dbg.debugger_active;}
virtual void debug_break();
virtual void debug_interpret_cmd(char *cmd);
virtual char *debug_get_next_command();
Expand Down
1 change: 1 addition & 0 deletions bochs/gui/siminterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ class BOCHSAPI bx_simulator_interface_c {
// return 1 if device is connected to the AGP slot
virtual bool is_agp_device(const char *name) {return 0;}
#if BX_DEBUGGER
virtual bool debugger_active() {return false;}
// for debugger: same behavior as pressing control-C
virtual void debug_break() {}
virtual void debug_interpret_cmd(char *cmd) {}
Expand Down
11 changes: 6 additions & 5 deletions bochs/gui/textconfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ extern "C" {
#endif

#include "osdep.h"
#include "bx_debug/debug.h"
#include "param_names.h"
#include "logio.h"
#include "paramtree.h"
Expand Down Expand Up @@ -768,12 +767,12 @@ void bx_plugin_ctrl()
}
}

const char *log_action_ask_choices[] = { "cont", "alwayscont", "die", "abort", "debug" };
int log_action_n_choices = 4 + (BX_DEBUGGER||BX_GDBSTUB?1:0);

BxEvent *
textconfig_notify_callback(void *unused, BxEvent *event)
{
const char *log_action_ask_choices[] = { "cont", "alwayscont", "die", "abort", "debug" };
int log_action_n_choices = 4 + (SIM->debugger_active()||BX_GDBSTUB?1:0);

event->retcode = -1;
switch (event->type)
{
Expand All @@ -798,7 +797,9 @@ textconfig_notify_callback(void *unused, BxEvent *event)
fprintf(stderr, " abort - dump core %s\n",
BX_HAVE_ABORT ? "" : "(Disabled)");
#if BX_DEBUGGER
fprintf(stderr, " debug - continue and return to bochs debugger\n");
if (SIM->debugger_active()) {
fprintf(stderr, " debug - continue and return to bochs debugger\n");
}
#endif
#if BX_GDBSTUB
fprintf(stderr, " debug - hand control to gdb\n");
Expand Down
4 changes: 3 additions & 1 deletion bochs/gui/win32config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ static BOOL CALLBACK LogAskProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Kill simulation");
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Abort (dump core)");
#if BX_DEBUGGER
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
if (bx_dbg.debugger_active) {
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_ADDSTRING, 0, (LPARAM)"Continue and return to debugger");
}
#endif
SendMessage(GetDlgItem(hDlg, IDASKLIST), LB_SETCURSEL, 2, 0);
} else {
Expand Down
8 changes: 5 additions & 3 deletions bochs/gui/x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2596,9 +2596,11 @@ int x11_ask_dialog(BxEvent *event)
}
if (mode == BX_LOG_DLG_ASK) {
#if BX_DEBUGGER || BX_GDBSTUB
buttons.btn[i].label = "Debugger";
buttons.btn[i].code = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
i++;
if (bx_dbg.debugger_active) {
buttons.btn[i].label = "Debugger";
buttons.btn[i].code = BX_LOG_ASK_CHOICE_ENTER_DEBUG;
i++;
}
#endif
#if BX_HAVE_ABORT
buttons.btn[i].label = "Dump Core";
Expand Down
11 changes: 7 additions & 4 deletions bochs/logio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,14 @@ void logfunctions::fatal(int level, const char *prefix, const char *fmt, va_list
fprintf(stderr, "%s", exit_msg);
fprintf(stderr, "\n%s\n", divider);
}
#if !BX_DEBUGGER
BX_EXIT(exit_status);
#else
bx_dbg_exit(exit_status);
#if BX_DEBUGGER
if (bx_dbg.debugger_active) {
bx_dbg_exit(exit_status);
} else
#endif
{
BX_EXIT(exit_status);
}
// not safe to use BX_* log functions in here.
fprintf(stderr, "fatal() should never return, but it just did\n");
}
Expand Down

0 comments on commit 89f86ab

Please sign in to comment.