]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw/
authorRoland McGrath <roland@redhat.com>
Mon, 16 Apr 2007 23:13:37 +0000 (23:13 +0000)
committerRoland McGrath <roland@redhat.com>
Mon, 16 Apr 2007 23:13:37 +0000 (23:13 +0000)
2007-04-16  Roland McGrath  <roland@redhat.com>

* libdw.map (ELFUTILS_0.127): Add dwfl_module_address_section.

libdwfl/
2007-04-16  Roland McGrath  <roland@redhat.com>

* derelocate.c (cache_sections): Apply bias to sh_addr.
(compare_secrefs): Fix address comparison to avoid signed overflow.
(find_section): New function, broken out of ...
(dwfl_module_relocate_address): ... here, call it.
(check_module): New function, broken out of ...
(dwfl_module_relocate_address): ... here, call it.
(dwfl_module_address_section): New function.
* libdwfl.h: Declare it.

tests/
2007-04-16  Roland McGrath  <roland@redhat.com>

* dwfl-addr-sect.c: New file.
* Makefile.am (noinst_PROGRAMS): Add it.
(dwfl_addr_sect_LDADD): New variable.

16 files changed:
NEWS
libdw/ChangeLog
libdw/Makefile.am
libdw/dwarf_getsrcdirs.c [new file with mode: 0644]
libdw/dwarf_getsrclines.c
libdw/libdw.h
libdw/libdw.map
libdw/libdwP.h
libdwfl/ChangeLog
libdwfl/derelocate.c
libdwfl/libdwfl.h
tests/ChangeLog
tests/Makefile.am
tests/dwfl-addr-sect.c [new file with mode: 0644]
tests/get-files.c
tests/run-get-files.sh

diff --git a/NEWS b/NEWS
index 3ca9f89940dc5f568ce4dd2c08f89f5579a51106..1a27aa1bd91bddc44cd8786caa5e212a53ac5eeb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 Version 0.127:
 
+libdw: new function dwarf_getsrcdirs
+
 libdwfl: new functions dwfl_module_addrsym, dwfl_report_begin_add
 
 Version 0.126:
index 5d55dee2eb622c88a33f45fab346d2e7287184b6..50dc089ebe4695eda4f46d4136bf0fc298cf857e 100644 (file)
@@ -1,5 +1,19 @@
+2007-04-16  Roland McGrath  <roland@redhat.com>
+
+       * libdw.map (ELFUTILS_0.127): Add dwfl_module_address_section.
+
 2007-04-05  Roland McGrath  <roland@redhat.com>
 
+       * dwarf_getsrcdirs.c: New file.
+       * Makefile.am (libdw_a_SOURCES): Add it.
+       * libdw.h: Declare dwarf_getsrcdirs.
+       * libdw.map (ELFUTILS_0.127): Add it.
+
+       * libdwP.h (struct Dwarf_Files_s): New member ndirs.
+       * dwarf_getsrclines.c (dwarf_getsrclines): Don't clobber NDIRLIST to
+       zero before we use it to check for DWARF_E_INVALID_DIR_IDX.
+       Save DIRARRAY in the Dwarf_Files.
+
        * dwarf_ranges.c (dwarf_ranges): Don't sign-extend 32-bit BEGIN
        address to check for all-ones base address entry.  Check directly.
        Reported by SĂ©bastien DuguĂ© <sebastien.dugue@bull.net>.
index 04d15bbf2231a743e64646a6a72940b4f4bcda3b..62057dc9057cc70aaa53e1911dbd405862747b1b 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -73,7 +73,7 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \
                  dwarf_lineendsequence.c dwarf_lineblock.c \
                  dwarf_lineprologueend.c dwarf_lineepiloguebegin.c \
                  dwarf_onesrcline.c dwarf_formblock.c \
-                 dwarf_getsrcfiles.c dwarf_filesrc.c \
+                 dwarf_getsrcfiles.c dwarf_filesrc.c dwarf_getsrcdirs.c \
                  dwarf_getlocation.c dwarf_getstring.c dwarf_offabbrev.c \
                  dwarf_getaranges.c dwarf_onearange.c dwarf_getarangeinfo.c \
                  dwarf_getarange_addr.c dwarf_getattrs.c dwarf_formflag.c \
