summaryrefslogtreecommitdiffstats
path: root/libdwfl
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into robustifyupstream/robustifyMark Wielaard2014-01-052-2/+8
|\
| * 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 <[email protected]>
* | Merge branch 'master' into robustifyMark Wielaard2014-01-0327-237/+3332
|\|
| * libdwfl: linux-pid-attach.c (dwfl_linux_proc_attach): Use and check strtolMark Wielaard2014-01-022-2/+13
| | | | | | | | Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.Mark Wielaard2013-12-3110-85/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]>
| * 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 <[email protected]>
| * 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 <[email protected]>
| * 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 <[email protected]>
| * libdwfl: linux-pid-attach.c: Report actual PID (Tgid) to dwfl_attach_state.Mark Wielaard2013-12-252-0/+29
| | | | | | | | Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Make sure to set the CFI return register only once (for ppc64).Mark Wielaard2013-12-252-2/+30
| | | | | | | | | | | | | | | | On PPC64 there are two DWARF registers numbers that can represent the same register. If that register is the CIE return register then we only want to set it once. The second setting will confuse the unwinder. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Add dwfl_getthread_frames.Mark Wielaard2013-12-236-0/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dwfl_getthread_frames is a convenience function for when the user is only interested in one specific thread id of a process. It can be implemented by a simple wrapper function that removes an extra callback layer just to filter on thread id. But it also provides an optimized path to getting access to just one particular Dwfl_Thread of the Dwfl process by providing and (optional) new callback for the state provider. The pid_thread_callbacks now provide an (optional) pid_getthread that doesn't need to travers all threads anymore. Which is implemented for the linux-pid-attach provider. stack now uses this to implement a new '-1' option that shows just one specific thread of a process. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Correct nested asprintf result check in report_kernel_archive.Mark Wielaard2013-12-212-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Because of wrongly placed parens the result of only one asprintf call was checked correctly. Causing dwfl_linux_kernel_report_offline to return ENOMEM. Rewrite nested if unlikely check into separate if statements to make clear what is actually being checked and what the actual unlikely condition is. Reported against systemtap "build-id difficulties with hand-built kernels" https://sourceware.org/bugzilla/show_bug.cgi?id=16358 Reported-by: Crestez Dan Leonard <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.Mark Wielaard2013-12-207-113/+327
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some arches like ppc64 use function descriptor values instead of function addresses causing matching of names and addresses to fail when using dwfl_module_getsym or dwfl_module_addrsym. Add ebl hook to resolve any function descriptor values found in non-ET_REL modules. The new function dwfl_module_getsym_info doesn't adjust the symbol value in any way, but returns the adjusted and/or resolved address associated with the symbol separately. The new function dwfl_module_addrinfo resolves against both the address associated with the symbol (which could be the function entry address) value and the adjusted st_value. So that it is easy to resolve and match either function descriptors and/or function entry addresses. Since these new functions also return more information they replace the dwfl_module_getsym_elf and dwfl_module_addrsym_elf functions that never made it into a released elfutils version. addr2line and readelf now use the new functions when looking up functions names. addr2line will now also display the section the address was found in when given -x. Extra testcases were added for both addr2line and the dwflsyms testscase. Signed-off-by: Mark Wielaard <[email protected]>
| * Use executable_for_core in dwfl_build_id_find_elf.Jan Kratochvil2013-12-183-27/+25
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * unwinder: s390 and s390xJan Kratochvil2013-12-184-14/+106
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Fix forgotten call of ebl_dwarf_to_regno.Jan Kratochvil2013-12-172-1/+5
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * libdwfl: linux-pid-attach.c (pid_next_thread): Use rewinddir on first call.Mark Wielaard2013-12-172-0/+8
| | | | | | | | | | | | | | | | dwfl_getthreads would otherwise fail to report any threads after it was called once. Reported-by: Masatake YAMATO <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Add dwfl_module_getsymtab_first_global.Mark Wielaard2013-12-165-3/+44
| | | | | | | | | | | | | | | | | | | | New function that provides the index after the last non-local symbol as returned by dwfl_module_getsym and dwfl_module_getsym_info. Allows users to first search through all global symbols before searching the local symbols in the table like dwfl_module_addrsym and dwfl_module_addrsym_info do as optimization. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: Fix various frame related memory leaks.Mark Wielaard2013-12-163-0/+14
| | | | | | | | | | | | | | | | | | | | The result of dwarf_cfi_addrframe should have been freed when done. Dwfl_Module cached the reloc_info and the eh_cfi it which also should have been released when disposing of the module. Reported-by: Masatake YAMATO <[email protected]> Tested-by: Masatake YAMATO <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
| * unwinder: ppc and ppc64Jan Kratochvil2013-12-154-0/+48
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Introduce process_attach_error.Jan Kratochvil2013-11-305-21/+47
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * libdwfl: Add dwfl_module_addrsym_elf and dwfl_module_getsym_elf.Mark Wielaard2013-11-277-49/+108
| | | | | | | | | | | | | | | | | | | | | | Introduce two new functions that also return the elf associated with a symbol to make symbol section indexing work for non-special sections. Simplify code by removing dwfl_file where appropriate and just track Elf directly. Document limitations of shndx with existing dwfl_module_addrsym and dwfl_module_getsym. Extend dwflsyms testcase to check some more symbol and section (index) properties. Signed-off-by: Mark Wielaard <[email protected]>
| * Fix non-build-id core files on build-id systemJan Kratochvil2013-11-212-3/+11
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Verify file vs. core build-id, when both availableJan Kratochvil2013-11-212-5/+31
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * link_map: Use proper bias, not l_addrJan Kratochvil2013-11-214-9/+27
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Compatibility with older kernels such as RHEL-6.Jan Kratochvil2013-11-192-4/+20
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * libdwfl: Fix and test aux_sym address_sync with relocated ELFJosh Stone2013-11-182-14/+36
| | | | | | | | | | | | | | | | | | | | The aux_sym address_sync already worked with a full prelink, which has .gnu.prelink_undo, but it failed on plain relocations with prelink -r. Now it uses the difference in ehdr.e_entry as a first offset guess, and the tests confirm this seems to work fine. Signed-off-by: Josh Stone <[email protected]>
| * Code cleanup: Remove const in prototypeJan Kratochvil2013-11-144-6/+12
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Fix dwfl_attach_state machine->elfJan Kratochvil2013-11-145-13/+25
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Provide __libdwfl_module_getsym to get dwfl_file *Jan Kratochvil2013-11-134-18/+35
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Fix dwfl_module_addrsym for minidebuginfoJan Kratochvil2013-11-132-7/+28
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Unwinder for x86*.Jan Kratochvil2013-11-0714-18/+2081
| | | | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
| * dwfl_core_file_report: Remove the use of MAX.Jan Kratochvil2013-11-072-1/+5
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * dwfl_core_file_report: Fix a regression of dwfl_core_file_report retvalJan Kratochvil2013-11-072-4/+10
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * dwfl_core_file_report: Fix core files for re-prelink-ed filesJan Kratochvil2013-11-074-3/+36
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * dwfl_core_file_report: Code cleanup: Reindentation.Jan Kratochvil2013-11-072-28/+35
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
| * Fix executable_for_core for non-dwfl_standard_argpJan Kratochvil2013-10-304-9/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ./ 2013-10-30 Jan Kratochvil <[email protected]> * NEWS (Version 0.158): New. libdw/ 2013-10-30 Jan Kratochvil <[email protected]> * libdw.map (ELFUTILS_0.158): New. libdwfl/ 2013-10-30 Jan Kratochvil <[email protected]> * argp-std.c (parse_opt): Use executable parameter of dwfl_core_file_report. * core-file.c (dwfl_core_file_report): Add parameter executable. Set it to DWFL. Add NEW_VERSION for it. (_compat_without_executable_dwfl_core_file_report): New. Twice. * libdwfl.h (dwfl_core_file_report): Add parameter executable, update the function comment. Signed-off-by: Jan Kratochvil <[email protected]>
| * libdwfl: Don't report and abort on non-file mappings in maps.Mark Wielaard2013-10-222-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | proc_maps_report, used for -p or -M, could report modules with names that were not absolute file names (and not the special vdso marker). dwfl_linux_proc_find_elf would abort on such names. This isn't a very nice thing to do in a library. Make sure only real (absolute) file mappings are reported and don't abort when unexpected file names are found, just report failure. Test case with some examples as found in Linux /proc/PID/maps added. Signed-off-by: Mark Wielaard <[email protected]>
* | Merge branch 'master' into robustifyMark Wielaard2013-09-275-4/+31
|\|
| * libdwfl: Fix memory leak in cu.c on bad DWARF.Mark Wielaard2013-09-122-1/+8
| | | | | | | | | | | | If libdw dwarf_offdie fails free cu structure. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl: proc_maps_report should not fclose the given file.Mark Wielaard2013-09-122-1/+5
| | | | | | | | | | | | | | | | | | Calling fclose only on bad_report, but not on other errors or success is confusing. The caller is always responsible for calling fclose on the given file. Otherwise flcose might be called twice (e.g. in dwfl_linux_proc_report). Signed-off-by: Mark Wielaard <[email protected]>
| * Fix typo in dwfl_module_getdwarf.c (find_symtab).Mark Wielaard2013-09-122-1/+6
| | | | | | | | | | | | | | Call elf_getdata with aux_xndxscn, not xndxscn, for aux_symxndxdata. This was a copy/paste error from the code just above for symxndxdata. Signed-off-by: Mark Wielaard <[email protected]>
| * libdwfl/linux-kernel-modules.c (report_kernel): Pass add_p_vaddr as true.Mark Wielaard2013-08-262-1/+12
| | | | | | | | | | | | | | | | | | | | On some architectures (e.g. x86_64) the vmlinux is ET_EXEC, while on others (e.g. ppc64) it is ET_DYN. In both cases the phdr p_vaddr will be non-zero. We want the image to be placed as if it was ET_DYN, so pass true for add_p_vaddr which will do the right thing (in combination with a zero base) in either case. Signed-off-by: Mark Wielaard <[email protected]>
* | Merge branch 'master' into robustifyJan Kratochvil2013-07-253-22/+41
|\|
| * Fix run-unstrip-n.sh regression on CentOS-5 ppc.Jan Kratochvil2013-07-252-21/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | last patch was a bit more heuristic than needed which was found on RHEL-5 ppc (32-bit): FAIL: run-unstrip-n.sh (exit: 1) ================================ --- unstrip.out 2013-07-23 23:23:49.000000000 +0200 +++ - 2013-07-23 23:23:49.434052534 +0200 @@ -4,4 +4,3 @@ 0xfdf0000+0x1c0000 edf3dd232e09d01b90683889bd16b9406c52d4de@0xfdf0184 - - libc.so.6 0xffb0000+0x50000 edec437a85026a1cf8cda94003706202733130c1@0xffb0124 - - ld.so.1 0x10000000+0x20000 979b7a26747cc09bd84a42b311b5288c704baea5@0x10000174 . - [exe] -0xf880000+0x201d4 - /lib/librt.so.1 /usr/lib/debug/lib/librt-2.5.so.debug librt.so.1 Therefore the new code generated this excessive line: 0xf880000+0x201d4 - /lib/librt.so.1 /usr/lib/debug/lib/librt-2.5.so.debug librt.so.1 The first part of debug dump is from DT_DEBUG, second part is from segments: start=0xf880000 end=0xf8a01d4 l_ld=0xfd6fe20 name=/lib/librt.so.1 start=0xfc60000 end=0xfe031e4 l_ld=0xff9e270 name=/lib/libc.so.6 start=0xfe10000 end=0xfe421dc l_ld=0xfddfd98 name=/lib/libpthread.so.0 start=0xffb0000 end=0xfff0668 l_ld=0xffef9ac name=/lib/ld.so.1 module_start=0x100000 module_end=0x110000 dyn_vaddr=0x100ee4 module_start=0xfd50000 module_end=0xfd80000 dyn_vaddr=0xfd6fe20 /lib/librt.so.1 module_start=0xfdb0000 module_end=0xfdf0000 dyn_vaddr=0xfddfd98 /lib/libpthread.so.0 module_start=0xfdf0000 module_end=0xffb0000 dyn_vaddr=0xff9e270 /lib/libc.so.6 module_start=0xffb0000 module_end=0x10000000 dyn_vaddr=0xffef9ac /lib/ld.so.1 module_start=0x10000000 module_end=0x10020000 dyn_vaddr=0x10010850 When comparing conflicts for (found in segments) module_start=0xfd50000 module_end=0xfd80000 dyn_vaddr=0xfd6fe20 /lib/librt.so.1 the code found this line conflicts (and discarded it): start=0xfc60000 end=0xfe031e4 l_ld=0xff9e270 name=/lib/libc.so.6 but it did not discard also conflicting: start=0xf880000 end=0xf8a01d4 l_ld=0xfd6fe20 name=/lib/librt.so.1 So I have changed/improved the algorithm - L_LD can be IMO compared exactly but otherwise the ranges should be compared for every module, not just the first one. Again I am not much happy from this code, it should be using NT_FILE instead, but when we keep compatibility with old OSes elfutils should not regress there. libdwfl/ 2013-07-25 Jan Kratochvil <[email protected]> * dwfl_segment_report_module.c (dwfl_segment_report_module): Check for conflicts all the modules, not just the first one. Compare L_LD if it is equal, not if it is in a module address range. Signed-off-by: Jan Kratochvil <[email protected]>
| * __libdwfl_elf_address_range: Add missing internal_function keyword.Jan Kratochvil2013-07-232-1/+5
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>
* | Merge branch 'master' into robustifyJan Kratochvil2013-07-236-40/+192
|\|
| * Fix false match of non-build-id disk library to build-id memory library.Jan Kratochvil2013-07-236-40/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this patch: Use DT_DEBUG library search first. 8ff862960efb648cdff647d7fad1be5acffe9b11 [patch 2/2] Fix loading core files without build-ids https://lists.fedorahosted.org/pipermail/elfutils-devel/2013-April/003031.html [patch 2/2 v2] Fix loading core files without build-ids https://lists.fedorahosted.org/pipermail/elfutils-devel/2013-May/003065.html has PASS->FAIL regression on CentOS-5 for run-unstrip-n.sh: -actual on CentOS-5 +expected by testcase -0xf77b3000+0x822c - /lib/librt.so.1 - librt.so.1 -0xf7603000+0x15c5c4 - /lib/libc.so.6 - libc.so.6 -0xf75e9000+0x191e4 - /lib/libpthread.so.0 - libpthread.so.0 -0xf77d7000+0x1c670 - /lib/ld-linux.so.2 - ld-linux.so.2 0x8048000+0x2000 f1c600bc36cb91bf01f9a63a634ecb79aa4c3199@0x8048178 . - [exe] +0xf75e9000+0x1a000 29a103420abe341e92072fb14274e250e4072148@0xf75e9164 - - libpthread.so.0 +0xf7603000+0x1b0000 0b9bf374699e141e5dfc14757ff42b8c2373b4de@0xf7603184 - - libc.so.6 +0xf77b3000+0x9000 c6c5b5e35ab9589d4762ac85b4bd56b1b2720e37@0xf77b3164 - - librt.so.1 0xf77d6000+0x1000 676560b1b765cde9c2e53f134f4ee354ea894747@0xf77d6210 . - linux-gate.so.1 +0xf77d7000+0x21000 6d2cb32650054f1c176d01d48713a4a5e5e84c1a@0xf77d7124 - - ld-linux.so.2 Therefore elfutils now incorrectly matches on-disk file without build-id to an in-core (in-memory) file with build-id. In fact due to its known FIXME: This verification gives false positive if in-core ELF had build-id but on-disk ELF does not have any. But we cannot reliably find ELF header and/or the ELF build id just from the link map (and checking core segments is also not reliable). */ So it probably should not be so ignorable as I did, one may want to analyze build-id core files on CentOS-5, not sure. In fact it can be fixed, when we find in dwfl_segment_report_module a module with build-id with conflicts in its address range with existing non-build-id dwfl_link_map_report module we should prefer the build-id module instead. The problem is that once Dwfl_Module is added to Dwfl it cannot be easily removed. Originally elfutils called dwfl_segment_report_module first and then dwfl_link_map_report. Currently the order is dwfl_link_map_report and then dwfl_segment_report_module only for modules missing from dwfl_link_map_report. Patch below unfortunately needs bidirectional negotiation between the two functions, therefore dwfl_link_map_report now no longer adds Dwfl_Modules to Dwfl but it only stores information about them to r_debug_info_module. This information is filtered then by dwfl_segment_report_module and only filtered r_debug_info_module entries get finally added to Dwfl (in dwfl_core_file_report). NT_FILE would make all this magic easy but it is true that on CentOS-5 it definitely does not exist. libdwfl/ 2013-07-23 Jan Kratochvil <[email protected]> * core-file.c (clear_r_debug_info): Close also ELF and FD. (dwfl_core_file_report): Call __libdwfl_report_elf for R_DEBUG_INFO.MODULE. * dwfl_report_elf.c (__libdwfl_elf_address_range): New function from code of ... (__libdwfl_report_elf): ... this function. Call it. * dwfl_segment_report_module.c: Include unistd.h. (dwfl_segment_report_module): Use basename for MODULE->NAME. Clear MODULE if it has no build-id and we have segment with build-id. Ignore this segment only if MODULE still contains valid ELF. * libdwflP.h (__libdwfl_elf_address_range): New declaration. (struct r_debug_info_module): New fields fd, elf, l_addr, start, end and disk_file_has_build_id. (dwfl_link_map_report): Extend the comment. * link_map.c (report_r_debug): Extend the comment. Always fill in new r_debug_info_module. Initialize also the new r_debug_info_module fields. Remove one FIXME comment. Call __libdwfl_elf_address_range instead of __libdwfl_report_elf when R_DEBUG_INFO is not NULL. tests/ 2013-07-23 Jan Kratochvil <[email protected]> * run-unstrip-n.sh (test-core.*): Ignore libc.so.6 entry and order of the entries. Signed-off-by: Jan Kratochvil <[email protected]>
* | Merge branch 'master' into robustifyJan Kratochvil2013-07-1924-394/+1298
|\|
| * __libdwfl_find_elf_build_id: Add missing internal_function keyword.Jan Kratochvil2013-07-192-1/+6
| | | | | | | | Signed-off-by: Jan Kratochvil <[email protected]>