aboutsummaryrefslogtreecommitdiff
path: root/sys/tools/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'sys/tools/gdb')
-rw-r--r--sys/tools/gdb/README.txt5
-rw-r--r--sys/tools/gdb/acttrace.py8
-rw-r--r--sys/tools/gdb/freebsd.py3
-rw-r--r--sys/tools/gdb/pcpu.py5
-rw-r--r--sys/tools/gdb/vnet.py5
5 files changed, 19 insertions, 7 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(<field>[, <cpuid>]) Display the value of a PCPU/DPCPU field
diff --git a/sys/tools/gdb/acttrace.py b/sys/tools/gdb/acttrace.py
index 147effbbddf1..da79fda59da1 100644
--- a/sys/tools/gdb/acttrace.py
+++ b/sys/tools/gdb/acttrace.py
@@ -11,13 +11,13 @@ import gdb
from freebsd import *
from pcpu import *
+
class acttrace(gdb.Command):
"""
- Register an acttrace command with gdb.
-
- When run, acttrace prints the stack trace of all threads that were on-CPU
- at the time of the panic.
+ Print the stack trace of all threads that were on-CPU at the time of
+ the panic.
"""
+
def __init__(self):
super(acttrace, self).__init__("acttrace", gdb.COMMAND_USER)
diff --git a/sys/tools/gdb/freebsd.py b/sys/tools/gdb/freebsd.py
index 81ea60373348..f88eef876c7f 100644
--- a/sys/tools/gdb/freebsd.py
+++ b/sys/tools/gdb/freebsd.py
@@ -6,6 +6,7 @@
import gdb
+
def symval(name):
sym = gdb.lookup_global_symbol(name)
if sym is None:
@@ -72,4 +73,6 @@ def tdfind(tid, pid=-1):
tdfind.cached_threads[int(ntid)] = td
if ntid == tid:
return td
+
+
tdfind.cached_threads = dict()
diff --git a/sys/tools/gdb/pcpu.py b/sys/tools/gdb/pcpu.py
index aadc4b2d42df..08ae81e5121e 100644
--- a/sys/tools/gdb/pcpu.py
+++ b/sys/tools/gdb/pcpu.py
@@ -7,15 +7,17 @@
import gdb
from freebsd import *
+
class pcpu(gdb.Function):
"""
- Register a function to lookup PCPU and DPCPU variables by name.
+ A function to look up PCPU and DPCPU fields by name.
To look up the value of the PCPU field foo on CPU n, use
$PCPU("foo", n). This works for DPCPU fields too. If the CPU ID is
omitted, and the currently selected thread is on-CPU, that CPU is
used, otherwise an error is raised.
"""
+
def __init__(self):
super(pcpu, self).__init__("PCPU")
@@ -73,5 +75,6 @@ class pcpu(gdb.Function):
obj = gdb.Value(pcpu_base + pcpu_entry_addr - start + base)
return obj.cast(pcpu_entry.type.pointer()).dereference()
+
# Register with gdb.
pcpu()
diff --git a/sys/tools/gdb/vnet.py b/sys/tools/gdb/vnet.py
index 36b4d512a3eb..6175a5d6f551 100644
--- a/sys/tools/gdb/vnet.py
+++ b/sys/tools/gdb/vnet.py
@@ -5,12 +5,12 @@
#
import gdb
-import traceback
from freebsd import *
+
class vnet(gdb.Function):
"""
- Register a function to look up VNET variables by name.
+ A function to look up VNET variables by name.
To look at the value of a VNET variable V_foo, print $V("foo"). The
currently selected thread's VNET is used by default, but can be optionally
@@ -18,6 +18,7 @@ class vnet(gdb.Function):
pointer to a struct vnet (e.g., vnet0 or allprison.tqh_first->pr_vnet) or a
string naming a jail.
"""
+
def __init__(self):
super(vnet, self).__init__("V")