Skip to content

Commit 1f86fdc

Browse files
The-Compilerzware
authored andcommitted
bpo-15817: gdbinit: Document commands after defining them (GH-15021)
The gdb manual[1] says the following for "document": The command commandname must already be defined. [1] https://sourceware.org/gdb/current/onlinedocs/gdb/Define.html And indeed when trying to use the gdbinit file with gdb 8.3, I get: .../cpython/Misc/gdbinit:17: Error in sourced command file: Undefined command: "pyo". Try "help". Fix this by moving all documentation blocks after the define blocks. This was introduced in GH-6384.
1 parent aa51508 commit 1f86fdc

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

Misc/gdbinit

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,27 @@
1414
# with embedded macros that you may find superior to what is in here.
1515
# See Tools/gdb/libpython.py and http://bugs.python.org/issue8032.
1616

17-
document pyo
18-
Prints a representation of the object to stderr, along with the
19-
number of reference counts it currently has and the hex address the
20-
object is allocated at. The argument must be a PyObject*
21-
end
2217
define pyo
2318
# side effect of calling _PyObject_Dump is to dump the object's
2419
# info - assigning just prevents gdb from printing the
2520
# NULL return value
2621
set $_unused_void = _PyObject_Dump($arg0)
2722
end
28-
29-
document pyg
23+
document pyo
3024
Prints a representation of the object to stderr, along with the
3125
number of reference counts it currently has and the hex address the
32-
object is allocated at. The argument must be a PyGC_Head*
26+
object is allocated at. The argument must be a PyObject*
3327
end
28+
3429
define pyg
3530
print _PyGC_Dump($arg0)
3631
end
37-
38-
document pylocals
39-
Print the local variables of the current frame.
32+
document pyg
33+
Prints a representation of the object to stderr, along with the
34+
number of reference counts it currently has and the hex address the
35+
object is allocated at. The argument must be a PyGC_Head*
4036
end
37+
4138
define pylocals
4239
set $_i = 0
4340
while $_i < f->f_code->co_nlocals
@@ -50,6 +47,9 @@ define pylocals
5047
set $_i = $_i + 1
5148
end
5249
end
50+
document pylocals
51+
Print the local variables of the current frame.
52+
end
5353

5454
# A rewrite of the Python interpreter's line number calculator in GDB's
5555
# command language
@@ -75,13 +75,13 @@ define lineno
7575
printf "%d", $__li
7676
end
7777

78-
document pyframev
79-
Print the current frame - verbose
80-
end
8178
define pyframev
8279
pyframe
8380
pylocals
8481
end
82+
document pyframev
83+
Print the current frame - verbose
84+
end
8585

8686
define pyframe
8787
set $__fn = PyUnicode_AsUTF8(f->f_code->co_filename)
@@ -134,9 +134,6 @@ end
134134
# the interpreter you may will have to change the functions you compare with
135135
# $pc.
136136

137-
document pystack
138-
Print the entire Python call stack
139-
end
140137
define pystack
141138
while $pc < Py_Main || $pc > Py_GetArgcArgv
142139
if $pc > PyEval_EvalFrameEx && $pc < _PyEval_EvalFrameDefault
@@ -146,10 +143,10 @@ define pystack
146143
end
147144
select-frame 0
148145
end
149-
150-
document pystackv
151-
Print the entire Python call stack - verbose mode
146+
document pystack
147+
Print the entire Python call stack
152148
end
149+
153150
define pystackv
154151
while $pc < Py_Main || $pc > Py_GetArgcArgv
155152
if $pc > PyEval_EvalFrameEx && $pc < _PyEval_EvalFrameDefault
@@ -159,10 +156,10 @@ define pystackv
159156
end
160157
select-frame 0
161158
end
162-
163-
document pu
164-
Generally useful macro to print a Unicode string
159+
document pystackv
160+
Print the entire Python call stack - verbose mode
165161
end
162+
166163
def pu
167164
set $uni = $arg0
168165
set $i = 0
@@ -174,3 +171,6 @@ def pu
174171
end
175172
end
176173
end
174+
document pu
175+
Generally useful macro to print a Unicode string
176+
end

0 commit comments

Comments
 (0)