1 /* Test program for dwfl_getmodules bug.
2 Copyright (C) 2008 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/>. */
19 #include ELFUTILS_HEADER(dwfl)
23 static const Dwfl_Callbacks callbacks =
25 .find_elf = dwfl_linux_proc_find_elf,
26 .find_debuginfo = dwfl_standard_find_debuginfo,
30 iterate (Dwfl_Module *mod __attribute__ ((unused)),
31 void **userdata __attribute__ ((unused)),
32 const char *name __attribute__ ((unused)),
33 Dwarf_Addr base, void *arg)
38 if (dwfl_addrmodule (arg, 0x2100) == NULL)
39 error (1, 0, "dwfl_addrmodule: %s", dwfl_errmsg (-1));
41 return DWARF_CB_ABORT;
47 Dwfl *dwfl = dwfl_begin (&callbacks);
49 dwfl_report_module (dwfl, "m1", 0, 0x1000);
50 dwfl_report_module (dwfl, "m2", 0x2000, 0x3000);
51 dwfl_report_module (dwfl, "m3", 0x4000, 0x5000);
53 dwfl_report_end (dwfl, NULL, NULL);
55 ptrdiff_t offset = dwfl_getmodules (dwfl, &iterate, dwfl, 0);
57 error (1, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
59 offset = dwfl_getmodules (dwfl, &iterate, NULL, offset);
61 error (1, 0, "dwfl_getmodules (%d): %s", (int) offset, dwfl_errmsg (-1));