From: Roland McGrath Date: Wed, 22 Jul 2009 01:14:52 +0000 (-0700) Subject: Fix dwarf_getsrc_file handling empty CUs. X-Git-Tag: elfutils-0.142~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e23e9e7de7d070a47ef641abeaf272467a1cff4c;p=thirdparty%2Felfutils.git Fix dwarf_getsrc_file handling empty CUs. --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index f04880b55..1b19e9fc5 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,11 @@ +2009-07-21 Roland McGrath + + * 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 * dwarf_getlocation.c (__libdw_intern_expression): diff --git a/libdw/dwarf_entry_breakpoints.c b/libdw/dwarf_entry_breakpoints.c index 578464f3f..1e5c1b819 100644 --- a/libdw/dwarf_entry_breakpoints.c +++ b/libdw/dwarf_entry_breakpoints.c @@ -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; diff --git a/libdw/dwarf_getsrc_file.c b/libdw/dwarf_getsrc_file.c index 91abbaeb9..bc612f6c6 100644 --- a/libdw/dwarf_getsrc_file.c +++ b/libdw/dwarf_getsrc_file.c @@ -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 , 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)