Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] sim: don't rely on inferior_ptid in gdbsim_target::wait
@ 2020-01-19 16:07 Simon Marchi
  2020-01-19 23:23 ` Andrew Burgess
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2020-01-19 16:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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.
---
 gdb/remote-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index fb05786d4e28..d43648bd5171 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -1016,7 +1016,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
-- 
2.24.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-20 15:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-19 16:07 [PATCH] sim: don't rely on inferior_ptid in gdbsim_target::wait Simon Marchi
2020-01-19 23:23 ` Andrew Burgess
2020-01-20  0:49   ` Simon Marchi
2020-01-20 15:28     ` Pedro Alves
2020-01-20 15:48       ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox