This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC][PATCH 05/15] Fix crash when tstart after detach.


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(-)

diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 78a5eb028b72..d2ad197e58ab 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -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.  */
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]