在Objective C中分析TraceGL中的代码路径? [英] Analyzing code path in Objective C a la TraceGL?

查看:178
本文介绍了在Objective C中分析TraceGL中的代码路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TraceGL是一个非常简洁的项目,它允许JS程序员在Javascript中跟踪代码路径。它看起来像这样:

TraceGL is a pretty neat project that allows JS programmers to trace code paths in Javascript. It looks something like this:

我想为Objective C构建类似的东西。我知道运行时使跟踪方法调用变得相当容易,但我如何跟踪控制流?例如,在上面的屏幕截图中,未执行的代码路径以红色突出显示为明显。在Objective C / Xcode工作流程中实现类似功能的最佳方法是什么?

I'd like to build something similar for Objective C. I know the runtime has made it rather easy to trace method calls, but how would I trace control flow? For example, in the screenshot above, code paths not executed are made obvious with a red highlight. What would be the best way to achieve something similar in an Objective C/Xcode workflow?

到目前为止,我想出的最好的方法是编写一个注入的预处理器在将它们发送到编译器之前将代码转换为临时源文件。任何人都有更好的主意吗?

The best I've come up with so far is to write a preprocessor that injects code into temporary source files before sending them to the compiler. Anyone have a better idea?

推荐答案

不完全回答Objective C和XCode。

Not exactly answer for Objective C and XCode.

对于C ++代码,有一个工业质量代码覆盖工具 BullseyeCoverage

For C++ code there is a industrial quality code coverage tool BullseyeCoverage



  • 功能覆盖率为您提供快速概览,条件/决策覆盖率为您提供高精度

  • 适用于您可以用C ++和C编写的所有内容,包括系统级和内核模式

如果您想自己发明/编写这种工具,我建议您查看(评估)一些解决相同任务的现有工具,这样您就不会错过关键功能

If you want to invent/write this kind of tool yourself I'd recommend to take a look at (evaluate) some existing tools that solve the same task so that you don't miss a key functionality

此类工具基本上 2类


  • 在二进制级别工作, 仪器字节代码,库入口点等。

  • 在源代码级工作,仪器源代码,然后再转到编译器

  • working at binary level, instrument byte code, library entry points etc.
  • working at source level, instrument source code before going to the compiler

目的检测是插入代码对分析运行时的调用,它收集运行时统计信息以进行进一步处理。

The purpose of the instrumentation is to insert into the code calls to a profiling runtime that collects the runtime statistics for further processing.

基本调用


  • 时间戳,线程ID,源代码地址,输入

  • 时间戳,线程ID ,源代码地址,离开

  • timestamp, thread id, source code address, entering
  • timestamp, thread id, source code address, leaving

源代码地址取决于您设置的粒度。它可以是一个函数名称,它可以是一个源文件和一个行号。

The source code address depends on the granularity you are interesetd in. It can be a function name ot it can be a source file and line number.

收集的性能数据可能非常大,所以它们通常是相加的,而且整个callstack都不是抓获。检测性能瓶颈通常具有足够的细节水平。

Collected performance data can be quite huge so they are usually summed-up and whole callstacks are not captured. It is usually sufficient level of detail for detecting performance bottlenecks.

另一个缺点是捕获详细的性能数据,尤其是在具有多次命中的代码点中,会显着降低应用程序的速度。

Another drawback is that capturing detailed performance data especially in code points with many hits will slow the application significantly.

如果你想要完整的历史记录然后捕获包括时间戳和线程ID的完整跟踪,你将能够在以后知道每个输入时重新创建调用堆栈有相应的离开

If you want complete history then capture the full trace including timestamps and thread-ids and you will be able to recreate the call stacks later knowing that each enter has corresponding leave.

为了保证这种配对,代码检测必须插入异常处理调用以确保即使函数抛出异常也会记录退出点(什么是异常以及如何尝试 - 最终它依赖于语言和OS平台)。

To guarantee this pairing the code instrumentation must insert exception handling calls to make sure that exit point will be logged even if the function throws an exception (what is the "exception" and how to try-finally it dependes on the language and the OS platform).

获取所有必要的技巧和提示评估一些工具并查看其工具样式

To get all necessary tricks and tips evaluate some tools and take a look at their instrumentation style.

BTW:in一般来说,要做很多工作并做好我的工作个人想了两次或更多次关于结果会是什么以及费用是多少。

BTW: in general it is quite a lot of work to do and to get right I'd personally thought twice or more times about what will be the outcome and what will be the costs.

作为一个想要玩的话题,我完全推荐。我创建了这样一个工具来解决在C ++源代码级和Java二进制级工作的Java MIDP应用程序的问题,并且在我们需要时它很有用。

As a want-to-play-with topic I fully recommend that. I created such a tool for troubleshooting Java MIDP applications working at C++ source level and Java binary level and it was helpful at the time when we needed it.

这篇关于在Objective C中分析TraceGL中的代码路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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