@@ -9,7 +9,7 @@ extern char** environ;
99namespace tinykvm {
1010void Machine::print_remote_gdb_backtrace (
1111 const std::string& filename,
12- const std::string& gdb_path )
12+ const RemoteGDBOptions& opts )
1313{
1414 const uint16_t port = 2159 ;
1515
@@ -23,7 +23,7 @@ void Machine::print_remote_gdb_backtrace(
2323 throw std::runtime_error (" Unable to create script for debugging" );
2424 }
2525
26- const std::string debugscript =
26+ std::string debugscript =
2727 // Delete the script file (after GDB closes it)
2828 " shell unlink " + std::string (scrname)
2929 + " \n "
@@ -34,7 +34,9 @@ void Machine::print_remote_gdb_backtrace(
3434 " target remote localhost:"
3535 + std::to_string (port)
3636 + " \n "
37- + " up\n bt\n " ;
37+ + opts.command + " \n " ;
38+ if (opts.quit )
39+ debugscript += " quit\n " ;
3840
3941 ssize_t len = write (fd, debugscript.c_str (), debugscript.size ());
4042 if (len < (ssize_t )debugscript.size ())
@@ -45,7 +47,7 @@ void Machine::print_remote_gdb_backtrace(
4547 close (fd);
4648
4749 const char * argv[]
48- = {gdb_path.c_str (), " -x" , scrname, nullptr };
50+ = {opts. gdb_path .c_str (), " -x" , scrname, nullptr };
4951 // XXX: This is not kosher, but GDB is open-source, safe and let's not
5052 // pretend that anyone downloads gdb-multiarch from a website anyway.
5153 // There is a finite list of things we should pass to GDB to make it
@@ -58,10 +60,15 @@ void Machine::print_remote_gdb_backtrace(
5860 }
5961
6062 RSP server {filename, *this , port};
63+ if (opts.verbose ) {
64+ printf (" Waiting for GDB to connect on port %u...\n " , port);
65+ }
6166 auto client = server.accept ();
6267 if (client != nullptr )
6368 {
64- printf (" GDB connected\n " );
69+ if (opts.verbose ) {
70+ printf (" GDB connected\n " );
71+ }
6572 // client->set_verbose(true);
6673 while (client->process_one ())
6774 ;
0 commit comments