Posts

gdb里调试信号处理函数

要执行handle signum nostop 这样在收到信号的时候gdb就不会暂停执行 对于SIGINT,还需要 handle SIGINT pass 这样SIGINT信号就不会被gdb所截住,而是发给正在debug中的程序

Videos of SHLUG's talk on 9.10 is releasing!

http://www.shlug.org/ There were 3 talks on that day. One of them is about Godson. A Godson's real machine was shown during the talk.

Emacs + Gdb

早有耳闻这两者是不错的搭配 真正试验了一把之后发现 那岂止是不错,那是相当的不错! 绝配啊 Linux的程序员一定要试一下 否则终生遗憾 两个提示: 一个是在~/.emacs里定义变量gdb-many-windows:(defvar gdb-many-windows t) 再一个是启用gub-tooltip-mode,这样鼠标指向源代码里的变量时,emacs就能以tooltip提示框的形式显示变量的地址和值。再也不用p和x了。 简直是太方便了,太方便了!

gdb in emacs, gdbtui and inputrc

In readline, C-j functions like "enter" key. However, I defined C-j as menu-complete in my ~/.inputrc. So, in gdbtui and when using gdb in emacs, enter key don't function as usual, instead it performs menu-complete. As a consequence, i can't use gdbtui and gdb in emacs. I solved the problem myself. I just thought that this problem should has something to do with readline library. Maybe my readline is too new? This is my first suspicion. Then I suddenly remembered that I had redefined some key-binding in my ~/.inputrc. Thus, the problem solved. reference: http://tiswww.tis.case.edu/~chet/readline/rltop.html

gdb在c++程序里设置断点

原来需要写出完整的函数名,从namespace开始 比如ost::ScriptCommand::getMember 不需要用mangle过的名字 有时候可能需要执行 set language c++ reference: http://sources.redhat.com/ml/gdb/2005-07/msg00066.html

mozilla-launcher支持aoss了

这样看youtube就不必再手工用aoss firefox来启动了。 还有audacious支持id3 tag的编码侦测了,这是Liu Qing提供的消息。 http://gentoogle.blogspot.com/2006/09/emerge-audacious-112.html

一点debug技巧

怎么样打印出一个函数的stack backtrace,也就是函数的调用路径? 可以使用glibc的backtrace()/backtrace_symbols()函数,info在这里 http://www.gnu.org/software/libc/manual/html_mono/libc.html#Backtraces 这里有一段代码,可以拿去用 #include<execinfo.h> int i; void *bt[128]; int bt_size; char **bt_sym; printf("\n########## Backtrace ##########\n"); bt_size = backtrace(bt, sizeof(bt) / sizeof(void *)); printf("Number of elements in backtrace: %d\n", bt_size); bt_sym = backtrace_symbols(bt, bt_size); for (i = 0; i < bt_size; i++) { printf("%s\n", bt_sym[i]); } free(bt_sym); printf("########## Done ##########\n"); 我参考了这个 http://sources.redhat.com/ml/crossgcc/2003-02/msg00013.html 如果不幸是C++程序可以利用c++filt来得到真正的函数原型 这里有段shell代码可以拿去用: sed -e 's/[^(]\+(/c++filt /' -e 's/+0x.*$//g' | xargs -0 sh -c 还有一个gcc内建函数,gcc的扩展,也可能有用,不过只能得到返回地址 http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Return-Address.html#Return-Address