From patchwork Sun Jan 19 03:55:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 37440 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: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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 To: gdb-patches@sourceware.org Cc: Simon Marchi 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 X-IsSubscribed: yes 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