1.core文件
为了给定位问题提供一个接口,在发生问题后将内存中的进程相关信息格式化地保存在一个文件中的手段,以便于在发生问题而中断了进程的执行后,通过内存信息转储文件得到问题发生时的蛛丝马迹,获得进一步的定位信息。这个进程内存信息转储文件就被命名为core。
2.配置生成 core 文件
(1)core文件开关
①使用 ulimit -c 查看core开关,如果为0表示关闭,不会生成core文件;
②使用 ulimit -c [filesize] 设置core文件大小,当最小设置为4之后才会生成core文件;
③使用 ulimit -c unlimited 设置core文件大小为不限制,这是常用的做法;
④如果需要开机就执行,则需要将这句命令写到 /etc/profile 等文件。
(2)core文件命名和保存路径
①core文件有默认的名称和路径,但为了方便,我们通常会自己命名和指定保存路径;
②可以通过 /proc/sys/kernel/core_pattern 设置 core 文件名和保存路径,方法如下:
echo "/corefile/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
命名的参数列表:
%p - insert pid into filename 添加pid
%u - insert current uid into filename 添加当前uid
%g - insert current gid into filename 添加当前gid
%s - insert signal that caused the coredump into the filename 添加导致产生core的信号
%t - insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间
%h - insert hostname where the coredump happened into filename 添加主机名
%e - insert coredumping executable name into filename 添加命令名。
3.调试core文件
(1)方法1: gdb [exec file] [core file] 然后执行bt看堆栈信息:
(2)方法②:gdb -c [core file],然后 file [exec file],最后再使用 bt 查看错误位置:
注:
问题1:
gdb bt/where调试出现0x0xxxxx in ?? ()
1.原因是可能没找到符号表。
解决方法,cd到可执行文件目录下, 执行 “gdb -c core文件绝对路径”
进入gdb命令行, 执行sharedlibrary加载符号表,再输入bt即能正确定位到错误点
2.gdb /opt/dmdbms/bin/dmserver core….
where
thread
查到对应进程号,可在sql日志里找到对应的sql
文章
阅读量
获赞