gdbserver: Fix crash when QTinit is handled with no inferior process attached

When gdbserver is called with --multi and attach has not been called yet
and tstart is called on the gdb client, gdbserver would crash.
This patch fixes gdbserver so that it returns E01 to the gdb client.

Also this patch adds a testcase to verify this bug named no-attach-trace.exp

gdb/gdbserver/ChangeLog:
	PR breakpoints/15956
	* tracepoint.c (cmd_qtinit): Add check for current_thread.

gdb/testsuite/ChangeLog:
	* gdb.trace/no-attach-trace.c: New file.
	* gdb.trace/no-attach-trace.exp: New file.
This commit is contained in:
Antoine Tremblay 2015-01-26 13:08:53 -05:00
parent 3ac240d438
commit b05ec7a53f
6 changed files with 98 additions and 2 deletions

View file

@ -2377,6 +2377,13 @@ cmd_qtinit (char *packet)
{
struct trace_state_variable *tsv, *prev, *next;
/* Can't do this command without a pid attached. */
if (current_thread == NULL)
{
write_enn (packet);
return;
}
/* Make sure we don't try to read from a trace frame. */
current_traceframe = -1;