Fix regcache::cooked_read_test selftest for mep
authorSimon Marchi <simon.marchi@polymtl.ca>
Wed, 4 Dec 2019 18:35:32 +0000 (13:35 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Dec 2019 18:35:32 +0000 (13:35 -0500)
commit894ecaf4cad84e6d50d97d36f5ddaf3695734c35
tree602f91f194272aa2428aa549e04d933c5d1757f4
parentbe155ebb949dd8e7ef6a494a9c276c3c4673643c
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 <save_group>) at /home/simark/src/binutils-gdb/gdb/mep-tdep.c:1029
    #15 0x000055fe2555ad87 in gdbarch_register_reggroup_p (gdbarch=0x62100056f510, regnum=152, reggroup=0x55fe2924d540 <save_group>) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:3622
    #16 0x000055fe25c61d45 in reg_buffer::save(gdb::function_view<register_status (int, unsigned char*)>) (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<register_status (int, unsigned char*)>) (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/ChangeLog
gdb/regcache.c
This page took 0.025779 seconds and 4 git commands to generate.