emacs中gdb

来源:互联网 发布:狙击精英4 知乎 编辑:程序博客网 时间:2024/05/02 01:16

一 .EMACS 中调试

1、using the clipboard

M-x menu-bar-enable-clipboard

(make cut,copy,pasty menu items,use the clipboard)

2、using wheelmice

M-x mouse-wheel-mode

(激活中间的滚动键)

3、退出出任何命令状态

C-g

4、进入编译模式

M-x compile 或者从菜单-》TOOLS-》COMPILE

5、用COMPILE 模式

C-x ` (搜索出错的源代码行)

(光标定位在compile buffer 的出错提示行上,按〈RET〉键,会跳到出错的源代码行)

C-u C-x ` 在compile buffer 列出同样的错误。

6、用GREP 搜索

一、M-x grep 进入搜索

参数为 a grep-style regexp(using in single-quotes to quote the shell's special characters)follows bye file names;

二、 C-x ` (搜索出错的源代码行 --grep 搜索出来的同种错误)

(光标定位在grep buffer 的出错提示行上,按〈RET〉键,会跳到出错的源代码行)

二、GUD 调试

1、进入

M-x gdb

2、命令

C-x 在指针所在源代码行上设置断点

说明 C-c 在GUD BUFFER,而C-x C-a 在gud buffer and source buffer 都行

3、 C-c C-l

C-x C-a C-l 到达最后一行

4、C-c C-s

C-x C-a C-s gud-step

5、C-c C-n

C-x C-a C-n gud-next

6、C-c C-r

C-x C-a C-r gud-cont 执行到下一个断点

7、C-c C-d

C-x C-a C-d gud-remove 删除当前断点

三、GDB 命令

1、调试命令

step next continue untile

2、设置断点

break file.c:foo

break file.c:11

break +12

break -12 如果执行到某一行,+表示往前,-表示向后

断点信息

info breakpoint

enable

disable

断点条件

break if

condition

delete breakpoints

clear

3、显示源代码

list 使用同断点

4、查看变量

print /fmt

5、查看内存

x /

6、切换目录

cd

7、添加源文件路径

dir

8、显示

如果有 char msg[25];

int *arr=(int *)mollac(len*sizeof(int));

则 display msg

display *arr@len

或者 p msg

p *arr@len

9、跳转执行

jump linespec

jump

四、Makefile 文件

//mt.h

#ifdef _cplusplus

extern "c" {

#endif

int add(int a,int b);

int substract(int num,int n,int *ret);

#ifdef _cplusplus

}

#endif

-----------------------------------------------

//math.c

#include"mt.h"

int add(int a,int b)

原创粉丝点击