Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* unexpected output from print
@ 2013-03-23 10:01 Markus Teich
  2013-03-26 18:12 ` Tom Tromey
       [not found] ` <m3sj3jvufa.fsf@redhat.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Markus Teich @ 2013-03-23 10:01 UTC (permalink / raw)
  To: gdb

Hi,

i am trying to parse the output of the print command on structs and 
arrays.
To distinguish between this two possibilities i look at the first 
element. If it contains a '=' (not in parantheses) i interpret the 
output as struct, else i interpret it as array.

Example:
{a = 'b', c = 5, d = 0x123456}
would be a struct.

{"this = does not confuse me", "hello", "world"}
would be an array.

Yesterday i stumbled upon an unexpected case, where gdb would output a 
single value without the attribute name in a struct:
__in6_u = {__u6_addr8 = "325243A2", '\000' <repeats 11 times>, 
__u6_addr16 = {41941, 12865, 0, 0, 0, 0, 0, 0}, __u6_addr32 = 
{843162581, 0, 0, 0}}

So i interpreted the __in6_u as struct but my parser noticed the 
missing name of the second element and returned NULL as expected.
I looked up the declaration of the struct in netinet/in.h and found 
there is a union in this struct:

struct in6_addr
{
   union
   {
     uint8_t __u6_addr8[16];
     #if defined __USE_MISC || defined __USE_GNU
     uint16_t __u6_addr16[8];
     uint32_t __u6_addr32[4];
     #endif
   } __in6_u;
   #define s6_addr         __in6_u.__u6_addr8
   #if defined __USE_MISC || defined __USE_GNU
   # define s6_addr16      __in6_u.__u6_addr16
   # define s6_addr32      __in6_u.__u6_addr32
   #endif¬
};

However i could not figure out the meaning of this unexpected result.
what does this single element
'\000' <repeats 11 times>
in the output tell me?

I am using
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04

Thanks for any hints.

Regards
Markus


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

end of thread, other threads:[~2013-03-27 13:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-23 10:01 unexpected output from print Markus Teich
2013-03-26 18:12 ` Tom Tromey
     [not found] ` <m3sj3jvufa.fsf@redhat.com>
2013-03-26 22:30   ` Markus Teich
2013-03-27 13:31     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox