从 Windbg 中 ASP.net 3.5 进程的转储中检索会话内容
我已经转储了 W3wp.exe 进程,并尝试使用 Windbg 检索会话的内容。我的测试应用程序是在 Windows 7 64 位上运行的 ASP.net 3.5,会话正在进行中。我可以检索各种其他对象的内容,但很难找到会话内容所在的位置。
是的,我知道在会话中存储内容是不好的,但我需要它来帮助调试客户端站点上的问题。
我发现 Tess Ferrendez 发表了一篇很棒的文章 (http://blogs.msdn.com/b/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx)描述创建一个脚本来迭代会话中的所有内容。
然而,我怀疑这是针对以前版本的 IIS(可能还有 .net 和 32 位),因为 Tess 的脚本查找似乎不存在于我的转储中的 InProcSessionState 对象。
有什么想法如何从转储中获取会话的内容吗?
谢谢,
亚历克斯
I have taken a dump of W3wp.exe process and am trying to retrieve the contents of session using Windbg. My test application is ASP.net 3.5 running on Windows 7 64 bit and the session is inprocess. I can retrieve the contents of various other objects but am struggling to find where session contents is located.
Yes I know storing stuff in session is bad but I need this to help debug an issue at a clients site.
I found a great post by Tess Ferrendez (http://blogs.msdn.com/b/tess/archive/2007/09/18/debugging-script-dumping-out-asp-net-session-contents.aspx) that describes creating a script to iterate through everything in session.
I suspect however that this was aimed at a previous version of IIS (and possibly .net & 32bit) as Tess's script looks for InProcSessionState objects which dont seem to exist in my dump.
Any ideas how to get at the contents of session from a dump?
Thanks,
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此解决方案用于转储 x64 asp.net 会话对象。
这是我用来将项目添加到会话的示例代码。
这是获取 HttpSession 对象内容的脚本
将上述脚本复制到文件中并像这样调用脚本
$$>a<"c:\temp\test.txt" 000007fef4115c20
在 Windbg 内。将 System.Web.SessionState.HttpSessionState 的 MT 作为脚本参数传递。这是脚本的输出,
我使用别名
!ds
来转储字符串,而不是使用!dumpobj
。要创建别名,请使用此命令as !ds .printf "%mu \n", 10+
该脚本有点神秘,除非您习惯编写 Windbg 脚本。
以下是脚本
$t5
的简要说明 - 包含对System.Collections.Specialized.NameObjectCollectionBase+NameObjectEntry
类型数组的引用.for循环是遍历数组项。如果您有兴趣了解自定义转储数组,我也写过同样的博客
.if
语句.if (poi((@$t5-0x8)+@$t1) = 0)
检查之前该项是否为 null使用!ds
命令转储内容。!ds poi(poi((@$t5-0x8)+@$t1)+0x8)
:- 会话的密钥字符串。示例
Name
!ds poi(poi((@$t5-0x8)+@$t1)+0x10)
:- 会话值。示例测试
HTH
编辑:- 这里还有一个独立于平台的脚本。这应该适用于 x86 和 x64
This solution is for dumping x64 asp.net session objects.
Here is the sample code i used to add the items to session.
Here is the script to get the contents of the HttpSession object
Copy the above script in to a file and invoke the script like this
$$>a<"c:\temp\test.txt" 000007fef4115c20
within Windbg. Passing the MT ofSystem.Web.SessionState.HttpSessionState
as the script argument.And here is the output from the script
I use the alias
!ds
for dumping strings instead of using!dumpobj
. To create the alias use this commandas !ds .printf "%mu \n", 10+
The script is little bit arcane unless you are used to writing windbg scripts.
Here is a brief explanation of the script
$t5
- Contains reference to the array of typeSystem.Collections.Specialized.NameObjectCollectionBase+NameObjectEntry
.for
loop is to iterate through the array items. I have blogged about the same if you are interested in understanding custom dumparray.if
statement within the nested for loop.if (poi((@$t5-0x8)+@$t1) = 0)
checks if the item is null before dumping the contents using!ds
command.!ds poi(poi((@$t5-0x8)+@$t1)+0x8)
:- The key string for the session . Example
Name
!ds poi(poi((@$t5-0x8)+@$t1)+0x10)
:- The session value . ExampleTest
HTH
EDIT:- Also here is a platform independent script . This should work for x86 and x64