sim: don't rely on inferior_ptid in gdbsim_target::wait
authorSimon Marchi <simon.marchi@polymtl.ca>
Mon, 20 Jan 2020 00:47:49 +0000 (19:47 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Mon, 20 Jan 2020 00:48:16 +0000 (19:48 -0500)
When running a program with the simulator target, I get:

    /home/simark/src/binutils-gdb/gdb/inferior.c:279: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.

This can be reproduced by building a GDB for --target=arm-none-gnueabi,
and running with

    $ ./gdb -nx --data-directory=data-directory a.out -ex "target sim" -ex load -ex "b main" -ex r

Where a.out is any program with a main.

The problem is that gdbsim_target::wait assumes that inferior_ptid has
the value of the thread it wants to report an event for.

Actually, it's the target's responsibility to come up with the ptid of
the thread the event is for.  In the sim target, that ptid is stored in
sim_inferior_data::remote_sim_ptid, so return that instead of
inferior_ptid.

ChangeLog:

* remote-sim.c (gdbsim_target::wait): Return
sim_data->remote_sim_ptid instead of inferior_ptid.

ChangeLog
gdb/remote-sim.c

index e75c8c249c9f28a971d6fdf5b770fddcc06c344c..582d1f27704688934176d730f621f4e7460e3aa8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-19  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * remote-sim.c (gdbsim_target::wait): Return
+       sim_data->remote_sim_ptid instead of inferior_ptid.
+
 2020-01-18  Nick Clifton  <nickc@redhat.com>
 
        Binutils 2.34 branch created.
index ac3b4d3a58014d56e8098f99ad9cdec375ace391..caa94464e1eb478aaf83140d4cc98c77f5eae076 100644 (file)
@@ -1022,7 +1022,7 @@ gdbsim_target::wait (ptid_t ptid, struct target_waitstatus *status, int options)
       break;
     }
 
-  return inferior_ptid;
+  return sim_data->remote_sim_ptid;
 }
 
 /* Get ready to modify the registers array.  On machines which store
This page took 0.03071 seconds and 4 git commands to generate.