Get the App
SLTechnology News&Howtos  ›  Development  › 

The call relationship between the functions within the Python script

Shulou Source: shulou.com Published: 2022-06-03 12:37:39 09月23日 Update

This article mainly explains "the call relationship between the functions within the Python script". The explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the call relationship between the functions within the Python script.

As you all know, python internal stack and function calls are completed by PyEval_EvalFrameEx, a PyEval_EvalFrameEx means a function call, such as the 19th and 13th lines above correspond to main, segv_test, and freeNode functions respectively. After locating the gdb to the corresponding line, you can use the pylocals macro to view the details of the internal variables of the function.

(gdb) up 13

# 13 0x007d6d2b in PyEval_EvalFrameEx

(f=0x81242fc, throwflag=0) at Python/ceval.c:2370

2370 in Python/ceval.c

(gdb) pylocals

S:

Object:

''

Type: str

Refcount: 3

Address: 0xb7f64440

Options:

Object: 97

Type: int

Refcount: 7

Address: 0x8082c20

Doc:

Object:

Type: instance

Refcount: 1

Address: 0xb7cc04ec

Ctxt:

Object:

Type: instance

Refcount: 1

Address: 0xb7f70ccc

Nodes:

Object: []

Type: list

Refcount: 2

Address: 0xb7f70a8c

Note:

Object:

Type: instance

Refcount: 2

Address: 0xb7cc0cac

Nexts:

Object: [

]

Type: list

Refcount: 1

Address: 0xb7f4ce4c

Setting breakpoints when debugging Python scripts is a hassle, and there are two ways I can think of:

1 set the breakpoint according to the python source code of the function

(2) sleep function and ctrl+c are used to interrupt the operation of the program.

Thank you for your reading, the above is the content of "the call relationship between the functions within the Python script". After the study of this article, I believe you have a deeper understanding of the call relationship between the functions within the Python script, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Functions scripts learning content situations breakpoints primary functions things variables stacks that is ideas meaning articles methods more such as source code knowledge knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Huawei Shulou Information Linux