在释放模式下从pdb获取行号 [英] Getting line number from pdb in release mode

查看:87
本文介绍了在释放模式下从pdb获取行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调试器(或CLR异常处理程序)是否可以使用pdb显示发布模式中发生异常的行?



代码,发布模式,被优化,并不总是遵循原始代码的顺序和逻辑。



令人惊讶的是,调试器可以逐步浏览我的代码,即使在释放模式。优化应该使导航非常不舒服。



可以请你澄清这两点吗?

解决方案

我不太熟悉CLR如何完成,但它可能与本机代码的完成方式非常相似。当编译器生成机器指令时,它将向pdb添加条目,基本上说当前地址的指令X,来自foo.cpp中的第25行。





此过程是相同的,无论调试或发布模式(只要一个pdb生成在所有释放模式)。然而,您是对的,由于优化,调试器通常不会通过代码线性地进行释放模式。它可能会意外地跳到不同的线。这是由于优化器改变了指令的顺序,但它并没有改变地址到源代码行的映射,所以调试器仍然可以遵循。


Is it possible for the debugger (or the CLR exception handler) to show the line where the exception happened in Release mode using the pdb?

The code, in release mode, is optimized and do not always follow the order and logic of the "original" code.

It's also surprising that the debugger can navigate through my code step by step, even in Release mode. The optimization should make the navigation very inconfortable.

Could you please clarify those two points for me?

解决方案

I'm not as familiar with how this is done with CLR, but it's probably very similar to how it's done with native code. When the compiler generates machine instructions, it adds entries to the pdb that basically say "the instruction at the current address, X, came from line 25 in foo.cpp".

The debugger knows what program address is currently executing. So it looks up some address, X, in the pdb and sees that it came from line 25 in foo.cpp. Using this, it's able to "step" through your source code.

This process is the same regardless of Debug or Release mode (provided that a pdb is generated at all in Release mode). You are right, however, that often in release mode due to optimizations the debugger won't step "linearly" through the code. It might jump around to different lines unexpectedly. This is due to the optimizer changing the order of instructions, but it doesn't change the address-to-source-line mapping, so the debugger is still able to follow it.

这篇关于在释放模式下从pdb获取行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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