Skip to content

Commit 3468a05

Browse files
miss-islingtonMarcel Plch
authored andcommittedApr 6, 2018
[3.6] bpo-29673: fix gdb scripts pystack and pystackv (pythonGH-6126) (pythonGH-6400)
(cherry picked from commit 3a9ccee) Co-authored-by: Marcel Plch <gmarcel.plch@gmail.com>
1 parent 2350a47 commit 3468a05

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed
 

‎Misc/ACKS

+1
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,7 @@ Zero Piraeus
12211221
Antoine Pitrou
12221222
Jean-François Piéronne
12231223
Oleg Plakhotnyuk
1224+
Marcel Plch
12241225
Remi Pointel
12251226
Jon Poler
12261227
Ariel Poliak
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix pystackv and pystack gdbinit macros.

‎Misc/gdbinit

+7-7
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3888,7 +3888,7 @@ too_many_positional(PyCodeObject *co, Py_ssize_t given, Py_ssize_t defcount,
38883888
}
38893889

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

38943894
static PyObject *

0 commit comments

Comments
 (0)