执行代码跟踪-如何知道项目中已执行了哪些代码? [英] Execution Code Tracking - How to know which code has been executed in project?

查看:127
本文介绍了执行代码跟踪-如何知道项目中已执行了哪些代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我说我有一个开源项目,我想从中借鉴一些功能.我可以得到在该项目的执行和/或交互期间生成的某种报告吗?

Let say that I have open source project from which I would like to borrow some functionality. Can I get some sort of report generated during execution and/or interaction of this project?

报告应包含例如:

  • 已调用哪个函数
  • 按顺序
  • 哪些类已实例化等等?

很高兴为此提供一些图形输出...如果您知道其他树并突出显示了已执行的分支等.

Would be nice to have some graphic output for that... you know, if else tree and highlighted the executed branch etc.

我对python和C最为感兴趣(也可以使用perl),但是如果有任何通用工具能够涵盖多种语言(或每种语言一种工具),那将是非常不错的.

I am mostly interested in python and C (perl would be fine too) but if there is any universal tool that cover multiple languages (or one tool per language) for that, it would be very nice.

PS:我熟悉调试器,但是我不想单步执行每一行代码,并检查这是否是正确的指令.我假设如果正确命名函数/方法/类等,则可以得到一些有关在哪里找到所需代码的提示.但是仅命名是不够的,因为您不知道(从代码的简要概述中)希望查找函数foo()是否不需要晦涩的功能bar()等生成的某些数据.因此,我正在寻找可以可以可视化正在运行的代码之间的关系.

PS: I am familiar with debuggers but I do not want to step every singe line of code and check if this is the correct instruction. I'm assuming that if functions/methods/classes etc. are properly named then one can get some hints about where to find desired piece of code. But only naming is not enough because you do not know (from brief overview of code) if hopefully looking function foo() does not require some data that was generated by obscure function bar() etc. For that reason I am looking for something that can visualize relations between running code.

PS:不知道这是SO还是程序员的问题.stackexchange.如果您愿意,请随时移动. PS:我注意到不建议使用我使用的标签,但是执行流跟踪是描述此过程的最佳短语

PS: Do not know if this is question for SO or programmers.stackexchange. Feel free to move if you wish. PS: I've noticed that tags that I've used are not recommended but execution flow tracking is the best phrase to describe this process

推荐答案

查看Ned Batchelder的 coverage 也许是称为 pycallgraph 的graphviz/dot库.可能不完全是您所需要的(也是仅限python),而是在球场上.

Check out Ned Batchelder's coverage and perhaps the graphviz/dot library called pycallgraph. May not be exactly what you need and also (python-only) but in the ballpark.

Pycallgraph实际上更可能引起人们的兴趣,因为它显示了执行路径,而不仅仅是执行了哪些代码行.它只能正常渲染为PDF,但是让它代替SVG并不是很困难(dot/graphviz支持svg和其他格式,pycallgraph则是对pdf渲染进行硬编码).

Pycallgraph is actually likelier to be of interest because it shows the execution path, not just what codelines got executed. It only renders to PDF normally, but it wasn't too difficult to get it to do SVG instead (dot/graphviz supports svg and other formats, pycallgraph was hardcoding pdf rendering).

两者都无法完全满足您的要求,但这只是一个开始.

Neither will do exactly what you want but they are a start.

这篇关于执行代码跟踪-如何知道项目中已执行了哪些代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