* register type as signed or unsigned?
@ 2006-10-10 8:37 ligang
2006-10-10 12:50 ` Daniel Jacobowitz
0 siblings, 1 reply; 7+ messages in thread
From: ligang @ 2006-10-10 8:37 UTC (permalink / raw)
To: gdb
hello all,
I am porting GDB to a new target.
I am not aware of the meaning of register type.
You can do as follows:
set_gdbarch_register_type (gdbarch, builtin_type_int32);
or
set_gdbarch_register_type (gdbarch, builtin_type_uint32);
What is the real difference between the two situation?
Why should GDB specify the register type as signed or unsigned?
Dose it mean the former must use regcache_cooked_read_signed() and the
latter must use
regcache_cooked_read_unsigned()?
Best regards
Ligang
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: register type as signed or unsigned?
2006-10-10 8:37 register type as signed or unsigned? ligang
@ 2006-10-10 12:50 ` Daniel Jacobowitz
2006-10-11 0:35 ` ligang
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2006-10-10 12:50 UTC (permalink / raw)
To: ligang; +Cc: gdb
On Tue, Oct 10, 2006 at 04:39:18PM +0800, ligang@sunnorth.com.cn wrote:
> hello all,
>
> I am porting GDB to a new target.
> I am not aware of the meaning of register type.
> You can do as follows:
> set_gdbarch_register_type (gdbarch, builtin_type_int32);
> or
> set_gdbarch_register_type (gdbarch, builtin_type_uint32);
>
> What is the real difference between the two situation?
> Why should GDB specify the register type as signed or unsigned?
> Dose it mean the former must use regcache_cooked_read_signed() and the
> latter must use
> regcache_cooked_read_unsigned()?
No; in fact, it doesn't make much difference. You should use whichever
is "more natural" for your target instruction set; it will affect
"print $reg" and "info reg".
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: register type as signed or unsigned?
2006-10-10 12:50 ` Daniel Jacobowitz
@ 2006-10-11 0:35 ` ligang
2006-10-11 0:48 ` Jan Kratochvil
0 siblings, 1 reply; 7+ messages in thread
From: ligang @ 2006-10-11 0:35 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb
Daniel Jacobowitz <drow@false.org> wrote on 2006-10-10 20:50:02:
> On Tue, Oct 10, 2006 at 04:39:18PM +0800, ligang@sunnorth.com.cn wrote:
> > hello all,
> >
> > I am porting GDB to a new target.
> > I am not aware of the meaning of register type.
> > You can do as follows:
> > set_gdbarch_register_type (gdbarch, builtin_type_int32);
> > or
> > set_gdbarch_register_type (gdbarch, builtin_type_uint32);
> >
> > What is the real difference between the two situation?
> > Why should GDB specify the register type as signed or unsigned?
> > Dose it mean the former must use regcache_cooked_read_signed() and the
> > latter must use
> > regcache_cooked_read_unsigned()?
>
> No; in fact, it doesn't make much difference. You should use whichever
> is "more natural" for your target instruction set; it will affect
> "print $reg" and "info reg".
That is to say, whether builtin_type_int32 or builtin_type_uint32 is
correct for GDB.
But how to understand "more natural" and how dose it affect "info reg"?
Would you please give me some more hints?
> --
> Daniel Jacobowitz
> CodeSourcery
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: register type as signed or unsigned?
2006-10-11 0:35 ` ligang
@ 2006-10-11 0:48 ` Jan Kratochvil
2006-10-11 1:11 ` Paul Koning
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jan Kratochvil @ 2006-10-11 0:48 UTC (permalink / raw)
To: ligang; +Cc: gdb
On Wed, 11 Oct 2006 02:37:57 +0200, ligang@sunnorth.com.cn wrote:
> Daniel Jacobowitz <drow@false.org> wrote on 2006-10-10 20:50:02:
...
> > No; in fact, it doesn't make much difference. You should use whichever
> > is "more natural" for your target instruction set; it will affect
> > "print $reg" and "info reg".
>
> That is to say, whether builtin_type_int32 or builtin_type_uint32 is
> correct for GDB.
If the register is used as address, use "uint32".
If it is used for general computation incl. offsets in memory, use "int32".
"uint32" should be IMO a safer bet but sometimes you may need `(int)$regname'.
> Would you please give me some more hints?
You may check the recent thread being affected by such register typing:
http://sourceware.org/ml/gdb-patches/2006-09/msg00191.html
Failed now to simulate it on 32-bit only gdbhost/inferior.
Regards,
Jan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: register type as signed or unsigned?
2006-10-11 0:48 ` Jan Kratochvil
@ 2006-10-11 1:11 ` Paul Koning
2006-10-11 2:06 ` Daniel Jacobowitz
2006-10-11 7:00 ` Mark Kettenis
2 siblings, 0 replies; 7+ messages in thread
From: Paul Koning @ 2006-10-11 1:11 UTC (permalink / raw)
To: jan.kratochvil; +Cc: ligang, gdb
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> On Wed, 11 Oct 2006 02:37:57 +0200, ligang@sunnorth.com.cn
Jan> wrote:
>> Daniel Jacobowitz <drow@false.org> wrote on 2006-10-10 20:50:02:
Jan> ...
>> > No; in fact, it doesn't make much difference. You should use
>> whichever > is "more natural" for your target instruction set; it
>> will affect > "print $reg" and "info reg".
>>
>> That is to say, whether builtin_type_int32 or builtin_type_uint32
>> is correct for GDB.
Jan> If the register is used as address, use "uint32".
Only if addresses are unsigned. That's the usual case, but MIPS has
the odd convention that addresses are viewed as signed.
paul
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: register type as signed or unsigned?
2006-10-11 0:48 ` Jan Kratochvil
2006-10-11 1:11 ` Paul Koning
@ 2006-10-11 2:06 ` Daniel Jacobowitz
2006-10-11 7:00 ` Mark Kettenis
2 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2006-10-11 2:06 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: ligang, gdb
On Wed, Oct 11, 2006 at 02:48:12AM +0200, Jan Kratochvil wrote:
> On Wed, 11 Oct 2006 02:37:57 +0200, ligang@sunnorth.com.cn wrote:
> > Daniel Jacobowitz <drow@false.org> wrote on 2006-10-10 20:50:02:
> ...
> > > No; in fact, it doesn't make much difference. You should use whichever
> > > is "more natural" for your target instruction set; it will affect
> > > "print $reg" and "info reg".
> >
> > That is to say, whether builtin_type_int32 or builtin_type_uint32 is
> > correct for GDB.
>
> If the register is used as address, use "uint32".
In fact, if you know the register is always used as an address, use
a pointer type.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: register type as signed or unsigned?
2006-10-11 0:48 ` Jan Kratochvil
2006-10-11 1:11 ` Paul Koning
2006-10-11 2:06 ` Daniel Jacobowitz
@ 2006-10-11 7:00 ` Mark Kettenis
2 siblings, 0 replies; 7+ messages in thread
From: Mark Kettenis @ 2006-10-11 7:00 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: ligang, gdb
> On Wed, 11 Oct 2006 02:37:57 +0200, ligang@sunnorth.com.cn wrote:
> > Daniel Jacobowitz <drow@false.org> wrote on 2006-10-10 20:50:02:
> ...
> > > No; in fact, it doesn't make much difference. You should use
> > whichever
> > > is "more natural" for your target instruction set; it will affect
> > > "print $reg" and "info reg".
> >
> > That is to say, whether builtin_type_int32 or builtin_type_uint32 is
> > correct for GDB.
>
> If the register is used as address, use "uint32".
If the register is typically used as an address, builtin_type_void_data_ptr
is probably more appropriate. For the instruction pointer you should use
builtin_type_void_func_ptr though.
> If it is used for general computation incl. offsets in memory, use
> "int32".
> "uint32" should be IMO a safer bet but sometimes you may need
> `(int)$regname'.
int32 is IMHO more useful since actually large unsigned numbers are rare.
But if your CPU only supports unsigned integer math, uint32 is the right
choice.
Mark
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-10-11 7:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-10 8:37 register type as signed or unsigned? ligang
2006-10-10 12:50 ` Daniel Jacobowitz
2006-10-11 0:35 ` ligang
2006-10-11 0:48 ` Jan Kratochvil
2006-10-11 1:11 ` Paul Koning
2006-10-11 2:06 ` Daniel Jacobowitz
2006-10-11 7:00 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox