]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix dwarf_getsrc_file handling empty CUs.
authorRoland McGrath <roland@redhat.com>
Wed, 22 Jul 2009 01:14:52 +0000 (18:14 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 22 Jul 2009 01:14:52 +0000 (18:14 -0700)
libdw/ChangeLog
libdw/dwarf_entry_breakpoints.c
libdw/dwarf_getsrc_file.c

index f04880b55629c8a5c198dee2a1e01ac3cd760820..1b19e9fc5835912453c5e701dfa4eb8c7c87abf5 100644 (file)
@@ -1,3 +1,11 @@
+2009-07-21  Roland McGrath  <roland@redhat.com>
+
+       * dwarf_getsrc_file.c: Ignore a CU that just has no DW_AT_stmt_list.
+       Fix loop iteration after skipping a bogus or useless CU.
+
+       * dwarf_entry_breakpoints.c: Handle 0 dwarf_errno () as harmless
+       absence, not DWARF_E_NO_DEBUG_LINE.
+
 2009-07-20  Roland McGrath  <roland@redhat.com>
 
        * dwarf_getlocation.c (__libdw_intern_expression):
index 578464f3f9144c1f7f63c02fb9c05494154f9c4c..1e5c1b81941d8aec50e3335ba1a74e4bd3999fe0 100644 (file)
@@ -1,5 +1,5 @@
 /* Find entry breakpoint locations for a function.
-   Copyright (C) 2005, 2008 Red Hat, Inc.
+   Copyright (C) 2005-2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -93,7 +93,7 @@ dwarf_entry_breakpoints (die, bkpts)
   if (INTUSE(dwarf_getsrclines) (&cudie, &lines, &nlines) < 0)
     {
       int error = INTUSE (dwarf_errno) ();
-      if (error == DWARF_E_NO_DEBUG_LINE)
+      if (error == 0)          /* CU has no DW_AT_stmt_list.  */
        return entrypc_bkpt ();
       __libdw_seterrno (error);
       return -1;
index 91abbaeb9389c1a5bdb6618f14b91230aefd00bd..bc612f6c6ca55f8c6bc45c3f69d1a37e0366246e 100644 (file)
@@ -1,5 +1,5 @@
 /* Find line information for given file/line/column triple.
-   Copyright (C) 2005 Red Hat, Inc.
+   Copyright (C) 2005-2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2005.
 
@@ -74,11 +74,11 @@ dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column,
   size_t cur_match = 0;
   Dwarf_Line **match = *nsrcs == 0 ? NULL : *srcsp;
 
-  Dwarf_Off off = 0;
   size_t cuhl;
   Dwarf_Off noff;
-
-  while (INTUSE(dwarf_nextcu) (dbg, off, &noff, &cuhl, NULL, NULL, NULL) == 0)
+  for (Dwarf_Off off = 0;
+       INTUSE(dwarf_nextcu) (dbg, off, &noff, &cuhl, NULL, NULL, NULL) == 0;
+       off = noff)
     {
       Dwarf_Die cudie_mem;
       Dwarf_Die *cudie = INTUSE(dwarf_offdie) (dbg, off + cuhl, &cudie_mem);
@@ -89,7 +89,14 @@ dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column,
       Dwarf_Lines *lines;
       size_t nlines;
       if (INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines) != 0)
-       return -1;
+       {
+         /* Ignore a CU that just has no DW_AT_stmt_list at all.  */
+         int error = INTUSE(dwarf_errno) ();
+         if (error == 0)
+           continue;
+         __libdw_seterrno (error);
+         return -1;
+       }
 
       /* Search through all the line number records for a matching
         file and line/column number.  If any of the numbers is zero,
@@ -175,8 +182,6 @@ dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column,
         already, there is no need to go on to the next CU.  */
       if (cur_match == max_match)
        break;
-
-      off = noff;
     }
 
   if (cur_match > 0)