您的位置:首页 > 其它

NASM汇编:如何通过 gdb 进行debug

2013-03-31 19:17 453 查看
转载:http://sleepycat.org/tech/os/nasm-debug

目录:

本文简介
1 NASM 版 Hello World 程序
2 编译
3 调试
4 参考文档

本文简介

概要:通过 gdb 调试 nasm 汇编程序
版本:Linux Mint 13(Ubuntu 11.10), nasm v2.09.08, gcc v4.6.1,
日期:2012-07-14
永久链接:http://sleepycat.org/tech/os/nasm-debug

1 NASM 版 Hello World 程序

?

2 编译

?
注:nasm => The -F Option: Selecting A Debug Information Format

3 调试

?
注:set disassembly-flavor intel => For use with nasm, it is best to set the flavor to intel

注:nexti => 表示只执行一步指令(To step one instruction)

4 参考文档

推荐:
http://www.csee.umbc.edu/portal/help/nasm/nasm.shtml#gdb
PS:这里使用gcc连接目标文件有需要注意的地方,我的ubuntu是64位的,使用命令
gcc t.o -o t -g提示错误如下:


/usr/bin/ld: i386 architecture of input file `t.o' is incompatible with i386:x86-64 output collect2: 错误: ld 返回 1

解决方法如下:

$ gcc t.o -o t -g -m32
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: