提供比trace.py更多输出的执行跟踪程序
ntrace的Python项目详细描述
用于跟踪python脚本的实用程序;与trace.py类似,它还可以输出函数参数和返回值 以及修改全局和局部变量。
可以作为脚本调用(安装包后)
python-m trace/ntrace[选项]<;要跟踪的python文件>;[要跟踪的python文件的命令行]
默认情况下,它显示函数参数和函数返回值
- 选项:
-f trace function parameter calls (default: on) -F do not trace function parameters -r trace function return values (default: on) -R do not trace function return values -l trace source lines before they are executed (default: on) -L do not trace source lines before they are executed -s trace setting of variablesa (default: off) -S do not trace setting of variables -g trace getting of variables (default: off) -G do not trace getting of variables -o print out object content (default: off) -O do not print out object content -t show the current thread id in prefix for each source line (default on) -T hide the current thread id -n show the nesting level, how many levels down the call stack (default on) -N hide the nesting level
默认情况下,以下选项处于启用状态:-l-f-r
可以作为API调用
- 类ntracefromcommandline
ntrace的命令行分析器
- 此处定义的方法:
- 初始化(自身,argv)
- NTracer类
跟踪程序对象;调用该类以运行带有跟踪的python文件
- 此处定义的方法:
- 初始化(self,traceoptions=31,follow\u objects=false)
- 对象构造函数;选项通过traceoptions参数作为位掩码值传递,可用选项:
to_function_arguments参数标志:打印函数参数 to_function_rvalues参数标志:打印函数返回值 to_set_vars参数标志:变量的打印修改 to_get_vars参数标志:打印变量访问 to_trace_src_lines参数标志:在执行源行之前显示源行 to_show_prefix_tid在跟踪的行的前缀字符串中显示线程ID 要显示前缀,请显示嵌套调用strack nesting in prefix string of line traced
如果要打印对象引用,follow_objects参数为true 跟踪(self,progname,tracingabled=true) 追踪器调用 progname-要跟踪的python文件 tracinenabled-如果跟踪最初处于打开状态(默认为true)
功能
- enabletrace(on)
- enable/disable tracing, can be called from the traced program