This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb print /x always big endian order?


 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]