platform/upstream/elfutils.git
10 years agobackends: Add aarch64 abi_cfi.
Mark Wielaard [Fri, 3 Jan 2014 17:15:02 +0000 (18:15 +0100)]
backends: Add aarch64 abi_cfi.

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>
10 years agostack: Show and handle -r,--raw even without USE_DEMANGLE.
Mark Wielaard [Thu, 2 Jan 2014 23:06:31 +0000 (00:06 +0100)]
stack: Show and handle -r,--raw even without USE_DEMANGLE.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agostack.c (print_frames): Print 0x before build-id hex-offset.
Mark Wielaard [Thu, 2 Jan 2014 22:59:41 +0000 (23:59 +0100)]
stack.c (print_frames): Print 0x before build-id hex-offset.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agostack: Allow -n 0 for unlimited frames. Make default 2048 frames.
Mark Wielaard [Thu, 2 Jan 2014 21:31:07 +0000 (22:31 +0100)]
stack: Allow -n 0 for unlimited frames. Make default 2048 frames.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: linux-pid-attach.c (dwfl_linux_proc_attach): Use and check strtol
Mark Wielaard [Thu, 2 Jan 2014 20:17:18 +0000 (21:17 +0100)]
libdwfl: linux-pid-attach.c (dwfl_linux_proc_attach): Use and check strtol

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.
Mark Wielaard [Mon, 30 Dec 2013 21:00:57 +0000 (22:00 +0100)]
libdwfl: Add dwfl_core_file_attach and dwfl_linux_proc_attach.

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>
10 years agolibdwfl: dwfl_linux_proc_find_elf should only return regular files.
Mark Wielaard [Sat, 28 Dec 2013 11:58:10 +0000 (12:58 +0100)]
libdwfl: dwfl_linux_proc_find_elf should only return regular files.

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>
10 years agolibdwfl: Fix memory leak in linux-core-attach. Allow reiterating threads.
Mark Wielaard [Tue, 24 Dec 2013 09:37:58 +0000 (10:37 +0100)]
libdwfl: Fix memory leak in linux-core-attach. Allow reiterating threads.

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>
10 years agolibdwfl: Fix build_id memory leak in dwfl_segment_report_module.
Mark Wielaard [Mon, 23 Dec 2013 22:21:59 +0000 (23:21 +0100)]
libdwfl: Fix build_id memory leak in dwfl_segment_report_module.

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>
10 years agostack: Add -l, --list-modules. Show module memory map, build-id and files.
Mark Wielaard [Sat, 28 Dec 2013 22:25:54 +0000 (23:25 +0100)]
stack: Add -l, --list-modules. Show module memory map, build-id and files.

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>
10 years agostack: Improve error checking and exit code handling.
Mark Wielaard [Fri, 27 Dec 2013 09:49:51 +0000 (10:49 +0100)]
stack: Improve error checking and exit code handling.

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>
10 years agostack: Add --quiet to not resolve addresses, add --raw to not demangle.
Mark Wielaard [Mon, 23 Dec 2013 20:19:05 +0000 (21:19 +0100)]
stack: Add --quiet to not resolve addresses, add --raw to not demangle.

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>
10 years agostack: Simplify argument parsing. Don't use dwfl_standard_argp.
Mark Wielaard [Mon, 23 Dec 2013 09:46:54 +0000 (10:46 +0100)]
stack: Simplify argument parsing. Don't use dwfl_standard_argp.

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>
10 years agostack: -b, --build-id shows module build-id, load address and pc offset.
Mark Wielaard [Sun, 22 Dec 2013 23:47:06 +0000 (00:47 +0100)]
stack: -b, --build-id shows module build-id, load address and pc offset.

