public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Maximilian Schneider <max@schneidersoft.net>, gdb@sourceware.org
Subject: Re: Incorrect thumb disassembly/detection
Date: Mon, 13 Sep 2021 21:31:41 +0200	[thread overview]
Message-ID: <b84d2974-687b-ed0c-a7b3-a5284d4a83a2@suse.de> (raw)
In-Reply-To: <b0168020bfc43b68ed3a4c2b9b8d6147b7d81809.camel@schneidersoft.net>

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!
> 

      reply	other threads:[~2021-09-13 19:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11 10:41 Maximilian Schneider
2021-09-13 19:31 ` Tom de Vries [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b84d2974-687b-ed0c-a7b3-a5284d4a83a2@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb@sourceware.org \
    --cc=max@schneidersoft.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).