From: Simon Marchi Date: Wed, 4 Dec 2019 18:35:32 +0000 (-0500) Subject: Fix regcache::cooked_read_test selftest for mep X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=894ecaf4cad84e6d50d97d36f5ddaf3695734c35;p=binutils-gdb.git Fix regcache::cooked_read_test selftest for mep 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 50f32638b42..14c06e49eed 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-12-04 Simon Marchi + + * regcache.c (cooked_read_test): Initialize thread list of + mock_inferior. + 2019-12-04 Simon Marchi * aarch64-linux-tdep.c: Remove includes. diff --git a/gdb/regcache.c b/gdb/regcache.c index 2e8b52ee751..f0f7730f3e4 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. */