A convenient format for offline processing of the backtrace.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agostack: Add new '-n MAXFRAMES' option. Resolve addresses after unwind.
Mark Wielaard [Sun, 22 Dec 2013 22:48:26 +0000 (23:48 +0100)]
stack: Add new '-n MAXFRAMES' option. Resolve addresses after unwind.

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>
10 years agolibdwfl: linux-pid-attach.c: Report actual PID (Tgid) to dwfl_attach_state.
Mark Wielaard [Mon, 23 Dec 2013 13:20:06 +0000 (14:20 +0100)]
libdwfl: linux-pid-attach.c: Report actual PID (Tgid) to dwfl_attach_state.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Make sure to set the CFI return register only once (for ppc64).
Mark Wielaard [Sat, 21 Dec 2013 20:56:35 +0000 (21:56 +0100)]
libdwfl: Make sure to set the CFI return register only once (for ppc64).

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 <mjw@redhat.com>
10 years agolibdwfl: Add dwfl_getthread_frames.
Mark Wielaard [Fri, 20 Dec 2013 09:09:12 +0000 (10:09 +0100)]
libdwfl: Add dwfl_getthread_frames.

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 <mjw@redhat.com>
10 years agotests: backtrace.c only check we caught the last instruction on x86_64.
Mark Wielaard [Sat, 21 Dec 2013 18:39:19 +0000 (19:39 +0100)]
tests: backtrace.c only check we caught the last instruction on x86_64.

On some architectures gcc might introduce some "padding instructions"
at the end of the function (like on ppc64). So only assert we are at the
last instruction of backtracegen if on x86_64 native. In theory the assert
could even fail on that architectures, but in practice it doesn't and it
is a nice test to have.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Correct nested asprintf result check in report_kernel_archive.
Mark Wielaard [Fri, 20 Dec 2013 23:04:21 +0000 (00:04 +0100)]
libdwfl: Correct nested asprintf result check in report_kernel_archive.

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 <lcrestez@ixiacom.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agobackends: aarch64 always has _GLOBAL_OFFSET_TABLE_ point to .got[0].
Mark Wielaard [Thu, 19 Dec 2013 15:11:19 +0000 (16:11 +0100)]
backends: aarch64 always has _GLOBAL_OFFSET_TABLE_ point to .got[0].

Like some other architectures aarch64 has a special rule for the
_GLOBAL_OFFSET_TABLE_ symbol. Even if there is a .plt.got section the symbol
value still points to the start of the .got section. This is also what the
dynamic linker expects.

See https://sourceware.org/ml/libc-ports/2013-06/msg00057.html

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.
Mark Wielaard [Wed, 18 Dec 2013 10:05:54 +0000 (11:05 +0100)]
libdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.

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 <mjw@redhat.com>
10 years agoFix s390_initreg.c patch copy/paste error.
Mark Wielaard [Wed, 18 Dec 2013 17:26:55 +0000 (18:26 +0100)]
Fix s390_initreg.c patch copy/paste error.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agobackends: Avoid type-punning issue in s390_set_initial_registers_tid.
Mark Wielaard [Wed, 18 Dec 2013 17:02:42 +0000 (18:02 +0100)]
backends: Avoid type-punning issue in s390_set_initial_registers_tid.

Use union to avoid type-punning when assigning a double to a Dwarf_Word.
gcc complains otherwise. error: dereferencing type-punned pointer will
break strict-aliasing rules.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUse executable_for_core in dwfl_build_id_find_elf.
Jan Kratochvil [Wed, 18 Dec 2013 14:02:19 +0000 (15:02 +0100)]
Use executable_for_core in dwfl_build_id_find_elf.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoAdd NEWS items for the new functions in 0.158.
Jan Kratochvil [Wed, 18 Dec 2013 13:37:49 +0000 (14:37 +0100)]
Add NEWS items for the new functions in 0.158.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agounwinder: s390 and s390x
Jan Kratochvil [Tue, 17 Dec 2013 17:49:54 +0000 (18:49 +0100)]
unwinder: s390 and s390x

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agostack: show binary and source file names where a function is defined
Masatake YAMATO [Tue, 17 Dec 2013 03:03:29 +0000 (12:03 +0900)]
stack: show binary and source file names where a function is defined

This patch adds the module and source file information to the
each stack trace line.  `-m' is for module file information
and `-s' is for source file information. `-v' is for both and more.

This is based on private discussion with Jan Kratochvil
<jan.kratochvil@redhat.com>.

