Search code examples

GDB outputs arm mnemonics

When I try to debug a C file, GDB debugs it in arm mnemonics. Can I change this to x86, or am I stuck with arm mnemonics? I have an arm64 M1 macbook.

(gdb) disas main
Dump of assembler code for function main:
   0x0000000100003f44 <+0>: sub sp, sp, #0x30
   0x0000000100003f48 <+4>: stp x29, x30, [sp, #32]
   0x0000000100003f4c <+8>: add x29, sp, #0x20
   0x0000000100003f50 <+12>:    mov w8, #0x0                    // #0
   0x0000000100003f54 <+16>:    str w8, [sp, #12]
   0x0000000100003f58 <+20>:    stur    wzr, [x29, #-4]
   0x0000000100003f5c <+24>:    mov w8, #0xf                    // #15
   0x0000000100003f60 <+28>:    stur    w8, [x29, #-8]
   0x0000000100003f64 <+32>:    mov w8, #0xc                    // #12
   0x0000000100003f68 <+36>:    stur    w8, [x29, #-12]
   0x0000000100003f6c <+40>:    ldur    w8, [x29, #-8]
   0x0000000100003f70 <+44>:    ldur    w9, [x29, #-12]
   0x0000000100003f74 <+48>:    add w8, w8, w9
   0x0000000100003f78 <+52>:    str w8, [sp, #16]
   0x0000000100003f7c <+56>:    ldr w9, [sp, #16]
   0x0000000100003f80 <+60>:    mov x8, x9
   0x0000000100003f84 <+64>:    mov x9, sp
   0x0000000100003f88 <+68>:    str x8, [x9]
   0x0000000100003f8c <+72>:    adrp    x0, 0x100003000
   0x0000000100003f90 <+76>:    add x0, x0, #0xfb4
   0x0000000100003f94 <+80>:    bl  0x100003fa8
   0x0000000100003f98 <+84>:    ldr w0, [sp, #12]
   0x0000000100003f9c <+88>:    ldp x29, x30, [sp, #32]
   0x0000000100003fa0 <+92>:    add sp, sp, #0x30
   0x0000000100003fa4 <+96>:    ret
End of assembler dump.


  • Yes, you are stuck with your computer's native instruction set.

    Low-level instruction sets are inherently machine dependent; your AArch64 CPU is completely incapable of comprehending instructions that are not ARM, like AMD64 instructions. While it is possible to translate your AArch64 code you are debugging to AMD64, doing so makes the “disassembly” no longer relevant for your debugging, as it is not what your processor actually executes.