xref: /freebsd/sys/tools/kernel-gdb.py (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1#
2# Copyright (c) 2025 Mark Johnston <markj@FreeBSD.org>
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6
7import importlib
8import os
9import sys
10
11gdb.set_parameter("python print-stack", "full")
12
13sys.path.append(os.path.join(os.path.dirname(__file__), "gdb"))
14
15modules = [
16    "acttrace",
17    "freebsd",
18    "pcpu",
19    "vnet"
20]
21
22
23def reload_modules(modules):
24    for mod in modules:
25        if mod in sys.modules:
26            importlib.reload(sys.modules[mod])
27        else:
28            importlib.import_module(mod)
29
30reload_modules(modules)
31
32
33class reload(gdb.Command):
34    """
35    Reload the FreeBSD kernel GDB helper scripts.
36    """
37    def __init__(self):
38        super(reload, self).__init__("kgdb-reload", gdb.COMMAND_USER)
39
40    def invoke(self, arg, from_tty):
41        reload_modules(modules)
42
43
44# Register the reload command with gdb.
45reload()
46