From nobody Mon Oct 27 16:39:11 2025 X-Original-To: dev-commits-src-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 4cwK341Qx8z6F3bW; Mon, 27 Oct 2025 16:39:12 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cwK334ryPz3qSQ; Mon, 27 Oct 2025 16:39:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761583151; 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=wlry0L5YWeVpjX1esJ3WFDsFwaZYxnSO0KT5z8IyIEs=; b=j3utqxVDDpWOncacFIFLy3Rh8g/6FqzQpYknkilsmK8Pp7CAtYGz8+eqRaeVohm6eD6c4f lYhdImDpL3Bt976QuxpPPrHoJLHTxad2I1Rfebt6Lbpc4tLfS/5O6+vmJYT2VQ6OYtASeq O2N2Y9eStUqDopL0CIDNeiuER47XZPYbKyaTulkxiZujJ053RBajjoPG6OTV2GcTBOerFM J5Vou/qh53K75K4vExDOyxk6NxqNIIMSzBht8/kzngl/HlWVl81022Qg9wkAD0j+w6tfZ0 kF/DW2T98P4bp3jlXgrSypTDWYo38n2mnK+mKf8Q+6loOPfSIXe4tR10F0F/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761583151; 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=wlry0L5YWeVpjX1esJ3WFDsFwaZYxnSO0KT5z8IyIEs=; b=QKI29D/iWfnp6eZuYBEnUftBTL9ID947sAZkmWUMIvIF4Ls0NqyY1oTzgMmKb3L1/kDrdH 01bRQpt4Ryt7Tx1cwbz0v9uhzXU+Zk2ilfrhoxuofMge6ewQx8W9seFHbiGiqnvIh5hY7O BCpfrK+ZOEMLnZXYMOunWzgdU+uyGFJ4NjmTe/8OnZq+AAamEWNOvBfdTOcH30IXlzRxuf UImaWkpsZJwJw5PwRrHVFUBq4raxnsZ3DkLT/zDAK+aL8hTLbFwE8jYIFa9LYX7fvn5yzm QVU30kVJ8tKs+sUsIqLN+XgE/8MZCQSkQLNvUmKU7fpJxL0bFsdbG9jtHSWDDw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761583151; a=rsa-sha256; cv=none; b=f8fxiPNJdb6MYPHS75kuO1Q+iuSKoQJifsHIb/hMNYVlQSwBVxr2BSCMnArWJ2N809LM7m KE4Xg3Ttz4YSFd15so6fX1/ceYodz0YUwD3vR+hoSCtpT/j3BClOwKr5nKZWKjcJezLl/G umDrOGHrqIaxi/MkSVS/omOb45Uae8kfym2/jtoieuznAYA1441fI5NXRHOXNrFY03RMIr D1BmPIl6wSO/vpCA/iX3M+5gzpXR/dqFTrpAfYuYZdNCJyMFF6XhPeH/VB4j6mAeMuLWn9 e875EvZr3R3N6orzixC4v2w73Bj6qtkNzxLigXUULLmb/JJ6vyr/feQ1I5Ewcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cwK333tcrz1Qnq; Mon, 27 Oct 2025 16:39:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59RGdBfW019730; Mon, 27 Oct 2025 16:39:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59RGdBqb019727; Mon, 27 Oct 2025 16:39:11 GMT (envelope-from git) Date: Mon, 27 Oct 2025 16:39:11 GMT Message-Id: <202510271639.59RGdBqb019727@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d5d47e1e67cd - main - gdb: Make development a bit easier List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d5d47e1e67cdf1707cb460c2722894305f3cb34d Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d5d47e1e67cdf1707cb460c2722894305f3cb34d commit d5d47e1e67cdf1707cb460c2722894305f3cb34d Author: Mark Johnston AuthorDate: 2025-10-27 16:33:34 +0000 Commit: Mark Johnston CommitDate: 2025-10-27 16:33:34 +0000 gdb: Make development a bit easier Provide a command which can be used to reload gdb modules. MFC after: 1 week --- sys/tools/gdb/README.txt | 5 +++++ sys/tools/kernel-gdb.py | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/sys/tools/gdb/README.txt b/sys/tools/gdb/README.txt index 8c31565ddc42..ad1544912c3c 100644 --- a/sys/tools/gdb/README.txt +++ b/sys/tools/gdb/README.txt @@ -8,6 +8,9 @@ be automatically loaded by kgdb when opening a vmcore, so if you add new GDB commands or functions, that script should be updated to import them, and you should document them here. +When improving these scripts, you can use the "kgdb-reload" command to reload +them from /usr/lib/debug/boot/kernel/gdb/*. + To provide some rudimentary testing, selftest.py tries to exercise all of the commands and functions defined here. To use it, run selftest.sh to panic the system. Then, create a kernel dump or attach to the panicked kernel, and invoke @@ -15,6 +18,8 @@ the script with "python import selftest" in (k)gdb. Commands: acttrace Display a backtrace for all on-CPU threads +kgdb-reload Reload all gdb modules, useful when developing the modules + themselves. Functions: $PCPU([, ]) Display the value of a PCPU/DPCPU field diff --git a/sys/tools/kernel-gdb.py b/sys/tools/kernel-gdb.py index 8a41ef6efab1..990bdaf31fda 100644 --- a/sys/tools/kernel-gdb.py +++ b/sys/tools/kernel-gdb.py @@ -4,12 +4,40 @@ # SPDX-License-Identifier: BSD-2-Clause # +import importlib import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), "gdb")) -# Import FreeBSD kernel debugging commands and modules below. -import acttrace -import pcpu -import vnet +modules = [ + "acttrace", + "freebsd", + "pcpu", + "vnet" +] + + +def reload_modules(modules): + for mod in modules: + if mod in sys.modules: + importlib.reload(sys.modules[mod]) + else: + importlib.import_module(mod) + +reload_modules(modules) + + +class reload(gdb.Command): + """ + Reload the FreeBSD kernel GDB helper scripts. + """ + def __init__(self): + super(reload, self).__init__("kgdb-reload", gdb.COMMAND_USER) + + def invoke(self, arg, from_tty): + reload_modules(modules) + + +# Register the reload command with gdb. +reload()