如何用gdb进行汇编级的调试
2007-05-26 20:40
441 查看
我的方法是编译成汇编文件后(gcc -S) 然后用gas编译成.o 文件,再生成执行文件.
给你一个我的调试过程.
CODE:
[Copy to clipboard]
#include <stdio.h>
int main()
{
printf("hello world/n");
return 0;
}
gcc -S 019.c
生成019.s文件
as -o 019.o -gstabs 019.s
生成019.o文件
gcc -o 019 -Wall 019.o
gdb 019
[root@JETTER-WEB c]# gdb 019
GNU gdb Red Hat Linux (6.1post-1.20040607.62rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) l
1 .file "019.c"
2 .section .rodata
3 .LC0:
4 .string "hello world/n"
5 .text
6 .globl main
7 .type main, @function
8 main:
9 pushl %ebp
10 movl %esp, %ebp
(gdb)
11 subl $8, %esp
12 andl $-16, %esp
13 movl $0, %eax
14 addl $15, %eax
15 addl $15, %eax
16 shrl $4, %eax
17 sall $4, %eax
18 subl %eax, %esp
19 subl $12, %esp
20 pushl $.LC0
(gdb)
21 call printf
22 addl $16, %esp
23 movl $0, %eax
24 leave
25 ret
26 .size main, .-main
27 .section .note.GNU-stack,"",@progbits
28 .ident "GCC: (GNU) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)"
(gdb)
b 行号就可以了.
给你一个我的调试过程.
CODE:
[Copy to clipboard]
#include <stdio.h>
int main()
{
printf("hello world/n");
return 0;
}
gcc -S 019.c
生成019.s文件
as -o 019.o -gstabs 019.s
生成019.o文件
gcc -o 019 -Wall 019.o
gdb 019
[root@JETTER-WEB c]# gdb 019
GNU gdb Red Hat Linux (6.1post-1.20040607.62rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) l
1 .file "019.c"
2 .section .rodata
3 .LC0:
4 .string "hello world/n"
5 .text
6 .globl main
7 .type main, @function
8 main:
9 pushl %ebp
10 movl %esp, %ebp
(gdb)
11 subl $8, %esp
12 andl $-16, %esp
13 movl $0, %eax
14 addl $15, %eax
15 addl $15, %eax
16 shrl $4, %eax
17 sall $4, %eax
18 subl %eax, %esp
19 subl $12, %esp
20 pushl $.LC0
(gdb)
21 call printf
22 addl $16, %esp
23 movl $0, %eax
24 leave
25 ret
26 .size main, .-main
27 .section .note.GNU-stack,"",@progbits
28 .ident "GCC: (GNU) 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)"
(gdb)
b 行号就可以了.
相关文章推荐
- (转载)如何用gdb进行汇编级的调试
- 如何用GDB进行多线程调试
- 使用 gdb 对程序进行汇编级调试
- 如何运用Gdb对ARM板上的程序进行远程调试
- Window平台Grmon下如何使用gdb进行调试
- 如何使用gdb进行调试
- 如何使用Eclipse和GDB对JNI代码进行调试(JAVA和C)
- 如何在Windows的命令行下进行程序编译和gdb调试
- [置顶] linux下如何利用gdb调试汇编代码
- Linux下的c如何进行GDB调试
- 使用 gdb 对程序进行汇编级调试
- WebKit技巧:如何用GDB进行调试
- GDB进行汇编级的调试
- 什么是 core dump ? 以及如何使用gdb对 core dumped 进行调试
- 如何进行adb模式下的调试
- linux下如何用GDB调试c++程序
- gdb的简单使用和gdb+gdbserver方式进行ARM程序调试
- 在Win7下Visual Studio如何使用IIS进行调试
- 如何用Myeclipse进行调试
- 使用GDB调试时如何保证不串行