summaryrefslogtreecommitdiff
path: root/sys/tools/kernel-gdb.py
blob: 990bdaf31fda33f0805fb205feaa6a60884ad1c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# Copyright (c) 2025 Mark Johnston <markj@FreeBSD.org>
#
# SPDX-License-Identifier: BSD-2-Clause
#

import importlib
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), "gdb"))

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()