public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Disassembling ARM and Thumb code
@ 2005-05-06  0:06 Shaun Jackman
  2005-05-06  1:56 ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Shaun Jackman @ 2005-05-06  0:06 UTC (permalink / raw)
  To: gdb

My ARM7TDMI processor is currently in Thumb mode, but the x/i command
dissects the instruction as an ARM instruction. The symbol
rdp_getargvsp is a Thumb symbol added using add-symbol-file [elf
binary here]. What is the command to disassemble a given memory
location as a Thumb instruction?

Thanks,
Shaun

(gdb) p/x $cpsr
$10 = 0x4000003f
(gdb) x/i $pc
0x20004dc <rdp_getargvsp>:      cmpcs   r4, #67108864   ; 0x4000000
(gdb)
0x20004e0 <rdp_getargvsp+4>:    strmibt r2, [r9], -r0, lsl #8

$ arm-elf-gdb --version
GNU gdb 6.2.1
...
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-elf".

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

* Re: Disassembling ARM and Thumb code
  2005-05-06  0:06 Disassembling ARM and Thumb code Shaun Jackman
@ 2005-05-06  1:56 ` Daniel Jacobowitz
  2005-05-06  3:35   ` Shaun Jackman
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2005-05-06  1:56 UTC (permalink / raw)
  To: Shaun Jackman; +Cc: gdb

On Thu, May 05, 2005 at 05:05:56PM -0700, Shaun Jackman wrote:
> My ARM7TDMI processor is currently in Thumb mode, but the x/i command
> dissects the instruction as an ARM instruction. The symbol
> rdp_getargvsp is a Thumb symbol added using add-symbol-file [elf
> binary here]. What is the command to disassemble a given memory
> location as a Thumb instruction?

How is it marked as Thumb in the binary?

GDB does not use the current CPSR value when disassembling; that way
lies madness.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

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

* Re: Disassembling ARM and Thumb code
  2005-05-06  1:56 ` Daniel Jacobowitz
@ 2005-05-06  3:35   ` Shaun Jackman
  2005-05-06  4:08     ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Shaun Jackman @ 2005-05-06  3:35 UTC (permalink / raw)
  To: gdb

On 5/5/05, Daniel Jacobowitz <drow@false.org> wrote:
> On Thu, May 05, 2005 at 05:05:56PM -0700, Shaun Jackman wrote:
> > My ARM7TDMI processor is currently in Thumb mode, but the x/i command
> > dissects the instruction as an ARM instruction. The symbol
> > rdp_getargvsp is a Thumb symbol added using add-symbol-file [elf
> > binary here]. What is the command to disassemble a given memory
> > location as a Thumb instruction?
> 
> How is it marked as Thumb in the binary?

It's marked with a $t symbol at the same address.

$ nm busybox | grep 020004dd
020004dd t $t
020004dd t rdp_getargvsp

I haven't read this in documentation; only noticed it from empirical
evidence. For example, here's a symbol compiled for ARM marked with a
$a symbol at the same address.

$ nm hello | grep 000081f8
000081f8 t $a
000081f8 T main

> GDB does not use the current CPSR value when disassembling; that way
> lies madness.

Hehe. I agree, that's probably not the best plan. However, for the
unique case of 'x/i $pc' it does make a certain amount of sense to use
the CPSR as a hint. I'm not sure if it's worth the special case
though. An explicit switch to the x/i and disas commands to specify
ARM or Thumb dissection is very much a good idea though.

Cheers,
Shaun

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

* Re: Disassembling ARM and Thumb code
  2005-05-06  3:35   ` Shaun Jackman
@ 2005-05-06  4:08     ` Daniel Jacobowitz
  2005-05-06 16:35       ` Shaun Jackman
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2005-05-06  4:08 UTC (permalink / raw)
  To: Shaun Jackman; +Cc: gdb

On Thu, May 05, 2005 at 08:35:02PM -0700, Shaun Jackman wrote:
> On 5/5/05, Daniel Jacobowitz <drow@false.org> wrote:
> > On Thu, May 05, 2005 at 05:05:56PM -0700, Shaun Jackman wrote:
> > > My ARM7TDMI processor is currently in Thumb mode, but the x/i command
> > > dissects the instruction as an ARM instruction. The symbol
> > > rdp_getargvsp is a Thumb symbol added using add-symbol-file [elf
> > > binary here]. What is the command to disassemble a given memory
> > > location as a Thumb instruction?
> > 
> > How is it marked as Thumb in the binary?
> 
> It's marked with a $t symbol at the same address.
> 
> $ nm busybox | grep 020004dd
> 020004dd t $t
> 020004dd t rdp_getargvsp
> 
> I haven't read this in documentation; only noticed it from empirical
> evidence. For example, here's a symbol compiled for ARM marked with a
> $a symbol at the same address.
> 
> $ nm hello | grep 000081f8
> 000081f8 t $a
> 000081f8 T main

GDB doesn't understand ARM mapping symbols.  It could, with some
work, but it doesn't yet.  However it should understand the odd symbol
address.  If that's not working, there's a bug somewhere.

> Hehe. I agree, that's probably not the best plan. However, for the
> unique case of 'x/i $pc' it does make a certain amount of sense to use
> the CPSR as a hint. I'm not sure if it's worth the special case
> though. An explicit switch to the x/i and disas commands to specify
> ARM or Thumb dissection is very much a good idea though.

Yes, probably; if you have a good idea for the syntax to use, then
maybe we can add it.  I don't much like the idea of target-specific
modifiers.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

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

* Re: Disassembling ARM and Thumb code
  2005-05-06  4:08     ` Daniel Jacobowitz
