blob: aa8030e1d05f2e5f259884cf2d877b7ffdb304a0 [file] [log] [blame]
Roland McGrathba949b32007-01-10 20:44:29 +00001/* Test program for libdwfl basic module tracking, relocation.
2 Copyright (C) 2007 Red Hat, Inc.
Mark Wielaardde2ed972012-06-05 17:15:16 +02003 This file is part of elfutils.
Roland McGrathba949b32007-01-10 20:44:29 +00004
Mark Wielaardde2ed972012-06-05 17:15:16 +02005 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.
Roland McGrathba949b32007-01-10 20:44:29 +00009
Mark Wielaardde2ed972012-06-05 17:15:16 +020010 elfutils is distributed in the hope that it will be useful, but
Roland McGrathba949b32007-01-10 20:44:29 +000011 WITHOUT ANY WARRANTY; without even the implied warranty of
Mark Wielaardde2ed972012-06-05 17:15:16 +020012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
Roland McGrathba949b32007-01-10 20:44:29 +000014
Mark Wielaardde2ed972012-06-05 17:15:16 +020015 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/>. */
Roland McGrathba949b32007-01-10 20:44:29 +000017
18#include <config.h>
19#include <assert.h>
20#include <inttypes.h>
21#include <stdio.h>
22#include <stdio_ext.h>
23#include <error.h>
24#include <locale.h>
25#include ELFUTILS_HEADER(dwfl)
26
27
28static const Dwfl_Callbacks offline_callbacks =
29 {
30 .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
31 .section_address = INTUSE(dwfl_offline_section_address),
32 };
33
34
35int
36main (void)
37{
38 /* We use no threads here which can interfere with handling a stream. */
39 (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
40
41 /* Set locale. */
42 (void) setlocale (LC_ALL, "");
43
44 Dwfl *dwfl = dwfl_begin (&offline_callbacks);
45 assert (dwfl != NULL);
46
47 Dwfl_Module *high = dwfl_report_module (dwfl, "high",
48 UINT64_C (0xffffffff00010000),
49 UINT64_C (0xffffffff00020000));
50 assert (high);
51 Dwfl_Module *low = dwfl_report_module (dwfl, "low",
52 UINT64_C (0x00010000),
53 UINT64_C (0x00020000));
54 assert (low);
55 Dwfl_Module *middle = dwfl_report_module (dwfl, "middle",
56 UINT64_C (0xffff00010000),
57 UINT64_C (0xffff00020000));
58 assert (middle);
59
60 int ret = dwfl_report_end (dwfl, NULL, NULL);
61 assert (ret == 0);
62
63 Dwfl_Module *mod = dwfl_addrmodule (dwfl, UINT64_C (0xffffffff00010123));
64 assert (mod == high);
65 mod = dwfl_addrmodule (dwfl, UINT64_C (0x00010123));
66 assert (mod == low);
67 mod = dwfl_addrmodule (dwfl, UINT64_C (0xffff00010123));
68 assert (mod == middle);
69
70 dwfl_end (dwfl);
71
72 return 0;
73}