This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Patch: stab info for const fields


For fields of the form
struct s {
char *const p;
}
the C FE sets the READONLY bit on the FIELD_DECL node, not
on its type. This results in the 'const' attribute not getting
passed to the debugger. Likewise for volatile. Note that C++
does this differently, and is already generating correct debug
info (READONLY bit is on both the FIELD_DECL and the type) so
this code avoids emitting the 'const' code twice in that case.

Testing: built the following -g, in C and C++, and verified that
gdb displayed all the types correctly. How do you put a test like
this in the suite? Also bootstrap and test.

struct ssc { char *const p1; const char* p2; };
struct ss { char *ptr; };
struct ssv { char* volatile p1; volatile char* p2; };
struct big { const volatile char* p1; const char* volatile p2;
volatile char* const p3; char* const volatile p4; };
struct sbits { char const p1:3; const char p2: 3; };
int main() {}

2002-10-30 Dale Johannesen <dalej@apple.com>

* dbxout.c (dbxout_type_fields): Emit correct debug info
for const and volatile fields.

Index: dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.128
diff -u -d -b -w -c -3 -p -r1.128 dbxout.c
cvs server: conflicting specifications of output style
*** dbxout.c 27 Sep 2002 03:08:37 -0000 1.128
--- dbxout.c 30 Oct 2002 23:12:29 -0000
*************** dbxout_type_fields (type)
*** 782,787 ****
--- 782,812 ----
CHARS (2);
}

+ if (use_gnu_debug_info_extensions
+ && TREE_CODE (tem) == FIELD_DECL
+ && (TREE_READONLY (tem) || TREE_THIS_VOLATILE (tem)))
+ {
+ tree type =
+ DECL_BIT_FIELD_TYPE (tem)
+ ? DECL_BIT_FIELD_TYPE (tem)
+ : TREE_TYPE (tem);
+ if ((TYPE_VOLATILE (type) != TREE_THIS_VOLATILE (tem))
+ || (TYPE_READONLY (type) != TREE_READONLY (tem)))
+ {
+ have_used_extensions = 1;
+ if ( TREE_READONLY (tem))
+ {
+ putc ('k', asmfile);
+ CHARS (1);
+ }
+ if ( TREE_THIS_VOLATILE (tem))
+ {
+ putc ('B', asmfile);
+ CHARS (1);
+ }
+ }
+ }
+
dbxout_type ((TREE_CODE (tem) == FIELD_DECL
&& DECL_BIT_FIELD_TYPE (tem))
? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);


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