如何将 CLR 方法表条目与 MethodDesc 进行匹配?

发布于 2024-09-08 08:48:30 字数 815 浏览 2 评论 0原文

使用 sos,我可以获得特定类的方法表条目列表:

!DumpMT -MD 1d3c58
PDB symbol for mscorwks.dll not loaded
EEClass: 001d195c
Module: 001d2f2c
Name: Class1.B
mdToken: 02000005
BaseSize: 0xc
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 7
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
691f6a90   69071248   PreJIT System.Object.ToString()
691f6ab0   69071250   PreJIT System.Object.Equals(System.Object)
691f6b20   69071280   PreJIT System.Object.GetHashCode()
692674c0   690712a4   PreJIT System.Object.Finalize()
001dc088   001d3c34     NONE Class1.B.M()
001dc090   001d3c40     NONE Class1.B.N()
001dc098   001d3c4c      JIT Class1.B..ctor()

但我无法弄清楚 sos 如何将表条目与 MethodDesc 相匹配 - 在方法表中进行查看内存仅提供指向 JIT 存根的 Entry 值。我不知道如何从那里获取 MethodDesc 。有人有什么想法吗?

Using sos, I can get the method table entry list for a particular class:

!DumpMT -MD 1d3c58
PDB symbol for mscorwks.dll not loaded
EEClass: 001d195c
Module: 001d2f2c
Name: Class1.B
mdToken: 02000005
BaseSize: 0xc
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 7
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
691f6a90   69071248   PreJIT System.Object.ToString()
691f6ab0   69071250   PreJIT System.Object.Equals(System.Object)
691f6b20   69071280   PreJIT System.Object.GetHashCode()
692674c0   690712a4   PreJIT System.Object.Finalize()
001dc088   001d3c34     NONE Class1.B.M()
001dc090   001d3c40     NONE Class1.B.N()
001dc098   001d3c4c      JIT Class1.B..ctor()

But I can't figure out how sos can match up a table entry with a MethodDesc - having a poke around the method table in memory only gives the Entry values, which point to the JIT stub. I can't figure out how you can get the MethodDescs from there. Anyone have any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深居我梦 2024-09-15 08:48:30

您可以从 Class1.B..ctor() 的条目中获取 MethodDesc

!dumpmd poi(001dc098-0x4)

例如,这里是一个示例 dumpmt

  0:021> !dumpmt -md poi(0x18e3d90)
EEClass: 012ef6a4
Module: 00d42c5c
Name: LINQPad.UserOptions
mdToken: 02000002  (C:\Documents and Settings\naveen\My Documents\Downloads\LINQPad.exe)
BaseSize: 0x3c
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 16
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
03aa6aa0   03924924   PreJIT System.Object.ToString()
03aa6ac0   0392492c   PreJIT System.Object.Equals(System.Object)
03aa6b30   0392495c   PreJIT System.Object.GetHashCode()
03b17410   03924980   PreJIT System.Object.Finalize()
01321618   00d481ac      JIT LINQPad.UserOptions..ctor()
01321458   00d481c0      JIT LINQPad.UserOptions..cctor()
013214a8   00d48140      JIT LINQPad.UserOptions.get_Instance()
01321580   00d4814c      JIT LINQPad.UserOptions.Load()
01321650   00d48158      JIT LINQPad.UserOptions.Deserialize(System.String)
00d4c249   00d48164     NONE LINQPad.UserOptions.Save()
018c8410   00d48170      JIT LINQPad.UserOptions.get_TabSizeActual()
00d4c251   00d4817c     NONE LINQPad.UserOptions.get_IsVBDefault()
01325ef0   00d48188      JIT LINQPad.UserOptions.GetDefaultCustomSnippetsFolder()
01325e00   00d48194      JIT LINQPad.UserOptions.GetCustomSnippetsFolder(Boolean)
0db83d50   00d481a0      JIT LINQPad.UserOptions.get_ActualEditorBackColor()
01321898   00d481b4      JIT LINQPad.UserOptions.<Deserialize>b__0(System.Reflection.FieldInfo)

从条目返回到 methoddesc 的引用

0:021> !dumpmd poi(01321458-0x4)
Method Name: LINQPad.UserOptions..cctor()
Class: 012ef6a4
MethodTable: 00d4838c
mdToken: 0600000c
Module: 00d42c5c
IsJitted: yes
CodeAddr: 01321458

这里是使用 !dumpmd HTH

You could get the MethodDesc from the entry for Class1.B..ctor()

!dumpmd poi(001dc098-0x4)

For example here is a sample dumpmt

  0:021> !dumpmt -md poi(0x18e3d90)
EEClass: 012ef6a4
Module: 00d42c5c
Name: LINQPad.UserOptions
mdToken: 02000002  (C:\Documents and Settings\naveen\My Documents\Downloads\LINQPad.exe)
BaseSize: 0x3c
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 16
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
03aa6aa0   03924924   PreJIT System.Object.ToString()
03aa6ac0   0392492c   PreJIT System.Object.Equals(System.Object)
03aa6b30   0392495c   PreJIT System.Object.GetHashCode()
03b17410   03924980   PreJIT System.Object.Finalize()
01321618   00d481ac      JIT LINQPad.UserOptions..ctor()
01321458   00d481c0      JIT LINQPad.UserOptions..cctor()
013214a8   00d48140      JIT LINQPad.UserOptions.get_Instance()
01321580   00d4814c      JIT LINQPad.UserOptions.Load()
01321650   00d48158      JIT LINQPad.UserOptions.Deserialize(System.String)
00d4c249   00d48164     NONE LINQPad.UserOptions.Save()
018c8410   00d48170      JIT LINQPad.UserOptions.get_TabSizeActual()
00d4c251   00d4817c     NONE LINQPad.UserOptions.get_IsVBDefault()
01325ef0   00d48188      JIT LINQPad.UserOptions.GetDefaultCustomSnippetsFolder()
01325e00   00d48194      JIT LINQPad.UserOptions.GetCustomSnippetsFolder(Boolean)
0db83d50   00d481a0      JIT LINQPad.UserOptions.get_ActualEditorBackColor()
01321898   00d481b4      JIT LINQPad.UserOptions.<Deserialize>b__0(System.Reflection.FieldInfo)

And here is reference back to methoddesc from entry using !dumpmd

0:021> !dumpmd poi(01321458-0x4)
Method Name: LINQPad.UserOptions..cctor()
Class: 012ef6a4
MethodTable: 00d4838c
mdToken: 0600000c
Module: 00d42c5c
IsJitted: yes
CodeAddr: 01321458

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文