diff options
author | Tom Tromey <tromey@redhat.com> | 2012-06-11 18:45:01 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-06-11 18:45:01 +0000 |
commit | 356d9f9d9ea883adf486ade721fc2b516a8902c7 (patch) | |
tree | 55683a8400864076bdbd6f731ae20359ee13dec9 | |
parent | bb2af9ccc58c2407f61aadc1b7d44aea3320f69b (diff) | |
download | gdb-356d9f9d9ea883adf486ade721fc2b516a8902c7.zip gdb-356d9f9d9ea883adf486ade721fc2b516a8902c7.tar.gz gdb-356d9f9d9ea883adf486ade721fc2b516a8902c7.tar.bz2 |
* dwarf2read.c (dw2_get_primary_filename_reader): New function.
(dw2_find_symbol_file): Use it.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/dwarf2read.c | 37 |
2 files changed, 37 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b902a41..ad6abdb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2012-06-11 Tom Tromey <tromey@redhat.com> + + * dwarf2read.c (dw2_get_primary_filename_reader): New function. + (dw2_find_symbol_file): Use it. + 2012-06-11 Michael Eager <eager@eagercon.com> * mips-linux-tdep.c (mips_gdb_signal_from_target): New diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 589361e..7e25d08 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2836,12 +2836,34 @@ dw2_expand_symtabs_with_filename (struct objfile *objfile, } } +/* A helper function for dw2_find_symbol_file that finds the primary + file name for a given CU. This is a die_reader_func. */ + +static void +dw2_get_primary_filename_reader (const struct die_reader_specs *reader, + gdb_byte *info_ptr, + struct die_info *comp_unit_die, + int has_children, + void *data) +{ + const char **result_ptr = data; + struct dwarf2_cu *cu = reader->cu; + struct attribute *attr; + + attr = dwarf2_attr (comp_unit_die, DW_AT_name, cu); + if (attr == NULL) + *result_ptr = NULL; + else + *result_ptr = DW_STRING (attr); +} + static const char * dw2_find_symbol_file (struct objfile *objfile, const char *name) { struct dwarf2_per_cu_data *per_cu; offset_type *vec; struct quick_file_names *file_data; + const char *filename; dw2_setup (objfile); @@ -2873,12 +2895,17 @@ dw2_find_symbol_file (struct objfile *objfile, const char *name) /* vec[0] is the length, which must always be >0. */ per_cu = dw2_get_cu (MAYBE_SWAP (vec[1])); - file_data = dw2_get_file_names (objfile, per_cu); - if (file_data == NULL - || file_data->num_file_names == 0) - return NULL; + if (per_cu->v.quick->symtab != NULL) + return per_cu->v.quick->symtab->filename; + + if (per_cu->is_debug_types) + init_cutu_and_read_dies (per_cu, 0, 0, dw2_get_primary_filename_reader, + &filename); + else + init_cutu_and_read_dies_simple (per_cu, dw2_get_primary_filename_reader, + &filename); - return file_data->file_names[file_data->num_file_names - 1]; + return filename; } static void |