1 /* Copyright (C) 2011 Red Hat, Inc.
2 This file is part of elfutils.
3 Written by Marek Polacek <mpolacek@redhat.com>, 2011.
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/>. */
22 #include ELFUTILS_HEADER(dwfl)
31 main (int argc, char *argv[])
35 for (cnt = 1; cnt < argc; ++cnt)
40 int fd = open64 (argv[cnt], O_RDONLY);
43 printf ("cannot open '%s': %m\n", argv[cnt]);
47 Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
50 printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1));
55 /* Try to use NULL Dwarf object. */
56 const char *str = dwarf_getstring (NULL, offset, &len);
59 /* Use insane offset. */
60 str = dwarf_getstring (dbg, ~0UL, &len);
63 /* Now do some real work. */
64 for (int i = 0; i < 100; ++i)
66 str = dwarf_getstring (dbg, offset, &len);