@ 2005-05-06 16:35       ` Shaun Jackman
  2005-05-09 12:48         ` Richard Earnshaw
  0 siblings, 1 reply; 7+ messages in thread
From: Shaun Jackman @ 2005-05-06 16:35 UTC (permalink / raw)
  To: gdb

On 5/5/05, Daniel Jacobowitz <drow@false.org> wrote:
> > Hehe. I agree, that's probably not the best plan. However, for the
> > unique case of 'x/i $pc' it does make a certain amount of sense to use
> > the CPSR as a hint. I'm not sure if it's worth the special case
> > though. An explicit switch to the x/i and disas commands to specify
> > ARM or Thumb dissection is very much a good idea though.
> 
> Yes, probably; if you have a good idea for the syntax to use, then
> maybe we can add it.  I don't much like the idea of target-specific
> modifiers.

I like the look of this:

x/i for intelligent
x/iw for ARM
x/ih for Thumb

Another option is...

set disassembly-flavor arm
set disassembly-flavor thumb

Cheers,
Shaun

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

* Re: Disassembling ARM and Thumb code
  2005-05-06 16:35       ` Shaun Jackman
@ 2005-05-09 12:48         ` Richard Earnshaw
  2005-05-09 16:07           ` Shaun Jackman
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Earnshaw @ 2005-05-09 12:48 UTC (permalink / raw)
  To: Shaun Jackman; +Cc: gdb

On Fri, 2005-05-06 at 17:35, Shaun Jackman wrote:
> On 5/5/05, Daniel Jacobowitz <drow@false.org> wrote:
> > > Hehe. I agree, that's probably not the best plan. However, for the
> > > unique case of 'x/i $pc' it does make a certain amount of sense to use
> > > the CPSR as a hint. I'm not sure if it's worth the special case
> > > though. An explicit switch to the x/i and disas commands to specify
> > > ARM or Thumb dissection is very much a good idea though.
> > 
> > Yes, probably; if you have a good idea for the syntax to use, then
> > maybe we can add it.  I don't much like the idea of target-specific
> > modifiers.
> 
> I like the look of this:
> 
> x/i for intelligent
> x/iw for ARM
> x/ih for Thumb
> 

Ug.  Doesn't really make sense for Thumb-2.  Nor does it make sense for
the 'disassemble' command.

> Another option is...
> 
> set disassembly-flavor arm
> set disassembly-flavor thumb

less objectionable, provided you avoid 'flavor' which is irritating to
those who use British English spelling.

I'd go for 

set disassembly-isa {auto|arm|thumb}

R.

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

* Re: Disassembling ARM and Thumb code
  2005-05-09 12:48         ` Richard Earnshaw
@ 2005-05-09 16:07           ` Shaun Jackman
  0 siblings, 0 replies; 7+ messages in thread
From: Shaun Jackman @ 2005-05-09 16:07 UTC (permalink / raw)
  To: gdb

On 5/9/05, Richard Earnshaw <rearnsha@gcc.gnu.org> wrote:
> On Fri, 2005-05-06 at 17:35, Shaun Jackman wrote:
> > I like the look of this:
> >
> > x/i for intelligent
> > x/iw for ARM
> > x/ih for Thumb
> >
> 
> Ug.  Doesn't really make sense for Thumb-2.  Nor does it make sense for
> the 'disassemble' command.

x/ia for ARM/Thumb-2 and x/it for Thumb then. Even with a 'set ...
{arm, thumb}' command, a quick-to-type and
quick-override-of-the-default x/i style command is useful.

> > Another option is...
> >
> > set disassembly-flavor arm
> > set disassembly-flavor thumb
> 
> less objectionable, provided you avoid 'flavor' which is irritating to
> those who use British English spelling.
> 
> I'd go for
> 
> set disassembly-isa {auto|arm|thumb}
> 
> R.

I agree entirely, but I'd guess that disassembly-flavor has been
around for a while. Should the previous spelling be deprecated?

objdump already has a name for this option:
	set disassembler-options {intel, att, force-thumb, ...}
I'd prefer simply `thumb' to `force-thumb', but parallelism between
tools is a healthy goal.

Cheers,
Shaun

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

end of thread, other threads:[~2005-05-09 16:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-06  0:06 Disassembling ARM and Thumb code Shaun Jackman
2005-05-06  1:56 ` Daniel Jacobowitz
2005-05-06  3:35   ` Shaun Jackman
2005-05-06  4:08     ` Daniel Jacobowitz
2005-05-06 16:35       ` Shaun Jackman
2005-05-09 12:48         ` Richard Earnshaw
2005-05-09 16:07           ` Shaun Jackman

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).