应用上线后可能出现一些问题,通过源码排查,日志分析都不能确定具体原因的情况下,可以使用dump转存文件分析,netcore对于linux系统dump提供了createdump工具,配合lldb sos插件进行clr级分析

启动一个dotnet容器,使用特权运行,createdump要访问其他进程内存,特权是必须的

docker run --name dotnet --rm -it --privileged=true microsoft/dotnet /bin/bash

创建并运行一个webapi示例

cd ~/
dotnet new webapi
dotnet run > /dev/null 2>&1 &

查找dotnet中的createdump工具路径

find /usr/share -name createdump

列出所有dotnet进程

ps -al | grep dotnet

创建dump文件

/usr/share/dotnet/shared/Microsoft.NETCore.App/2.1.2/createdump PID
ls /tmp/

将dump文件复制到本机,因为docker不支持容器之间复制,需要中转

docker cp dotnet:/tmp/coredump.324 ./

启动一个lldb容器

docker run --name lldb --rm -it -v ./:var/dump/ daocloud.io/ss22219/dotnet-lldb /bin/bash

复制dump文件到容器,分析dump文件

docker cp coredump.324 lldb:/root
lldb coredump.324

ss22219/dotnet-lldb镜像开源在github上,将lldb集成到dotnet sdk中,并且自动加载sos插件

使用方法是lldb dumpfile,sos的命令列表如下

SOS 命令列表

输入 "soshelp <functionname>" 查看函数详情

Object Inspection                  Examining code and stacks
----------------------------- -----------------------------
DumpObj (dumpobj) Threads (clrthreads)
DumpArray ThreadState
DumpStackObjects (dso) IP2MD (ip2md)
DumpHeap (dumpheap) u (clru)
DumpVC DumpStack (dumpstack)
GCRoot (gcroot) EEStack (eestack)
PrintException (pe) ClrStack (clrstack)
GCInfo
EHInfo
bpmd (bpmd) Examining CLR data structures Diagnostic Utilities
----------------------------- -----------------------------
DumpDomain VerifyHeap
EEHeap (eeheap) FindAppDomain
Name2EE (name2ee) DumpLog (dumplog)
DumpMT (dumpmt) CreateDump (createdump)
DumpClass (dumpclass)
DumpMD (dumpmd)
Token2EE
DumpModule (dumpmodule)
DumpAssembly
DumpRuntimeTypes
DumpIL (dumpil)
DumpSig
DumpSigElem Examining the GC history Other
----------------------------- -----------------------------
HistInit (histinit) FAQ
HistRoot (histroot) Help (soshelp)
HistObj (histobj)
HistObjFind (histobjfind)
HistClear (histclear)

别名列表

bpmd            -> sos bpmd
clrstack -> sos ClrStack
clrthreads -> sos Threads
clru -> sos U
createdump -> sos CreateDump
dso -> sos DumpStackObjects
dumpclass -> sos DumpClass
dumpheap -> sos DumpHeap
dumpil -> sos DumpIL
dumplog -> sos DumpLog
dumpmd -> sos DumpMD
dumpmodule -> sos DumpModule
dumpmt -> sos DumpMT
dumpobj -> sos DumpObj
dumpstack -> sos DumpStack
eeheap -> sos EEHeap
eestack -> sos EEStack
gcroot -> sos GCRoot
histinit -> sos HistInit
histroot -> sos HistRoot
histobj -> sos HistObj
histobjfind -> sos HistObjFind
histclear -> sos HistClear
ip2md -> sos IP2MD
name2ee -> sos Name2EE
pe -> sos PrintException
soshelp -> sos Help

相关资料:

https://github.com/dotnet/coreclr/blob/master/Documentation/building/debugging-instructions.md

https://github.com/dotnet/coreclr/blob/master/Documentation/botr/xplat-minidump-generation.md

