简体   繁体   English

显示寄存器的当前值。 (AArch64 Android 汇编调试)

[英]Show what's current value of registers. (AArch64 Android assembly debugging)

I want see what's happening inside of all registers from my program.我想看看我的程序中所有寄存器内部发生了什么。

I have this code that works fine on AArch64 Linux as a static executable.我有这段代码在 AArch64 Linux 上作为静态可执行文件运行良好。

.data

msg:
    .ascii "Hello World\n"
len = . - msg

.text

.globl _start
_start:
 mov x0, #0x1
 ldr x1, =msg
 ldr x2, =len
 mov x8, #0x40
 svc #0x0

 mov x0, #0x0
 mov x8, #0x5d
 svc #0x0

And compile and run it with this command (in Termux on Android).并使用此命令编译并运行它(在 Android 上的 Termux 中)。

as hello.s -o hello.o
ld hello.o -o hello
./hello

Unlike in emulation of 8086 processor application (emu8086), I can see step by step how CPU fetching, decoding, and executing inside of that emulator also what is current register value also current memory value and its addresses.与 8086 处理器应用程序 (emu8086) 的仿真不同,我可以一步一步地看到 CPU 如何在该仿真器内部获取、解码和执行,以及当前寄存器值以及当前内存值及其地址。

In this real assembly (not emulation), I even can't see what is memory value in addresses.在这个真正的程序集(不是仿真)中,我什至看不到地址中的内存值是什么。

I was thinking about to use gdb .我正在考虑使用gdb But I think I need example how to use it.但我认为我需要示例如何使用它。

At least I want see:至少我想看看:

  • Current value of all registers.所有寄存器的当前值。
  • Current value of program address in memory.内存中程序地址的当前值。
  • Flag register标志寄存器

So far I was tinkering gdb到目前为止,我正在修补gdb

And here what I learned在这里我学到了什么

Suppose the program still same like my post.假设程序仍然和我的帖子一样。

To start debug just simply只需简单地开始调试

gdb ./hello

Then it will show up gdb interpreter然后它会显示gdb解释器

  • To add breakpoint添加断点
b _start

It will add breakpoint 1 Then add again if necessary它将添加断点 1 然后如果需要再次添加

b *_start+4

It will add breakpoint 2 And so on until end of program.它将添加断点 2 等等,直到程序结束。

Run the program by just simply只需简单地运行程序

run

It will run breakpoint 1它将运行断点 1

Okay now to show current memory value just simply好的,现在只是简单地显示当前内存值

x /5i _start

It will show first 5 memory value in instruction format from _start.它将以指令格式显示 _start 的前 5 个内存值。

0x4000b0 <_start>:
    mov x0, #0x1                        // #1
=> 0x4000b4 <_start+4>: ldr     x1, 0x4000d0 <_start+32>
   0x4000b8 <_start+8>: ldr     x2, 0x4000d8 <_start+40>
   0x4000bc <_start+12>:
    mov x8, #0x40                       // #64
   0x4000c0 <_start+16>:        svc     #0x0

=> marks mean current breakpoint =>标记表示当前断点

To show current register just type要显示当前寄存器,只需键入

i r

Then type n to exexute next breakpoint.然后键入n执行下一个断点。

Okay so far it's burdening enough usig gdb, I wish there's easiest way to add breakpoint from specific address to end address with step +4.好的,到目前为止,usig gdb 的负担已经足够了,我希望有一种最简单的方法可以通过步骤 +4 将断点从特定地址添加到结束地址。

Also I still didnt figure out how to see flag register.另外我仍然没有弄清楚如何查看标志寄存器。

I'm still expecting if gdb show current register value, current memory value, and current flag register value in one display/screen.我仍然期待gdb在一个显示/屏幕中显示当前寄存器值、当前内存值和当前标志寄存器值。 and when I next breakpoint the screen will autoupdate ,Also I expecting it's adding breakpoint from _start, _start+4, and so on.. without add manually one by one like above并且当我下一个断点时,屏幕将自动更新,而且我希望它会从 _start、_start+4 等添加断点.. 无需像上面那样手动添加

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM