binutils-gdb/gdb/mi
Bruno Larsen c29a6445a9 gdb/frame: Add reinflation method for frame_info_ptr
Currently, despite having a smart pointer for frame_infos, GDB may
attempt to use an invalidated frame_info_ptr, which would cause internal
errors to happen.  One such example has been documented as PR
python/28856, that happened when printing frame arguments calls an
inferior function.

To avoid failures, the smart wrapper was changed to also cache the frame
id, so the pointer can be reinflated later.  For this to work, the
frame-id stuff had to be moved to their own .h file, which is included
by frame-info.h.

Frame_id caching is done explicitly using the prepare_reinflate method.
Caching is done manually so that only the pointers that need to be saved
will be, and reinflating has to be done manually using the reinflate
method because the get method and the -> operator must not change
the internals of the class.  Finally, attempting to reinflate when the
pointer is being invalidated causes the following assertion errors:

check_ptrace_stopped_lwp_gone: assertion `lp->stopped` failed.
get_frame_pc: Assertion `frame->next != NULL` failed.

As for performance concerns, my personal testing with `time make
chec-perf GDB_PERFTEST_MODE=run` showed an actual reduction of around
10% of time running.

This commit also adds a testcase that exercises the python/28856 bug with
7 different triggers, run, continue, step, backtrace, finish, up and down.
Some of them can seem to be testing the same thing twice, but since this
test relies on stale pointers, there is always a chance that GDB got lucky
when testing, so better to test extra.

Regression tested on x86_64, using both gcc and clang.

Approved-by: Tom Tomey <tom@tromey.com>
2022-10-10 11:57:10 +02:00
..
ChangeLog-1999-2003
mi-cmd-break.c
mi-cmd-break.h
mi-cmd-catch.c
mi-cmd-disas.c gdb/mi: new options for -data-disassemble command 2022-10-02 11:58:28 +01:00
mi-cmd-env.c
mi-cmd-file.c
mi-cmd-info.c
mi-cmd-stack.c gdb/frame: Add reinflation method for frame_info_ptr 2022-10-10 11:57:10 +02:00
mi-cmd-target.c
mi-cmd-var.c
mi-cmds.c gdb/mi: fix breakpoint script field output 2022-08-10 15:38:19 -04:00
mi-cmds.h
mi-common.c
mi-common.h
mi-console.c
mi-console.h
mi-getopt.c
mi-getopt.h
mi-interp.c Remove a call to clear_interpreter_hooks 2022-08-31 11:03:40 -06:00
mi-interp.h Remove two unused members from mi_interp 2022-08-31 11:03:40 -06:00
mi-main.c Change GDB to use frame_info_ptr 2022-10-10 11:57:10 +02:00
mi-main.h gdb/mi: fix breakpoint script field output 2022-08-10 15:38:19 -04:00
mi-out.c Use checked_static_cast in more places 2022-09-12 14:25:06 -06:00
mi-out.h gdb/mi: fix breakpoint script field output 2022-08-10 15:38:19 -04:00
mi-parse.c
mi-parse.h
mi-symbol-cmds.c