This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC][PATCH 03/15] Fix crash in enable/disable after detach
- From: henrik dot wallin at windriver dot com
- To: gdb-patches at sourceware dot org
- Date: Wed, 14 Oct 2015 13:14:21 +0200
- Subject: [RFC][PATCH 03/15] Fix crash in enable/disable after detach
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1444820235 dot git dot henrik dot wallin at windriver dot com>
- References: <cover dot 1444820235 dot git dot henrik dot wallin at windriver dot com>
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(-)
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index a2723e39e500..78a5eb028b72 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -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
--
2.1.4