Message ID | 20200119035557.5975-1-simon.marchi@polymtl.ca |
---|---|
State | New, archived |
Headers |
Received: (qmail 74260 invoked by alias); 19 Jan 2020 03:56:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 74249 invoked by uid 89); 19 Jan 2020 03:56:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.1 spammy=remotesimc, remote-sim.c, UD:remote-sim.c, HContent-Transfer-Encoding:8bit X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 19 Jan 2020 03:56:00 +0000 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id labvTIcgCo4R5zDK (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 18 Jan 2020 22:55:58 -0500 (EST) Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 6108A441B21; Sat, 18 Jan 2020 22:55:58 -0500 (EST) From: Simon Marchi <simon.marchi@polymtl.ca> To: gdb-patches@sourceware.org Cc: Simon Marchi <simon.marchi@polymtl.ca> Subject: [PATCH] sim: don't rely on inferior_ptid in gdbsim_target::wait Date: Sat, 18 Jan 2020 22:55:57 -0500 Message-Id: <20200119035557.5975-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes |
Commit Message
Simon Marchi
Jan. 19, 2020, 3:55 a.m. UTC
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(-)
Comments
* Simon Marchi <simon.marchi@polymtl.ca> [2020-01-18 22:55:57 -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. This makes sense. LGTM. Thanks, Andrew > --- > 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 >
On 2020-01-19 4:12 p.m., Andrew Burgess wrote: > * Simon Marchi <simon.marchi@polymtl.ca> [2020-01-18 22:55:57 -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. > > This makes sense. LGTM. > > Thanks, > Andrew Thanks, I pushed it. Simon
On 1/20/20 12:48 AM, Simon Marchi wrote: > On 2020-01-19 4:12 p.m., Andrew Burgess wrote: >> * Simon Marchi <simon.marchi@polymtl.ca> [2020-01-18 22:55:57 -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. >> >> This makes sense. LGTM. >> >> Thanks, >> Andrew > > Thanks, I pushed it. Thanks for doing this. This was a recent assertion I added with the multi-target work. It's possibly (and likely) that other ports will need similar adjustments, but it's hard to tell with actually running into the issue. Thanks, Pedro Alves
On 2020-01-20 10:13 a.m., Pedro Alves wrote: > Thanks for doing this. This was a recent assertion I added with > the multi-target work. It's possibly (and likely) that other ports > will need similar adjustments, but it's hard to tell with actually > running into the issue. For the record, this commit [1] helped me understand that this was expected, and that not using inferior_ptid was indeed the right fix. [1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=e7af6c702da7a77529afdeffbbe6e13639beb441 Simon
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