From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12784 invoked by alias); 23 Mar 2013 10:01:27 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 12768 invoked by uid 89); 23 Mar 2013 10:01:19 -0000 X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from hermod.fs.tum.de (HELO hermod.fs.tum.de) (129.187.202.12) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 23 Mar 2013 10:01:16 +0000 Received: from freyr.fs.tum.de (freyr.fs.tum.de [IPv6:2001:4ca0:2002::81bb:ca3d]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by hermod.fs.tum.de (FachschaftsNachrichtenDienst) with ESMTPS id BF9E5E02A2 for ; Sat, 23 Mar 2013 11:01:14 +0100 (CET) Received: from www-data by freyr.fs.tum.de with local (Exim 4.80) (envelope-from ) id 1UJLGE-0008Fk-MP for gdb@sourceware.org; Sat, 23 Mar 2013 11:01:14 +0100 To: Subject: unexpected output from print X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sat, 23 Mar 2013 10:01:00 -0000 From: Markus Teich Message-ID: <4dbff288e0c76a516273ba1cb19694b4@mail.fs.tum.de> X-Sender: markus.teich@stusta.mhn.de User-Agent: Roundcube Webmail/0.7.2 X-SW-Source: 2013-03/txt/msg00071.txt.bz2 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' , __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' 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