Chinaunix首页 | 论坛 | 博客
  • 博客访问: 756493
  • 博文数量: 176
  • 博客积分: 2548
  • 博客等级: 少校
  • 技术积分: 1749
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-29 16:36
个人简介

爱咋咋地

文章分类

全部博文(176)

文章存档

2024年(1)

2023年(17)

2022年(19)

2021年(3)

2020年(1)

2018年(1)

2017年(1)

2014年(1)

2013年(4)

2012年(11)

2011年(19)

2010年(22)

2009年(71)

2008年(5)

分类: LINUX

2011-04-12 19:11:31

1. Generating core files from gdb

While debugging a problem a few weeks back, I needed to generate a core file from a hung process. I typically use the gcore utility to generate core files from running processes, but in this case I was already attached to the process with gdb, so gcore failed:

$ gcore 2575
ptrace: Operation not permitted.
You can’t do that without a process to debug.

Gak! I remembered reading about a gdb option that would dump core, so I wandered off to read through my gdb notes. Sure enough, gdb has a “generate-core-file” command to create a core file:

$ gdb -q – 2575

Attaching to process 2575 Reading symbols from /usr/sbin/gpm...(no debugging symbols found)...done. Using host libthread_db library "/lib/tls/libthread_db.so.1". Reading symbols from /lib/tls/libm.so.6...(no debugging symbols found)...done. Loaded symbols for /lib/tls/libm.so.6 Reading symbols from /lib/tls/libc.so.6... (no debugging symbols found)...done. Loaded symbols for /lib/tls/libc.so.6 Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done. Loaded symbols for /lib/ld-linux.so.2 0x0046e7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 (gdb) generate-core-file Saved corefile core.2575 (gdb) detach Detaching from program: /usr/sbin/gpm, process 2575 (gdb) quit $ ls -al core.* -rw-r--r-- 1 root root 2468288 Dec 11 13:49 core.2575

Nifty! I am starting to wonder if there is anything gdb can’t do. :)

 

2. show backtrace of all threads like pstack

(gdb) thread apply all bt

 

3. don't print information in multi-pages

set height 0

4. set the size of content for print

set print element xxxx

5. logging gdb output into a file

set logging on [file name]

set logging off

阅读(1694) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~