diff --git a/libdw/dwarf_getsrcdirs.c b/libdw/dwarf_getsrcdirs.c
new file mode 100644 (file)
index 0000000..74786dd
--- /dev/null
@@ -0,0 +1,69 @@
+/* Find include directories in source file information.
+   Copyright (C) 2007 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   In addition, as a special exception, Red Hat, Inc. gives You the
+   additional right to link the code of Red Hat elfutils with code licensed
+   under any Open Source Initiative certified open source license
+   (http://www.opensource.org/licenses/index.php) which requires the
+   distribution of source code with any binary distribution and to
+   distribute linked combinations of the two.  Non-GPL Code permitted under
+   this exception must only link to the code of Red Hat elfutils through
+   those well defined interfaces identified in the file named EXCEPTION
+   found in the source code files (the "Approved Interfaces").  The files
+   of Non-GPL Code may instantiate templates or use macros or inline
+   functions from the Approved Interfaces without causing the resulting
+   work to be covered by the GNU General Public License.  Only Red Hat,
+   Inc. may make changes or additions to the list of Approved Interfaces.
+   Red Hat's grant of this exception is conditioned upon your not adding
+   any new exceptions.  If you wish to add a new Approved Interface or
+   exception, please contact Red Hat.  You must obey the GNU General Public
+   License in all respects for all of the Red Hat elfutils code and other
+   code used in conjunction with Red Hat elfutils except the Non-GPL Code
+   covered by this exception.  If you modify this file, you may extend this
+   exception to your version of the file, but you are not obligated to do
+   so.  If you do not wish to provide this exception without modification,
+   you must delete this exception statement from your version and license
+   this file solely under the GPL without exception.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libdwP.h"
+
+
+int
+dwarf_getsrcdirs (files, result, ndirs)
+     Dwarf_Files *files;
+     const char *const **result;
+     size_t *ndirs;
+{
+  if (files == NULL)
+    return -1;
+
+  *result = (void *) &files->info[files->nfiles];
+  *ndirs = files->ndirs;
+  return 0;
+}
index 2aed5d938f473a64d7d10a21e9378921d50b9852..666cca22f9011e4d965696bb86c668506a12dfa3 100644 (file)
@@ -1,5 +1,5 @@
 /* Return line number information of CU.
-   Copyright (C) 2004, 2005 Red Hat, Inc.
+   Copyright (C) 2004, 2005, 2007 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
 
@@ -256,13 +256,10 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
       /* Rearrange the list in array form.  */
       struct dirlist **dirarray
        = (struct dirlist **) alloca (ndirlist * sizeof (*dirarray));
-      while (ndirlist-- > 0)
-       {
-         dirarray[ndirlist] = dirlist;
-         dirlist = dirlist->next;
-       }
+      for (unsigned int n = ndirlist; n-- > 0; dirlist = dirlist->next)
+       dirarray[n] = dirlist;
 
-        /* Now read the files.  */
+      /* Now read the files.  */
       struct filelist null_file =
        {
          .info =
@@ -618,8 +615,11 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
       /* Put all the files in an array.  */
       Dwarf_Files *files = libdw_alloc (dbg, Dwarf_Files,
                                        sizeof (Dwarf_Files)
-                                       + nfilelist * sizeof (Dwarf_Fileinfo),
-                                      1);
+                                       + nfilelist * sizeof (Dwarf_Fileinfo)
+                                       + (ndirlist + 1) * sizeof (char *),
+                                       1);
+      const char **dirs = (void *) &files->info[nfilelist];
+
       files->nfiles = nfilelist;
       while (nfilelist-- > 0)
        {
@@ -628,6 +628,12 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
        }
       assert (filelist == NULL);
 
+      /* Put all the directory strings in an array.  */
+      files->ndirs = ndirlist;
+      for (unsigned int i = 0; i < ndirlist; ++i)
+       dirs[i] = dirarray[i]->dir;
+      dirs[ndirlist] = NULL;
+
       /* Remember the debugging descriptor.  */
       files->dbg = dbg;
 
index d44f427dad5057800603d84be030763c6b75f0b5..968e73a2d9d9493bf461573af279e6f791803928 100644 (file)
@@ -1,5 +1,5 @@
 /* Interfaces for libdw.
-   Copyright (C) 2002, 2004, 2005, 2006 Red Hat, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, 2007 Red Hat, Inc.
    This file is part of Red Hat elfutils.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -473,6 +473,14 @@ extern const char *dwarf_linesrc (Dwarf_Line *line,
 extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
                                  Dwarf_Word *mtime, Dwarf_Word *length);
 
+/* Return the directory list used in the file information extracted.
+   (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
+   (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
+   encoded by the compiler.  */
+extern int dwarf_getsrcdirs (Dwarf_Files *files,
+                            const char *const **result, size_t *ndirs)
+  __nonnull_attribute__ (2, 3);
+
 
 /* Return location expression, decoded as a list of operations.  */
 extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
