summaryrefslogtreecommitdiffstats
path: root/tests/varlocs.c
Commit message (Collapse)AuthorAgeFilesLines
* Add helper function for basenameKhem Raj2023-12-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | musl does not provide GNU version of basename and lately have removed the definiton from string.h [1] which exposes this problem. It can be made to work by providing a local implementation of basename which implements the GNU basename behavior, this makes it work across C libraries which have POSIX implementation only. [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7 * lib/system.h (xbasename): New static inline functions. Poison basename. * libdw/dwarf_getsrc_file.c (dwarf_getsrc_file): Use xbasename. * libdwfl/core-file.c (dwfl_core_file_report): Likewise. * libdwfl/dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Likewise. * libdwfl/dwfl_segment_report_module.c (dwfl_segment_report_module): Likewise. * libdwfl/find-debuginfo.c (find_debuginfo_in_path): Likewise. * libdwfl/link_map.c (report_r_debug): Likewise. * libdwfl/linux-kernel-modules.c (try_kernel_name): Likewise. * src/addr2line.c (print_dwarf_function): Likewise. (print_src): Likewise. * src/ar.c (do_oper_insert): Likewise. And cast away const in entry.key assignment. * src/nm.c (show_symbols): Use xbasename. * src/stack.c (module_callback): Likewise. * src/strip.c (handle_elf): Likewise. * tests/show-die-info.c: Include system.h. (dwarf_tag_string): Use xbasename. * tests/varlocs.c: Likewise. * debuginfod/debuginfod.cxx: Move include system.h to the end. (register_file_name): Rename basename to filename. Signed-off-by: Khem Raj <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Handle DW_OP_GNU_uninit in dwarf_getlocationMark Wielaard2023-02-141-0/+6
| | | | | | | | | | | dwarf_getlocation would return an error when it saw a DW_OP_GNU_uninit. Handle it by simply recognizing as a no argument operation. DW_OP_GNU_uninit is emitted by GCC as a marker to flag the location expression as referring to an uninitialized value. Signed-off-by: Mark Wielaard <[email protected]>
* tests: varlocs workaround format-overflow errorsMark Wielaard2021-12-091-6/+5
| | | | | | | | | | | | | | | | In function ‘printf’, inlined from ‘handle_attr’ at varlocs.c:932:3: error: ‘%s’ directive argument is null [-Werror=format-overflow=] The warning is technically correct. A %s argument should not be NULL. Although in practice all implementations will print it as "(null)". Workaround this by simply changing the dwarf string functions to return an "<unknown>" string. The test is for the correct names, either "(null)" or "<unknown>" would make it fail (also remove a now unnecessary assert, the switch statement will check for unknown opcodes anyway). Signed-off-by: Mark Wielaard <[email protected]>
* tests: fix spelling typos in error diagnostics and commentsDmitry V. Levin2020-12-121-1/+1
| | | | | | | | | | | | | | | Cannnot -> Cannot decriptors -> descriptors experssions -> expressions explit -> explicit falg -> flag irrelevent -> irrelevant mininum -> minimum outselves -> ourselves proces -> process versio -> version Signed-off-by: Dmitry V. Levin <[email protected]>
* Consolidate error.h inclusion in system.hRoss Burton2018-07-051-1/+1
| | | | | | | | | error.h isn't standard and so isn't part of the musl C library. To easy future porting, consolidate the inclusion of error.h into system.h. https://sourceware.org/bugzilla/show_bug.cgi?id=21008 Signed-off-by: Ross Burton <[email protected]>
* tests: Limit varlocs print_expr_block recursion depth.Mark Wielaard2018-06-291-13/+17
| | | | | | | | This is only useful for bad DWARF where an expression block might have an expression that refers to a DIE that contains the expression block itself. But that might happen with bad DWARF generated by a fuzzer. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Don't assert on bad DW_OP_GNU_parameter_ref target in varlocs.Mark Wielaard2018-06-111-1/+2
| | | | | | | | If the target of a DW_OP_GNU_parameter_ref isn't a DW_TAG_formal_parameter that is bad data (which varlocs should error on). But it isn't an internal consistency check (for which varlocs should assert). Signed-off-by: Mark Wielaard <[email protected]>
* tests: Fix cfi_debug_bias assert in varlocs.Mark Wielaard2018-06-101-1/+2
| | | | | | | | It is only a consistency issue if we actually have an cfi_debug and the cfi_debug_bias is not zero (because they come from the same file as the other debug data). Signed-off-by: Mark Wielaard <[email protected]>
* tests: Use error, not assert, when trying to print a non-base type DIE.Mark Wielaard2018-06-081-1/+2
| | | | | | | | | When using the varlocs test with a fuzzer using assert for internal sanity checks is great to find issues. But when encountering bad data using an assert is wrong. Just use error to show we handle the data correctly (by reporting it is bad, instead of crashing). Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Handle .debug_loclists in dwarf_getlocation.Mark Wielaard2018-05-301-8/+31
| | | | | | | | | | | | | 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]>
* libdw: Support DW_OP_addrx/constx and split DWARF addrx/constx support.Mark Wielaard2018-05-251-14/+51
| | | | | | | | | | | | | | | | | | | DW_OP_addrx/constx and GNU DebugFission DW_OP_GNU_addr/const_index take as argument an index into the .debug_addr section for the associated CU. This index gets resolved through dwarf_getlocation_attr. A new fake addr CU is created per Dwarf for use with this new attribute. For split DWARF files, the IDX_debug_addr gets replaced with the skeleton section and the addr base is resolved immediately when constructing the split DWARF CU. Move __libdw_cu_addr_base to libdwP.h to share with eu-readelf. Also make it possible to resolve addrx[1234]/GNU_addr_index also as constant indexes to (also) show when displaying these attributes in eu-readelf. A new varlocs tests is added to test the resolving for both the DWARF4 and DWARF5 DW_OP variants. And now that addrx forms are resolved in split DWARF files add the new DIEs with "single ranges" (those DIEs that have a lowpc/highpc attribute pair) to run-all-dwarf-ranges.sh. Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Add new DWARF5 Dwarf expression operations.Mark Wielaard2018-03-111-2/+23
| | | | | | | | | | | | | | DW_OP_implicit_pointer, DW_OP_entry_value, DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_xderef_type, DW_OP_convert and OP_reinterpret are implemented like their pre-DWARF5 GNU variants. DW_OP_xderef_type is implemented as a (non-CU relative) variant of DW_OP_deref_type. DW_OP_addrx and DW_OP_constx are recognized but not interpreted yet. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Fix cfi_debug => cfi_debug_bias typo in varlocs assert.Mark Wielaard2017-11-161-1/+1
| | | | | | | | | | We want to check whether the bias is zero, not whether we have dwarf debug_frame cfi. This triggered on a ppc64/ppc64le self-check since it has both debug_frame and eh_frame cfi (other arches often only have eh_frame). Signed-off-by: Mark Wielaard <[email protected]>
* tests: Add varlocs-self and exprlocs-self tests.Mark Wielaard2017-11-151-16/+48
| | | | | | | | | Make sure the testcases (library functions they use) don't crash, triggers self-check/asserts or leaks memory under valgrind. This also helps making sure newer DWARF constructs are handled (when building with -gdwarf-5). Signed-off-by: Mark Wielaard <[email protected]>
* libdw: Handle DW_OP_GNU_variable_value.Mark Wielaard2017-11-101-5/+223
| | | | | | | | | | | | | Handle DW_OP_GNU_variable_value in dwarf_getlocation[_attr,_die]. DW_OP_GNU_variable_value takes one argument a DIE reference that describes a value given by a location of const_value attribute. To test handling of the new operand the varlocs test is adapted to print out all DIEs and attributes with expressions or location lists (the original varlocs test only prints out variables and arguments of function DIEs). Signed-off-by: Mark Wielaard <[email protected]>
* tests: Init local variable enctype before use in print_base_type varlocs.c.Chih-Hung Hsieh2015-09-071-1/+1
| | | | | | | clang compiler static analysis failed. Signed-off-by: Chih-Hung Hsieh <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
* Publish known-dwarf.hPetr Machata2015-03-311-9/+7
| | | | | | | | | | | | | - Make the macro names properly scoped (DWARF_ALL_KNOWN_* and DWARF_ONE_KNOWN_*). - Simplify the calling convention: don't keep track of the comment associated with the enumerator, always use the non-_DESC DWARF_ONE_KNOWN_* callback. - Install known-dwarf.h alongside libdw.h and others. Signed-off-by: Petr Machata <[email protected]>
* libdw: Handle empty location expression for (indirect) DIE locations.Mark Wielaard2013-12-131-1/+1
| | | | | | | | | | When dwarf_getlocation_implicit_pointer and dwarf_getlocation_attr refer to a DIE that doesn't contain a DW_AT_location then don't generate an error, but return an empty location expression to signal the actual value pointed to is not available. This isn't invalid DWARF. Also make sure that __libdw_intern_expression handles empty location expressions. Signed-off-by: Mark Wielaard <[email protected]>
* tests: Add new varlocs test for dwarf_getlocation* functions.Mark Wielaard2013-09-061-0/+826
This tests the new dwarf_getlocations, dwarf_getlocation_attr and dwarf_getlocation_die functions. But it is also an example of how to handle location expressions and which libdw functions can be used to access all information required to interpret each DW_OP. It might make sense to extend this test/example into a program that verifies various properties of DWARF expressions. Signed-off-by: Mark Wielaard <[email protected]>