Commit 89708594 by Caroline Tice Committed by Caroline Tice

Add ability to generate DWARF pubtypes section if DEBUG_PUBTYPES_SECTION is defined.

Add ability to generate DWARF pubtypes section if DEBUG_PUBTYPES_SECTION
is defined.  Also add dejagnu testcases for pubtypes.

From-SVN: r118826
parent f0c1ebb7
2006-11-14 Caroline Tice <ctice@apple.com>
* dwarf2out.c (debug_pubtypes_section): New static global variable.
(pubname_entry): Add DEF_VEC_O and DEF_VEC_ALLOC_O statements for
this type.
(pubname_table): Redefine as a vector.
(pubtype_table): New static global variable, defined as a vector.
(pubname_table_allocated): Remove static global variable.
(pubname_table_in_use): Remove static global variable.
(PUBNAME_TABLE_INCREMENT): Remove constant.
(size_of_pubnames): Add parameter to deal with either pubnames or
pubtypes, and change code to deal with table being a vector.
(add_pubname): Change to deal with table being a vector.
(add_pubtype): New function.
(output_pubnames): Add parameter to deal with either pubnames or
pubtypes, and change code to deal with table being a vector.
(gen_array_type_die): Add call to add_pubtype.
(gen_enumeration_type_die): Add call to add_pubtype.
(gen_struct_or_union_type_die): Add call to add_pubtype.
(gen_subroutine_type_die): Add call to add_pubtype.
(gen_typedef_die): Add call to add_pubtype.
(dwarf2out_init): Add code to initialize pubname_table and
pubtype_table vectors; also initialize debug_pubtypes_section.
(prune_unused_types): Change to deal with pubnames being a vector.
(dwarf2out_finish): Change to deal with pubnames being a vector; add
pubnames table to call to output_pubnames; Add code to output pubtypes
table if DEBUG_PUBTYPES_SECTION is defined.
* config/darwin.c (darwin_file_start): Add DEBUG_PUBTYPES_SECTION to
debugnames.
* config/darwin.h (DEBUG_PUBTYPES_SECTION): Define new global variable.
2006-11-14 Joseph Myers <joseph@codesourcery.com> 2006-11-14 Joseph Myers <joseph@codesourcery.com>
* config/arm/arm.h (FUNCTION_ARG_ADVANCE): Only adjust * config/arm/arm.h (FUNCTION_ARG_ADVANCE): Only adjust
......
...@@ -1516,6 +1516,7 @@ darwin_file_start (void) ...@@ -1516,6 +1516,7 @@ darwin_file_start (void)
DEBUG_LINE_SECTION, DEBUG_LINE_SECTION,
DEBUG_LOC_SECTION, DEBUG_LOC_SECTION,
DEBUG_PUBNAMES_SECTION, DEBUG_PUBNAMES_SECTION,
DEBUG_PUBTYPES_SECTION,
DEBUG_STR_SECTION, DEBUG_STR_SECTION,
DEBUG_RANGES_SECTION DEBUG_RANGES_SECTION
}; };
......
...@@ -407,6 +407,7 @@ extern GTY(()) int darwin_ms_struct; ...@@ -407,6 +407,7 @@ extern GTY(()) int darwin_ms_struct;
#define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug" #define DEBUG_LINE_SECTION "__DWARF,__debug_line,regular,debug"
#define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug" #define DEBUG_LOC_SECTION "__DWARF,__debug_loc,regular,debug"
#define DEBUG_PUBNAMES_SECTION "__DWARF,__debug_pubnames,regular,debug" #define DEBUG_PUBNAMES_SECTION "__DWARF,__debug_pubnames,regular,debug"
#define DEBUG_PUBTYPES_SECTION "__DWARF,__debug_pubtypes,regular,debug"
#define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug" #define DEBUG_STR_SECTION "__DWARF,__debug_str,regular,debug"
#define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug" #define DEBUG_RANGES_SECTION "__DWARF,__debug_ranges,regular,debug"
......
2006-11-14 Caroline Tice <ctice@apple.com>
* gcc.dg/pubtypes-1.c: New file/testcase.
* gcc.dg/pubtypes-2.c: New file/testcase.
* gcc.dg/pubtypes-3.c: New file/testcase.
* gcc.dg/pubtypes-4.c: New file/testcase.
* g++.dg/pubtypes.C: New file/testcase.
2006-11-14 Mark Mitchell <mark@codesourcery.com> 2006-11-14 Mark Mitchell <mark@codesourcery.com>
PR c++/29106 PR c++/29106
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-options "-O0 -gdwarf-2 -dA -fno-eliminate-unused-debug-types" } */
/* { dg-final { scan-assembler "__debug_pubtypes" } } */
/* { dg-final { scan-assembler "long+\[ \t\]+0x24+\[ \t\]+\[#;]+\[ \t\]+Length of Public Type Names Info" } } */
/* { dg-final { scan-assembler "\"empty\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler "\"A\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler "\"B\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
struct A
{
virtual ~A ();
int a1;
};
A::~A()
{
a1 = 800;
}
struct B : public A
{
virtual ~B ();
int b1;
int b2;
};
B::~B()
{
a1 = 900;
b1 = 901;
b2 = 902;
}
// Stop the compiler from optimizing away data.
void refer (A *)
{
;
}
struct empty {};
// Stop the compiler from optimizing away data.
void refer (empty *)
{
;
}
int main (void)
{
A alpha, *aap, *abp;
B beta, *bbp;
empty e;
alpha.a1 = 100;
beta.a1 = 200; beta.b1 = 201; beta.b2 = 202;
aap = &alpha; refer (aap);
abp = &beta; refer (abp);
bbp = &beta; refer (bbp);
refer (&e);
return 0; // marker return 0
} // marker close brace
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-options "-O0 -gdwarf-2 -dA -fno-eliminate-unused-debug-types" } */
/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "__debug_pubtypes" } } */
/* { dg-final { scan-assembler "long+\[ \t\]+0x\[0-9a-f]+\[ \t\]+\[#;]+\[ \t\]+Length of Public Type Names Info" } } */
/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
#include <stdlib.h>
#include <stdio.h>
struct used_struct
{
int key;
char *name;
};
struct unused_struct
{
int key1;
int f2;
double f3;
char *f4;
struct unused_struct *next;
};
int
main (int argc, char **argv)
{
int i;
struct used_struct *my_list;
my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct));
for (i = 0; i < 10; i++)
{
my_list[i].key = i;
my_list[i].name = (char *) malloc (11);
sprintf (my_list[i].name, "Alice_%d", i);
}
for (i = 0; i < 10; i++)
fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name);
return 0;
}
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-options "-O0 -gdwarf-2 -dA" } */
/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "__debug_pubtypes" } } */
/* { dg-final { scan-assembler "long+\[ \t\]+0x6a+\[ \t\]+\[#;]+\[ \t\]+Length of Public Type Names Info" } } */
/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
#include <stdlib.h>
#include <stdio.h>
struct used_struct
{
int key;
char *name;
};
struct unused_struct
{
int key1;
int f2;
double f3;
char *f4;
struct unused_struct *next;
};
int
main (int argc, char **argv)
{
int i;
struct used_struct *my_list;
my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct));
for (i = 0; i < 10; i++)
{
my_list[i].key = i;
my_list[i].name = (char *) malloc (11);
sprintf (my_list[i].name, "Alice_%d", i);
}
for (i = 0; i < 10; i++)
fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name);
return 0;
}
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-options "-O0 -gdwarf-2 -dA" } */
/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "__debug_pubtypes" } } */
/* { dg-final { scan-assembler "long+\[ \t\]+0x6a+\[ \t\]+\[#;]+\[ \t\]+Length of Public Type Names Info" } } */
/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler-not "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
#include <stdlib.h>
#include <stdio.h>
struct used_struct
{
int key;
char *name;
};
struct unused_struct
{
int key1;
int f2;
double f3;
char *f4;
struct unused_struct *next;
};
void
foo (struct used_struct *list)
{
enum list_name_type {
boy_name,
girl_name,
unknown
};
int b_count = 0;
int g_count = 0;
int i;
enum list_name_type *enum_list;
enum_list = (enum list_name_type *) malloc (10 * sizeof (enum list_name_type));
for (i = 0; i < 10; i++)
{
if (strncmp (list[i].name, "Alice", 5) == 0)
{
enum_list[i] = girl_name;
g_count++;
}
else if (strncmp (list[i].name, "David", 5) == 0)
{
enum_list[i] = boy_name;
b_count++;
}
else
enum_list[i] = unknown;
}
}
int
main (int argc, char **argv)
{
int i;
struct used_struct *my_list;
my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct));
for (i = 0; i < 10; i++)
{
my_list[i].key = i;
my_list[i].name = (char *) malloc (11);
sprintf (my_list[i].name, "Alice_%d", i);
}
foo (my_list);
for (i = 0; i < 10; i++)
fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name);
return 0;
}
/* { dg-do compile { target *-*-darwin* } } */
/* { dg-options "-O0 -gdwarf-2 -dA" } */
/* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */
/* { dg-final { scan-assembler "__debug_pubtypes" } } */
/* { dg-final { scan-assembler "long+\[ \t\]+0xa1+\[ \t\]+\[#;]+\[ \t\]+Length of Public Type Names Info" } } */
/* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler "\"enum_list_array\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
/* { dg-final { scan-assembler "\"field_union\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
#include <stdlib.h>
#include <stdio.h>
struct used_struct
{
int key;
char *name;
union field_union
{
char u_c;
int u_i;
long u_l;
double u_d;
} u;
};
struct unused_struct
{
int key1;
int f2;
double f3;
char *f4;
struct unused_struct *next;
};
enum list_name_type {
boy_name,
girl_name,
unknown
};
typedef enum list_name_type *enum_list_array;
enum_list_array enum_list;
void
foo (struct used_struct *list)
{
int b_count = 0;
int g_count = 0;
int i;
enum_list = (enum_list_array) malloc (10 * sizeof (enum list_name_type));
for (i = 0; i < 10; i++)
{
if (strncmp (list[i].name, "Alice", 5) == 0)
{
enum_list[i] = girl_name;
g_count++;
}
else if (strncmp (list[i].name, "David", 5) == 0)
{
enum_list[i] = boy_name;
b_count++;
}
else
enum_list[i] = unknown;
}
}
int
main (int argc, char **argv)
{
int i;
struct used_struct *my_list;
my_list = (struct used_struct *) malloc (10 * sizeof (struct used_struct));
for (i = 0; i < 10; i++)
{
my_list[i].key = i;
my_list[i].name = (char *) malloc (11);
sprintf (my_list[i].name, "Alice_%d", i);
}
foo (my_list);
for (i = 0; i < 10; i++)
fprintf (stdout, "Key: %d, Name: %s\n", my_list[i].key, my_list[i].name);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment