lldb dived into python stack #7
j8xixo12
started this conversation in
General (discussions)
Replies: 2 comments 1 reply
-
If |
Beta Was this translation helpful? Give feedback.
0 replies
-
I plan to write some gdb or lldb script that user can directly put break point into python script. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have studied cpython for a while, I found python interpreter stored many informations into
PyFrameObject
, what I care about is line number.In order to get python script's line number, I used
co_lontab
which is bytecode offset <----> line number mapping to calculate python source code line number.The cpython also provides a helper function
PyCode_Addr2Line(PyCodeObject *co, int addrq)
to convert bytecode offset to line number, andPyFrame_GetLineNumber(PyFrameObject *f)
also can get line number directly fromPyFrameObject
.Here is my test python script
I used
br s -n _PyEval_EvalFrame -c '((int)strcmp(PyUnicode_AsUTF8(f->f_code->co_name), "foo1")) == 0'
to set breakpoint at first line ofmain()
.Here is the output
I tried to use
PyFrame_GetLineNumber
to get line number, and I got what I want, but when I triedusing
br s -n _PyEval_EvalFrame -c '(int)PyFrame_GetLineNumber(f) == 10'
to put breakpoint at the same linelldb didn't hit the breakpoint.....
I don't know what's going on?
Beta Was this translation helpful? Give feedback.
All reactions