1 /* Copyright (C) 2002, 2005 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)
32 callback (Dwarf *dbg, Dwarf_Global *gl, void *arg __attribute__ ((unused)))
34 int result = DWARF_CB_OK;
36 printf (" [%2d] \"%s\", die: %llu, cu: %llu\n",
37 globcnt++, gl->name, (unsigned long long int) gl->die_offset,
38 (unsigned long long int) gl->cu_offset);
42 if (dwarf_offdie (dbg, gl->cu_offset, &cu_die) == NULL
43 || (cuname = dwarf_diename (&cu_die)) == NULL)
45 puts ("failed to get CU die");
46 result = DWARF_CB_ABORT;
49 printf ("CU name: \"%s\"\n", cuname);
53 if (dwarf_offdie (dbg, gl->die_offset, &die) == NULL
54 || (diename = dwarf_diename (&die)) == NULL)
56 puts ("failed to get object die");
57 result = DWARF_CB_ABORT;
60 printf ("object name: \"%s\"\n", diename);
67 main (int argc, char *argv[])
72 for (cnt = 1; cnt < argc; ++cnt)
74 int fd = open (argv[cnt], O_RDONLY);
75 Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
78 printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1));
86 if (dwarf_getpubnames (dbg, callback, NULL, 0) != 0)
88 printf ("dwarf_get_pubnames didn't return zero: %s\n",