[gdb/symtab] Implement addrmap_mutable_find
authorTom de Vries <tdevries@suse.de>
Wed, 4 Aug 2021 10:53:47 +0000 (12:53 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 4 Aug 2021 10:53:47 +0000 (12:53 +0200)
commit6a7ee0010e63a3eac4c58c48f2484a0fafdb7d2e
tree1ee105086a4085c759131cb02827edefb851887f
parenta83ef1c760b4146d49d0f5729989e300ed4261fa
[gdb/symtab] Implement addrmap_mutable_find

Currently addrmap_mutable_find is not implemented:
...
static void *
addrmap_mutable_find (struct addrmap *self, CORE_ADDR addr)
{
  /* Not needed yet.  */
  internal_error (__FILE__, __LINE__,
                  _("addrmap_find is not implemented yet "
                    "for mutable addrmaps"));
}
...

I implemented this because I needed it during debugging, to be able to do:
...
(gdb) p ((dwarf2_psymtab *)addrmap_find (map, addr))->filename
...
before and after a call to addrmap_set_empty.

Since this is not used otherwise, added addrmap unit test.

Build on x86_64-linux, tested by doing:
...
$ gdb -q -batch -ex "maint selftest addrmap"
Running selftest addrmap.
Ran 1 unit tests, 0 failed
...

gdb/ChangeLog:

2021-08-03  Tom de Vries  <tdevries@suse.de>

        * gdb/addrmap.c (addrmap_mutable_find): Implement
        [GDB_SELF_TESTS] (CHECK_ADDRMAP_FIND): New macro.
        [GDB_SELF_TESTS] (core_addr, addrmap_foreach_check, test_addrmap)
(_initialize_addrmap): New function.
gdb/addrmap.c