1 /* Test program for libdwfl ... foo
2 Copyright (C) 2007 Red Hat, Inc.
3 This file is part of elfutils.
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/>. */
21 #include <sys/types.h>
23 #include <stdio_ext.h>
29 #include ELFUTILS_HEADER(dwfl)
33 handle_address (Dwfl *dwfl, Dwarf_Addr address)
35 Dwfl_Module *mod = dwfl_addrmodule (dwfl, address);
36 Dwarf_Addr adjusted = address;
38 Elf_Scn *scn = dwfl_module_address_section (mod, &adjusted, &bias);
41 error (0, 0, "%#" PRIx64 ": dwfl_module_address_section: %s",
42 address, dwfl_errmsg (-1));
45 printf ("address %#" PRIx64 " => module \"%s\" section %zu + %#" PRIx64 "\n",
47 dwfl_module_info (mod, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
48 elf_ndxscn (scn), adjusted);
53 main (int argc, char **argv)
55 /* We use no threads here which can interfere with handling a stream. */
56 (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
59 (void) setlocale (LC_ALL, "");
63 (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
64 assert (dwfl != NULL);
67 for (; remaining < argc; ++remaining)
70 uintmax_t addr = strtoumax (argv[remaining], &endp, 0);
71 if (endp != argv[remaining])
72 result |= handle_address (dwfl, addr);