Don't write to inferior_ptid in gdbarch-selftests.c, mock address_space too
authorPedro Alves <palves@redhat.com>
Thu, 18 Jun 2020 20:28:19 +0000 (21:28 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 18 Jun 2020 22:03:47 +0000 (23:03 +0100)
commitc5316fc6e634858a3821e612e613342da562e0b3
treea77bdcb78df2ebdc878007f1d0d2cbc116af263a
parent8df017996f662ce6ab23aea4abeb8f7ac1f62651
Don't write to inferior_ptid in gdbarch-selftests.c, mock address_space too

Use switch_to_thread instead of writing to inferior_ptid.  This
requires a couple of improvements to the mocking environment.  One is
to mock a pspace too, and assigning it to the inferior.  In turn, this
requires heap-allocating the address space, so that the regular
program_space dtor destroys the address space correctly.

(Note that new the mock program_space is allocated on the stack, and
thus depends on the previous patch that eliminated
delete_program_space.)

gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

* gdbarch-selftests.c: Include "progspace-and-thread.h".
(register_to_value_test): Mock a program_space too.  Heap-allocate
the address space.  Don't write to inferior_ptid.  Use
switch_to_thread instead.
gdb/ChangeLog
gdb/gdbarch-selftests.c