aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c71
1 files changed, 20 insertions, 51 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 35e9bb4..6eea17e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2356,33 +2356,10 @@ dw2_get_primary_cu (int index)
return dwarf2_per_objfile->all_comp_units[index];
}
-/* A helper function that knows how to read a 64-bit value in a way
- that doesn't make gdb die. Returns 1 if the conversion went ok, 0
- otherwise. */
-
-static int
-extract_cu_value (const char *bytes, ULONGEST *result)
-{
- if (sizeof (ULONGEST) < 8)
- {
- int i;
-
- /* Ignore the upper 4 bytes if they are all zero. */
- for (i = 0; i < 4; ++i)
- if (bytes[i + 4] != 0)
- return 0;
-
- *result = extract_unsigned_integer (bytes, 4, BFD_ENDIAN_LITTLE);
- }
- else
- *result = extract_unsigned_integer (bytes, 8, BFD_ENDIAN_LITTLE);
- return 1;
-}
-
/* A helper for create_cus_from_index that handles a given list of
CUs. */
-static int
+static void
create_cus_from_index_list (struct objfile *objfile,
const gdb_byte *cu_list, offset_type n_elements,
struct dwarf2_section_info *section,
@@ -2396,9 +2373,9 @@ create_cus_from_index_list (struct objfile *objfile,
struct dwarf2_per_cu_data *the_cu;
ULONGEST offset, length;
- if (!extract_cu_value (cu_list, &offset)
- || !extract_cu_value (cu_list + 8, &length))
- return 0;
+ gdb_static_assert (sizeof (ULONGEST) >= 8);
+ offset = extract_unsigned_integer (cu_list, 8, BFD_ENDIAN_LITTLE);
+ length = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE);
cu_list += 2 * 8;
the_cu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
@@ -2412,15 +2389,12 @@ create_cus_from_index_list (struct objfile *objfile,
the_cu->is_dwz = is_dwz;
dwarf2_per_objfile->all_comp_units[base_offset + i / 2] = the_cu;
}
-
- return 1;
}
/* Read the CU list from the mapped index, and use it to create all
- the CU objects for this objfile. Return 0 if something went wrong,
- 1 if everything went ok. */
+ the CU objects for this objfile. */
-static int
+static void
create_cus_from_index (struct objfile *objfile,
const gdb_byte *cu_list, offset_type cu_list_elements,
const gdb_byte *dwz_list, offset_type dwz_elements)
@@ -2433,21 +2407,20 @@ create_cus_from_index (struct objfile *objfile,
dwarf2_per_objfile->n_comp_units
* sizeof (struct dwarf2_per_cu_data *));
- if (!create_cus_from_index_list (objfile, cu_list, cu_list_elements,
- &dwarf2_per_objfile->info, 0, 0))
- return 0;
+ create_cus_from_index_list (objfile, cu_list, cu_list_elements,
+ &dwarf2_per_objfile->info, 0, 0);
if (dwz_elements == 0)
- return 1;
+ return;
dwz = dwarf2_get_dwz_file ();
- return create_cus_from_index_list (objfile, dwz_list, dwz_elements,
- &dwz->info, 1, cu_list_elements / 2);
+ create_cus_from_index_list (objfile, dwz_list, dwz_elements, &dwz->info, 1,
+ cu_list_elements / 2);
}
/* Create the signatured type hash table from the index. */
-static int
+static void
create_signatured_type_table_from_index (struct objfile *objfile,
struct dwarf2_section_info *section,
const gdb_byte *bytes,
@@ -2470,9 +2443,10 @@ create_signatured_type_table_from_index (struct objfile *objfile,
ULONGEST offset, type_offset_in_tu, signature;
void **slot;
- if (!extract_cu_value (bytes, &offset)
- || !extract_cu_value (bytes + 8, &type_offset_in_tu))
- return 0;
+ gdb_static_assert (sizeof (ULONGEST) >= 8);
+ offset = extract_unsigned_integer (bytes, 8, BFD_ENDIAN_LITTLE);
+ type_offset_in_tu = extract_unsigned_integer (bytes + 8, 8,
+ BFD_ENDIAN_LITTLE);
signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE);
bytes += 3 * 8;
@@ -2495,8 +2469,6 @@ create_signatured_type_table_from_index (struct objfile *objfile,
}
dwarf2_per_objfile->signatured_types = sig_types_hash;
-
- return 1;
}
/* Read the address map data from the mapped index, and use it to
@@ -2793,9 +2765,8 @@ dwarf2_read_index (struct objfile *objfile)
}
}
- if (!create_cus_from_index (objfile, cu_list, cu_list_elements,
- dwz_list, dwz_list_elements))
- return 0;
+ create_cus_from_index (objfile, cu_list, cu_list_elements, dwz_list,
+ dwz_list_elements);
if (types_list_elements)
{
@@ -2809,10 +2780,8 @@ dwarf2_read_index (struct objfile *objfile)
section = VEC_index (dwarf2_section_info_def,
dwarf2_per_objfile->types, 0);
- if (!create_signatured_type_table_from_index (objfile, section,
- types_list,
- types_list_elements))
- return 0;
+ create_signatured_type_table_from_index (objfile, section, types_list,
+ types_list_elements);
}
create_addrmap_from_index (objfile, &local_map);