All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
To: Nicolas <nikos42-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: dwarves-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Brain fart alert
Date: Thu, 16 Aug 2012 16:52:24 -0300	[thread overview]
Message-ID: <20120816195224.GC10277@infradead.org> (raw)
In-Reply-To: <20120815175647.GK2370-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>

Em Wed, Aug 15, 2012 at 02:56:47PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Sat, Jul 21, 2012 at 08:22:33PM +0200, Nicolas escreveu:
> > Hello,
> > 
> > I tried using pahole, but I get a brain fart alert with the file
> > attached (which is an extract from stdio.h). I'm running dwarves 1.10,
> > libdw1 0.152 and g++ 4.6.1, on i386.
> > 
> > Here is what I get:
> > 
> > $ g++ -Wall -g -c brainfart.cpp -o brainfart.o && pahole brainfart.o
> > class ios_base {
> > 	enum _Ios_Openmodeconst    in;                   /*     0     4 */
> > 	typedef enum _Ios_Fmtflags fmtflags;
> > 
> > 
> > 	/* size: 1, cachelines: 1, members: 1 */
> > 	/* padding: 65533 */
> > 	/* last cacheline: 1 bytes */
> > 
> > 	/* BRAIN FART ALERT! 1 != 4 + 0(holes), diff = -3 */
> > 
> > };
> > 
> > Moreover, on amd64, pahole segfaults if I do the same (with dwarves
> > 1.10, libdw1 0.152, g++ 4.6.3).
> 
> that is strange, I just tried it on rhel6, x86_64, and just reproduced
> what you describe on i386:
> 
> [acme@sandy pahole]$ uname -a
> Linux sandy.ghostprotocols.net 3.6.0-rc1+ #13 SMP Fri Aug 10 12:42:33 BRT 2012 x86_64 x86_64 x86_64 GNU/Linux
> [acme@sandy pahole]$ g++ -Wall -g -c brainfart.cpp -o brainfart.o && pahole brainfart.o
> class ios_base {
> 	enum _Ios_Openmodeconst    in;                   /*     0     4 */
> 	typedef enum _Ios_Fmtflags fmtflags;
> 
> 
> 	/* size: 1, cachelines: 1, members: 1 */
> 	/* padding: 65533 */
> 	/* last cacheline: 1 bytes */
> 
> 	/* BRAIN FART ALERT! 1 != 4 + 0(holes), diff = -3 */
> 
> };

So the problem is that 'in' is (from the .cpp file):

static const _Ios_Openmode in = _S_in;

 <2><82>: Abbrev Number: 10 (DW_TAG_member)
    <83>   DW_AT_name        : in       
    <86>   DW_AT_decl_file   : 1        
    <87>   DW_AT_decl_line   : 15       
    <88>   DW_AT_type        : <0x9b>   
    <8c>   DW_AT_external    : 1        
    <8d>   DW_AT_declaration : 1        
    <8e>   DW_AT_const_value : 8

So 'in' type is...

 <1><9b>: Abbrev Number: 12 (DW_TAG_const_type)
    <9c>   DW_AT_type        : <0x49>

That links to:

 <2><49>: Abbrev Number: 3 (DW_TAG_enumeration_type)
    <4a>   DW_AT_name        : (indirect string, offset: 0xa9): _Ios_Openmode   
    <4e>   DW_AT_byte_size   : 4        
    <4f>   DW_AT_decl_file   : 1        
    <50>   DW_AT_decl_line   : 7        

So it thinks that the size is 4 bytes:

65533 == (unsigned short)((short)(1 - 4))

I need to capture the fact that it is a static const, and investigate
the C++ structure encoding rules, why is that it takes 1 byte when it
has no per instance members?

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe dwarves" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-08-16 19:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-21 18:22 Brain fart alert Nicolas
     [not found] ` <CACHCVZ6oDyFwGbC4EwF_wsR9tCkoych5N6buLhRRLcyaL6iifw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-15 17:56   ` Arnaldo Carvalho de Melo
     [not found]     ` <20120815175647.GK2370-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2012-08-16 19:52       ` Arnaldo Carvalho de Melo [this message]
     [not found]         ` <20120816195224.GC10277-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2012-08-19 22:16           ` Mark Wielaard
2012-08-20 13:45         ` Dodji Seketeli
     [not found]           ` <m3obm5fzhs.fsf-fIDRvF7C5exg9hUCZPvPmw@public.gmane.org>
2012-08-20 17:35             ` Arnaldo Carvalho de Melo
2012-08-20 18:02   ` Arnaldo Carvalho de Melo
     [not found]     ` <20120820180216.GE3046-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2012-08-20 18:28       ` Arnaldo Carvalho de Melo
2012-08-30 16:35       ` Nicolas
     [not found]         ` <CACHCVZ5EJadxOTJ0T4phSfAcm1FK7wfeDTp9QcSa1V1JCpa8SA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-03 12:22           ` Mark Wielaard
     [not found]             ` <1346674948.3090.40.camel-OO0OHOuVXW89n/EXqpbZ8ns8WZQLr0HW@public.gmane.org>
2012-09-24 22:19               ` Nicolas
     [not found]                 ` <5060DC56.4080609-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-26  1:50                   ` Nicolas
     [not found]                     ` <CACHCVZ6uvDW1CpyxXio3P17EL6bE=FKGDNm11RNZTceR-dWLjg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-26 10:56                       ` Mark Wielaard
     [not found]                         ` <1361876163.4930.4.camel-Et2QWsRS+g7yukXOleVwRPp4M6BF03vq@public.gmane.org>
2013-03-20 13:37                           ` Arnaldo Carvalho de Melo
  -- strict thread matches above, loose matches on Subject: below --
2015-11-11 18:26 David Sterba
     [not found] ` <20151111182618.GF6445-AlSwsSmVLrQ@public.gmane.org>
2015-11-11 20:11   ` Arnaldo Carvalho de Melo
     [not found]     ` <20151111201151.GA6712-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-11-11 21:05       ` David Sterba
     [not found]         ` <20151111210519.GG6445-AlSwsSmVLrQ@public.gmane.org>
2015-11-11 22:13           ` Arnaldo Carvalho de Melo
     [not found]             ` <20151111221340.GB12579-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-11-11 22:17               ` Arnaldo Carvalho de Melo
     [not found]                 ` <20151111221747.GC12579-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-11-11 22:48                   ` Arnaldo Carvalho de Melo

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=20120816195224.GC10277@infradead.org \
    --to=acme-wegcikhe2lqwvfeawa7xhq@public.gmane.org \
    --cc=dwarves-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nikos42-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.