In v2 patch, `-s' and `-m' options are introduced instead
of using `-v' repeatedly as suggested by Mark Wielaard <mjw@redhat.com>.

In v3 patch `-a' is added as extra option and source lines are
printed on their own line.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoRemove tests/backtrace-dwarf.c unused code.
Jan Kratochvil [Tue, 17 Dec 2013 20:11:48 +0000 (21:11 +0100)]
Remove tests/backtrace-dwarf.c unused code.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix forgotten call of ebl_dwarf_to_regno.
Jan Kratochvil [Tue, 17 Dec 2013 17:17:32 +0000 (18:17 +0100)]
Fix forgotten call of ebl_dwarf_to_regno.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolibdwfl: linux-pid-attach.c (pid_next_thread): Use rewinddir on first call.
Mark Wielaard [Tue, 17 Dec 2013 09:37:29 +0000 (10:37 +0100)]
libdwfl: linux-pid-attach.c (pid_next_thread): Use rewinddir on first call.

dwfl_getthreads would otherwise fail to report any threads after it was
called once.

Reported-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Add dwfl_module_getsymtab_first_global.
Mark Wielaard [Mon, 16 Dec 2013 12:28:59 +0000 (13:28 +0100)]
libdwfl: Add dwfl_module_getsymtab_first_global.

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 <mjw@redhat.com>
10 years agolibdwfl: Fix various frame related memory leaks.
Mark Wielaard [Sat, 14 Dec 2013 14:02:56 +0000 (15:02 +0100)]
libdwfl: Fix various frame related memory leaks.

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 <yamato@redhat.com>
Tested-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agounwinder: ppc and ppc64
Jan Kratochvil [Sun, 15 Dec 2013 17:56:17 +0000 (18:56 +0100)]
unwinder: ppc and ppc64

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agotests: Add backtrace_child_biarch_SOURCES to make distcheck happy.
Mark Wielaard [Fri, 13 Dec 2013 22:12:18 +0000 (23:12 +0100)]
tests: Add backtrace_child_biarch_SOURCES to make distcheck happy.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Disable valgrind for core dumping and for self-introspecting tests.
Mark Wielaard [Fri, 13 Dec 2013 21:42:46 +0000 (22:42 +0100)]
tests: Disable valgrind for core dumping and for self-introspecting tests.

The only tests that fork and exec are those that will then try to ptrace
attach the child for unwind testing. That won't work when the child is
also running under valgrind. So remove --trace-children=yes. Also disable
valgrind while dumping a core or for tests that try to inspect their own
state. They will get confused otherwise finding pieces of valgrind in
their maps.

Note we still seem to hit the following valgrind bug because the way we
map and unmap some shared libraries gets valgrind confused:
https://bugs.kde.org/show_bug.cgi?id=327427

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolib: Avoid the hash-lookup division if possible
Josh Stone [Fri, 13 Dec 2013 00:34:15 +0000 (16:34 -0800)]
lib: Avoid the hash-lookup division if possible

For Dwarf_Abbrev codes, the most common case is that they're packed at
the low end, saving uleb128 encoding size.  Since the hash table is
always resized to be no more than 90% full, those codes are always less
than the table size, and dividing for the remainder is unnecessary.

Dwarf_Dies are frequently created anew, and need to find abbrev each
time, so even that one division becomes a noticeable hotspot.  This
patch adds a branch to avoid it, which is very predictable for the CPU.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agolibdw: Simplify and inline get_uleb128 and get_sleb128
Josh Stone [Tue, 10 Dec 2013 22:19:09 +0000 (14:19 -0800)]
libdw: Simplify and inline get_uleb128 and get_sleb128

This removes the IS_LIBDW distinction so LEB128 operations are now
always inlined, and the implementations are simplified, more direct.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agolibdw: Add an inlined fast path for __libdw_form_val_len
Josh Stone [Mon, 9 Dec 2013 21:52:10 +0000 (13:52 -0800)]
libdw: Add an inlined fast path for __libdw_form_val_len

