Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <vladimir@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: RFA: unbreak typedefed bitfield
Date: Fri, 18 Dec 2009 12:41:00 -0000	[thread overview]
Message-ID: <200912181541.30891.vladimir@codesourcery.com> (raw)


GDB presently crashes on any attempt to get a value of a bitfield that
has typedefed type. The bugzilla report is here:

	http://sourceware.org/bugzilla/show_bug.cgi?id=10884

An easier reproducer is this program:

typedef unsigned int uint;

      struct Data {
	  int alloc;
	  int begin;
	  int end;
	  uint sharable : 1;
      };

      int main()
      {
	  Data d = {1, 2, 3, 1};
	  return 0;
      }

and this session:

      ~"Breakpoint 1, main () at div.cpp:13\n"                                                                                                                
      ~"13\t    Data d = {1, 2, 3, 1};\n"                                                                                                                     
      *stopped,frame={addr="0x0804849a",func="main",args=[],file="div.cpp",fullname="/home/ghost/Build/gdb-git/gdb/div.cpp",line="13"},thread-id="1",stopped-threads="all",core="1"
      (gdb)                                                                                                                                                                        
      n                                                                                                                                                                            
      &"n\n"                                                                                                                                                                       
      &"During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x8048497.\n"                                                                             
      ^running                                                                                                                                                                     
      *running,thread-id="1"                                                                                                                                                       
      (gdb)                                                                                                                                                                        
      ~"14\t    return 0;\n"                                                                                                                                                       
      *stopped,frame={addr="0x080484b9",func="main",args=[],file="div.cpp",fullname="/home/ghost/Build/gdb-git/gdb/div.cpp",line="14"},thread-id="1",stopped-threads="all",core="1"
      (gdb)                                                                                                                                                                        
      -var-create V * d                                                                                                                                                            
      ^done,name="V",numchild="1",value="{...}",type="Data",thread-id="1",has_more="0"                                                                                             
      (gdb)                                                                                                                                                                        
      -var-list-children V                                                                                                                                                         
      ^done,numchild="1",children=[child={name="V.public",exp="public",numchild="4",thread-id="1"}],has_more="0"                                                                   
      (gdb)                                                                                                                                                                        
      -var-list-children --all-values V.public                                                                                                                                     

      Program received signal SIGFPE, Arithmetic exception.
      0x0813add3 in value_primitive_field (arg1=0x8644840, offset=0, fieldno=3, arg_type=0x85a9d7c) at /home/ghost/Work/CodeSourcery/Projects/egdb/gdb-git/gdb/value.c:1892
      1892          if ((bitpos % container_bitsize) + v->bitsize <= container_bitsize

And here's a trivial patch to fix this problem. I would claim this clearly indicates a design bug in GDB
type mechanism -- and it bites us repeatedly, but I'm not ready to propose a specific way to fix it, yet.

OK to commit?

- Volodya

--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1873,6 +1873,7 @@ value_primitive_field (struct value *arg1, int offset,

   CHECK_TYPEDEF (arg_type);
   type = TYPE_FIELD_TYPE (arg_type, fieldno);
+  check_typedef (type);

   /* Handle packed fields */


             reply	other threads:[~2009-12-18 12:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18 12:41 Vladimir Prus [this message]
2009-12-18 13:06 ` Joel Brobecker
2009-12-18 14:17   ` Daniel Jacobowitz
2009-12-18 14:20     ` Vladimir Prus
2009-12-18 14:24       ` Daniel Jacobowitz
2009-12-21  9:51         ` Vladimir Prus
2009-12-21 13:23           ` Joel Brobecker
2009-12-18 19:55   ` Tom Tromey
2009-12-21 10:00     ` Vladimir Prus
2009-12-21 17:08       ` Tom Tromey
2009-12-21 17:15         ` Daniel Jacobowitz
2009-12-21 17:18           ` Vladimir Prus
2009-12-21 17:37             ` Joel Brobecker

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=200912181541.30891.vladimir@codesourcery.com \
    --to=vladimir@codesourcery.com \
    --cc=gdb-patches@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