From nobody Tue Sep 5 18:24:17 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RgDRk3mj8z4smMw; Tue, 5 Sep 2023 18:24:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RgDRk0n2wz4G38; Tue, 5 Sep 2023 18:24:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693938258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RNbjL4L4qRK2B3lRy7wtExDNcS9SbgkA7MXmrgVG8fM=; b=KB8Hsz7TtEQx/ErC623USkhsQCnjWWe34XKuTz+cnsiSBizZuL7QgUqDrNtjN639wLznCn O3Xiz256jsaonaunoSFTqZjFftgP+du5G/utoI18PNnRb4riPbLqNb0zTB/fxWw5nvY+5C 90E6vCx+3R3pTrJHAjW/1wzL+kspkqKH4lRAcowGPaBpe+oos9q/W8wpgoz722lWkG2l+Q 235xWMft/sO/ru8ShBW3SonUrziyR5nFh13uxroYek1tVL/lhnrZY6JzkcL6e3ZMY9RZb4 2EHnpjlS3eEuhlsM68fMYIRUfcfLdjrPeqJvWvb9GjvNuhnmlLVGoC24lYTaHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693938258; a=rsa-sha256; cv=none; b=vWWOj13+Jd8GEIghJU/FiidM4hLFdCwczBqhEVEn7XvLExfEbrOr1VMXN0c66wdqF9hs1R hSscqwg2QcLTFl81Mrcp6JzDNLLF48/9phfsK62RM7/THQABS9XPDYCv4ka0/xb6bcojTY UnatnQEPZGTnFRtMigPDA/nZNyd3M8ys/YyW8YGtRvdJSKAQLm2pRItAGh8cCOzmK5kwsL Wc5XmGEa+4NAoSPNw1/Ef3g5ItfkEN29+zKoK45ZG18NVPMQmS+Gf0r/acRa5DKt0GILIA r13g7lzv6fxcdIIT/JGHnR68DvNy3mwATr4HBBjyumoAVgkST/+6OzRu61ULiw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693938258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RNbjL4L4qRK2B3lRy7wtExDNcS9SbgkA7MXmrgVG8fM=; b=MR6QW1XSwwJuNUpsEqo7g8WWkPJ19L7TDngrjtpg3i8ASWH0/2zHD4RWumd9zNHMxVpDn3 15VFlYWo3k2nQnQsYowd4F4+2Hgm68HHcf2CH8PjCyv0vnQl2xN4A8qivAKCrN2NWJDHL0 Z97RyKA9HTO/OjME18p2W+EjJsSOoOD0ccfdjUJYF+YNMrr0jxrmInY8j1dBhb9hrelsd4 3kJ3vQeqJ9ZeXpsX3iempxSJEYlDOA2bu12MTNLCOSsIGhMqOJawlgNHs6TXuGifppxEDw IfXyhEL1n+YL0khHRJYVPYILnaVMOiEKPH9oeWkonXvPgGqDJ8dfoQPL47TDuw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RgDRj6j4kzk6L; Tue, 5 Sep 2023 18:24:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 385IOHA9074584; Tue, 5 Sep 2023 18:24:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 385IOHDR074581; Tue, 5 Sep 2023 18:24:17 GMT (envelope-from git) Date: Tue, 5 Sep 2023 18:24:17 GMT Message-Id: <202309051824.385IOHDR074581@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Kyle Evans Subject: git: 7e2852846872 - main - devel/gdb: kgdb: Handle stoppcbs compat List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7e2852846872215c7d7ad36d9ea15d593bbf343e Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/ports/commit/?id=7e2852846872215c7d7ad36d9ea15d593bbf343e commit 7e2852846872215c7d7ad36d9ea15d593bbf343e Author: Mark Jonhston AuthorDate: 2023-09-05 18:10:40 +0000 Commit: Kyle Evans CommitDate: 2023-09-05 18:16:32 +0000 devel/gdb: kgdb: Handle stoppcbs compat Use __FreeBSD_version to decide whether to dereference the stoppcbs symbol. PORTREVISION will be bumped as part of the next commit, which fixes another KBI breakage. Reviewed by: jhb, kevans Approved by: jhb (maintainer) MFH: 2023Q3 Differential Revision: https://reviews.freebsd.org/D39951 --- devel/gdb/files/kgdb/fbsd-kvm.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/devel/gdb/files/kgdb/fbsd-kvm.c b/devel/gdb/files/kgdb/fbsd-kvm.c index b5bc0f924612..bd4f71fecddd 100644 --- a/devel/gdb/files/kgdb/fbsd-kvm.c +++ b/devel/gdb/files/kgdb/fbsd-kvm.c @@ -279,6 +279,7 @@ fbsd_kvm_target_open (const char *args, int from_tty) kvm_t *nkvm; const char *kernel; std::string filename; + int osreldate; bool writeable; if (ops == NULL || ops->supply_pcb == NULL || ops->cpu_pcb_addr == NULL) @@ -340,6 +341,14 @@ fbsd_kvm_target_open (const char *args, int from_tty) } #endif + kvm = nkvm; + vmcore = std::move(filename); + current_inferior()->push_target (&fbsd_kvm_ops); + + /* Pop the target automatically upon failure. */ + target_unpush_up unpusher; + unpusher.reset (&fbsd_kvm_ops); + /* * Determine the first address in KVA. Newer kernels export * VM_MAXUSER_ADDRESS and the first kernel address can be @@ -353,11 +362,29 @@ fbsd_kvm_target_open (const char *args, int from_tty) kernstart = kgdb_lookup("kernbase"); } + try { + CORE_ADDR osreldatesym = kgdb_lookup("osreldate"); + osreldate = read_memory_unsigned_integer(osreldatesym, 4, + gdbarch_byte_order (target_gdbarch ())); + } catch (const gdb_exception_error &e) { + error ("Failed to look up osreldate"); + } + /* - * Lookup symbols needed for stoppcbs[] handling, but don't + * Look up symbols needed for stoppcbs handling, but don't * fail if they aren't present. */ stoppcbs = kgdb_lookup("stoppcbs"); + if (osreldate > 1400088) { + /* stoppcbs is now a pointer rather than an array. */ + try { + stoppcbs = read_memory_typed_address(stoppcbs, + builtin_type(target_gdbarch())->builtin_data_ptr); + } catch (const gdb_exception_error &e) { + stoppcbs = 0; + } + } + try { pcb_size = parse_and_eval_long("pcb_size"); } catch (const gdb_exception_error &e) { @@ -379,10 +406,6 @@ fbsd_kvm_target_open (const char *args, int from_tty) } } - kvm = nkvm; - vmcore = std::move(filename); - current_inferior()->push_target (&fbsd_kvm_ops); - kgdb_dmesg(); inf = current_inferior(); @@ -406,6 +429,9 @@ fbsd_kvm_target_open (const char *args, int from_tty) reinit_frame_cache (); print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC, 1); + + /* Keep the target pushed. */ + unpusher.release (); } void