Quite a few DW_FORMs have a fixed length for their data, and we can
easily represent these in a small lookup table.  The rest of the forms
are left in the old function to compute as needed.  Combined with
inlining, this takes care of many forms with fewer branches and without
any call.  (It's conceivable that a smart compiler could make a similar
lookup transformation from the large switch itself, but GCC doesn't.)

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agolibdw: Handle empty location expression for (indirect) DIE locations.
Mark Wielaard [Mon, 9 Dec 2013 15:33:26 +0000 (16:33 +0100)]
libdw: Handle empty location expression for (indirect) DIE locations.

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 <mjw@redhat.com>
10 years agoAdd config/ar-lib to .gitignore
Josh Stone [Mon, 9 Dec 2013 21:15:56 +0000 (13:15 -0800)]
Add config/ar-lib to .gitignore

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agoFix test FAIL with -O2
Jan Kratochvil [Thu, 5 Dec 2013 15:16:14 +0000 (16:16 +0100)]
Fix test FAIL with -O2

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agotests: SKIP backtrace-data and backtrace-dwarf on unsupported arches.
Mark Wielaard [Thu, 5 Dec 2013 14:26:51 +0000 (15:26 +0100)]
tests: SKIP backtrace-data and backtrace-dwarf on unsupported arches.

run-backtrace-data.sh did check stderr whether the arch was unsupported
but the test didn't print that message yet. backtrace-dwarf did print
the message but was missing a check_unsupported test. Also add an explicit
check_main test for backtrace-dwarf.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: automake 1.13 compatibility fix.
Mark Wielaard [Wed, 4 Dec 2013 19:55:23 +0000 (20:55 +0100)]
tests: automake 1.13 compatibility fix.

tests/Makefile.am:65: warning: deprecated feature: target
'backtrace-child-biarch' overrides 'backtrace-child-biarch$(EXEEXT)'
tests/Makefile.am:65: change your target to read
'backtrace-child-biarch$(EXEEXT)'

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoTests for unwinder of x86*.
Jan Kratochvil [Mon, 2 Dec 2013 19:54:28 +0000 (20:54 +0100)]
Tests for unwinder of x86*.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoIntroduce process_attach_error.
Jan Kratochvil [Sat, 30 Nov 2013 20:40:29 +0000 (21:40 +0100)]
Introduce process_attach_error.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolibdwfl: Add dwfl_module_addrsym_elf and dwfl_module_getsym_elf.
Mark Wielaard [Wed, 27 Nov 2013 15:45:44 +0000 (16:45 +0100)]
libdwfl: Add dwfl_module_addrsym_elf and dwfl_module_getsym_elf.

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 <mjw@redhat.com>
10 years agoMark new dwfl functions with version ELFUTILS_0.158.
Mark Wielaard [Tue, 26 Nov 2013 14:13:22 +0000 (15:13 +0100)]
Mark new dwfl functions with version ELFUTILS_0.158.

It took two versions to get the new thread state and unwind dwfl functions
in. Make sure they carry the latest elfutils symbol version in which they
were actually added.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: Makefile.am (EXTRA_DIST): Add run-funcretval.sh.
Mark Wielaard [Tue, 26 Nov 2013 09:44:18 +0000 (10:44 +0100)]
tests: Makefile.am (EXTRA_DIST): Add run-funcretval.sh.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoSupport AArch64 architecture
Petr Machata [Tue, 26 Nov 2013 02:10:31 +0000 (03:10 +0100)]
Support AArch64 architecture

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoSupport new 'h' core note item format for hidden fields
Petr Machata [Thu, 14 Nov 2013 00:07:22 +0000 (01:07 +0100)]
Support new 'h' core note item format for hidden fields

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoFix non-build-id core files on build-id system
Jan Kratochvil [Thu, 21 Nov 2013 14:33:22 +0000 (15:33 +0100)]
Fix non-build-id core files on build-id system

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoVerify file vs. core build-id, when both available
Jan Kratochvil [Thu, 21 Nov 2013 14:31:04 +0000 (15:31 +0100)]
Verify file vs. core build-id, when both available

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolink_map: Use proper bias, not l_addr
Jan Kratochvil [Thu, 21 Nov 2013 14:28:02 +0000 (15:28 +0100)]
link_map: Use proper bias, not l_addr

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoCompatibility with older kernels such as RHEL-6.
Jan Kratochvil [Tue, 19 Nov 2013 14:00:15 +0000 (15:00 +0100)]
Compatibility with older kernels such as RHEL-6.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agolibdwfl: Fix and test aux_sym address_sync with relocated ELF
Josh Stone [Mon, 18 Nov 2013 22:29:35 +0000 (14:29 -0800)]
libdwfl: Fix and test aux_sym address_sync with relocated ELF

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 <jistone@redhat.com>
10 years agotests: Fix broken dwflsyms tests, extend test and add prelink tests.
Mark Wielaard [Fri, 15 Nov 2013 23:11:38 +0000 (00:11 +0100)]
tests: Fix broken dwflsyms tests, extend test and add prelink tests.

The two test files that contains minisymtab tables and the expected test
output were wrongly generated. Also prelink tests were missing to check
that a prelinked main ELF file with separate debug or minisyms generated
correctly adjusted symbol values. The dwflsyms test was also extended to
check print and check the result of dwfl_module_relocate_address.

Reported-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUpdate m4/ChangeLog for m4/biarch.m4 authorship.
Jan Kratochvil [Fri, 15 Nov 2013 16:10:45 +0000 (17:10 +0100)]
Update m4/ChangeLog for m4/biarch.m4 authorship.

10 years agoCode cleanup: Remove const in prototype
Jan Kratochvil [Thu, 14 Nov 2013 19:55:41 +0000 (20:55 +0100)]
Code cleanup: Remove const in prototype

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix dwfl_attach_state machine->elf
Jan Kratochvil [Thu, 14 Nov 2013 19:53:20 +0000 (20:53 +0100)]
Fix dwfl_attach_state machine->elf

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoProvide __libdwfl_module_getsym to get dwfl_file *
Jan Kratochvil [Wed, 13 Nov 2013 19:00:56 +0000 (20:00 +0100)]
Provide __libdwfl_module_getsym to get dwfl_file *

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoFix dwfl_module_addrsym for minidebuginfo
Jan Kratochvil [Wed, 13 Nov 2013 18:58:06 +0000 (19:58 +0100)]
Fix dwfl_module_addrsym for minidebuginfo

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agostack: Add basic argp version and bug definitions.
Mark Wielaard [Sun, 10 Nov 2013 21:17:05 +0000 (22:17 +0100)]
stack: Add basic argp version and bug definitions.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibelf: Only memcpy ehdr back when not already directly mmapped.
Mark Wielaard [Fri, 8 Nov 2013 18:28:16 +0000 (19:28 +0100)]
libelf: Only memcpy ehdr back when not already directly mmapped.

When the elf file is mmapped ehdr can still point to ehdr_mem if the
address is unaligned.  In such cases we do need to memcpy the ehdr back
to the file. We shouldn't when ehdr already comes directly from the mmapped
file, because that would cause an memcpy call with overlapping addresses
(ehdr being copied directly over itself).

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix some (harmless) cppcheck warnings.
Mark Wielaard [Sat, 9 Nov 2013 15:45:22 +0000 (16:45 +0100)]
Fix some (harmless) cppcheck warnings.

[dwarf_getaranges.c:149]: (warning) Ineffective statement similar to '*A++;'.
Did you intend to write '(*A)++;'?

There was already an XXX statement that we weren't using the result.
Explicitly read the segment_size and check it is zero. And report an
error if it isn't, since we aren't prepared to handle such a case.

[arlib.c:62]: (error) Uninitialized variable: tmpbuf
[arlib.c:124]: (error) Uninitialized variable: tmpbuf

cppcheck is wrong. tmpbuf is initialized in the snprintf call whose result
is use in the same memcpy call. It does make the code less readable and
harder to understand. So explicitly split the snprintf and memcpy calls.

[nm.c:766]: (warning) Assert statement modifies 'cnt'.

The cnt variable was only used for this assert sanity check.
But it is bad style to do have side effects inside an assert statement.
Increase cnt after the assert.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUnwinder for x86*.
Jan Kratochvil [Thu, 30 May 2013 12:37:38 +0000 (14:37 +0200)]
Unwinder for x86*.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agodwfl_core_file_report: Remove the use of MAX.
Jan Kratochvil [Thu, 7 Nov 2013 20:30:17 +0000 (21:30 +0100)]
dwfl_core_file_report: Remove the use of MAX.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agodwfl_core_file_report: Fix a regression of dwfl_core_file_report retval
Jan Kratochvil [Thu, 7 Nov 2013 20:27:54 +0000 (21:27 +0100)]
dwfl_core_file_report: Fix a regression of dwfl_core_file_report retval

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agodwfl_core_file_report: Fix core files for re-prelink-ed files
Jan Kratochvil [Thu, 7 Nov 2013 15:47:19 +0000 (16:47 +0100)]
dwfl_core_file_report: Fix core files for re-prelink-ed files

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agodwfl_core_file_report: Code cleanup: Reindentation.
Jan Kratochvil [Thu, 7 Nov 2013 15:34:58 +0000 (16:34 +0100)]
dwfl_core_file_report: Code cleanup: Reindentation.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
10 years agoconfigure.ac: Warn when --enable-dwz=no, but /usr/lib/debug/.dwz exists.
Mark Wielaard [Wed, 6 Nov 2013 13:57:33 +0000 (14:57 +0100)]
configure.ac: Warn when --enable-dwz=no, but /usr/lib/debug/.dwz exists.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoconfigure.ac: Add warning that --enable-thread-safety is experimental.
Mark Wielaard [Wed, 6 Nov 2013 11:21:32 +0000 (12:21 +0100)]
configure.ac: Add warning that --enable-thread-safety is experimental.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibelf: Write all section headers if elf flags contains ELF_F_DIRTY.
Mark Wielaard [Tue, 5 Nov 2013 15:27:32 +0000 (16:27 +0100)]
libelf: Write all section headers if elf flags contains ELF_F_DIRTY.

When ehdr e_shoff changes, elf flags is set dirty. This indicates that
the section header moved because sections were added/removed or changed
in size.

Reported-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix expansion of libdw_a_LIBADD
Michael Forney [Fri, 1 Nov 2013 07:51:05 +0000 (00:51 -0700)]
Fix expansion of libdw_a_LIBADD

At least with automake-1.14, libdw_a_LIBADD currently expands to:

    <snip>
    am__DEPENDENCIES_1 =
    libdw_a_DEPENDENCIES = $(addprefix ../libdwfl/,$(shell \
            $(am__DEPENDENCIES_1) t ../libdwfl/libdwfl.a))
    <snip>
    libdw_a_LIBADD = $(addprefix ../libdwfl/,$(shell $(AR) t ../libdwfl/libdwfl.a))

This leads to the spurious error message:

    make[2]: t: Command not found

Signed-off-by: Michael Forney <mforney@mforney.org>
10 years agoCheck for prefixed ar, readelf, and nm
Michael Forney [Fri, 1 Nov 2013 07:51:04 +0000 (00:51 -0700)]
Check for prefixed ar, readelf, and nm

Sometimes with cross-compile toolchains, the tools are prefixed with the
target arch. Using AC_CHECK_TOOL looks for tools named like this.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoreadelf: Solve comparison between signed and unsigned compiler warning.
Mark Wielaard [Tue, 5 Nov 2013 12:37:33 +0000 (13:37 +0100)]
readelf: Solve comparison between signed and unsigned compiler warning.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agotests: allfcts.c (main): Correct dwarf_getfuncs return value check.
Mark Wielaard [Tue, 5 Nov 2013 10:27:19 +0000 (11:27 +0100)]
tests: allfcts.c (main): Correct dwarf_getfuncs return value check.

The return value of dwarf_getfuncs is a ptrdiff_t that is zero on success,
or non-zero (an offset to continue the search) when the callback returned
DWARF_CB_ABORT or on error. When an error occurs dwarf_errno is set.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoREADME: Fix compatbile -> compatible typo.
Mark Wielaard [Mon, 4 Nov 2013 14:43:33 +0000 (15:43 +0100)]
README: Fix compatbile -> compatible typo.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoREADME: Document that tools and libraries should be upgraded together.
Mark Wielaard [Mon, 4 Nov 2013 14:19:32 +0000 (15:19 +0100)]
README: Document that tools and libraries should be upgraded together.

On some distributions it was possible to upgrade separate parts of elfutils
individually. That causes hard to debug issues since some tools (e.g. readelf)
and some libraries (e.g. libdw) depend on libelf internal data structures,
which could be different between versions (or when configured with different
flags). So explicitly document that they should always be upgraded together.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix executable_for_core for non-dwfl_standard_argp
Jan Kratochvil [Wed, 30 Oct 2013 09:48:20 +0000 (10:48 +0100)]
Fix executable_for_core for non-dwfl_standard_argp

./
2013-10-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

* NEWS (Version 0.158): New.

libdw/
2013-10-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

* libdw.map (ELFUTILS_0.158): New.

libdwfl/
2013-10-30  Jan Kratochvil  <jan.kratochvil@redhat.com>

* 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 <jan.kratochvil@redhat.com>
10 years agolibdw: Handle dwz multi files correctly in dwarf_getfuncs.
Mark Wielaard [Thu, 10 Oct 2013 09:40:12 +0000 (11:40 +0200)]
libdw: Handle dwz multi files correctly in dwarf_getfuncs.

Don't use DIE offsets, but use their addresses to make sure they are unique.
Include test cases where main and alt file have subprograms at same offsets.

Reported-by: Josh Stone <jistone@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Don't report and abort on non-file mappings in maps.
Mark Wielaard [Tue, 15 Oct 2013 21:53:32 +0000 (23:53 +0200)]
libdwfl: Don't report and abort on non-file mappings in maps.

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 <mjw@redhat.com>
10 years agoar: Correct operation check when instance_specifed is set.
Mark Wielaard [Fri, 18 Oct 2013 08:37:53 +0000 (10:37 +0200)]
ar: Correct operation check when instance_specifed is set.

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUpdate Ukrainian translation
Yuri Chornoivan [Wed, 9 Oct 2013 15:04:59 +0000 (18:04 +0300)]
Update Ukrainian translation

Signed-off-by: Yuri Chornoivan <yurchor@ukr.net>
10 years agobackends: ppc_abi_cfi reg1 use DW_CFA_val_offset not DW_CFA_val_expression.
Mark Wielaard [Sun, 6 Oct 2013 15:04:07 +0000 (17:04 +0200)]
backends: ppc_abi_cfi reg1 use DW_CFA_val_offset not DW_CFA_val_expression.

Register rules using expressions are stored using an offset from the
start of the .eh_frame or .debug_frame ELF section data. Since abi_cfi
rules aren't stored in those ELF sections they should use neither
DW_CFA_expression nor DW_CFA_val_expression. The only backend that used
DW_CFA_val_expression was ppc_cfi.c. It was easier to express the same
rule using DW_CFA_val_offset than to change the code to handle register
rules using expressions. On most architectures this did work by accident.
See the definition of struct dwarf_frame_register value in libdw/cfi.h to
see why. But on ia64 the abi_cfi data and actual frame data were placed
too far apart and caused a crash in tests/run-addrcfi.sh for ppc32.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdw: Make sure that every debug_types sig8 is hashed
Josh Stone [Thu, 3 Oct 2013 19:38:25 +0000 (12:38 -0700)]
libdw: Make sure that every debug_types sig8 is hashed

When dwarf_formref_die can't find a sig8 in the hash, it walks
__libdw_intern_next_unit, and was then adding those to the hash.
However, if dwarf_offdie_types is called earlier, which also uses that
next_unit, then they are missed from the hash (and never revisited).

This patch makes __libdw_intern_next_unit do the sig8 hash insert, so no
type unit is ever missed.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agoUpdate elf.h from glibc
Petr Machata [Tue, 1 Oct 2013 14:29:41 +0000 (16:29 +0200)]
Update elf.h from glibc

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years ago0.157 release updates for NEWS, elfutils.spec.in and .po files. elfutils-0.157
Mark Wielaard [Mon, 30 Sep 2013 11:50:26 +0000 (13:50 +0200)]
0.157 release updates for NEWS, elfutils.spec.in and .po files.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoShow contents NT_FILE core note in readelf
Petr Machata [Thu, 26 Sep 2013 19:02:22 +0000 (21:02 +0200)]
Show contents NT_FILE core note in readelf

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoShow contents NT_SIGINFO core note in readelf
Petr Machata [Wed, 25 Sep 2013 22:39:34 +0000 (00:39 +0200)]
Show contents NT_SIGINFO core note in readelf

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agolibdw: Fix compiler warnings on 32-bit.
Mark Wielaard [Sun, 29 Sep 2013 22:39:07 +0000 (00:39 +0200)]
libdw: Fix compiler warnings on 32-bit.

Don't cast directly to/from Dwarf_Word (uint64_t) to/from pointers,
but use uintptr_t as intermediary to prevent cast to pointer from
integer of different size warnings.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoRecognize names of some new core note types in ebl_core_note_type_name
Petr Machata [Wed, 25 Sep 2013 22:38:37 +0000 (00:38 +0200)]
Recognize names of some new core note types in ebl_core_note_type_name

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agoPrepare 0.157 release.
Mark Wielaard [Fri, 27 Sep 2013 12:02:26 +0000 (14:02 +0200)]
Prepare 0.157 release.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoUpdate elf.h from glibc
Petr Machata [Mon, 17 Jun 2013 21:52:27 +0000 (23:52 +0200)]
Update elf.h from glibc

Signed-off-by: Petr Machata <pmachata@redhat.com>
10 years agolibdw: Simplify __libdw_visit_scopes' tag checks
Josh Stone [Tue, 24 Sep 2013 22:52:05 +0000 (15:52 -0700)]
libdw: Simplify __libdw_visit_scopes' tag checks

The former classify_die() was splitting tags into more classes than
actually needed.

The one place that used the "imported" die_class now just compares to
DW_TAG_imported_unit directly.

The recursion check was squashing "match", "match_inline", and "walk"
into the same action.  Now that uses the new may_have_scopes(), which
just returns true for all tags that had those classifications.

The net result has no functional change, but performs better.

Signed-off-by: Josh Stone <jistone@redhat.com>
10 years agoeblsectionstripp.c (ebl_section_strip_p): Check shdr_l is not NULL.
Mark Wielaard [Wed, 25 Sep 2013 11:02:53 +0000 (13:02 +0200)]
eblsectionstripp.c (ebl_section_strip_p): Check shdr_l is not NULL.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdw: Make dwarf_getfuncs find all (defining) DW_TAG_subprogram DIEs.
Mark Wielaard [Fri, 20 Sep 2013 13:50:42 +0000 (09:50 -0400)]
libdw: Make dwarf_getfuncs find all (defining) DW_TAG_subprogram DIEs.

dwarf_getfuncs used to return only the DW_TAG_subprogram DIEs that were
direct children of the given CU. This is normally how GCC outputs the
subprogram DIEs. But not always. For nested functions the subprogram DIE
is placed under the code construct DIE where it is nested. Other compilers
might output the defining subprogram DIE of a C++ class function under
the DW_TAG_namespace DIE where it was defined. Both such constructs seem
allowed by the DWARF specification. So just searching the CU DIE children
was wrong.

To find all (defining) subprogram DIEs in a CU dwarf_getfuncs should
use __libdw_visit_scopes to walk the tree for all DIEs that can contain
subprograms as children. The only tricky part is making sure the offset
returned and used when the callback returns DWARF_CB_ABORT is correct
and the search continues at the right spot in the CU DIE tree. This
operation now needs to rewalk the whole tree.

Two new testcases were added that fail without this patch. And the
allfcts test was tweaked so that it always returns DWARF_CB_ABORT
from its callback to make sure the offset handling is correct.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoMake sure --enable-dwz code is also tested during make distcheck.
Mark Wielaard [Fri, 20 Sep 2013 12:48:00 +0000 (14:48 +0200)]
Make sure --enable-dwz code is also tested during make distcheck.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agolibdwfl: Fix memory leak in cu.c on bad DWARF.
Mark Wielaard [Thu, 12 Sep 2013 14:49:25 +0000 (16:49 +0200)]
libdwfl: Fix memory leak in cu.c on bad DWARF.

If libdw dwarf_offdie fails free cu structure.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
10 years agoFix memory leak and set libdw errno when intern_fde cannot parse start/end.
Mark Wielaard [Thu, 12 Sep 2013 13:49:47 +0000 (15:49 +0200)]
Fix memory leak and set libdw errno when intern_fde cannot parse start/end.

Signed-off-by: Mark Wielaard <mjw@redhat.com>