diff options
| author | Mark Wielaard <[email protected]> | 2018-04-07 23:48:27 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2018-05-30 00:16:15 +0200 |
| commit | 4dc31fde711c69fed6acfe18e7e57dfd5665cebb (patch) | |
| tree | 1f8cac4d4e3a2da4314cf37410dd94cd418d47d8 /tests | |
| parent | 7cfe2c16f9ddaa7478a2d97dd893c6b89080020a (diff) | |
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 <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 8 | ||||
| -rwxr-xr-x | tests/run-varlocs.sh | 152 | ||||
| -rw-r--r-- | tests/varlocs.c | 39 |
3 files changed, 191 insertions, 8 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 6e366eb3..3ed88f6d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2018-04-07 Mark Wielaard <[email protected]> + + * run-varlocs.sh: Run on testfileranges5.debug and + testsplitfileranges5.debug. + * varlocs.c (is_debug): New bool. + (print_expr): Don't fail on missing CFI for is_debug. + (main): Parse --debug, set is_debug. + 2018-04-12 Mark Wielaard <[email protected]> * run-readelf-loc.sh: Add new testcases. diff --git a/tests/run-varlocs.sh b/tests/run-varlocs.sh index 2781fef4..8426d20d 100755 --- a/tests/run-varlocs.sh +++ b/tests/run-varlocs.sh @@ -124,6 +124,158 @@ module 'testfile_implicit_pointer' frame_base: {call_frame_cfa {bregx(7,8)}} EOF +# Multi CU DWARF5. See run-dwarf-ranges.sh. +testfiles testfileranges5.debug +testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfileranges5.debug <<\EOF +module 'testfileranges5.debug' +[c] CU 'hello.c'@0 + [2a] function 'no_say'@401160 + frame_base: {call_frame_cfa {...}} + [4a] parameter 'prefix' + [401160,401169) {reg5} + [401169,40116a) {entry_value(1) {reg5}, stack_value} + [40116a,401175) {reg5} + [401175,40117a) {entry_value(1) {reg5}, stack_value} + [59] variable 'world' + [401160,40117a) {addr(0x402004), stack_value} + [bd] function 'main'@401050 + frame_base: {call_frame_cfa {...}} + [dd] parameter 'argc' + [401050,401062) {reg5} + [401062,401067) {entry_value(1) {reg5}, stack_value} + [ec] parameter 'argv' + [401050,401066) {reg4} + [401066,401067) {entry_value(1) {reg4}, stack_value} + [fb] inlined function 'subject'@401053 + [117] parameter 'count' + [401053,40105f) {reg5} + [120] parameter 'word' + [401053,40105f) {reg0} + [168] function 'subject'@401150 + frame_base: {call_frame_cfa {...}} + [183] parameter 'word' + [401150,401160) {reg5} + [18a] parameter 'count' + [401150,401160) {reg4} +module 'testfileranges5.debug' +[1ab] CU 'world.c'@401180 + [1cd] function 'no_main'@4011d0 + frame_base: {call_frame_cfa {...}} + [1ef] parameter 'argc' + [4011d0,4011e2) {reg5} + [4011e2,4011e7) {entry_value(1) {reg5}, stack_value} + [1fe] parameter 'argv' + [4011d0,4011e6) {reg4} + [4011e6,4011e7) {entry_value(1) {reg4}, stack_value} + [20d] inlined function 'no_subject'@4011d3 + [229] parameter 'count' + [4011d3,4011df) {reg5} + [232] parameter 'word' + [4011d3,4011df) {reg0} + [28d] function 'say'@401180 + frame_base: {call_frame_cfa {...}} + [2af] parameter 'prefix' + [401180,40118e) {reg5} + [40118e,40119c) {reg3} + [40119c,4011a7) {entry_value(1) {reg5}, stack_value} + [4011a7,4011b5) {reg3} + [4011b5,4011c0) {entry_value(1) {reg5}, stack_value} + [2be] variable 'world' + [401193,40119b) {reg0} + [4011a7,4011b4) {reg0} + [2ce] inlined function 'happy'@40119b + [2e6] parameter 'w' + [4011a7,4011b4) {reg0} + [2ef] inlined function 'sad'@40119b + [303] parameter 'c' + [40119b,4011a6) {reg0} + [4011a6,4011a7) {entry_value(1) {reg5}} + [4011b4,4011bf) {reg0} + [36b] function 'no_subject'@4011c0 + frame_base: {call_frame_cfa {...}} + [386] parameter 'word' + [4011c0,4011d0) {reg5} + [38d] parameter 'count' + [4011c0,4011d0) {reg4} +EOF + +# Multi CU Split DWARF5. See run-dwarf-ranges.sh. +# Note that the DIE numbers change, but the actual location addresses are +# the same as above, even though the representation is totally different. +testfiles testfilesplitranges5.debug +testfiles testfile-ranges-hello5.dwo testfile-ranges-world5.dwo +testrun_compare ${abs_top_builddir}/tests/varlocs --debug -e testfilesplitranges5.debug <<\EOF +module 'testfilesplitranges5.debug' +[14] CU 'hello.c' + [1d] function 'no_say'@401160 + frame_base: {call_frame_cfa {...}} + [33] parameter 'prefix' + [401160,401169) {reg5} + [401169,40116a) {entry_value(1) {reg5}, stack_value} + [40116a,401175) {reg5} + [401175,40117a) {entry_value(1) {reg5}, stack_value} + [3c] variable 'world' + [401160,40117a) {addr: 0x402004, stack_value} + [7e] function 'main'@401050 + frame_base: {call_frame_cfa {...}} + [94] parameter 'argc' + [401050,401062) {reg5} + [401062,401067) {entry_value(1) {reg5}, stack_value} + [9d] parameter 'argv' + [401050,401066) {reg4} + [401066,401067) {entry_value(1) {reg4}, stack_value} + [a6] inlined function 'subject'@401053 + [bb] parameter 'count' + [401053,40105f) {reg5} + [c1] parameter 'word' + [401053,40105f) {reg0} + [f6] function 'subject'@401150 + frame_base: {call_frame_cfa {...}} + [10a] parameter 'word' + [401150,401160) {reg5} + [111] parameter 'count' + [401150,401160) {reg4} +module 'testfilesplitranges5.debug' +[14] CU 'world.c' + [1d] function 'no_main'@4011d0 + frame_base: {call_frame_cfa {...}} + [35] parameter 'argc' + [4011d0,4011e2) {reg5} + [4011e2,4011e7) {entry_value(1) {reg5}, stack_value} + [3e] parameter 'argv' + [4011d0,4011e6) {reg4} + [4011e6,4011e7) {entry_value(1) {reg4}, stack_value} + [47] inlined function 'no_subject'@4011d3 + [5c] parameter 'count' + [4011d3,4011df) {reg5} + [62] parameter 'word' + [4011d3,4011df) {reg0} + [a7] function 'say'@401180 + frame_base: {call_frame_cfa {...}} + [c2] parameter 'prefix' + [401180,40118e) {reg5} + [40118e,40119c) {reg3} + [40119c,4011a7) {entry_value(1) {reg5}, stack_value} + [4011a7,4011b5) {reg3} + [4011b5,4011c0) {entry_value(1) {reg5}, stack_value} + [cb] variable 'world' + [401193,40119b) {reg0} + [4011a7,4011b4) {reg0} + [d5] inlined function 'happy'@40119b + [e3] parameter 'w' + [4011a7,4011b4) {reg0} + [e9] inlined function 'sad'@40119b + [f3] parameter 'c' + [40119b,4011a6) {reg0} + [4011a6,4011a7) {entry_value(1) {reg5}} + [4011b4,4011bf) {reg0} + [147] function 'no_subject'@4011c0 + frame_base: {call_frame_cfa {...}} + [15b] parameter 'word' + [4011c0,4011d0) {reg5} + [162] parameter 'count' + [4011c0,4011d0) {reg4} +EOF # DW_OP_addrx and DW_OP_constx testcases. # 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; |
