@@ -36,7 +36,7 @@ void Machine::print_remote_gdb_backtrace(
3636 + " \n "
3737 + opts.command + " \n " ;
3838 if (opts.quit )
39- debugscript += " quit \n " ;
39+ debugscript += " disconnect \n quit \n " ;
4040
4141 ssize_t len = write (fd, debugscript.c_str (), debugscript.size ());
4242 if (len < (ssize_t )debugscript.size ())
@@ -46,16 +46,20 @@ void Machine::print_remote_gdb_backtrace(
4646 }
4747 close (fd);
4848
49- const char * argv[]
50- = {opts.gdb_path .c_str (), " -x" , scrname, nullptr };
51- // XXX: This is not kosher, but GDB is open-source, safe and let's not
52- // pretend that anyone downloads gdb-multiarch from a website anyway.
49+ std::vector<const char *> argv;
50+ argv.push_back (opts.gdb_path .c_str ());
51+ argv.push_back (" -x" );
52+ argv.push_back (scrname);
53+ if (opts.quit ) {
54+ argv.push_back (" -batch" );
55+ }
56+ argv.push_back (nullptr );
5357 // There is a finite list of things we should pass to GDB to make it
5458 // behave well, but I haven't been able to find the right combination.
55- if (-1 == execve (argv[0 ], (char * const *)argv, environ))
59+ if (-1 == execve (argv[0 ], (char * const *)argv. data () , environ))
5660 {
5761 throw std::runtime_error (
58- " Unable to start gdb-multiarch for debugging" );
62+ " Unable to start gdb for debugging" );
5963 }
6064 }
6165
0 commit comments