Default to ARM Thumb for disassembly?

I’m debugging a Cortex-M0+ target via the gcc-generated ELF file. By default, lldb disassembles what it thinks is ARM instructions, but really they’re Thumb:

(lldb) dis
->  0x294: stmdami r5!, {r2, r5, r8, r11, lr}
    0x298: addmi  r11, r1, #112, #10
    0x29c: blmi   0x9342cc
    0x2a0: andhs  r1, r0, #196, #28
    0x2a4: movwle r4, #0x32a3
    0x2a8: bne    0x68cebc
    0x2ac: umullseq r0, r2, r2, r8
    0x2b0: .long  0xfc2af001                ; unknown opcode
(lldb) dis -A thumb
->  0x294: ldr    r1, [pc, #0x90]
    0x296: ldr    r0, [pc, #0x94]
    0x298: push   {r4, r5, r6, lr}
    0x29a: cmp    r1, r0
    0x29c: beq    0x2b4
    0x29e: ldr    r3, [pc, #0x90]
    0x2a0: subs   r4, r0, #0x3
    0x2a2: movs   r2, #0x0
    0x2a4: cmp    r3, r4
    0x2a6: blo    0x2b0
    0x2a8: adds   r3, #0x3
    0x2aa: subs   r2, r3, r0
    0x2ac: lsrs   r2, r2, #0x2
    0x2ae: lsls   r2, r2, #0x2
    0x2b0: bl     0x1b08

Is there any way to default to Thumb?

lldb does not have an equivalent to gdb’s setting (debugging - GDB doesn't disassemble program running in RAM correctly - Stack Overflow).

I see a lot of code checking for Thumb so we do handle it in at least some situations. I’d have to reproduce to see exactly why this doesn’t work (e.g. does the debug stub here report the PC with the bottom bit cleared for some reason).

And I see you made a longer post with more info and I do intend to read that when I have time, it will probably give more clues.

1 Like