index e79b6e01abb191945e1e112131f3e69f8716e534..654bdfba4feab79f4583120f996b929f87699385 100644 (file)
@@ -156,8 +156,11 @@ ELFUTILS_0.126 {
 
 ELFUTILS_0.127 {
   global:
+    dwarf_getsrcdirs;
+
     dwfl_module_addrsym;
     dwfl_report_begin_add;
+    dwfl_module_address_section;
 
   local:
     *;
index 8baa3fa33e70baaa003b3dba8afffe34d3f681f1..f069075b98e34de7b460a06865c7e859b5df50f1 100644 (file)
@@ -1,5 +1,5 @@
 /* Internal definitions for libdwarf.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -209,6 +209,7 @@ struct Dwarf_Abbrev
 struct Dwarf_Files_s
   {
     Dwarf *dbg;
+    unsigned int ndirs;
     unsigned int nfiles;
     struct Dwarf_Fileinfo_s
     {
@@ -216,6 +217,7 @@ struct Dwarf_Files_s
       Dwarf_Word mtime;
       Dwarf_Word length;
     } info[0];
+    /* nfiles of those, followed by char *[ndirs].  */
   };
 typedef struct Dwarf_Fileinfo_s Dwarf_Fileinfo;
 
index 6f8ff4bcd04f25e2cc127acb1f7a83e8db68f803..3e030d305652e6e6c56dab867d26eb6b33f3cd4e 100644 (file)
@@ -1,3 +1,14 @@
+2007-04-16  Roland McGrath  <roland@redhat.com>
+
+       * derelocate.c (cache_sections): Apply bias to sh_addr.
+       (compare_secrefs): Fix address comparison to avoid signed overflow.
+       (find_section): New function, broken out of ...
+       (dwfl_module_relocate_address): ... here, call it.
+       (check_module): New function, broken out of ...
+       (dwfl_module_relocate_address): ... here, call it.
+       (dwfl_module_address_section): New function.
+       * libdwfl.h: Declare it.
+
 2007-03-26  Roland McGrath  <roland@redhat.com>
 
        * dwfl_module.c (__libdwfl_module_free): Free MOD itself.
index d110299e804c7b77ac67e030b33826000bf608bf..cd01a7e80de9026d8817006e6e4bec87a36ccb5f 100644 (file)
@@ -75,7 +75,14 @@ compare_secrefs (const void *a, const void *b)
   struct secref *const *p1 = a;
   struct secref *const *p2 = b;
 
-  return (*p1)->start - (*p2)->start;
+  /* No signed difference calculation is correct here, since the
+     terms are unsigned and could be more than INT64_MAX apart.  */
+  if ((*p1)->start < (*p2)->start)
+    return -1;
+  if ((*p1)->start > (*p2)->start)
+    return 1;
+
+  return 0;
 }
 
 static int
@@ -120,8 +127,8 @@ cache_sections (Dwfl_Module *mod)
          struct secref *newref = alloca (sizeof *newref);
          newref->scn = scn;
          newref->name = name;
-         newref->start = shdr->sh_addr;
-         newref->end = shdr->sh_addr + shdr->sh_size;
+         newref->start = shdr->sh_addr + mod->symfile->bias;
+         newref->end = newref->start + shdr->sh_size;
          newref->next = refs;
          refs = newref;
          ++nrefs;
@@ -224,25 +231,41 @@ dwfl_module_relocation_info (Dwfl_Module *mod, unsigned int idx,
   return sections->refs[idx].name;
 }
 
-int
-dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
+/* Check that MOD is valid and make sure its relocation has been done.  */
+static bool
+check_module (Dwfl_Module *mod)
 {
-  if (mod == NULL)
-    return -1;
+  if (INTUSE(dwfl_module_getsymtab) (mod) < 0)
+    {
+      Dwfl_Error error = dwfl_errno ();
+      if (error != DWFL_E_NO_SYMTAB)
+       {
+         __libdwfl_seterrno (error);
+         return true;
+       }
+    }
 
   if (mod->dw == NULL)
     {
       Dwarf_Addr bias;
       if (INTUSE(dwfl_module_getdwarf) (mod, &bias) == NULL)
-       return -1;
+       {
+         Dwfl_Error error = dwfl_errno ();
+         if (error != DWFL_E_NO_DWARF)
+           {
+             __libdwfl_seterrno (error);
+             return true;
+           }
+       }
     }
 
-  if (mod->e_type != ET_REL)
-    {
-      *addr -= mod->debug.bias;
-      return 0;
-    }
+  return false;
+}
 
