This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [10/10] use the referring CU's language
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 10 May 2012 14:15:42 -0600
- Subject: Re: [10/10] use the referring CU's language
- References: <87mx5zaadq.fsf@fleche.redhat.com>
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> So, this patch changes the DWARF reader to propagate a CU's language to
Tom> the PU, when reading the PU.
Here's the new version.
This too will be in a single commit with the last few patches.
I never did come up with any confounding examples, so I left this code
as-is. However, if need be, it should not be too hard to revisit the
problem and come up with a different solution, along the lines of what I
suggested originally.
Tom
>From 13399fa21a7a208bec9e129f7e61696983c46ade Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Tue, 24 Apr 2012 23:29:58 -0600
Subject: [PATCH 09/10] when reading a partial unit, use the referring CU's
language
* dwarf2read.c (struct dwarf2_queue_item) <pretend_language>: New
field.
(load_cu, dw2_do_instantiate_symtab, process_psymtab_comp_unit)
(load_partial_comp_unit): Update.
(queue_comp_unit): Add argument 'pretend_language'.
(process_queue): Update.
(psymtab_to_symtab_1): Skip dependencies that have a user.
(load_partial_comp_unit_reader): Give meaning to the 'data'
argument.
(load_full_comp_unit): Add 'pretend_language' argument.
(process_full_comp_unit): Add 'pretend_language' argument. Set
language on CU.
(process_imported_unit_die, read_file_scope, read_type_unit_scope):
Update.
(maybe_queue_comp_unit): Add 'pretend_language' argument.
(follow_die_offset, follow_die_sig, read_signatured_type_reader):
Update.
(prepare_one_comp_unit): Add 'pretend_language' argument.
---
gdb/dwarf2read.c | 76 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 47 insertions(+), 29 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ff1babd..c4f1887 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -905,6 +905,7 @@ struct field_info
struct dwarf2_queue_item
{
struct dwarf2_per_cu_data *per_cu;
+ enum language pretend_language;
struct dwarf2_queue_item *next;
};
@@ -1364,7 +1365,8 @@ static void init_one_comp_unit (struct dwarf2_cu *cu,
struct dwarf2_per_cu_data *per_cu);
static void prepare_one_comp_unit (struct dwarf2_cu *cu,
- struct die_info *comp_unit_die);
+ struct die_info *comp_unit_die,
+ enum language pretend_language);
static void free_heap_comp_unit (void *);
@@ -1381,9 +1383,11 @@ static void create_all_comp_units (struct objfile *);
static int create_all_type_units (struct objfile *);
-static void load_full_comp_unit (struct dwarf2_per_cu_data *);
+static void load_full_comp_unit (struct dwarf2_per_cu_data *,
+ enum language);
-static void process_full_comp_unit (struct dwarf2_per_cu_data *);
+static void process_full_comp_unit (struct dwarf2_per_cu_data *,
+ enum language);
static void dwarf2_add_dependence (struct dwarf2_cu *,
struct dwarf2_per_cu_data *);
@@ -1399,10 +1403,12 @@ static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
static void dwarf2_release_queue (void *dummy);
-static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu);
+static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
+ enum language pretend_language);
static int maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
- struct dwarf2_per_cu_data *per_cu);
+ struct dwarf2_per_cu_data *per_cu,
+ enum language pretend_language);
static void process_queue (void);
@@ -1949,7 +1955,7 @@ load_cu (struct dwarf2_per_cu_data *per_cu)
if (per_cu->is_debug_types)
load_full_type_unit (per_cu);
else
- load_full_comp_unit (per_cu);
+ load_full_comp_unit (per_cu, language_minimal);
gdb_assert (per_cu->cu != NULL);
@@ -1969,7 +1975,7 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
? per_cu->v.quick->symtab == NULL
: (per_cu->v.psymtab == NULL || !per_cu->v.psymtab->readin))
{
- queue_comp_unit (per_cu);
+ queue_comp_unit (per_cu, language_minimal);
load_cu (per_cu);
}
@@ -4050,7 +4056,7 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader,
|| !*want_partial_unit_ptr))
return;
- prepare_one_comp_unit (cu, comp_unit_die);
+ prepare_one_comp_unit (cu, comp_unit_die, language_minimal);
cu->list_in_scope = &file_symbols;
@@ -4318,7 +4324,7 @@ load_partial_comp_unit_reader (const struct die_reader_specs *reader,
{
struct dwarf2_cu *cu = reader->cu;
- prepare_one_comp_unit (cu, comp_unit_die);
+ prepare_one_comp_unit (cu, comp_unit_die, language_minimal);
/* Check if comp unit has_children.
If so, read the rest of the partial symbols from this comp unit.
@@ -5181,13 +5187,15 @@ dwarf2_psymtab_to_symtab (struct partial_symtab *pst)
/* Add PER_CU to the queue. */
static void
-queue_comp_unit (struct dwarf2_per_cu_data *per_cu)
+queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
+ enum language pretend_language)
{
struct dwarf2_queue_item *item;
per_cu->queued = 1;
item = xmalloc (sizeof (*item));
item->per_cu = per_cu;
+ item->pretend_language = pretend_language;
item->next = NULL;
if (dwarf2_queue == NULL)
@@ -5212,7 +5220,7 @@ process_queue (void)
if (dwarf2_per_objfile->using_index
? !item->per_cu->v.quick->symtab
: (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
- process_full_comp_unit (item->per_cu);
+ process_full_comp_unit (item->per_cu, item->pretend_language);
item->per_cu->queued = 0;
next_item = item->next;
@@ -5264,7 +5272,8 @@ psymtab_to_symtab_1 (struct partial_symtab *pst)
return;
for (i = 0; i < pst->number_of_dependencies; i++)
- if (!pst->dependencies[i]->readin)
+ if (!pst->dependencies[i]->readin
+ && pst->dependencies[i]->user == NULL)
{
/* Inform about additional files that need to be read in. */
if (info_verbose)
@@ -5330,6 +5339,7 @@ load_full_comp_unit_reader (const struct die_reader_specs *reader,
{
struct dwarf2_cu *cu = reader->cu;
struct attribute *attr;
+ enum language *language_ptr = data;
gdb_assert (cu->die_hash == NULL);
cu->die_hash =
@@ -5353,17 +5363,19 @@ load_full_comp_unit_reader (const struct die_reader_specs *reader,
or we won't be able to build types correctly.
Similarly, if we do not read the producer, we can not apply
producer-specific interpretation. */
- prepare_one_comp_unit (cu, cu->dies);
+ prepare_one_comp_unit (cu, cu->dies, *language_ptr);
}
/* Load the DIEs associated with PER_CU into memory. */
static void
-load_full_comp_unit (struct dwarf2_per_cu_data *this_cu)
+load_full_comp_unit (struct dwarf2_per_cu_data *this_cu,
+ enum language pretend_language)
{
gdb_assert (! this_cu->is_debug_types);
- init_cutu_and_read_dies (this_cu, 1, 1, load_full_comp_unit_reader, NULL);
+ init_cutu_and_read_dies (this_cu, 1, 1, load_full_comp_unit_reader,
+ &pretend_language);
}
/* Add a DIE to the delayed physname list. */
@@ -5597,7 +5609,8 @@ process_cu_includes (void)
already been loaded into memory. */
static void
-process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
+process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
+ enum language pretend_language)
{
struct dwarf2_cu *cu = per_cu->cu;
struct objfile *objfile = per_cu->objfile;
@@ -5614,6 +5627,9 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
cu->list_in_scope = &file_symbols;
+ cu->language = pretend_language;
+ cu->language_defn = language_def (cu->language);
+
/* Do line number decoding in read_file_scope () */
process_die (cu->dies, cu);
@@ -5698,8 +5714,8 @@ process_imported_unit_die (struct die_info *die, struct dwarf2_cu *cu)
per_cu = dwarf2_find_containing_comp_unit (offset, cu->objfile);
/* Queue the unit, if needed. */
- if (maybe_queue_comp_unit (cu, per_cu))
- load_full_comp_unit (per_cu);
+ if (maybe_queue_comp_unit (cu, per_cu, cu->language))
+ load_full_comp_unit (per_cu, cu->language);
VEC_safe_push (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
per_cu);
@@ -6493,7 +6509,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
find_file_and_directory (die, cu, &name, &comp_dir);
- prepare_one_comp_unit (cu, die);
+ prepare_one_comp_unit (cu, die, cu->language);
/* The XLCL doesn't generate DW_LANG_OpenCL because this attribute is not
standardised yet. As a workaround for the language detection we fall
@@ -6603,7 +6619,7 @@ read_type_unit_scope (struct die_info *die, struct dwarf2_cu *cu)
if (name == NULL)
name = "<unknown>";
- prepare_one_comp_unit (cu, die);
+ prepare_one_comp_unit (cu, die, language_minimal);
/* We assume that we're processing GCC output. */
processing_gcc_compilation = 2;
@@ -14820,7 +14836,8 @@ dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
static int
maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
- struct dwarf2_per_cu_data *per_cu)
+ struct dwarf2_per_cu_data *per_cu,
+ enum language pretend_language)
{
/* We may arrive here during partial symbol reading, if we need full
DIEs to process an unusual case (e.g. template arguments). Do
@@ -14849,7 +14866,7 @@ maybe_queue_comp_unit (struct dwarf2_cu *this_cu,
}
/* Add it to the queue. */
- queue_comp_unit (per_cu);
+ queue_comp_unit (per_cu, pretend_language);
return 1;
}
@@ -14908,8 +14925,8 @@ follow_die_offset (sect_offset offset, struct dwarf2_cu **ref_cu)
per_cu = dwarf2_find_containing_comp_unit (offset, cu->objfile);
/* If necessary, add it to the queue and load its DIEs. */
- if (maybe_queue_comp_unit (cu, per_cu))
- load_full_comp_unit (per_cu);
+ if (maybe_queue_comp_unit (cu, per_cu, cu->language))
+ load_full_comp_unit (per_cu, cu->language);
target_cu = per_cu->cu;
}
@@ -14917,7 +14934,7 @@ follow_die_offset (sect_offset offset, struct dwarf2_cu **ref_cu)
{
/* We're loading full DIEs during partial symbol reading. */
gdb_assert (dwarf2_per_objfile->reading_partial_symbols);
- load_full_comp_unit (cu->per_cu);
+ load_full_comp_unit (cu->per_cu, language_minimal);
}
*ref_cu = target_cu;
@@ -15049,7 +15066,7 @@ follow_die_sig (struct die_info *src_die, struct attribute *attr,
/* If necessary, add it to the queue and load its DIEs. */
- if (maybe_queue_comp_unit (*ref_cu, &sig_type->per_cu))
+ if (maybe_queue_comp_unit (*ref_cu, &sig_type->per_cu, language_minimal))
read_signatured_type (sig_type);
gdb_assert (sig_type->per_cu.cu != NULL);
@@ -15162,7 +15179,7 @@ read_signatured_type_reader (const struct die_reader_specs *reader,
or we won't be able to build types correctly.
Similarly, if we do not read the producer, we can not apply
producer-specific interpretation. */
- prepare_one_comp_unit (cu, cu->dies);
+ prepare_one_comp_unit (cu, cu->dies, language_minimal);
}
/* Read in a signatured type and build its CU and DIEs.
@@ -16628,7 +16645,8 @@ init_one_comp_unit (struct dwarf2_cu *cu, struct dwarf2_per_cu_data *per_cu)
/* Initialize basic fields of dwarf_cu CU according to DIE COMP_UNIT_DIE. */
static void
-prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die)
+prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die,
+ enum language pretend_language)
{
struct attribute *attr;
@@ -16638,7 +16656,7 @@ prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die)
set_cu_language (DW_UNSND (attr), cu);
else
{
- cu->language = language_minimal;
+ cu->language = pretend_language;
cu->language_defn = language_def (cu->language);
}
--
1.7.7.6