From f2c9a503d19d61b9b07faf5b95d7ffcaacbac527 Mon Sep 17 00:00:00 2001 From: Volker Ruppert Date: Thu, 18 Dec 2014 20:29:37 +0000 Subject: [PATCH] Added debugger support for the term gui using a pseudo-terminal. The command-line debugger appears on main terminal and Bochs screen on pseudo-terminal connected to minicom (based on SF patch #522). --- bochs/gui/term.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/bochs/gui/term.cc b/bochs/gui/term.cc index 809c65c89..55d68b837 100644 --- a/bochs/gui/term.cc +++ b/bochs/gui/term.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2000-2013 The Bochs Project +// Copyright (C) 2000-2014 The Bochs Project // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -50,6 +50,9 @@ public: // declare one instance of the gui object and call macro to insert the // plugin code static bx_term_gui_c *theGui = NULL; +#if BX_DEBUGGER +static int scr_fd = -1; +#endif IMPLEMENT_GUI_PLUGIN_CODE(term) #define LOG_THIS theGui-> @@ -180,12 +183,27 @@ void bx_term_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y) // the ask menu causes trouble io->set_log_action(LOGLEV_PANIC, ACT_FATAL); +#if !BX_DEBUGGER // logfile should be different from stderr, otherwise terminal mode // really ends up having fun if (!strcmp(SIM->get_param_string(BXPN_LOG_FILENAME)->getptr(), "-")) BX_PANIC(("cannot log to stderr in term mode")); - +#else + FILE *old_stdin = stdin; + FILE *old_stdout = stdout; + scr_fd = open("/dev/ptmx",O_RDWR); + if(scr_fd > 0){ + stdin = stdout = fdopen(scr_fd,"wr"); + grantpt(scr_fd); + unlockpt(scr_fd); + fprintf(stderr, "\nBochs connected to screen \"%s\"\n",ptsname(scr_fd)); + } +#endif initscr(); +#if BX_DEBUGGER + stdin = old_stdin; + stdout = old_stdout; +#endif start_color(); cbreak(); curs_set(2); @@ -775,6 +793,10 @@ void bx_term_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id) void bx_term_gui_c::exit(void) { if (!initialized) return; +#if BX_DEBUGGER + if(scr_fd > 0) + close(scr_fd); +#endif clear(); flush(); endwin();