gdb: make regcache's cooked_write_test selftest work with native-extended-gdbserver...
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 5 May 2022 13:54:59 +0000 (09:54 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 5 May 2022 14:09:22 +0000 (10:09 -0400)
commitd890c720b8c4daf8892a175296d8e88ec992c92d
tree482d385e3089d0f769d1948cde9c24a32aa3976d
parent8e1ada9e0bd4f57597b835b2d09b100d24c604d8
gdb: make regcache's cooked_write_test selftest work with native-extended-gdbserver board

Running

    $ make check TESTS="gdb.gdb/unittest.exp" RUNTESTFLAGS="--target_board=native-extended-gdbserver"

I get some failures:

    Running selftest regcache::cooked_write_test::i386.^M
    Self test failed: target already pushed^M
    Running selftest regcache::cooked_write_test::i386:intel.^M
    Self test failed: target already pushed^M
    Running selftest regcache::cooked_write_test::i386:x64-32.^M
    Self test failed: target already pushed^M
    Running selftest regcache::cooked_write_test::i386:x64-32:intel.^M
    Self test failed: target already pushed^M
    Running selftest regcache::cooked_write_test::i386:x86-64.^M
    Self test failed: target already pushed^M
    Running selftest regcache::cooked_write_test::i386:x86-64:intel.^M
    Self test failed: target already pushed^M
    Running selftest regcache::cooked_write_test::i8086.^M
    Self test failed: target already pushed^M

This is because the native-extended-gdbserver automatically connects GDB
to a GDBserver on startup, and therefore pushes a remote target on the
initial inferior.  cooked_write_test is currently written in a way that
errors out if the current inferior has a process_stratum_target pushed.

Rewrite it to use scoped_mock_context, so it doesn't depend on the
current inferior (the current one upon entering the function).

Change-Id: I0357f989eacbdecc4bf88b043754451b476052ad
gdb/regcache.c