Docker中使用createdump调试coreclr的更多相关文章

  1. ref:phpstorm配置远程调试(xdebug)(docker中)

    ref:https://www.cnblogs.com/yjken/p/6555438.html readme:本文设置远程调试ubuntu中的php代码. 在docker中也可以,经过测试phpin ...

  2. 保姆级教程:VsCode调试docker中的NodeJS程序

    最近在写NodeJS相关的项目,运行在docker容器中,也是想研究一下断点调试,于是查阅相关资料,最终顺利配置好了. 首先我选择了VsCode作为ide,并用VsCode来做NodeJS可视化deb ...

  3. 在Windows上编译和调试CoreCLR

    生成CoreCLR - Windows篇 本文的唯一目的就是让你运行Hello World 运行环境 Window 7+ Visual studio 2015 确保C++ 工具已经被安装,默认是不安装 ...

  4. Calico在Docker中的搭建

    一,Multi-host网络需求 开始之前推荐两篇文章 http://xelatex.github.io/2015/11/15/Battlefield-Calico-Flannel-Weave-and ...

  5. 三、使用vscode在docker中debug

    上篇博文中分享了如何用docker-compose搭建AspNetCore的开发环境,在开发过程中debug是必不可少的,如果你使用VS2017的话,右键就可以了,而作为跨平台的.net core开发 ...

  6. [转]Docker中的镜像

    引言 这篇文章中我们主要来探讨下Docker镜像,它是用来启动容器的构建基石,本文的所用到的Dcoker版本是17.1,API版本是1.33,Go的版本是1.9.2,OS是基于Arch Linux的M ...

  7. 让docker中的mysql启动时自动执行sql文件

    本文提要 本文目的不仅仅是创建一个MySQL的镜像,而是在其基础上再实现启动过程中自动导入数据及数据库用户的权限设置,并且在新创建出来的容器里自动启动MySQL服务接受外部连接,主要是通过Docker ...

  8. ASP.NET Core 3.0 : 二十八. 在Docker中的部署以及docker-compose的使用

    本文简要说一下ASP.NET Core 在Docker中部署以及docker-compose的使用  (ASP.NET Core 系列目录). 系统环境为CentOS 8 . 打个广告,求职中.. 一 ...

  9. Visual Studio Code IDE + Docker实现PHP Xdebug调试

    一.Docker中安装配置Xdebug 通过phpinfo()输出当前安装的PHP版本信息,将信息拷贝到https://xdebug.org/wizard.php相应输入框中,系统会自动检测并推荐合适 ...

随机推荐

  1. (7)Why 30 is not the new 20

    https://www.ted.com/talks/meg_jay_why_30_is_not_the_new_20/transcript 00:12When I was in my 20s, I s ...

  2. boost-断言

    标准assert宏的原型声明在<assert.h>中,其作用是如果它的测试条件为假,则调用abort()终止程序执行,程序退出的时候会弹出一个错误提示框,并向控制台输出所在文件及行号.as ...

  3. MFC连接MySQL C API方法

    1.首先下载一个32位的MySQL,因为vc的版本是32位了,不用32 位的MySQL会出现无效的机械码错误. MySQL安装地址:https://dev.mysql.com/downloads/my ...

  4. IntelliJ IDEA 2017版 spring-boot2.0.4+mybatis 自动部署的细节问题

    一.加载pom依赖包 <!--spring-boot开发热部署--> <dependency> <groupId>org.springframework.boot& ...

  5. user\db\table_privs\column_privs四张表的权限控制

    今天要做的测试是:user\db\table_privs\column_privs这四张权限表分别控制哪些级别的权限: 测试准备: [超级用户]root@'127.0.0.1' [操作库权限的用户]g ...

  6. asp.net 多线程

    //开启一条线程并执行一个方法      Thread oThread = new Thread(new ThreadStart(IIMsSqlToSqlitle2));            oTh ...

  7. jq+download+文件夹下载

    最近公司在做工程项目,实现文件夹下载. 网上找了很久,发现网上的代码都有相似的问题,不过最终还是让我找到了一个符合的项目. 工程: 进行项目文件夹下载功能分析,弄清楚文件夹下载的原理,提供的数据支持. ...

  8. HTTP协议(一)[草稿版]

    (一)HTTP客户端请求头格式

  9. python基础回顾

    1.第二个缺点就是代码不能加密.如果要发布你的Python程序,实际上就是发布源代码,这一点跟C语言不同,C语言不用发布源代码,只需要把编译后的机器码(也就是你在Windows 上常见的xxx.exe ...

  10. Codeforces Round #540 (Div. 3)--1118D1 - Coffee and Coursework (Easy version)

    https://codeforces.com/contest/1118/problem/D1 能做完的天数最大不超过n,因为假如每天一杯咖啡,每杯咖啡容量大于1 首先对容量进行从大到小的排序, sor ...