+/* Find the index in MOD->reloc_info.refs containing *ADDR.  */
+static int
+find_section (Dwfl_Module *mod, Dwarf_Addr *addr)
+{
   if (unlikely (mod->reloc_info == NULL) && cache_sections (mod) < 0)
     return -1;
 
@@ -275,4 +298,34 @@ dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
   __libdw_seterrno (DWARF_E_NO_MATCH);
   return -1;
 }
+
+int
+dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
+{
+  if (check_module (mod))
+    return -1;
+
+  if (mod->e_type != ET_REL)
+    {
+      *addr -= mod->debug.bias;
+      return 0;
+    }
+
+  return find_section (mod, addr);
+}
 INTDEF (dwfl_module_relocate_address)
+
+Elf_Scn *
+dwfl_module_address_section (Dwfl_Module *mod, Dwarf_Addr *address,
+                            Dwarf_Addr *bias)
+{
+  if (check_module (mod))
+    return NULL;
+
+  int idx = find_section (mod, address);
+  if (idx < 0)
+    return NULL;
+
+  *bias = mod->symfile->bias;
+  return mod->reloc_info->refs[idx].scn;
+}
index c36f9206bc3f104c168c1acb0d9663040781bda6..ee1b505467fb57b13211293ee63224cc111de909 100644 (file)
@@ -346,6 +346,15 @@ extern const char *dwfl_module_addrsym (Dwfl_Module *mod, GElf_Addr address,
                                        GElf_Sym *sym, GElf_Word *shndxp)
   __nonnull_attribute__ (3);
 
+/* Find the ELF section that *ADDRESS lies inside and return it.
+   On success, adjusts *ADDRESS to be relative to the section,
+   and sets *BIAS to the difference between addresses used in
+   the returned section's headers and run-time addresses.  */
+extern Elf_Scn *dwfl_module_address_section (Dwfl_Module *mod,
+                                            Dwarf_Addr *address,
+                                            Dwarf_Addr *bias)
+  __nonnull_attribute__ (2, 3);
+
 
 /*** Dwarf access functions ***/
 
index f57c6e10f4f4c52a6f187d6ab6b8250dbae21728..df78c086aa5d0f014ebf294602762e3f1972859f 100644 (file)
@@ -1,3 +1,14 @@
+2007-04-16  Roland McGrath  <roland@redhat.com>
+
+       * dwfl-addr-sect.c: New file.
+       * Makefile.am (noinst_PROGRAMS): Add it.
+       (dwfl_addr_sect_LDADD): New variable.
+
+2007-04-05  Roland McGrath  <roland@redhat.com>
+
+       * get-files.c: Test dwarf_getsrcdirs.
+       * run-get-files.sh: Update expected output.
+
 2007-04-01  Roland McGrath  <roland@redhat.com>
 
        * run-allregs.sh: Updated expected output for x86_64.
index c72ea3ce6cba380936bba7636773ea9e0c8f40ef..0715fff83a3eca7f48992fb1d211ae5462afa81f 100644 (file)
@@ -58,7 +58,8 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
                  get-aranges allfcts line2addr addrscopes funcscopes \
                  show-abbrev hash newscn ecp dwflmodtest \
                  find-prologues funcretval allregs rdwrmmap \
-                 dwfl-bug-addr-overflow arls dwfl-bug-fd-leak
+                 dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \
+                 dwfl-addr-sect
 # get-ciefde
 asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
            asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -204,6 +205,7 @@ rdwrmmap_LDADD = $(libelf)
 dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
 arls_LDADD = $(libelf) $(libmudflap)
 dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
+dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
 
 CLEANFILES = xxx *.gcno *.gcda *gconv
 
