* [arm] force gdb into disassembling in thumb (arm) mode
@ 2002-01-23 1:56 Adrian von Bidder
2002-01-23 3:44 ` Richard Earnshaw
0 siblings, 1 reply; 3+ messages in thread
From: Adrian von Bidder @ 2002-01-23 1:56 UTC (permalink / raw)
To: gdb mailing list
Heyho!
[May have been asked before - just point me in the general direction as
I couldn't find it with google or in the mailing lsit archive]
How can I force gdb to disassemble a memory region in thumb?
gdb 5.1 gets it right if there is symbol information, but just
disassembles to arm instructions when no symbol information is present
(apparently). Can I change this default to thumb (runtime), or is it
possible with a argument to the x/i command?
The sensible way (imho) would be to interpret the (h)alfword/(w)ord
format letters, so that x/ih and x/iw would force to interpret 16/32 bit
instructions.
x/i on an odd address currently does switch to thumb mode - but it seems
to interpret the instructions at the odd address (it doesn't strip the
lsb when loading the data):
(gdb) x/20i 0xbe1
0xbe1: ldrsh r5, [r6, r6]
0xbe3: strb r6, [r0, r5]
0xbe5: ldr r4, [pc, #280] (0xd00)
0xbe7: add sp, #280
0xbe9: undefined instruction 0x47b4
0xbeb: strh r6, [r0, #2]
but the halfword at 0xbe0 does (in this example) disassemble to
ldr r7,[sp, #0xb5].
greets from Zürich
-- vbi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [arm] force gdb into disassembling in thumb (arm) mode
2002-01-23 1:56 [arm] force gdb into disassembling in thumb (arm) mode Adrian von Bidder
@ 2002-01-23 3:44 ` Richard Earnshaw
2002-01-23 4:27 ` Adrian von Bidder
0 siblings, 1 reply; 3+ messages in thread
From: Richard Earnshaw @ 2002-01-23 3:44 UTC (permalink / raw)
To: Adrian von Bidder; +Cc: gdb mailing list, Richard.Earnshaw
> The sensible way (imho) would be to interpret the (h)alfword/(w)ord
> format letters, so that x/ih and x/iw would force to interpret 16/32 bit
> instructions.
Yes, something like this would be nice.
> x/i on an odd address currently does switch to thumb mode - but it seems
> to interpret the instructions at the odd address (it doesn't strip the
> lsb when loading the data):
>
> (gdb) x/20i 0xbe1
> 0xbe1: ldrsh r5, [r6, r6]
> 0xbe3: strb r6, [r0, r5]
> 0xbe5: ldr r4, [pc, #280] (0xd00)
> 0xbe7: add sp, #280
> 0xbe9: undefined instruction 0x47b4
> 0xbeb: strh r6, [r0, #2]
Hmm, a quick test on the CVS sources shows that using an odd address will
DTRT (ie force thumb mode but then round the address down); I can't see
anything from the commit log that might have changed. The key is this
line of code:
gdb/arm-tdep.c/gdb_print_insn_arm()
memaddr = UNMAKE_THUMB_ADDR (memaddr);
Which strips off the thumb bit before actually loading the half-word.
R.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [arm] force gdb into disassembling in thumb (arm) mode
2002-01-23 3:44 ` Richard Earnshaw
@ 2002-01-23 4:27 ` Adrian von Bidder
0 siblings, 0 replies; 3+ messages in thread
From: Adrian von Bidder @ 2002-01-23 4:27 UTC (permalink / raw)
To: Richard.Earnshaw; +Cc: gdb mailing list
On Wed, 2002-01-23 at 11:44, Richard Earnshaw wrote:
> Hmm, a quick test on the CVS sources shows that using an odd address will
> DTRT (ie force thumb mode but then round the address down); I can't see
> anything from the commit log that might have changed. The key is this
> line of code:
>
> gdb/arm-tdep.c/gdb_print_insn_arm()
> memaddr = UNMAKE_THUMB_ADDR (memaddr);
>
> Which strips off the thumb bit before actually loading the half-word.
Sorry, my fault, mostly - Memory didn't contain what I thought it did,
which did confuse me, together with the memory addresses on the
disassembler output having the lsb set. But you're right, the data
actually displayed is at the right addresses.
But then I should be able to do "display/i $pc+1" but this has no effect
(neither does disp/i $pc|1):
(gdb) disp/i $pc+1
4: x/i $pc + 1 0xf54: undefined
(is the same as plain disp/i $pc - it tries to decode arm).
while
(gdb) x/i $pc+1
0xf55: push {r4, r5, r7, lr}
shows the thumb instruction really at 0xf54.
greets from Zürich
-- vbi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-01-23 12:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-23 1:56 [arm] force gdb into disassembling in thumb (arm) mode Adrian von Bidder
2002-01-23 3:44 ` Richard Earnshaw
2002-01-23 4:27 ` Adrian von Bidder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox