|
Packit Service |
97d2fb |
/* Test program for dwfl_getmodules bug.
|
|
Packit Service |
97d2fb |
Copyright (C) 2008 Red Hat, Inc.
|
|
Packit Service |
97d2fb |
This file is part of elfutils.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
This file is free software; you can redistribute it and/or modify
|
|
Packit Service |
97d2fb |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
97d2fb |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit Service |
97d2fb |
(at your option) any later version.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
elfutils is distributed in the hope that it will be useful, but
|
|
Packit Service |
97d2fb |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
97d2fb |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
97d2fb |
GNU General Public License for more details.
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
You should have received a copy of the GNU General Public License
|
|
Packit Service |
97d2fb |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
#include <config.h>
|
|
Packit Service |
97d2fb |
#include ELFUTILS_HEADER(dwfl)
|
|
Packit Service |
97d2fb |
#include "system.h"
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static const Dwfl_Callbacks callbacks =
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
.find_elf = dwfl_linux_proc_find_elf,
|
|
Packit Service |
97d2fb |
.find_debuginfo = dwfl_standard_find_debuginfo,
|
|
Packit Service |
97d2fb |
};
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static int
|
|
Packit Service |
97d2fb |
iterate (Dwfl_Module *mod __attribute__ ((unused)),
|
|
Packit Service |
97d2fb |
void **userdata __attribute__ ((unused)),
|
|
Packit Service |
97d2fb |
const char *name __attribute__ ((unused)),
|
|
Packit Service |
97d2fb |
Dwarf_Addr base, void *arg)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
if (base != 0x2000)
|
|
Packit Service |
97d2fb |
return DWARF_CB_OK;
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
if (dwfl_addrmodule (arg, 0x2100) == NULL)
|
|
Packit Service |
97d2fb |
error (1, 0, "dwfl_addrmodule: %s", dwfl_errmsg (-1));
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return DWARF_CB_ABORT;
|
|
Packit Service |
97d2fb |
}
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
int
|
|
Packit Service |
97d2fb |
main (void)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
Dwfl *dwfl = dwfl_begin (&callbacks);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
dwfl_report_module (dwfl, "m1", 0, 0x1000);
|
|
Packit Service |
97d2fb |
dwfl_report_module (dwfl, "m2", 0x2000, 0x3000);
|
|
Packit Service |
97d2fb |
dwfl_report_module (dwfl, "m3", 0x4000, 0x5000);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
dwfl_report_end (dwfl, NULL, NULL);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
ptrdiff_t offset = dwfl_getmodules (dwfl, &iterate, dwfl, 0);
|
|
Packit Service |
97d2fb |
if (offset <= 0)
|
|
Packit Service |
97d2fb |
error (1, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
offset = dwfl_getmodules (dwfl, &iterate, NULL, offset);
|
|
Packit Service |
97d2fb |
if (offset != 0)
|
|
Packit Service |
97d2fb |
error (1, 0, "dwfl_getmodules (%d): %s", (int) offset, dwfl_errmsg (-1));
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
dwfl_end (dwfl);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return 0;
|
|
Packit Service |
97d2fb |
}
|