diff options
author | Mark Wielaard <mark@klomp.org> | 2018-04-07 23:48:27 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-05-30 00:16:15 +0200 |
commit | 4dc31fde711c69fed6acfe18e7e57dfd5665cebb (patch) | |
tree | 1f8cac4d4e3a2da4314cf37410dd94cd418d47d8 /tests/varlocs.c | |
parent | 7cfe2c16f9ddaa7478a2d97dd893c6b89080020a (diff) | |
download | elfutils-4dc31fde711c69fed6acfe18e7e57dfd5665cebb.tar.gz |
libdw: Handle .debug_loclists in dwarf_getlocation.
Handle all new DW_LLE opcodes in .debug_loclists in dwarf_getlocation.
__libdw_read_begin_end_pair_inc now also handles a default location
(which is simply the range [0,-1]). Since expression blocks can now
also come from the .debug_loclists section add a new fake_loclists_cu
necessary for checking bounds while parsing expression blocks.
Adapt varlocs test to handle debug-only files.
Test testfileranges5.debug and testfilesplitranges5.debug with it.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'tests/varlocs.c')
-rw-r--r-- | tests/varlocs.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/tests/varlocs.c b/tests/varlocs.c index 859068d6..31a1069a 100644 --- a/tests/varlocs.c +++ b/tests/varlocs.c @@ -1,5 +1,5 @@ /* Test program for dwarf location functions. - Copyright (C) 2013, 2015, 2017 Red Hat, Inc. + Copyright (C) 2013, 2015, 2017, 2018 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -44,6 +44,7 @@ Dwarf_CFI *cfi_eh; Dwarf_Addr cfi_eh_bias; bool is_ET_REL; +bool is_debug; // Whether the current function has a DW_AT_frame_base defined. // Needed for DW_OP_fbreg. @@ -257,7 +258,7 @@ print_expr (Dwarf_Attribute *attr, Dwarf_Op *expr, Dwarf_Addr addr) error (EXIT_FAILURE, 0, "%s used in CFI", opname); printf ("%s ", opname); - if (cfi_eh == NULL && cfi_debug == NULL) + if (cfi_eh == NULL && cfi_debug == NULL && !is_debug) error (EXIT_FAILURE, 0, "DW_OP_call_frame_cfa used but no cfi found."); Dwarf_Frame *frame; @@ -275,11 +276,11 @@ print_expr (Dwarf_Attribute *attr, Dwarf_Op *expr, Dwarf_Addr addr) print_expr_block (NULL, cfa_ops, cfa_nops, 0); free (frame); } - else if (is_ET_REL) + else if (is_ET_REL || is_debug) { /* XXX In ET_REL files there might be an .eh_frame with relocations we don't handle (e.g. X86_64_PC32). Maybe we should? */ - printf ("{...}\n"); + printf ("{...}"); } else error (EXIT_FAILURE, 0, "dwarf_cfi_addrframe 0x%" PRIx64 ": %s", @@ -1033,12 +1034,34 @@ main (int argc, char *argv[]) which contains an DWARF expression (but not location lists) and print those. Otherwise we process all function DIEs and print all DWARF expressions and location lists associated with - parameters and variables). */ + parameters and variables). It must be the first argument, + or the second, after --debug. */ bool exprlocs = false; - if (argc > 1 && strcmp ("--exprlocs", argv[1]) == 0) + + /* With --debug we ignore not being able to find .eh_frame. + It must come as first argument. */ + is_debug = false; + if (argc > 1) + { + if (strcmp ("--exprlocs", argv[1]) == 0) + { + exprlocs = true; + argv[1] = ""; + } + else if (strcmp ("--debug", argv[1]) == 0) + { + is_debug = true; + argv[1] = ""; + } + } + + if (argc > 2) { - exprlocs = true; - argv[1] = ""; + if (strcmp ("--exprlocs", argv[2]) == 0) + { + exprlocs = true; + argv[2] = ""; + } } int remaining; |