public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Incorrect thumb disassembly/detection
@ 2021-09-11 10:41 Maximilian Schneider
  2021-09-13 19:31 ` Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Maximilian Schneider @ 2021-09-11 10:41 UTC (permalink / raw)
  To: gdb

Hello,

I am working on some code for a cortex-M33 and see that the gdb
disassembly does not match that of objdump, but only when a target is
connected.

$ arm-none-eabi-objdump -d bin/usb_cdc.elf | awk -v RS=
'/^[[:xdigit:]]+ <main>/'
00000cb8 <main>:
     cb8:	b500      	push	{lr}
     cba:	b085      	sub	sp, #20
     cbc:	ab03      	add	r3, sp, #12
[-snip-]

$ gdb-multiarch bin/usb_cdc.elf 
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
[-snip-]
(gdb) disas main
Dump of assembler code for function main:
   0x00000cb8 <+0>:	push	{lr}
   0x00000cba <+2>:	sub	sp, #20
   0x00000cbc <+4>:	add	r3, sp, #12
[-snip-]
End of assembler dump.
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0x00000000 in __isr_vector ()
(gdb) disas main
Dump of assembler code for function main:
   0x00000cb8 <+0>:	bl	0xd6e4 <USB__IsHighSpeedCapable+12>
   0x00000cbc <+4>:	cbz	r0, 0xcc8 <main+16>
   0x00000cbe <+6>:	ldrb.w	r1, [sp, #6]
[-snip-]
End of assembler dump.

stepping instructions increments the program counter by 2 indicating
thumb mode. So i expect the disassembly also to be thumb.

What is causeing the disasembly to change to arm mode when a target is
used?

Best Regards!


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Incorrect thumb disassembly/detection
  2021-09-11 10:41 Incorrect thumb disassembly/detection Maximilian Schneider
@ 2021-09-13 19:31 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2021-09-13 19:31 UTC (permalink / raw)
  To: Maximilian Schneider, gdb

On 9/11/21 12:41 PM, Maximilian Schneider via Gdb wrote:
> Hello,
> 
> I am working on some code for a cortex-M33 and see that the gdb
> disassembly does not match that of objdump, but only when a target is
> connected.
> 
> $ arm-none-eabi-objdump -d bin/usb_cdc.elf | awk -v RS=
> '/^[[:xdigit:]]+ <main>/'
> 00000cb8 <main>:
>      cb8:	b500      	push	{lr}
>      cba:	b085      	sub	sp, #20
>      cbc:	ab03      	add	r3, sp, #12
> [-snip-]
> 
> $ gdb-multiarch bin/usb_cdc.elf 
> GNU gdb (Debian 8.2.1-2+b3) 8.2.1
> [-snip-]
> (gdb) disas main
> Dump of assembler code for function main:
>    0x00000cb8 <+0>:	push	{lr}
>    0x00000cba <+2>:	sub	sp, #20
>    0x00000cbc <+4>:	add	r3, sp, #12
> [-snip-]
> End of assembler dump.
> (gdb) target remote localhost:2331
> Remote debugging using localhost:2331
> 0x00000000 in __isr_vector ()
> (gdb) disas main
> Dump of assembler code for function main:
>    0x00000cb8 <+0>:	bl	0xd6e4 <USB__IsHighSpeedCapable+12>
>    0x00000cbc <+4>:	cbz	r0, 0xcc8 <main+16>
>    0x00000cbe <+6>:	ldrb.w	r1, [sp, #6]
> [-snip-]
> End of assembler dump.
> 
> stepping instructions increments the program counter by 2 indicating
> thumb mode. So i expect the disassembly also to be thumb.
> 
> What is causeing the disasembly to change to arm mode when a target is
> used?
> 

Hi,

It's a bit of a guess at this point, but you could look at
https://sourceware.org/gdb/current/onlinedocs/gdb/ARM.html .  There I
found f.i.:
...
set arm fallback-mode (arm|thumb|auto)

    GDB uses the symbol table, when available, to determine whether
instructions are ARM or Thumb. This command controls GDB’s default
behavior when the symbol table is not available. The default is ‘auto’,
which causes GDB to use the current execution mode (from the T bit in
the CPSR register).
...
and the behaviour of auto could explain why you're seeing different results.

Thanks
- Tom

> Best Regards!
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-13 19:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 10:41 Incorrect thumb disassembly/detection Maximilian Schneider
2021-09-13 19:31 ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).