summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Drepper <[email protected]>2006-05-22 18:16:45 +0000
committerUlrich Drepper <[email protected]>2006-05-22 18:16:45 +0000
commite7a73177dfbbc650fb43e5caa3ce29143f02fabd (patch)
tree86c12564092ffb764689fb12491ed0a5084b1ee4
parent4f3d2a2aff351b2c202c8d6e7854a9e3a05153f2 (diff)
Handle files without aranges information.
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/dwarf_getaranges.c11
-rw-r--r--libdwfl/ChangeLog4
-rw-r--r--libdwfl/cu.c56
4 files changed, 50 insertions, 26 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index d904e424..c6ee77af 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-22 Ulrich Drepper <[email protected]>
+
+ * dwarf_getaranges.c (dwarf_getaranges): Handle files without
+ aranges information.
+
2006-05-21 Ulrich Drepper <[email protected]>
* libdw.h: Add nonnull attributes to dwarf_tag, dwarf_getattrs,
diff --git a/libdw/dwarf_getaranges.c b/libdw/dwarf_getaranges.c
index 61eb4f74..d2294ea3 100644
--- a/libdw/dwarf_getaranges.c
+++ b/libdw/dwarf_getaranges.c
@@ -1,5 +1,5 @@
/* Return list address ranges.
- Copyright (C) 2000, 2001, 2002, 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <[email protected]>, 2000.
@@ -89,6 +89,15 @@ dwarf_getaranges (dbg, aranges, naranges)
return 0;
}
+ if (dbg->sectiondata[IDX_debug_aranges] == NULL)
+ {
+ /* No such section. */
+ *aranges = NULL;
+ if (naranges != NULL)
+ *naranges = 0;
+ return 0;
+ }
+
if (dbg->sectiondata[IDX_debug_aranges]->d_buf == NULL)
return -1;
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index d78194aa..34f8f46f 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2006-05-22 Ulrich Drepper <[email protected]>
+
+ * cu.c (addrarange): Handle files without aranges information.
+
2006-05-16 Ulrich Drepper <[email protected]>
* dwfl_addrmodule.c (dwfl_addrmodule): Also return NULL of
diff --git a/libdwfl/cu.c b/libdwfl/cu.c
index e8dbf329..4c6d876e 100644
--- a/libdwfl/cu.c
+++ b/libdwfl/cu.c
@@ -1,5 +1,5 @@
/* Keeping track of DWARF compilation units in libdwfl.
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005, 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -65,32 +65,38 @@ addrarange (Dwfl_Module *mod, Dwarf_Addr addr, struct dwfl_arange **arange)
{
if (mod->aranges == NULL)
{
- Dwarf_Aranges *dwaranges;
- if (INTUSE(dwarf_getaranges) (mod->dw, &dwaranges, NULL) != 0)
+ struct dwfl_arange *aranges = NULL;
+ Dwarf_Aranges *dwaranges = NULL;
+ size_t naranges;
+ if (INTUSE(dwarf_getaranges) (mod->dw, &dwaranges, &naranges) != 0)
return DWFL_E_LIBDW;
- struct dwfl_arange *aranges = malloc (dwaranges->naranges
- * sizeof *aranges);
- if (unlikely (aranges == NULL))
- return DWFL_E_NOMEM;
-
- /* libdw has sorted its list by address, which is how we want it.
- But the sorted list is full of not-quite-contiguous runs pointing
- to the same CU. We don't care about the little gaps inside the
- module, we'll consider them part of the surrounding CU anyway.
- Collect our own array with just one record for each run of ranges
- pointing to one CU. */
-
- size_t naranges = 0;
- Dwarf_Off lastcu = 0;
- for (size_t i = 0; i < dwaranges->naranges; ++i)
- if (i == 0 || dwaranges->info[i].offset != lastcu)
- {
- aranges[naranges].arange = i;
- aranges[naranges].cu = NULL;
- ++naranges;
- lastcu = dwaranges->info[i].offset;
- }
+ /* If the module has no aranges (when no code is included) we
+ allocate nothing. */
+ if (naranges != 0)
+ {
+ aranges = malloc (naranges * sizeof *aranges);
+ if (unlikely (aranges == NULL))
+ return DWFL_E_NOMEM;
+
+ /* libdw has sorted its list by address, which is how we want it.
+ But the sorted list is full of not-quite-contiguous runs pointing
+ to the same CU. We don't care about the little gaps inside the
+ module, we'll consider them part of the surrounding CU anyway.
+ Collect our own array with just one record for each run of ranges
+ pointing to one CU. */
+
+ naranges = 0;
+ Dwarf_Off lastcu = 0;
+ for (size_t i = 0; i < dwaranges->naranges; ++i)
+ if (i == 0 || dwaranges->info[i].offset != lastcu)
+ {
+ aranges[naranges].arange = i;
+ aranges[naranges].cu = NULL;
+ ++naranges;
+ lastcu = dwaranges->info[i].offset;
+ }
+ }
/* Store the final array, which is probably much smaller than before. */
mod->naranges = naranges;