From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id HEPuOsbN3mLSYBoAWB0awg (envelope-from ) for ; Mon, 25 Jul 2022 13:07:18 -0400 Received: by simark.ca (Postfix, from userid 112) id E23271E9E9; Mon, 25 Jul 2022 13:07:18 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=j8xh7SzS; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 177E01E21F for ; Mon, 25 Jul 2022 13:07:18 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 724E1383A309 for ; Mon, 25 Jul 2022 17:07:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 724E1383A309 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1658768837; bh=2kJISV3fP8LlHIEJnsiXh8/S+5IcO112nzhTJqQXV9k=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=j8xh7SzScLqJT5q83ep/l+FClv1MXYF8Np07H5SbiZ/UP4l/oKkxYqRQHYgnOg0+z 9RFQ91RQ2uss52RcNR7XuqGzAMTg/QYTr/zdRHqNviwCF0oQeIbq4uTK7KXI0mDkJZ Dhc2YnMuF4T5rNiaRVgeImUiBs6nv0EAcrxheFcc= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9E39B385840F for ; Mon, 25 Jul 2022 17:06:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9E39B385840F Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-iTpqzUfdNs6XIQ_Wr2BuCQ-1; Mon, 25 Jul 2022 13:06:54 -0400 X-MC-Unique: iTpqzUfdNs6XIQ_Wr2BuCQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CBD7A29ABA05 for ; Mon, 25 Jul 2022 17:06:53 +0000 (UTC) Received: from blarsen.com (ovpn-116-28.gru2.redhat.com [10.97.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64B281121314; Mon, 25 Jul 2022 17:06:50 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH v3 0/5] Smart pointer wrapper for frame_info Date: Mon, 25 Jul 2022 14:06:32 -0300 Message-Id: <20220725170637.79699-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Bruno Larsen via Gdb-patches Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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. 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 | 62 ++-- 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 | 37 +- 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 | 208 +++++++++++ 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/guile/guile-internal.h | 4 +- gdb/guile/scm-frame.c | 48 +-- gdb/guile/scm-symbol.c | 4 +- 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 +- gdbsupport/intrusive_list.h | 10 +- 257 files changed, 2205 insertions(+), 1733 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.31.1