[RFC,05/15] Fix crash when tstart after detach.
Commit Message
From: Par Olsson <par.olsson@windriver.com>
When calling tstart after detaching the process,
gdbserver tries to access inferior memory which
results in a crash.
Also add error message when calling tstart if
there is no inferior.
gdb/gdbserver/ChangeLog:
* tracepoint.c (cmd_qtinit): Add check that inferior is
present before calling clear_inferior_trace_buffer.
(cmd_qtstart): Add check that inferior is present.
Signed-off-by: Par Olsson <par.olsson@windriver.com>
Signed-off-by: Henrik Wallin <henrik.wallin@windriver.com>
---
gdb/gdbserver/tracepoint.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
Comments
On 10/14/2015 12:14 PM, henrik.wallin@windriver.com wrote:
> From: Par Olsson <par.olsson@windriver.com>
>
> When calling tstart after detaching the process,
> gdbserver tries to access inferior memory which
> results in a crash.
> Also add error message when calling tstart if
> there is no inferior.
>
You know what I'll ask for by now. :-)
Thanks,
Pedro Alves
@@ -2402,7 +2402,8 @@ cmd_qtinit (char *packet)
}
clear_trace_buffer ();
- clear_inferior_trace_buffer ();
+ if (agent_loaded_p ())
+ clear_inferior_trace_buffer ();
write_ok (packet);
}
@@ -3203,6 +3204,13 @@ cmd_qtstart (char *packet)
struct tracepoint *tpoint, *prev_ftpoint, *prev_stpoint;
CORE_ADDR tpptr = 0, prev_tpptr = 0;
+ if (current_thread == NULL)
+ {
+ trace_debug ("Trying to start the trace without inferior");
+ strcpy (packet, "E.No process attached.");
+ return;
+ }
+
trace_debug ("Starting the trace");
/* Pause all threads temporarily while we patch tracepoints. */