Skip to content

Commit 3c193cf

Browse files
miss-islingtonMarcel Plch
authored andcommitted
[3.7] bpo-29673: fix gdb scripts pystack and pystackv (GH-6126) (GH-6399)
(cherry picked from commit 3a9ccee) Co-authored-by: Marcel Plch <[email protected]>
1 parent 252f10c commit 3c193cf

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ Zero Piraeus
12481248
Antoine Pitrou
12491249
Jean-François Piéronne
12501250
Oleg Plakhotnyuk
1251+
Marcel Plch
12511252
Remi Pointel
12521253
Jon Poler
12531254
Ariel Poliak
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix pystackv and pystack gdbinit macros.

Misc/gdbinit

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ define pylocals
3636
set $_i = 0
3737
while $_i < f->f_code->co_nlocals
3838
if f->f_localsplus + $_i != 0
39-
set $_names = co->co_varnames
40-
set $_name = _PyUnicode_AsString(PyTuple_GetItem($_names, $_i))
39+
set $_names = f->f_code->co_varnames
40+
set $_name = PyUnicode_AsUTF8(PyTuple_GetItem($_names, $_i))
4141
printf "%s:\n", $_name
4242
pyo f->f_localsplus[$_i]
4343
end
@@ -76,8 +76,8 @@ define pyframev
7676
end
7777

7878
define pyframe
79-
set $__fn = _PyUnicode_AsString(co->co_filename)
80-
set $__n = _PyUnicode_AsString(co->co_name)
79+
set $__fn = PyUnicode_AsUTF8(f->f_code->co_filename)
80+
set $__n = PyUnicode_AsUTF8(f->f_code->co_name)
8181
printf "%s (", $__fn
8282
lineno
8383
printf "): %s\n", $__n
@@ -102,7 +102,7 @@ end
102102
#end
103103

104104
define printframe
105-
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
105+
if $pc > PyEval_EvalFrameEx && $pc < _PyEval_EvalFrameDefault
106106
pyframe
107107
else
108108
frame
@@ -129,7 +129,7 @@ end
129129
# print the entire Python call stack
130130
define pystack
131131
while $pc < Py_Main || $pc > Py_GetArgcArgv
132-
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
132+
if $pc > PyEval_EvalFrameEx && $pc < _PyEval_EvalFrameDefault
133133
pyframe
134134
end
135135
up-silently 1
@@ -140,7 +140,7 @@ end
140140
# print the entire Python call stack - verbose mode
141141
define pystackv
142142
while $pc < Py_Main || $pc > Py_GetArgcArgv
143-
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
143+
if $pc > PyEval_EvalFrameEx && $pc < _PyEval_EvalFrameDefault
144144
pyframev
145145
end
146146
up-silently 1

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3650,7 +3650,7 @@ too_many_positional(PyCodeObject *co, Py_ssize_t given, Py_ssize_t defcount,
36503650
}
36513651

36523652
/* This is gonna seem *real weird*, but if you put some other code between
3653-
PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust
3653+
PyEval_EvalFrame() and _PyEval_EvalFrameDefault() you will need to adjust
36543654
the test in the if statements in Misc/gdbinit (pystack and pystackv). */
36553655

36563656
PyObject *

0 commit comments

Comments
 (0)