调试处理略有不同的输入 [英] Debugging handling slightly different inputs

查看:112
本文介绍了调试处理略有不同的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事Java编译器。在编译器的上下文中,稍微不同的输入可能导致不同的输出(例如,在Java中添加 final 可以使编译器执行更多的优化)。在某些其他情况下,不同的输入可能会导致相同的输出(例如,为每个循环取消构造一些构造)。



当调试编译器如何处理这些情况时,我通常运行编译器,并尝试找出编译器的运行时执行路径发散(或收敛)的位置。不用说,这很麻烦。



我想知道您是否有任何帮助我调试这些情况的提示。



另外,是否有任何工具可以跟踪两个程序执行,并提供执行路径的差异。

解决方案

我正在使用CLI字节码 - >本机代码JIT,这是不同的,但我们面临着类似的障碍。我把一个特殊的 ToString 方法,这将打印当前状态的字节代码以及强类型的评估堆栈等。它允许我目视检查代码转换在每个步骤都有一个文本diff工具。最终,我想制作一个调试器可视化程序,它将在每个步骤中的 ToString 代码,让我在调试器中直接向后/向前走,突出显示更改。 p>

如果你漂亮打印语法树,你可以以类似的方式进行区分。



编辑:我写了一个基本的 Annotator 类,用于将IL字节代码与生成的本机代码的汇编语言表示进行交织。它有一个 ToHtmlString()方法,允许我利用Visual Studio调试器中内置的HTML Visualizer。请不要批评ARM代码 - 我只是劫持了一些东西,所以我可以专注于注释器,现在它正在使用它来处理正确的代码。



右键单击→查看图像,如果你想看到它正确的大小。 :)



alt text http://www.280z28.org/images/vmx/2009-08-23-Annotator.png


I am currently working on a Java compiler. In the context of the compiler, slightly different inputs may result in different output (e.g. adding final in Java permits compiler to perform more optimizations). In some other cases, different inputs may result into the same output (e.g. de-sugering some constructs - for-each loops).

When debugging how a compiler handles these cases, I usually run the compiler and try to figure out where the runtime execution path of the compiler diverge (or converge). Needless to say, it's very tedious.

I am wondering if you have any tips that could help me debugging these situations.

Also, is there any tool that can trace two program executions and provide you the diffs of the execution path.

解决方案

I'm working on a CLI byte code -> native code JIT, which is different but we're facing similar obstacles. I put a special ToString method in that will pretty-print the current state of the byte code along with the strongly typed evaluation stack, etc. It allows me to visually inspect code transformations at each step with a text diff tool. Eventually I want to make a debugger visualizer that will "ToString" the code at each step and let me walk backwards/forwards directly in the debugger with highlighting for the changes.

If you pretty-print the syntax tree, you can diff it in a similar manner.

Edit: I wrote a basic Annotator class that interleaves the IL byte code with the assembly language representation of the generated native code. It has a ToHtmlString() method that allows me to take advantage of the HTML Visualizer built into the Visual Studio debugger. Please don't critique the ARM code - I just hacked something in so I could focus on the Annotator, and now that it's working I'll use it to work on proper codegen.

Right click → View image if you want to see it proper size. :)

alt text http://www.280z28.org/images/vmx/2009-08-23-Annotator.png

这篇关于调试处理略有不同的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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