找到一个字节的.NET程序集偏移 [英] Find a byte offset in a .NET Assembly

查看:115
本文介绍了找到一个字节的.NET程序集偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想调试错误,该客户端已经向我们报告。该堆栈跟踪只有字节偏移,而不是行号。

I'm trying to debug an error that the client has reported to us. The stacktrace only has byte offsets, not line numbers.

例如。

[NullReferenceException:未将对象引用不设置到对象的实例。]
     Foo.Bar(foofoo把P)+32
     Foo.BarBar()+191
     Foo.BarBarBar()+15

[NullReferenceException: Object reference not set to an instance of an object.]
Foo.Bar(FooFoo p) +32
Foo.BarBar() +191
Foo.BarBarBar() +15

如何逆向工程这些字节偏移的code线/方法调用等?

How can I reverse engineer these byte offsets into lines of code / method calls etc?

我如何才能找到其中的NullReferenceException被抛出?

How can I find where the NullReferenceException is being thrown?

推荐答案

下面是可能的工作(或者可能是不:))的解决方案。问题在于之间的偏移和行号的映射包含在PDB(又名调试符号)

Here is a solution that might work (or may be not :) ). The problem is that the mapping between offset and line numbers is contained in pdb (aka the debug symbols)

  1. 以完全相同(重要)相同的构建配置,这是用来运输二进制文件的客户端之一。然后去项目属性,选项卡构建,点击按钮高级在页面的底部。然后找到调试信息,然后选择PDB-只有
  2. 生成项目,并转到输出文件夹。
  3. 选择反汇编,可以将其添加到 PATH 或者复制到某个地方。
  4. 在你的build文件夹做反汇编/ LINENUM / SOURCE YourFile.exe 。它会输出IL失调和源代码行的映射。
  1. Take exactly (important) same build configuration as the one that was used to ship binaries to client. Then go to project properties, tab "Build", click button "Advanced" on the bottom of the page. Then find "Debug Info" and select "pdb-only"
  2. Build the project and go to output folder.
  3. Pick ildasm, either add it to PATH or copy it somewhere.
  4. In your build folder do ildasm /LINENUM /SOURCE YourFile.exe. It will output IL with offset and source line mapping.

这是我看到,​​你将不能够生产的完全的相同的二进制文件和映射可能fluctate唯一的问题。

The only problem that I see that you will not be able to produce exactly same binaries and mapping might fluctate.

这篇关于找到一个字节的.NET程序集偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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