Linux 程序集调试器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5761171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:47:53  来源:igfitidea点击:

Linux Assembly Debugger

linuxdebuggingassembly

提问by Saustin

I need a debugger for assembly on Linux. I am extremely surprised by the LACK of debuggers out there for Linux! It should have various features, such as showing the registers and what not. I would use GDB, however it isn't exactly friendly with NASM.

我需要一个用于在 Linux 上进行组装的调试器。我对 Linux 缺乏调试器感到非常惊讶!它应该具有各种功能,例如显示寄存器和不显示的内容。我会使用 GDB,但是它对 NASM 并不完全友好。

I would rather have the debugger have intel syntax however I can make a sacrifice.

我宁愿让调试器具有英特尔语法,但我可以做出牺牲。

I have tried kdb, gdb/ddd, and ald. Does anyone know of any else? Don't recommend strace, because I am going beyond syscalls!

我尝试过 kdb、gdb/ddd 和 ald。有没有人知道其他的?不要推荐strace,因为我要超越系统调用!

采纳答案by Alexander Sandler

I am not sure what exactly you mean when you say that gdb is not friendly with NASM. The thing is that gdb uses AT&T notation for displaying assembler. NASM uses Intel notation. There are couple of differences, which you can find on google.

当你说 gdb 对 NASM 不友好时,我不确定你到底是什么意思。问题是 gdb 使用 AT&T 表示法来显示汇编程序。NASM 使用 Intel 表示法。有几个区别,你可以在谷歌上找到。

You can configure gdb to display assembler using Intel notation. The command is set disassembly-flavor intel

您可以将 gdb 配置为使用 Intel 表示法显示汇编程序。命令是 set disassembly-flavor intel

Programs that you've tried, kdb, ddd and friends are all gdb front-ends. I.e. they present you different UI while use gdb as their back-end.

你试过的程序,kdb,ddd,朋友都是gdb前端。即他们在使用 gdb 作为后端时为您呈现不同的 UI。

I think your best and perhaps the only reasonable option is gdb. Other option is to write debugger your-self, but this is quiet complicated.

我认为你最好的,也许是唯一合理的选择是 gdb。另一种选择是自己编写调试器,但这很复杂。

Hope it helps.

希望能帮助到你。

回答by Omri Barel

Could any of the debuggers listed herehelp you?

此处列出的任何调试器都可以帮助您吗?

回答by Israel Alberto RV

I'm really understand the @Saustin's question because I was looking for a Linux Assembly Debugger too, which means the possibility for create breakpoints, run step by step, see the registers on real time, go back (backtrace) or go forward, see the data in memory, etc,.

我真的很理解@Saustin的问题,因为我也在寻找 Linux 程序集调试器,这意味着可以创建断点、逐步运行、实时查看寄存器、返回(回溯)或前进,查看内存中的数据等。

The solution is use properly DDD/GDB.

解决方案是正确使用DDD/ GDB

First at all it is the screenshot show how it looks.

首先它是屏幕截图显示它的外观。

ddd debugging an ASM file

ddd 调试 ASM 文件



It needs some special requirement:

它需要一些特殊的要求:

  • When you create the executable file use the special flag -F stabsin nasmlike this:
  • 创建可执行文件时,请使用特殊标志-F stabsnasm如下所示:

Linux command line:

Linux命令行:

nasm -f elf -F stabs hello.asm -o hello_stabs.o
ld -m elf_i386 hello_stabs.o -o hello_stabs
  • Then you run your the debug normally like: ddd hello_stabs

  • Enjoy!

  • 然后你运行你的调试正常像: ddd hello_stabs

  • 享受!

The option -F stabs, tells the assembler to include debugging information in the output file. DDD and GDBuse the STABSdebugging format.

选项-F stabs告诉汇编器在输出文件中包含调试信息。DDD 和GDB使用STABS调试格式。



Source and good short tutorial:

来源和良好的简短教程:

The Data Display Debugger (DDD), A Quick Start Guide

数据显示调试器 (DDD),快速入门指南