From: Markus Teich <markus.teich@stusta.mhn.de>
To: <gdb@sourceware.org>
Subject: unexpected output from print
Date: Sat, 23 Mar 2013 10:01:00 -0000 [thread overview]
Message-ID: <4dbff288e0c76a516273ba1cb19694b4@mail.fs.tum.de> (raw)
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
next reply other threads:[~2013-03-23 10:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-23 10:01 Markus Teich [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4dbff288e0c76a516273ba1cb19694b4@mail.fs.tum.de \
--to=markus.teich@stusta.mhn.de \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox