(转载)如何用gdb进行汇编级的调试
2013-05-20 15:09
357 查看
我的方法是编译成汇编文件后(gcc -S) ,然后用as编译成.o文件,最后再生成执行文件。
给你一个我的调试过程。
#include <stdio.h> #include <stdlib.h> #include <string.h> void test(void) { int number = 10; printf("The number: %d\n", number); } int main(int argc, char* argv[]) { test(); return 0; }
(1)生成.s文件
(2)生成.o文件
(3)生成可执行文件
~ # gdb main GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /root/main...done. (gdb) l 1 .file "main.c" 2 .section .rodata 3 .LC0: 4 .string "The number: %d\n" 5 .text 6 .globl test 7 .type test, @function 8 test: 9 pushl %ebp 10 movl %esp, %ebp (gdb) l 11 subl $40, %esp 12 movl $10, -12(%ebp) 13 movl $.LC0, %eax 14 movl -12(%ebp), %edx 15 movl %edx, 4(%esp) 16 movl %eax, (%esp) 17 call printf 18 leave 19 ret 20 .size test, .-test (gdb) l 21 .globl main 22 .type main, @function 23 main: 24 pushl %ebp 25 movl %esp, %ebp 26 andl $-16, %esp 27 call test 28 movl $0, %eax 29 movl %ebp, %esp 30 popl %ebp (gdb) l 31 ret 32 .size main, .-main 33 .ident "GCC: (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3" 34 .section .note.GNU-stack,"",@progbits (gdb) l Line number 35 out of range; main.s has 34 lines. (gdb)
相关文章推荐
- 如何用gdb进行汇编级的调试
- (转载)gdb中汇编调试
- 如何使用gdb进行调试
- 如何在Windows的命令行下进行程序编译和gdb调试
- 使用 gdb 对程序进行汇编级调试
- 如何将Android例子程序添加到Eclipse进行调试运行(转载)
- 如何运用Gdb对ARM板上的程序进行远程调试
- gdb调试nasm语法的汇编程序(转载)
- 使用 gdb 对程序进行汇编级调试
- (转载)GDB 进行调试 使用心得
- 什么是 core dump ? 以及如何使用gdb对 core dumped 进行调试
- Window平台Grmon下如何使用gdb进行调试
- (转载)gdb中汇编调试
- automake 及 autoconfig, 以及如何用gdb调试[转载]
- GDB进行汇编级的调试
- Linux下的c如何进行GDB调试
- WebKit技巧:如何用GDB进行调试
- (转载)Linux平台可以用gdb进行反汇编和调试
- (转载)gdb中汇编调试
- 如何用GDB进行多线程调试