Fix dwarf_getsrc_file handling empty CUs.
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index f04880b..1b19e9f 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -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):
diff --git a/libdw/dwarf_entry_breakpoints.c b/libdw/dwarf_entry_breakpoints.c
index 578464f..1e5c1b8 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 @@
   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 91abbae..bc612f6 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 <drepper@redhat.com>, 2005.
 
@@ -74,11 +74,11 @@
   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_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 @@
 	 already, there is no need to go on to the next CU.  */
       if (cur_match == max_match)
 	break;
-
-      off = noff;
     }
 
   if (cur_match > 0)