[PATCH v4 0/5] Smart pointer wrapper for frame_info
Bruno Larsen
blarsen@redhat.com
Tue Aug 30 10:08:32 GMT 2022
GDB occasionally gets bugs where a frame_info is kept alive across a
call to reinit_frame_cache. This causes a use-after-free and, if
you're lucky, a crash.
This series aims to make this setup more "reliable", in the sense that
you'll always get a crash if you break the rules. This is done by
wrapping frame_info in a smart pointer class, and having
reinit_frame_cache invalidate all the pointers.
Tromey's original plan was that these pointers could be automatically
reinflated after being invalidated, but most uses of the class would not
need to be reinflated, and setting everything up to be reinflatable
would be quite expensive, as calculating a frame_id requires some
unwinding.
I added a prepare_reinflate method, which stashes the relevant frame_id
and allows the pointer to be reinflated. However, reinflation is done
manually for now because doing it when reinit_frame_cache was creating
weird problems.
Changelog:
v3:
Reverted instrusive list changes
Guile doesn't get fancy pointers because of exceptions through longjumps.
v2:
Fix commit squashing and email threading
Version 2 had some problematic squashing of commits, and I tried to add
some unit tests, but those didn't work out, so I eventually dropped
that.
Bruno Larsen (2):
Continue making GDB use frame_info_ptr
gdb/frame: Add reinflation method for frame_info_ptr
Tom Tromey (3):
Remove frame_id_eq
Introduce frame_info_ptr smart pointer class
Change GDB to use frame_info_ptr
gdb/aarch64-fbsd-tdep.c | 2 +-
gdb/aarch64-linux-tdep.c | 2 +-
gdb/aarch64-tdep.c | 34 +-
gdb/ada-lang.c | 10 +-
gdb/ada-lang.h | 4 +-
gdb/alpha-linux-tdep.c | 2 +-
gdb/alpha-mdebug-tdep.c | 16 +-
gdb/alpha-netbsd-tdep.c | 2 +-
gdb/alpha-obsd-tdep.c | 2 +-
gdb/alpha-tdep.c | 22 +-
gdb/alpha-tdep.h | 2 +-
gdb/amd64-darwin-tdep.c | 2 +-
gdb/amd64-fbsd-tdep.c | 2 +-
gdb/amd64-linux-tdep.c | 6 +-
gdb/amd64-netbsd-tdep.c | 4 +-
gdb/amd64-obsd-tdep.c | 12 +-
gdb/amd64-sol2-tdep.c | 2 +-
gdb/amd64-tdep.c | 34 +-
gdb/amd64-tdep.h | 2 +-
gdb/amd64-windows-tdep.c | 12 +-
gdb/arc-linux-tdep.c | 4 +-
gdb/arc-tdep.c | 20 +-
gdb/arc-tdep.h | 4 +-
gdb/arch-utils.c | 6 +-
gdb/arch-utils.h | 8 +-
gdb/arm-fbsd-tdep.c | 2 +-
gdb/arm-linux-tdep.c | 14 +-
gdb/arm-obsd-tdep.c | 2 +-
gdb/arm-tdep.c | 64 ++--
gdb/arm-tdep.h | 4 +-
gdb/arm-wince-tdep.c | 2 +-
gdb/avr-tdep.c | 14 +-
gdb/ax-gdb.c | 2 +-
gdb/bfin-linux-tdep.c | 2 +-
gdb/bfin-tdep.c | 12 +-
gdb/blockframe.c | 8 +-
gdb/bpf-tdep.c | 8 +-
gdb/break-catch-throw.c | 2 +-
gdb/breakpoint.c | 20 +-
gdb/c-lang.c | 2 +-
gdb/cli/cli-cmds.c | 2 +-
gdb/compile/compile-c-symbols.c | 2 +-
gdb/compile/compile-cplus-symbols.c | 2 +-
gdb/compile/compile-loc2c.c | 2 +-
gdb/cp-abi.c | 2 +-
gdb/cp-abi.h | 6 +-
gdb/cris-tdep.c | 36 +-
gdb/csky-linux-tdep.c | 2 +-
gdb/csky-tdep.c | 22 +-
gdb/defs.h | 2 +-
gdb/dtrace-probe.c | 4 +-
gdb/dummy-frame.c | 12 +-
gdb/dummy-frame.h | 2 +-
gdb/dwarf2/expr.c | 20 +-
gdb/dwarf2/expr.h | 6 +-
gdb/dwarf2/frame-tailcall.c | 41 +--
gdb/dwarf2/frame-tailcall.h | 6 +-
gdb/dwarf2/frame.c | 39 +--
gdb/dwarf2/frame.h | 12 +-
gdb/dwarf2/loc.c | 38 +--
gdb/dwarf2/loc.h | 8 +-
gdb/elfread.c | 4 +-
gdb/eval.c | 2 +-
gdb/extension-priv.h | 2 +-
gdb/extension.c | 2 +-
gdb/extension.h | 4 +-
gdb/f-valprint.c | 2 +-
gdb/findvar.c | 26 +-
gdb/frame-base.c | 8 +-
gdb/frame-base.h | 12 +-
gdb/frame-id.h | 135 ++++++++
gdb/frame-info.h | 206 +++++++++++
gdb/frame-unwind.c | 26 +-
gdb/frame-unwind.h | 36 +-
gdb/frame.c | 323 +++++++++---------
gdb/frame.h | 278 +++++----------
gdb/frv-linux-tdep.c | 10 +-
gdb/frv-tdep.c | 10 +-
gdb/ft32-tdep.c | 8 +-
gdb/gcore.c | 2 +-
gdb/gdbarch-components.py | 30 +-
gdb/gdbarch-gen.h | 60 ++--
gdb/gdbarch-selftests.c | 2 +-
gdb/gdbarch.c | 30 +-
gdb/gdbtypes.h | 5 +-
gdb/gnu-v3-abi.c | 2 +-
gdb/h8300-tdep.c | 12 +-
gdb/hppa-bsd-tdep.c | 2 +-
gdb/hppa-linux-tdep.c | 8 +-
gdb/hppa-netbsd-tdep.c | 4 +-
gdb/hppa-tdep.c | 32 +-
gdb/hppa-tdep.h | 8 +-
gdb/i386-bsd-tdep.c | 2 +-
gdb/i386-darwin-tdep.c | 4 +-
gdb/i386-darwin-tdep.h | 2 +-
gdb/i386-fbsd-tdep.c | 2 +-
gdb/i386-gnu-tdep.c | 6 +-
gdb/i386-linux-tdep.c | 10 +-
gdb/i386-netbsd-tdep.c | 4 +-
gdb/i386-nto-tdep.c | 4 +-
gdb/i386-obsd-tdep.c | 10 +-
gdb/i386-sol2-tdep.c | 2 +-
gdb/i386-tdep.c | 54 +--
gdb/i386-tdep.h | 10 +-
gdb/i386-windows-tdep.c | 2 +-
gdb/i387-tdep.c | 6 +-
gdb/i387-tdep.h | 8 +-
gdb/ia64-libunwind-tdep.c | 12 +-
gdb/ia64-libunwind-tdep.h | 12 +-
gdb/ia64-tdep.c | 54 +--
gdb/ia64-tdep.h | 4 +-
gdb/infcall.c | 4 +-
gdb/infcmd.c | 30 +-
gdb/inferior.h | 6 +-
gdb/infrun.c | 78 +++--
gdb/infrun.h | 4 +-
gdb/inline-frame.c | 14 +-
gdb/inline-frame.h | 4 +-
gdb/iq2000-tdep.c | 10 +-
gdb/jit.c | 12 +-
gdb/language.c | 6 +-
gdb/language.h | 8 +-
gdb/lm32-tdep.c | 8 +-
gdb/loongarch-linux-tdep.c | 4 +-
gdb/loongarch-tdep.c | 8 +-
gdb/loongarch-tdep.h | 2 +-
gdb/m32c-tdep.c | 10 +-
gdb/m32r-linux-tdep.c | 14 +-
gdb/m32r-tdep.c | 8 +-
gdb/m68hc11-tdep.c | 16 +-
gdb/m68k-linux-tdep.c | 12 +-
gdb/m68k-tdep.c | 18 +-
gdb/m68k-tdep.h | 2 +-
gdb/macroscope.c | 2 +-
gdb/mep-tdep.c | 8 +-
gdb/mi/mi-cmd-stack.c | 29 +-
gdb/mi/mi-main.c | 12 +-
gdb/microblaze-linux-tdep.c | 4 +-
gdb/microblaze-tdep.c | 10 +-
gdb/minsyms.c | 2 +-
gdb/mips-fbsd-tdep.c | 4 +-
gdb/mips-linux-tdep.c | 22 +-
gdb/mips-netbsd-tdep.c | 2 +-
gdb/mips-sde-tdep.c | 12 +-
gdb/mips-tdep.c | 96 +++---
gdb/mips-tdep.h | 2 +-
gdb/mips64-obsd-tdep.c | 2 +-
gdb/mn10300-linux-tdep.c | 4 +-
gdb/mn10300-tdep.c | 8 +-
gdb/moxie-tdep.c | 8 +-
gdb/msp430-tdep.c | 10 +-
gdb/nds32-tdep.c | 20 +-
gdb/nios2-linux-tdep.c | 4 +-
gdb/nios2-tdep.c | 22 +-
gdb/nios2-tdep.h | 2 +-
gdb/objc-lang.c | 10 +-
gdb/observable.h | 2 +-
gdb/or1k-linux-tdep.c | 4 +-
gdb/or1k-tdep.c | 12 +-
gdb/ppc-fbsd-tdep.c | 8 +-
gdb/ppc-linux-tdep.c | 12 +-
gdb/ppc-netbsd-tdep.c | 2 +-
gdb/ppc-obsd-tdep.c | 8 +-
gdb/ppc-tdep.h | 4 +-
gdb/ppc64-tdep.c | 20 +-
gdb/ppc64-tdep.h | 4 +-
gdb/printcmd.c | 4 +-
gdb/probe.c | 4 +-
gdb/probe.h | 4 +-
gdb/python/py-event.h | 2 +-
gdb/python/py-finishbreakpoint.c | 6 +-
gdb/python/py-frame.c | 44 +--
gdb/python/py-framefilter.c | 22 +-
gdb/python/py-inferior.c | 2 +-
gdb/python/py-infevents.c | 4 +-
gdb/python/py-symbol.c | 6 +-
gdb/python/py-unwind.c | 12 +-
gdb/python/python-internal.h | 6 +-
gdb/record-btrace.c | 32 +-
gdb/riscv-fbsd-tdep.c | 2 +-
gdb/riscv-linux-tdep.c | 6 +-
gdb/riscv-tdep.c | 12 +-
gdb/riscv-tdep.h | 2 +-
gdb/rl78-tdep.c | 12 +-
gdb/rs6000-aix-tdep.c | 10 +-
gdb/rs6000-tdep.c | 34 +-
gdb/rx-tdep.c | 16 +-
gdb/s12z-tdep.c | 10 +-
gdb/s390-linux-tdep.c | 8 +-
gdb/s390-tdep.c | 38 +--
gdb/s390-tdep.h | 2 +-
gdb/sentinel-frame.c | 6 +-
gdb/sh-linux-tdep.c | 6 +-
gdb/sh-tdep.c | 16 +-
gdb/skip.c | 2 +-
gdb/sol2-tdep.c | 2 +-
gdb/sol2-tdep.h | 2 +-
gdb/solib-svr4.c | 4 +-
gdb/sparc-linux-tdep.c | 6 +-
gdb/sparc-netbsd-tdep.c | 12 +-
gdb/sparc-obsd-tdep.c | 8 +-
gdb/sparc-sol2-tdep.c | 8 +-
gdb/sparc-tdep.c | 20 +-
gdb/sparc-tdep.h | 12 +-
gdb/sparc64-fbsd-tdep.c | 8 +-
gdb/sparc64-linux-tdep.c | 8 +-
gdb/sparc64-netbsd-tdep.c | 10 +-
gdb/sparc64-obsd-tdep.c | 16 +-
gdb/sparc64-sol2-tdep.c | 8 +-
gdb/sparc64-tdep.c | 10 +-
gdb/sparc64-tdep.h | 4 +-
gdb/stack.c | 119 ++++---
gdb/stack.h | 4 +-
gdb/stap-probe.c | 4 +-
gdb/std-regs.c | 8 +-
gdb/symfile.h | 2 +-
gdb/symtab.h | 10 +-
.../gdb.python/pretty-print-call-by-hand.c | 53 +++
.../gdb.python/pretty-print-call-by-hand.exp | 136 ++++++++
.../gdb.python/pretty-print-call-by-hand.py | 41 +++
gdb/tic6x-linux-tdep.c | 4 +-
gdb/tic6x-tdep.c | 22 +-
gdb/tic6x-tdep.h | 2 +-
gdb/tilegx-linux-tdep.c | 2 +-
gdb/tilegx-tdep.c | 12 +-
gdb/top.c | 2 +-
gdb/tracepoint.c | 5 +-
gdb/trad-frame.c | 10 +-
gdb/trad-frame.h | 10 +-
gdb/tramp-frame.c | 10 +-
gdb/tramp-frame.h | 6 +-
gdb/tui/tui-disasm.c | 2 +-
gdb/tui/tui-disasm.h | 2 +-
gdb/tui/tui-hooks.c | 6 +-
gdb/tui/tui-regs.c | 8 +-
gdb/tui/tui-regs.h | 4 +-
gdb/tui/tui-source.c | 4 +-
gdb/tui/tui-source.h | 2 +-
gdb/tui/tui-stack.c | 4 +-
gdb/tui/tui-stack.h | 4 +-
gdb/tui/tui-winsource.c | 4 +-
gdb/tui/tui-winsource.h | 2 +-
gdb/user-regs.c | 4 +-
gdb/user-regs.h | 6 +-
gdb/v850-tdep.c | 10 +-
gdb/valops.c | 10 +-
gdb/value.c | 6 +-
gdb/value.h | 16 +-
gdb/varobj.c | 8 +-
gdb/vax-tdep.c | 14 +-
gdb/xstormy16-tdep.c | 12 +-
gdb/xtensa-tdep.c | 22 +-
gdb/z80-tdep.c | 6 +-
253 files changed, 2172 insertions(+), 1702 deletions(-)
create mode 100644 gdb/frame-id.h
create mode 100644 gdb/frame-info.h
create mode 100644 gdb/testsuite/gdb.python/pretty-print-call-by-hand.c
create mode 100644 gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
create mode 100644 gdb/testsuite/gdb.python/pretty-print-call-by-hand.py
--
2.37.2
More information about the Gdb-patches
mailing list