* gdb print /x always big endian order?
@ 2004-02-05 18:00 J K
2004-02-05 18:04 ` Daniel Jacobowitz
2004-02-06 1:03 ` Andreas Schwab
0 siblings, 2 replies; 4+ messages in thread
From: J K @ 2004-02-05 18:00 UTC (permalink / raw)
To: gdb
Hello,
I've used a simple code to examine the storage
of a short on a big and little endian machine.
It seems in GNU gdb Red Hat Linux (5.1-1) when
I do a print /x the order is Big Endian regardless
of the host architecture. Just wondering if this
is expected, I didn't see anything in the docs.
short short_val = 31415;
unsigned char buff[8];
memcpy(buff,&short_val,2);
printf("Short bytes 0x%x 0x%x\n",buff[0],buff[1]);
on Little Endian machine:
Short bytes 0xb7 0x7a
on Big Endian machine:
Short bytes 0x7a 0xb7
On the Little Endian machine in gdb:
(gdb) p short_val
$18 = 31415
(gdb) p /x short_val
$19 = 0x7ab7 <- not what I expected.
(gdb) x/2xb &short_val
0xbffff82a: 0xb7 0x7a
(gdb) x/2ub &short_val
0xbffff82a: 183 122
Memory is in the order I would expect but the
print /x shows the order as Big Endian.
Thanks,
J.K.
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: gdb print /x always big endian order?
2004-02-05 18:00 gdb print /x always big endian order? J K
@ 2004-02-05 18:04 ` Daniel Jacobowitz
2004-02-06 1:03 ` Andreas Schwab
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2004-02-05 18:04 UTC (permalink / raw)
To: J K; +Cc: gdb
On Thu, Feb 05, 2004 at 10:00:42AM -0800, J K wrote:
>
> Hello,
>
> I've used a simple code to examine the storage
> of a short on a big and little endian machine.
>
> It seems in GNU gdb Red Hat Linux (5.1-1) when
> I do a print /x the order is Big Endian regardless
> of the host architecture. Just wondering if this
> is expected, I didn't see anything in the docs.
Yes, this is expected. Consider:
> short short_val = 31415;
What would C do if you said short_val = 0x7ab7?
> on Little Endian machine:
> Short bytes 0xb7 0x7a
Precisely the same thing :)
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gdb print /x always big endian order?
2004-02-05 18:00 gdb print /x always big endian order? J K
2004-02-05 18:04 ` Daniel Jacobowitz
@ 2004-02-06 1:03 ` Andreas Schwab
2004-02-06 1:14 ` Bill Gatliff
1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2004-02-06 1:03 UTC (permalink / raw)
To: J K; +Cc: gdb
J K <ellips@yahoo.com> writes:
> It seems in GNU gdb Red Hat Linux (5.1-1) when
> I do a print /x the order is Big Endian regardless
> of the host architecture.
The print command just prints a value, and values don't have endianess.
Only memory contents have.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gdb print /x always big endian order?
2004-02-06 1:03 ` Andreas Schwab
@ 2004-02-06 1:14 ` Bill Gatliff
0 siblings, 0 replies; 4+ messages in thread
From: Bill Gatliff @ 2004-02-06 1:14 UTC (permalink / raw)
To: gdb
JK:
Indeed. If you want to see endianness, use 'x' instead, and ask it for a
string of hex bytes. :^)
b.g.
Andreas Schwab writes:
> J K <ellips@yahoo.com> writes:
>
>> It seems in GNU gdb Red Hat Linux (5.1-1) when
>> I do a print /x the order is Big Endian regardless
>> of the host architecture.
>
> The print command just prints a value, and values don't have endianess.
> Only memory contents have.
>
> Andreas.
>
> --
> Andreas Schwab, SuSE Labs, schwab@suse.de
> SuSE Linux AG, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
> Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
--
Bill Gatliff
Embedded GNU, Linux training and development.
bgat@billgatliff.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-02-06 1:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-05 18:00 gdb print /x always big endian order? J K
2004-02-05 18:04 ` Daniel Jacobowitz
2004-02-06 1:03 ` Andreas Schwab
2004-02-06 1:14 ` Bill Gatliff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox