1 /* Copyright (C) 2002, 2004, 2005, 2007 Red Hat, Inc.
2 This file is part of elfutils.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
5 This file is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 elfutils is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include ELFUTILS_HEADER(dw)
30 main (int argc, char *argv[])
35 for (cnt = 1; cnt < argc; ++cnt)
37 int fd = open (argv[cnt], O_RDONLY);
39 Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
42 printf ("%s not usable\n", argv[cnt]);
55 while (dwarf_nextcu (dbg, o, &ncu, &cuhl, &ao, &asz, &osz) == 0)
57 printf ("cuhl = %zu, o = %llu, asz = %hhu, osz = %hhu, ncu = %llu\n",
58 cuhl, (unsigned long long int) ao,
59 asz, osz, (unsigned long long int) ncu);
62 Dwarf_Die *die = dwarf_offdie (dbg, o + cuhl, &die_mem);
65 printf ("%s: cannot get CU die\n", argv[cnt]);
72 if (dwarf_getsrcfiles (die, &files, &nfiles) != 0)
74 printf ("%s: cannot get files\n", argv[cnt]);
79 const char *const *dirs;
81 if (dwarf_getsrcdirs (files, &dirs, &ndirs) != 0)
83 printf ("%s: cannot get include directories\n", argv[cnt]);
89 puts (" dirs[0] = (null)");
91 printf (" dirs[0] = \"%s\"\n", dirs[0]);
92 for (size_t i = 1; i < ndirs; ++i)
93 printf (" dirs[%zu] = \"%s\"\n", i, dirs[i]);
95 for (size_t i = 0; i < nfiles; ++i)
96 printf (" file[%zu] = \"%s\"\n", i,
97 dwarf_filesrc (files, i, NULL, NULL));