summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Access deleted files by /dev/PID/mem.jankratochvil/devmemJan Kratochvil2014-02-229-9/+172
| | | | | | | | | | | | | | | | | | | | | | | | | | | libdwfl/ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Access deleted files by /dev/PID/mem. * dwfl_module.c (dwfl_report_module_pid): New function. * dwfl_module_getdwarf.c (open_elf): Call __libdw_open_file_at_offset. * libdwfl.h (dwfl_report_module_pid): New declaration. * libdwflP.h (struct Dwfl_Module): New field pid. (INTDECL (dwfl_report_module_pid)): New. * linux-proc-maps.c (proc_maps_report): New variable first_high. (proc_maps_report) (report): Possibly call dwfl_report_module_pid. tests/ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Access deleted files by /dev/PID/mem. * Makefile.am (check_PROGRAMS): Add deleted and deleted-lib.so. (TESTS, EXTRA_DIST): Add run-deleted.sh. (deleted_LDADD, deleted_lib_so_LDFLAGS, deleted_lib_so_CFLAGS): New. * deleted-lib.c: New file. * deleted.c: New file. * run-deleted.sh: New file. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Fix abort() on missing section headers.Jan Kratochvil2014-02-221-3/+3
| | | | | | | | | | libdw/ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Fix abort() on missing section headers. * dwarf_begin_elf.c (check_section): Replace abort call by a return; Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* Extend __libdw_open_file and elf_begin as *_at_offset.Jan Kratochvil2014-02-226-8/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ./ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Extend __libdw_open_file and elf_begin as *_at_offset. * NEWS (libelf): New, with elf_begin_at_offset. libdwfl/ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Extend __libdw_open_file and elf_begin as *_at_offset. * libdwflP.h (__libdw_open_file_at_offset): New declaration. * open.c (__libdw_open_file): Rename to ... (__libdw_open_file_at_offset): ... here and add parameters start_offset and maximum_size. (__libdw_open_file): New wrapper of it. libelf/ 2014-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> Extend __libdw_open_file and elf_begin as *_at_offset. * elf_begin.c (elf_begin): Rename to ... (elf_begin_at_offset): ... here and add parameters start_offset and maximum_size. (elf_begin): New wrapper of it. * libelf.h (elf_begin_at_offset): New declaration. * libelf.map (ELFUTILS_1.7): New, with elf_begin_at_offset. Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* readelf: Robustify print_phdr program interpreter printing.Mark Wielaard2014-02-072-1/+9
| | | | | | | | Check phdr->p_filesz and make sure interpreter string is zero terminated before calling printf. Reported-by: Florian Weimer <fweimer@redhat.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdw: Read DW_AT_decl_file/line/column as unsignedJosh Stone2014-02-053-6/+17
| | | | | | | | | | | | Section 2.14 of the DWARF v3 & v4 standards specifies that all three declaration coordinates are unsigned integer constants. DWARF v2 did not specify signedness. Now dwarf_decl_* use dwarf_formudata to read these values. Also, an assertion on the range of line/column is now a handled error, setting DWARF_E_INVALID_DWARF for values greater than INT_MAX. Signed-off-by: Josh Stone <jistone@redhat.com>
* backends: Make aarch64_regs.c checkable by -WprintfPetr Machata2014-01-302-22/+21
|
* backends: Add arm frame_nregs and set_initial_registers_tid.Mark Wielaard2014-01-306-2/+87
| | | | | | | | | | | | | This allows CFI unwinding for ARM. It relies on having .debug_frame around which is always the case in our testsuite. All native backtrace tests PASS on arm if debuginfo (for glibc) is installed on the system. Otherwise the tests SKIP. For non-debug unwinding ARM uses EXIDX tables, not .eh_frames, which would have to be translated to CFI to do unwinding without .debug_frame available. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* backends: arm_cfi SP (r13) is restored from CFA by default.Mark Wielaard2014-01-304-1/+13
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* backends: Update arm_reloc.def.Mark Wielaard2014-01-302-2/+83
| | | | | | | | | The elflint self test now also checks ET_REL files. Update the list of relocation types to include all known relocations from elf.h. R_ARM_SWI24 was obsolete and is now named R_ARM_TLS_DESC. The only other relocation used in the dynamic linker is R_ARM_IRELATIVE. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Use -Wformat=2 by default for all files.Mark Wielaard2014-01-3012-92/+145
| | | | | | | | This just makes sure that all format strings are given as literals to printf like functions so the compiler can see and check them. Remove all no_Wformat, add -Wformat=2 unconditionally to AM_CFLAGS. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Add -i, --inlines. Show inlined call frames using DWARF debuginfo.Mark Wielaard2014-01-277-79/+271
| | | | | | | | | | Using dwarf_getscopes_die we can get all scopes that make up the current subprogram representing an address. Using the call_file/line/column attributes we can also show the source locations of these "inlined" calls. Includes a test that shows that when DWARF debuginfo is available all inlined function call frames and their source location can be shown. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Initialize -n maxframes to 256 by default.Mark Wielaard2014-01-272-2/+10
| | | | | | | Make -n default just 256 frames, 2048 was too big. Also Document magic number used in frames.allocated initialization. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Add -d, --debugname. Lookup DWARF debuginfo name for frame address.Mark Wielaard2014-01-279-5/+196
| | | | | | | Includes test that shows -d matches the function name that corresponds to the actual source line we report with -s for a frame address. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* addr2line: handle_address initialize scopes to NULL.Mark Wielaard2014-01-242-1/+5
| | | | | | | | | dwarf_getscopes returns the number of scope DIEs containing a PC address. It returns -1 for errors or 0 if no scopes match PC. If dwarf_getscopes returned 0, then scopes will not be allocated and handle_address might free the uninitialized scopes pointer. Make sure it always has a defined value. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* robustify: libelf gelf define INVALID_NDX macro.Jakub Jelinek2014-01-2320-103/+74
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* robustify: libelf.Jakub Jelinek2014-01-239-18/+139
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* robustify: strip.Roland McGrath2014-01-232-31/+63
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* robustify: readelf.Roland McGrath2014-01-232-26/+60
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* robustify: elflint.Jakub Jelinek2014-01-232-28/+86
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* robustify: Use gelf_fsize instead of relying on shdr->sh_entsize.Petr Machata2014-01-234-13/+46
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Reduce the total number of self-test files and add ET_REL files.Mark Wielaard2014-01-203-6/+26
| | | | | | | | | | | | | | Some self tests would run for a really long time (especially under valgrind) because we included all libebl backends in the list (there are 12 backends). Now only test two explicitly. Also there were no ET_REL files in the self test file list. So add two ET_REL files. The total number of self test files is now 12. run-nm-self.sh would run 4 * 3 * 3 * 22 = 792 tests (on all self test files). Reduce the number of different files to test to 3 (one ET_EXEC, one ET_DYN and one ET_REL file). Reducing the number of test runs to 99. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: run-backtrace-demangle.sh check exitcode and max number of frames.Mark Wielaard2014-01-202-2/+15
| | | | | | | | | | There can be more than 3 frames, but depending on the system/installed glibc we might not be able to unwind fully till the end. cxxfunc -> f -> main Expect to see the top two and a warning that there are more frames (exit code 1) Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Fix false FAILs on testsuite with ulimit -c unlimited.Jan Kratochvil2014-01-182-3/+11
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* backends: aarch64_check_special_symbol check shdr is not NULL before usage.Mark Wielaard2014-01-172-3/+11
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* readelf: print_debug_macro_section clear vendor array before use.Mark Wielaard2014-01-172-0/+6
| | | | | | | | Not setting a vendor code before use would be invalid which we tried to catch. But to detect that we do need to initialize the vendor array to zero first. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* lib: Add missing config.h #include to crc32_file.c.Lei Zhang2014-01-172-0/+8
| | | | | | Without config.h, there is no possibility of large file support. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Fix corruption of non-C++ symbols by the demangler.Jan Kratochvil2014-01-159-13/+127
| | | | Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
* tests: backtrace-subr.sh (check_native_core) should check core file name.Matthias Klose2014-01-072-0/+11
| | | | | | | Needed when /proc/sys/kernel/core_uses_pid is set to 0. Try to rename the core file, and if it does still fail, skip the test. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Only skip reset of return register for non-CIE-return regno (ppc64).elfutils-0.158Mark Wielaard2014-01-052-2/+8
| | | | | | | | | | | | | For PPC64 we skip resetting the return register if it is already set. This is because on PPC64 there are two DWARF registers numbers that can represent the same register. Setting the return address again confuses the unwinder. But we do want to reset it if the register number (non-translated by the ppc64 ebl) is equal to the actual register number as set in the CIE as return address. This happens on older toolchains in .debug_frame where the return address is set to 108, but the ebl abi_cfi also sets register number 65. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Don't use ptrace detach stopped trick. Raise can return.Mark Wielaard2014-01-044-25/+15
| | | | | | | | | | On older kernels the ptrace detach stop trick doesn't work reliably. Just keep the child processes attached and stopped during the tests, dwfl_linux_proc_attach will handle that fine now. Also on older kernels raise would sometimes return anyway and cause a spurious assert. Just ignore it. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* backends: Add PPC64 machine_flag_check.Mark Wielaard2014-01-043-2/+18
| | | | | | | | | | To distinguish between the current PPC64 ELF ABI and the revised ELFv2 ABI that will not use function descriptors binutils started to emit the version (currently 1) in the ehdr e_flags. Recognize all valid versions (0, 1 or 2) in elflint by adding the hook ppc64_machine_flag_check. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: backtrace-subr.sh skip check_native_core test if core ulimit fails.Mark Wielaard2014-01-042-1/+7
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* tests: Simplify backtrace-dwarf (gcc cleanup-13.c) testcase.Mark Wielaard2014-01-042-21/+9
| | | | | | | | The testcase originally came from GCC which was testing the runtime unwinder using _Unwind_ForcedUnwind. Since we are using our own external unwinder we can just abort at the right place and unwind from there. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Prepare 0.158 release.Mark Wielaard2014-01-0311-383/+762
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* backends: Add aarch64 abi_cfi.Mark Wielaard2014-01-039-3/+175
| | | | | | | | Setup initial CIE values for aarch64 for use with dwarf_frame functions. Register info prefix should be the empty string (not NULL) when not used. Add an EM_AARCH64 testcase to tests/run-addrcfi.sh to check both issues. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Show and handle -r,--raw even without USE_DEMANGLE.Mark Wielaard2014-01-032-6/+6
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack.c (print_frames): Print 0x before build-id hex-offset.Mark Wielaard2014-01-022-1/+6
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Allow -n 0 for unlimited frames. Make default 2048 frames.Mark Wielaard2014-01-022-15/+41
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: linux-pid-attach.c (dwfl_linux_proc_attach): Use and check strtolMark Wielaard2014-01-022-2/+13
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.Mark Wielaard2013-12-3117-85/+157
| | | | | | | | | | | | | | Rewrite __libdwfl_attach_state_for_pid and __libdwfl_attach_state_for_core as public functions and don't call them from dwfl_linux_proc_report and dwfl_core_file_report anymore. This lets the user attach state explicitly independ from how the dwfl modules have been reported. Since attaching state is an explicit action now the error can be returned directly and we don't need to keep track of process_attach_error. dwfl_linux_proc_attach lets the user can tell libdwfl whether caller takes care of ptrace attaching and stopping the threads under inspection, or whether the callback needs to take care of that and detaching again. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: dwfl_linux_proc_find_elf should only return regular files.Mark Wielaard2013-12-312-0/+14
| | | | | | | | | | | When the dwfl_linux_proc_find_elf callback is used together with the dwfl_linux_proc_report callback that reads /proc/PID/maps files we might see and try to open special character device files that cannot be normally read and processed by libelf (and might hang the library on the initial open or read from the file). Make sure we only try to open and return regular files. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Fix memory leak in linux-core-attach. Allow reiterating threads.Mark Wielaard2013-12-312-8/+25
| | | | | | | | | core_next_thread would allocate a new thread_arg each time but never free it. We only need one active thread_arg to keep the state. Free it when there are no more threads. It was also not possible to start walking all threads in the core again. Just reset the note offset at the start. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: Fix build_id memory leak in dwfl_segment_report_module.Mark Wielaard2013-12-312-2/+13
| | | | | | | | | | | | We might already have allocated memory to hold the build_id early in consider_notes when we called consider_phdr for the program headers we've read from the image. We would leak that memory when we don't use it then because we return early/fail. This can be because either we didn't find the correct bias or we skip the module because it would conflict in address space with any already existing module of DWFL. In both cases explicitly free the build_id memory. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Add -l, --list-modules. Show module memory map, build-id and files.Mark Wielaard2013-12-312-17/+92
| | | | | | | | Use to list modules detected for process or core file by stack program and to see build-ids and which main elf and debug files were recognized by libdwfl callbacks. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Improve error checking and exit code handling.Mark Wielaard2013-12-312-22/+97
| | | | | | | | | | | | | Check up front whether we attached correctly, if not error out. Make sure callbacks report -1 only on real errors and DWARF_CB_ABORT if exiting early (but not in error). Handle all errors from frame callback in print_frames after printing of good frames. Print as much information as possible like tid, address and module name if known with error messages. Only exit with exit code zero if everything went fine. Exit with error code one if there were any non-fatal errors. Exit with error code two if no frames could be printed or a fatal error occurred. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Add --quiet to not resolve addresses, add --raw to not demangle.Mark Wielaard2013-12-313-3/+57
| | | | | | | | | Resolving addresses to function symbol names can be expensive. Use -q to only print addresses (use together with --build-id to process later). Demangle names by default, but add the -r option to not demangle and show the raw names. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Simplify argument parsing. Don't use dwfl_standard_argp.Mark Wielaard2013-12-312-28/+120
| | | | | | | | | | | | We were using dwfl_standard_argp but trying to add our own and substract some options from it. dwfl_standard_argp also handles kernel, modules, executables without state and process maps that stack doesn't support. That made argp parsing somewhat ugly and meant our --help and --usage didn't really match. Just handle the dwfl_standard_argp options we do want directly ('-p', '--core', '-e' and '--debuginfo-path'). That way we can also do sanity checking on the options given. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: -b, --build-id shows module build-id, load address and pc offset.Mark Wielaard2013-12-312-4/+35
| | | | | | A convenient format for offline processing of the backtrace. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* stack: Add new '-n MAXFRAMES' option. Resolve addresses after unwind.Mark Wielaard2013-12-312-63/+127
| | | | | | | | | Limit the number of frames printed per thread (defaults to 64) and resolve addresses to names, modules and source after unwinding so the thread is only stopped for the minimum time needed to do the actual unwinding. The thread doesn't need to wait for the lookups and printing of information. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libdwfl: linux-pid-attach.c: Report actual PID (Tgid) to dwfl_attach_state.Mark Wielaard2013-12-252-0/+29
| | | | Signed-off-by: Mark Wielaard <mjw@redhat.com>