[PATCH] remote-sim add call to init_thread_list

Andrew Burgess aburgess@broadcom.com
Wed Oct 3 12:05:00 GMT 2012

When running using a basic exec style target (on linux) I see the following behaviour:

> gdb ./test-program
(gdb) start
(gdb) info threads
  Id   Target Id         Frame 
* 1    process 12285     main () at hello.c:5
(gdb) start
The program being debugged has been started already.
Start it from the beginning? (y or n) y

(gdb) info threads 
  Id   Target Id         Frame 
* 1    process 16295     main () at hello.c:5

## END ##

Notice that the thread ID remains as 1 after the restart.  This is due to the call to init_thread_list in gdb/fork-child.c:fork_inferior.

Currently, when using a simulator target, the ID will increment on each restart.

The patch below adds a similar call to init_thread_list to remote-sim.c:create_inferior so the simulator behaviour will match the native exec style target behaviour.

OK to apply?



2012-10-03  Andrew Burgess <aburgess@broadcom.com>

	* remote-sim.c (gdbsim_create_inferior): Call init_thread_list to
	reset thread numbering back to 1.

diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 14e989c..adc77e7 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -640,6 +640,9 @@ gdbsim_create_inferior (struct target_ops *target, char *exec_file, char *args,
     argv = NULL;
+  if (!have_inferiors ())
+    init_thread_list ();
   if (sim_create_inferior (sim_data->gdbsim_desc, exec_bfd, argv, env)
       != SIM_RC_OK)
     error (_("Unable to create sim inferior."));

More information about the Gdb-patches mailing list