This is the mail archive of the gdb@sourceware.org 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]

unexpected output from print


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


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