|
Packit Service |
97d2fb |
/* Test program for fetching debuginfo with debuginfo-server.
|
|
Packit Service |
97d2fb |
Copyright (C) 2019 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 |
|
|
Packit Service |
97d2fb |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
97d2fb |
# include <config.h>
|
|
Packit Service |
97d2fb |
#endif
|
|
Packit Service |
97d2fb |
#include <stdio.h>
|
|
Packit Service |
97d2fb |
#include ELFUTILS_HEADER(dwfl)
|
|
Packit Service |
97d2fb |
#include <elf.h>
|
|
Packit Service |
97d2fb |
#include <dwarf.h>
|
|
Packit Service |
97d2fb |
#include <argp.h>
|
|
Packit Service |
97d2fb |
#include <assert.h>
|
|
Packit Service |
97d2fb |
#include <string.h>
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
static const char *debuginfo_path = "";
|
|
Packit Service |
97d2fb |
static const Dwfl_Callbacks cb =
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
NULL,
|
|
Packit Service |
97d2fb |
dwfl_standard_find_debuginfo,
|
|
Packit Service |
97d2fb |
NULL,
|
|
Packit Service |
97d2fb |
(char **)&debuginfo_path,
|
|
Packit Service |
97d2fb |
};
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
int
|
|
Packit Service |
97d2fb |
main (int argc __attribute__ ((unused)), char **argv)
|
|
Packit Service |
97d2fb |
{
|
|
Packit Service |
97d2fb |
int expect_pass = strcmp(argv[3], "0");
|
|
Packit Service |
97d2fb |
Dwarf_Addr bias = 0;
|
|
Packit Service |
97d2fb |
Dwfl *dwfl = dwfl_begin(&cb;;
|
|
Packit Service |
97d2fb |
dwfl_report_begin(dwfl);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* Open an executable. */
|
|
Packit Service |
97d2fb |
Dwfl_Module *mod = dwfl_report_offline(dwfl, argv[2], argv[2], -1);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
/* The corresponding debuginfo will not be found in debuginfo_path
|
|
Packit Service |
97d2fb |
(since it's empty), causing the server to be queried. */
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
Dwarf *res = dwfl_module_getdwarf(mod, &bias);
|
|
Packit Service |
97d2fb |
if (expect_pass)
|
|
Packit Service |
97d2fb |
assert(res);
|
|
Packit Service |
97d2fb |
else
|
|
Packit Service |
97d2fb |
assert(!res);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
dwfl_end (dwfl);
|
|
Packit Service |
97d2fb |
|
|
Packit Service |
97d2fb |
return 0;
|
|
Packit Service |
97d2fb |
}
|