From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id ACFB23858402 for ; Mon, 13 Sep 2021 19:31:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ACFB23858402 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E100A1FDAA; Mon, 13 Sep 2021 19:31:41 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C80A513B32; Mon, 13 Sep 2021 19:31:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WoHFLx2nP2EsfAAAMHmgww (envelope-from ); Mon, 13 Sep 2021 19:31:41 +0000 Subject: Re: Incorrect thumb disassembly/detection To: Maximilian Schneider , gdb@sourceware.org References: From: Tom de Vries Message-ID: Date: Mon, 13 Sep 2021 21:31:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2021 19:31:44 -0000 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:]]+
/' > 00000cb8
: > 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 > 0x00000cbc <+4>: cbz r0, 0xcc8 > 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! >