我们如何脚本脚本dotnet转储分析命令?
在调试 Windows 转储时,我经常使用 cdb 脚本。这样的脚本加载转储,进行所有必要的准备(例如设置符号和加载 sosex),然后:
- 打开日志文件
- 运行所需的命令
- 关闭日志文件
例如:
...
.imgscan /l
.load e:\utils\sosex\64\sosex.dll
!lhi
.logopen "D:\tmp\dumpheap-stat.txt"
!dumpheap -stat
.logclose
现在我想关注 linux 转储相同的方法,即编写脚本并将结果转储到文件。是否可以?
When debugging windows dumps I often use cdb scripts. Such a script loads the dump, does all the necessary preparations (like setting up the symbols and loading sosex) and then:
- Opens a log file
- Runs the desired command
- Closes the log file
For example:
...
.imgscan /l
.load e:\utils\sosex\64\sosex.dll
!lhi
.logopen "D:\tmp\dumpheap-stat.txt"
!dumpheap -stat
.logclose
Now with the linux dump I would like to follow the same methodology, namely - scripting and dumping results to files. Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用此命令来运行
dotnet-dumpanalyze
的预定义命令,并将输出保存到文本文件中:将所需的命令放入
dumpcommands
文件中,一个 sos每行命令。最后一个应该是exit
:忽略绝对路径。我必须在 docker 容器中运行它
I'm using this commands to run predefined commands for
dotnet-dump analyze
and save the output to a text file:Put the command you need into the
dumpcommands
file, one sos command per line. The last one should beexit
:Ignore the absolute paths. I have to run it within a docker container
我在使用
dotnet dumpanalyze
时遇到问题 - 由于某种原因gcroot
不起作用 - 它只是永远挂在我们的 10GB 转储上。不过,我看到Tess Ferrandez正在使用lldb,我尝试了一下,效果非常好。
这是我的工作流程:
最后一个命令下载相关的 dotnet 可执行文件。接下来我们可以调试:
现在 lldb 可以运行文件中的命令或命令行上给出的命令。这使我们能够编写脚本。现在我知道
dotnet dumpanalyze
也可以编写脚本,如各自的答案所示。我希望我们可以利用 lldb Python API,尽管目前我不知道如何按照我的其他 SO 问题从中调用自定义命令 - 如何通过 lldb python API 运行 sos 扩展命令?
I have a problem with
dotnet dump analyze
- for some reasongcroot
does not work - it just hangs forever on our 10GB dump.However, I saw that Tess Ferrandez was using lldb and I gave it a try and it is very good.
Here is my worklow:
dotnet symbol --host-only TheCoreDumpFilePath
The last command downloads the relevant
dotnet
executable. Next we can debug:lldb -c TheCoreDumpFilePath dotnet
Now lldb can run commands from file or given on the command line. This gives us ability to script it. Now I understand that
dotnet dump analyze
can be scripted too as shown in the respective answer.I hope we can leverage the lldb Python API, though currently I do not see how one can invoke custom commands from it as per my other SO question here - How to run sos extension commands through the lldb python API?