static void read_namespace (struct die_info *die, struct dwarf2_cu *);
+static const char *namespace_name (struct die_info *die,
+ int *is_anonymous);
+
static void read_enumeration (struct die_info *, struct dwarf2_cu *);
static struct type *dwarf_base_type (int, int, struct dwarf2_cu *);
{
struct objfile *objfile = cu->objfile;
CORE_ADDR addr = 0;
+ char *actual_name = pdi->name;
const struct partial_symbol *psym = NULL;
switch (pdi->tag)
case DW_TAG_subprogram:
if (pdi->is_external)
{
- /*prim_record_minimal_symbol (pdi->name, pdi->lowpc + baseaddr,
+ /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
mst_text, objfile); */
- psym = add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ psym = add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_BLOCK,
&objfile->global_psymbols,
0, pdi->lowpc + baseaddr,
}
else
{
- /*prim_record_minimal_symbol (pdi->name, pdi->lowpc + baseaddr,
+ /*prim_record_minimal_symbol (actual_name, pdi->lowpc + baseaddr,
mst_file_text, objfile); */
- psym = add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ psym = add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_BLOCK,
&objfile->static_psymbols,
0, pdi->lowpc + baseaddr,
if (pdi->locdesc)
addr = decode_locdesc (pdi->locdesc, cu);
if (pdi->locdesc || pdi->has_type)
- psym = add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ psym = add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_STATIC,
&objfile->global_psymbols,
0, addr + baseaddr,
if (pdi->locdesc == NULL)
return;
addr = decode_locdesc (pdi->locdesc, cu);
- /*prim_record_minimal_symbol (pdi->name, addr + baseaddr,
+ /*prim_record_minimal_symbol (actual_name, addr + baseaddr,
mst_file_data, objfile); */
- psym = add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ psym = add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_STATIC,
&objfile->static_psymbols,
0, addr + baseaddr,
break;
case DW_TAG_typedef:
case DW_TAG_base_type:
- add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
references. */
if (pdi->has_children == 0)
return;
- add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
if (cu_language == language_cplus)
{
/* For C++, these implicitly act as typedefs as well. */
- add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_TYPEDEF,
&objfile->static_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
}
break;
case DW_TAG_enumerator:
- add_psymbol_to_list (pdi->name, strlen (pdi->name),
+ add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_DOMAIN, LOC_CONST,
&objfile->static_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
if (!processing_has_namespace_info)
{
processing_has_namespace_info = 1;
- processing_current_namespace = "";
+ processing_current_prefix = "";
}
read_namespace (die, cu);
break;
if (!processing_has_namespace_info)
{
processing_has_namespace_info = 1;
- processing_current_namespace = "";
+ processing_current_prefix = "";
}
gdb_assert (die->child == NULL);
break;
read_namespace (struct die_info *die, struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
- const char *previous_namespace = processing_current_namespace;
+ const char *previous_prefix = processing_current_prefix;
const char *name = NULL;
int is_anonymous;
struct die_info *current_die;
- /* Loop through the extensions until we find a name. */
-
- for (current_die = die;
- current_die != NULL;
- current_die = dwarf2_extension (die))
- {
- name = dwarf2_name (current_die);
- if (name != NULL)
- break;
- }
-
- /* Is it an anonymous namespace? */
-
- is_anonymous = (name == NULL);
- if (is_anonymous)
- name = "(anonymous namespace)";
+ name = namespace_name (die, &is_anonymous);
/* Now build the name of the current namespace. */
- if (previous_namespace[0] == '\0')
+ if (previous_prefix[0] == '\0')
{
- processing_current_namespace = name;
+ processing_current_prefix = name;
}
else
{
- /* We need temp_name around because processing_current_namespace
+ /* We need temp_name around because processing_current_prefix
is a const char *. */
- char *temp_name = alloca (strlen (previous_namespace)
+ char *temp_name = alloca (strlen (previous_prefix)
+ 2 + strlen(name) + 1);
- strcpy (temp_name, previous_namespace);
+ strcpy (temp_name, previous_prefix);
strcat (temp_name, "::");
strcat (temp_name, name);
- processing_current_namespace = temp_name;
+ processing_current_prefix = temp_name;
}
/* Add a symbol associated to this if we haven't seen the namespace
/* FIXME: carlton/2003-06-27: Once GDB is more const-correct,
this cast will hopefully become unnecessary. */
type = init_type (TYPE_CODE_NAMESPACE, 0, 0,
- (char *) processing_current_namespace,
+ (char *) processing_current_prefix,
objfile);
TYPE_TAG_NAME (type) = TYPE_NAME (type);
new_symbol (die, type, cu);
if (is_anonymous)
- cp_add_using_directive (processing_current_namespace,
- strlen (previous_namespace),
- strlen (processing_current_namespace));
+ cp_add_using_directive (processing_current_prefix,
+ strlen (previous_prefix),
+ strlen (processing_current_prefix));
}
if (die->child != NULL)
}
}
- processing_current_namespace = previous_namespace;
+ processing_current_prefix = previous_prefix;
+}
+
+/* Return the name of the namespace represented by DIE. Set
+ *IS_ANONYMOUS to tell whether or not the namespace is an anonymous
+ namespace. */
+
+static const char *
+namespace_name (struct die_info *die, int *is_anonymous)
+{
+ struct die_info *current_die;
+ const char *name = NULL;
+
+ /* Loop through the extensions until we find a name. */
+
+ for (current_die = die;
+ current_die != NULL;
+ current_die = dwarf2_extension (die))
+ {
+ name = dwarf2_name (current_die);
+ if (name != NULL)
+ break;
+ }
+
+ /* Is it an anonymous namespace? */
+
+ *is_anonymous = (name == NULL);
+ if (*is_anonymous)
+ name = "(anonymous namespace)";
+
+ return name;
}
/* Extract all information from a DW_TAG_pointer_type DIE and add to