From patchwork Tue Dec 3 06:20:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 36454 Received: (qmail 74716 invoked by alias); 3 Dec 2019 06:20:37 -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 74701 invoked by uid 89); 3 Dec 2019 06:20:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.9 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=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; Tue, 03 Dec 2019 06:20:35 +0000 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id qqLEjER1SYcJHAZl (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 03 Dec 2019 01:20:32 -0500 (EST) Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id C7FC6441B21; Tue, 3 Dec 2019 01:20:32 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] Fix regcache::cooked_read_test selftest for mep Date: Tue, 3 Dec 2019 01:20:30 -0500 Message-Id: <20191203062031.2844278-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 X-IsSubscribed: yes When running the regcache::cooked_read_test selftest in an all targets build, I get the following internal error: /home/simark/src/binutils-gdb/gdb/thread.c:95: internal-error: thread_info* inferior_thread(): Assertion `tp' failed. The stack trace is the followiing: #9 0x000055fe25584a52 in internal_error (file=0x55fe27a25fe0 "/home/simark/src/binutils-gdb/gdb/thread.c", line=95, fmt=0x55fe27a25c80 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdb/gdbsupport/errors.c:55 #10 0x000055fe260674bc in inferior_thread () at /home/simark/src/binutils-gdb/gdb/thread.c:95 #11 0x000055fe25c62f0f in get_current_regcache () at /home/simark/src/binutils-gdb/gdb/regcache.c:372 #12 0x000055fe2594fcf1 in current_options () at /home/simark/src/binutils-gdb/gdb/mep-tdep.c:873 #13 0x000055fe2594ff08 in mep_register_name (gdbarch=0x62100056f510, regnr=152) at /home/simark/src/binutils-gdb/gdb/mep-tdep.c:958 #14 0x000055fe25950112 in mep_register_reggroup_p (gdbarch=0x62100056f510, regnum=152, group=0x55fe2924d540 ) at /home/simark/src/binutils-gdb/gdb/mep-tdep.c:1029 #15 0x000055fe2555ad87 in gdbarch_register_reggroup_p (gdbarch=0x62100056f510, regnum=152, reggroup=0x55fe2924d540 ) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:3622 #16 0x000055fe25c61d45 in reg_buffer::save(gdb::function_view) (this=0x7ffc61a0ed90, cooked_read=...) at /home/simark/src/binutils-gdb/gdb/regcache.c:247 #17 0x000055fe2552ac60 in readonly_detached_regcache::readonly_detached_regcache(gdbarch*, gdb::function_view) (this=0x7ffc61a0ed90, gdbarch=0x62100056f510, cooked_read=...) at /home/simark/src/binutils-gdb/gdb/regcache.h:444 #18 0x000055fe25c61867 in readonly_detached_regcache::readonly_detached_regcache (this=0x7ffc61a0ed90, src=...) at /home/simark/src/binutils-gdb/gdb/regcache.c:212 #19 0x000055fe25c6a5ca in selftests::cooked_read_test (gdbarch=0x62100056f510) at /home/simark/src/binutils-gdb/gdb/regcache.c:1613 The problems is that mep's code ends up calling inferior_thread, which calls find_thread_ptid. find_thread_ptid searches for a thread by ptid in the thread list of the inferior that is expected to contain that thread. However, the thread list of the mock inferior set up in cooked_read_test is never initialized. So find_thread_ptid doesn't find the thread, which is an unexpected situation for inferior_thread. This is failing since this commit: 080363310650c93ad8e93018bcb6760ba5d32d1c Per-inferior thread list, thread ranges/iterators, down with ALL_THREADS, etc. Fix it by putting the mock thread in the thread list of the mock inferior in cooked_read_test. gdb/ChangeLog: * regcache.c (cooked_read_test): Initialize thread list of mock_inferior. --- gdb/regcache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gdb/regcache.c b/gdb/regcache.c index 2e8b52ee751e..f0f7730f3e4c 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1535,6 +1535,7 @@ cooked_read_test (struct gdbarch *gdbarch) mock_inferior.gdbarch = gdbarch; mock_inferior.aspace = &mock_aspace; thread_info mock_thread (&mock_inferior, mock_ptid); + mock_inferior.thread_list = &mock_thread; /* Add the mock inferior to the inferior list so that look ups by target+ptid can find it. */