[RFC,03/15] Fix crash in enable/disable after detach
Commit Message
From: Par Olsson <par.olsson@windriver.com>
When calling enable/disable on a fast tracepoint
after detaching the process, gdbserver tries to
access inferior memory which results in a crash.
gdb/gdbserver/ChangeLog:
* tracepoint.c (cmd_qtenable_disable): Fix problem with
enabling tracepoint after inferior have disconnected.
Signed-off-by: Par Olsson <par.olsson@windriver.com>
Signed-off-by: Henrik Wallin <henrik.wallin@windriver.com>
---
gdb/gdbserver/tracepoint.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Comments
On 10/14/2015 12:14 PM, henrik.wallin@windriver.com wrote:
> From: Par Olsson <par.olsson@windriver.com>
>
> When calling enable/disable on a fast tracepoint
> after detaching the process, gdbserver tries to
> access inferior memory which results in a crash.
>
> gdb/gdbserver/ChangeLog:
>
> * tracepoint.c (cmd_qtenable_disable): Fix problem with
> enabling tracepoint after inferior have disconnected.
Can you write/show a test case?
Thanks,
Pedro Alves
2015-10-15 18:30 GMT+02:00 Pedro Alves <palves@redhat.com>:
> On 10/14/2015 12:14 PM, henrik.wallin@windriver.com wrote:
>> From: Par Olsson <par.olsson@windriver.com>
>>
>> When calling enable/disable on a fast tracepoint
>> after detaching the process, gdbserver tries to
>> access inferior memory which results in a crash.
>>
>> gdb/gdbserver/ChangeLog:
>>
>> * tracepoint.c (cmd_qtenable_disable): Fix problem with
>> enabling tracepoint after inferior have disconnected.
>
> Can you write/show a test case?
Yes, I will loook into adding that. Same for the other ones :)
thanks,
/ Henrik
>
> Thanks,
> Pedro Alves
>
@@ -2775,14 +2775,20 @@ cmd_qtenable_disable (char *own_buf, int enable)
enable ? "Enabling" : "Disabling",
(int) num, paddress (addr));
- tp->enabled = enable;
-
if (tp->type == fast_tracepoint || tp->type == static_tracepoint)
{
int ret;
int offset = offsetof (struct tracepoint, enabled);
CORE_ADDR obj_addr = tp->obj_addr_on_target + offset;
+ if (current_thread == NULL)
+ {
+ trace_debug ("Trying to enable/disable the tracepoint "
+ "without inferior");
+ strcpy (own_buf, "E.No process attached.");
+ return;
+ }
+
ret = prepare_to_access_memory ();
if (ret)
{
@@ -2803,6 +2809,8 @@ cmd_qtenable_disable (char *own_buf, int enable)
}
}
+ tp->enabled = enable;
+
write_ok (own_buf);
}
else