随笔分类 -  Debugging with GDB

摘要:Gdb调试多进程程序程序经常使用fork/exec创建多进程程序。多进程程序有自己独立的地址空间,这是多进程调试首要注意的地方。Gdb功能强大,对调试多线程提供很多支持。方法1:调试多进程最土的办法:attach pidAttach是调试进程的常用办法,只要有可执行程序以及相应PID,即可工作。当然,为方便调试,可以在进程启动后,设定sleep一段时间,如30s,这样即可有充足的时间来attach。方法2: set follow-fork-mode child + main断点当设置set follow-fork-mode child,gdb将在fork之后直接执行子进程,知道碰到断点后停止。 阅读全文
posted @ 2014-04-03 13:21 Me.thinking 阅读(189) 评论(0) 推荐(0)
摘要:提供以下功能:automatic notification of new threads‘thread threadno’, a command to switch among threads‘info threads’, a command to inquire about existing threads‘thread apply [threadno] [all] args’, a command to apply a command to a list of threadsthread-specific breakpoints‘set print thread-events’, whic 阅读全文
posted @ 2013-09-25 17:01 Me.thinking 阅读(235) 评论(0) 推荐(0)
摘要:1. 编译 加 -g2. 启动run或者startThe `start' command does the equivalent of setting a temporary breakpoint at the beginning of the main procedure and then invoking the `run' command. gdb ./main(gdb) start3. 可以使用wrapper4. set argsshow args5. 当前工作目录cd directory Set the gdb working directory to directo 阅读全文
posted @ 2013-03-30 21:30 Me.thinking 阅读(167) 评论(0) 推荐(0)
摘要:1. 回车重复。 windbg也实现了。shell不可能实现。(有些命令不支持,比如run,因为不能支持)2. 支持Tab自动完成,跟shell一样。命令和symbol都支持。 <ESC> followed by ?. 可以打印出所有可能。比如输入info 然后<ESC> followed by ? (gdb) inf inferior info 还能支持结构成员变量扩展3. 命令可以接参数,比如step 54. 命令只要没有二义就不用写全。 更有甚者(这样的设计很好),有二义也有二义的优先级,比如s就指的是step5. Getting Help help h help 阅读全文
posted @ 2013-03-28 18:35 Me.thinking 阅读(321) 评论(0) 推荐(0)
摘要:啥东西有logging就是牛X的,Django也有logging。set logging onEnable logging. 默认打印到当前目录的gdb.txt文件set logging offDisable logging. set logging file fileChange the name of the current logfile. The default logfile isgdb.txt.set logging overwrite [on|off]By default, gdb will append to the logfile. Set overwrite if you 阅读全文
posted @ 2013-03-28 18:08 Me.thinking 阅读(312) 评论(0) 推荐(0)
摘要:shell command-string 阅读全文
posted @ 2013-03-28 18:04 Me.thinking 阅读(265) 评论(0) 推荐(0)
摘要:quit [expression]qTo exit gdb, use the quit command (abbreviated q), or type an end-of-file character (usually Ctrl-d). If you do not supply expression, gdb will terminate normally; otherwise it will terminate using the result of expression as the error code.An interrupt (often Ctrl-c) does not exit 阅读全文
posted @ 2013-03-28 17:59 Me.thinking 阅读(317) 评论(0) 推荐(0)
摘要:怎么调用gdbgdb programgdb program corefile <=> gdb program -c corefilegdb program 1234 would attach gdb to process 1234 (unless you also have a file named 1234; gdb does check for a core file first). gdb --args gcc -O2 -c foo.c This will cause gdb to debug gcc, and to set gcc's command-line ar 阅读全文
posted @ 2013-03-28 17:57 Me.thinking 阅读(188) 评论(0) 推荐(0)
摘要:学习gdb 记录:http://sourceware.org/gdb/download/onlinedocs/gdb/index.html有时候总是感觉学不透彻,不能成为高手,那是因为没有系统学习。把guide通读一遍是一个途径。网上有些文章为什么不想读,是因为太长长。。。。 阅读全文
posted @ 2013-03-28 16:40 Me.thinking 阅读(210) 评论(0) 推荐(0)