blob: 7972edc9d443b7cac47e81c5f7c867725668643d [file] [log] [blame]
Petr Machatad24c7bf2009-05-07 20:58:19 +02001/* Test program for dwfl_module_return_value_location.
2 Copyright (C) 2009 Red Hat, Inc.
Mark Wielaardde2ed972012-06-05 17:15:16 +02003 This file is part of elfutils.
Petr Machatad24c7bf2009-05-07 20:58:19 +02004
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.
Petr Machatad24c7bf2009-05-07 20:58:19 +02009
Mark Wielaardde2ed972012-06-05 17:15:16 +020010 elfutils is distributed in the hope that it will be useful, but
Petr Machatad24c7bf2009-05-07 20:58:19 +020011 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.
Petr Machatad24c7bf2009-05-07 20:58:19 +020014
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/>. */
Petr Machatad24c7bf2009-05-07 20:58:19 +020017
18#include <config.h>
19#include ELFUTILS_HEADER(dw)
20#include <dwarf.h>
21#include <sys/types.h>
22#include <sys/stat.h>
23#include <fcntl.h>
24#include <stdio.h>
25#include <stdint.h>
26#include <stdlib.h>
27
28int
29main (int argc __attribute__ ((unused)), char *argv[])
30{
31 const char *name = argv[1];
32 ptrdiff_t cuoff = strtol (argv[2], NULL, 0);
33
34 int fd = open (name, O_RDONLY);
35 Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
36
37 Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, cuoff, &cudie_mem);
38 int mac (Dwarf_Macro *macro, void *data __attribute__ ((unused)))
39 {
40 unsigned int opcode;
41 dwarf_macro_opcode (macro, &opcode);
42 if (opcode == DW_MACINFO_define)
43 {
44 const char *value;
45 dwarf_macro_param2 (macro, NULL, &value);
46 puts (value);
47 }
48 return DWARF_CB_ABORT;
49 }
50
51 ptrdiff_t off = 0;
52 while ((off = dwarf_getmacros (cudie, mac, NULL, off)) > 0)
53 ;
54
55 return 0;
56}