diff --git a/tests/dwfl-addr-sect.c b/tests/dwfl-addr-sect.c
new file mode 100644 (file)
index 0000000..b1f29f7
--- /dev/null
@@ -0,0 +1,85 @@
+/* Test program for libdwfl ... foo
+   Copyright (C) 2007 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <string.h>
+#include <error.h>
+#include <locale.h>
+#include <argp.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <dwarf.h>
+
+
+static void
+handle_address (Dwfl *dwfl, Dwarf_Addr address)
+{
+  Dwfl_Module *mod = dwfl_addrmodule (dwfl, address);
+  Dwarf_Addr adjusted = address;
+  Dwarf_Addr bias;
+  Elf_Scn *scn = dwfl_module_address_section (mod, &adjusted, &bias);
+  if (scn == NULL)
+    error (EXIT_FAILURE, 0, "%#" PRIx64 ": dwfl_module_address_section: %s",
+          address, dwfl_errmsg (-1));
+  printf ("address %#" PRIx64 " => module \"%s\" section %zu + %#" PRIx64 "\n",
+         address,
+         dwfl_module_info (mod, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+         elf_ndxscn (scn), adjusted);
+}
+
+int
+main (int argc, char **argv)
+{
+  /* We use no threads here which can interfere with handling a stream.  */
+  (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+  /* Set locale.  */
+  (void) setlocale (LC_ALL, "");
+
+  int remaining;
+  Dwfl *dwfl = NULL;
+  (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+  assert (dwfl != NULL);
+
+  int result = 0;
+  for (; remaining < argc; ++remaining)
+    {
+      char *endp;
+      uintmax_t addr = strtoumax (argv[remaining], &endp, 0);
+      if (endp != argv[remaining])
+       handle_address (dwfl, addr);
+      else
+       result = 1;
+    }
+
+  dwfl_end (dwfl);
+
+  return result;
+}
index 69dd77eeb5588f933a9df84fefe8ce6b14b00d78..81daea276b367452dd07147dbd275ec986ef6751 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004, 2005 Red Hat, Inc.
+/* Copyright (C) 2002, 2004, 2005, 2007 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -84,6 +84,22 @@ main (int argc, char *argv[])
              break;
            }
 
+         const char *const *dirs;
+         size_t ndirs;
+         if (dwarf_getsrcdirs (files, &dirs, &ndirs) != 0)
+           {
+             printf ("%s: cannot get include directories\n", argv[cnt]);
+             result = 1;
+             break;
+           }
+
+         if (dirs[0] == NULL)
+           puts (" dirs[0] = (null)");
+         else
+           printf (" dirs[0] = \"%s\"\n", dirs[0]);
+         for (size_t i = 1; i < ndirs; ++i)
+           printf (" dirs[%zu] = \"%s\"\n", i, dirs[i]);
+
          for (size_t i = 0; i < nfiles; ++i)
            printf (" file[%zu] = \"%s\"\n", i,
                    dwarf_filesrc (files, i, NULL, NULL));
index e301f8d4a58bd5749ca569ee5da09395c11dfcf3..7d51f5fc7846088e172ef756e556660a393139cf 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1999, 2000, 2002, 2004, 2005 Red Hat, Inc.
+# Copyright (C) 1999, 2000, 2002, 2004, 2005, 2007 Red Hat, Inc.
 # This file is part of Red Hat elfutils.
 # Written by Ulrich Drepper <drepper@redhat.com>, 1999.
 #
@@ -30,9 +30,11 @@ testfiles testfile testfile2
 
 testrun_compare ./get-files testfile testfile2 <<\EOF
 cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 191
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
  file[0] = "???"
  file[1] = "/home/drepper/gnu/new-bu/build/ttt/m.c"
 cuhl = 11, o = 114, asz = 4, osz = 4, ncu = 5617
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
  file[0] = "???"
  file[1] = "/home/drepper/gnu/new-bu/build/ttt/b.c"
  file[2] = "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h"
@@ -46,9 +48,11 @@ cuhl = 11, o = 114, asz = 4, osz = 4, ncu = 5617
  file[10] = "/usr/include/_G_config.h"
  file[11] = "/usr/include/gconv.h"
 cuhl = 11, o = 412, asz = 4, osz = 4, ncu = 5752
+ dirs[0] = "/home/drepper/gnu/new-bu/build/ttt"
  file[0] = "???"
  file[1] = "/home/drepper/gnu/new-bu/build/ttt/f.c"
 cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 2418
+ dirs[0] = "/shoggoth/drepper"
  file[0] = "???"
  file[1] = "/shoggoth/drepper/b.c"
  file[2] = "/home/geoffk/objs/laurel-000912-branch/lib/gcc-lib/powerpc-unknown-linux-gnu/2.96-laurel-000912/include/stddef.h"
@@ -59,9 +63,11 @@ cuhl = 11, o = 0, asz = 4, osz = 4, ncu = 2418
  file[7] = "/usr/include/libio.h"
  file[8] = "/usr/include/_G_config.h"
 cuhl = 11, o = 213, asz = 4, osz = 4, ncu = 2521
+ dirs[0] = "/shoggoth/drepper"
  file[0] = "???"
  file[1] = "/shoggoth/drepper/f.c"
 cuhl = 11, o = 267, asz = 4, osz = 4, ncu = 2680
+ dirs[0] = "/shoggoth/drepper"
  file[0] = "???"
  file[1] = "/shoggoth/drepper/m.c"
 EOF