Commit Graph

50 Commits

Author SHA1 Message Date
Mark Wielaard 209f149fdc libdw: Add new function dwarf_cu_getdwarf.
In both systemtap and libabigail there is a need to get the actual Dwarf
underlying an Dwarf_Die or Dwarf_Attribute. Following a DIE reference
might end up in an alternate Dwarf since the addition of DWZ multifile
forms. Both Dwarf_Die and Dwarf_Attribute already contain a Dwarf_CU
handle. Add a function dwarf_cu_getdwarf to retrieve the underlying
Dwarf using the Dwarf_CU.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-08-15 20:29:48 +02:00
Mark Wielaard d81d32d2a4 libdwelf: Add dwelf_elf_gnu_build_id.
Move internal function __libdwfl_find_build_id to libdwelf and use it to
add a public dwelf_elf_gnu_build_id function to extract the NT_GNU_BUILD_ID
from an ELF file using either the shdrs or phdrs. Adjust internal callers
and add a testcase.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-05-01 13:51:31 +02:00
Florian Weimer 4813dbbcb8 libdwelf: Add dwelf_dwarf_gnu_debugaltlink
Signed-off-by: Florian Weimer <fweimer@redhat.com>
2014-04-24 14:40:59 +02:00
Florian Weimer 35e2a765c0 libdw: Add dwarf_getalt, dwarf_setalt
Signed-off-by: Florian Weimer <fweimer@redhat.com>
2014-04-24 13:18:33 +02:00
Mark Wielaard 9380297e13 libdwelf: New DWARF ELF Low-level Functions. Add dwelf_elf_gnu_debuglink.
New public header elfutils/libdwelf.h for low-level DWARF/ELF helper
functions.  The new function dwelf_elf_gnu_debuglink returns the name and
crc as found in the .gnu_debuglink section of an ELF file.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-04-24 13:18:33 +02:00
Mark Wielaard 1910801919 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>
2013-12-31 13:59:51 +01:00
Mark Wielaard e962ec3bcb 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>
2013-12-23 22:57:22 +01:00
Mark Wielaard 159ac52b06 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>
2013-12-20 10:09:49 +01:00
Mark Wielaard 14c2d9e614 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>
2013-12-16 15:27:27 +01:00
Mark Wielaard 819c349f63 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>
2013-11-27 16:45:44 +01:00
Mark Wielaard 16bc4569a9 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>
2013-11-26 15:15:56 +01:00
Jan Kratochvil 0b86746007 Unwinder for x86*.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
Signed-off-by: Mark Wielaard  <mjw@redhat.com>
2013-11-07 21:39:00 +01:00
Jan Kratochvil 3cf491ee10 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>
2013-10-30 10:48:20 +01:00
Mark Wielaard b2535b6a6b libdw: Add new functions dwarf_getlocation_attr and dwarf_getlocation_die.
Some location expression operations have a DIE associated with them.
Examples are some of the new GNU typed DWARF extensions, DW_OP_GNU_convert,
DW_OP_GNU_reinterpret, DW_OP_GNU_const_type, DW_OP_GNU_regval_type and
DW_OP_GNU_deref_type. Others have (block) values associated with them,
like DW_OP_GNU_entry_value and DW_OP_GNU_const_type.

It is not always easy to access these values. The DIE offset is given in
various formats either as global offset or CU relative offset. The (block)
value might be constant or a location description. And the block might be
encoded with a uleb128 or ubyte length. The new functions help to easily
get at the DIE or attribute value.

In theory dwarf_getlocation_attr could be used for all cases, since
besides returning DW_AT_const_value or DW_AT_location, it could also
return an attribute referencing a DIE. But at least one operation,
DW_OP_GNU_const_type, has both a (type) DIE and a constant (block)
value associated with it. And directly getting the DIE when needed
is easier than first having to retrieve a (synthesized) attribute
and then getting the actual (type) DIE.

Expression operations that reference an actual DIE for the
DW_AT_location or DW_AT_const_value, like DW_OP_call2, DW_OP_call4,
DW_OP_callref and DW_OP_GNU_implicit_pointer can be used with both
dwarf_getlocation_attr and dwarf_getlocation_die.

DW_OP_implicit_value and DW_OP_GNU_implicit_pointer already had
their own special accessors (dwarf_getlocation_implicit_value
and dwarf_getlocation_implicit_pointer), but it seemed consistent
to include them in the new more generic accessors too.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-09-06 12:09:45 +02:00
Mark Wielaard 66eaae9bcc libdw: Add new function dwarf_getlocations.
Using dwarf_getlocation it is possible to get single location
descriptions and with dwarf_getlocation_addr it is possible to
get a location list covering a specific address.  But sometimes
it is more convenient to get all ranges covered by a location
list.  For example when a specific address isn't covered and
you want to find alternative addresses where a location
description is defined.

dwarf_getlocations is modelled after dwarf_ranges. It enumerates
the location ranges and descriptions covered by the given
attribute.  In the first call OFFSET should be zero and *BASEP
need not be initialized.  Returns -1 for errors, zero when
there are no more locations to report, or a nonzero OFFSET
value to pass to the next call.  Each subsequent call must
preserve *BASEP from the prior call.  Successful calls fill in
*STARTP and *ENDP with a contiguous address range and *EXPR with
a pointer to an array of operations with length *EXPRLEN.  If
the attribute describes a single location description and not a
location list the first call (with OFFSET zero) will return the
location description in *EXPR with *STARTP set to zero and *ENDP
set to minus one.

ptrdiff_t dwarf_getlocations (Dwarf_Attribute *attr, ptrdiff_t offset,
                              Dwarf_Addr *basep, Dwarf_Addr *startp,
                              Dwarf_Addr *endp, Dwarf_Op **expr,
                              size_t *exprlen);

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-09-06 12:09:45 +02:00
Jan Kratochvil 904aec2c2f Add parameter add_p_vaddr to dwfl_report_elf.
libdwfl/
	* dwfl_report_elf.c (__libdwfl_report_elf): Add parameter add_p_vaddr.
	Set it to true for ET_EXEC and ET_CORE.  Provide alternative
	setup of START and BIAS if !ADD_P_VADDR.  Set END from BIAS, not BASE.
	(dwfl_report_elf): Add parameter add_p_vaddr.  Pass it down.  Add
	NEW_VERSION.
	(_compat_without_add_p_vaddr_dwfl_report_elf) <SHARED>: New, with
	COMPAT_VERSION.
	* libdwfl.h (dwfl_report_elf): Add parameter add_p_vaddr.  Describe it.
	* libdwflP.h (__libdwfl_report_elf): Add parameter add_p_vaddr.
	* link_map.c (report_r_debug): Use true add_p_vaddr for dwfl_report_elf.
	* linux-kernel-modules.c (report_kernel): Use false add_p_vaddr for
	dwfl_report_elf.
	* offline.c (process_elf): Use true add_p_vaddr for dwfl_report_elf.

tests/
	* dwfl-report-elf-align.c: Use false add_p_vaddr for dwfl_report_elf.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2013-05-05 19:08:50 +02:00
Roland McGrath 932585d238 Handle DW_OP_GNU_implicit_pointer. 2010-08-30 04:10:41 -07:00
Roland McGrath de44f133b2 Add dwfl_dwarf_line, addr2line -F to print out more line info bits. 2010-08-24 15:39:12 -07:00
Roland McGrath 9616b85b08 Back out dwarf_cfi_validate_fde. 2010-06-23 03:17:28 -07:00
Roland McGrath 2b1f09548b Finish .debug_types support in libdw and readelf. 2010-06-20 17:55:50 -07:00
Roland McGrath 183e8abb7b Merge branch 'roland/debug_types'
Conflicts:
	libdw/ChangeLog
	libdw/libdw.map
2010-06-20 17:15:02 -07:00
Roland McGrath c70cf4e5e5 Record new line table fields, export APIs to fetch them. 2010-06-18 17:01:05 -07:00
Roland McGrath 3e0f7d1d1b Handle reading .debug_types section. 2010-06-16 12:11:03 -07:00
Roland McGrath 3e4b5bbeca Add new dwarf_cfi_validate_fde call. 2010-06-16 11:16:45 -07:00
Roland McGrath 8068e06dd7 Export dwfl_core_file_report. 2010-03-11 00:00:20 -08:00
Roland McGrath ebc5c885e6 Add dwarf_aggregate_size helper function to libdw. 2010-01-05 22:53:31 -08:00
Roland McGrath f037104199 DW_OP_implicit_value support 2009-09-10 12:39:09 -07:00
Roland McGrath ebfb6484d5 New macros for symbol versioning definitions, use them for libdw convenience wrappers just changed. 2009-08-09 15:40:52 -07:00
Roland McGrath 3c84db3b4b CFI support: lookup by PC and translate into DWARF location per register 2009-07-08 15:15:52 -07:00
Roland McGrath 45d7b29b1b Bug compatibility wrapper for ELFUTILS_0.130 dwfl_module_build_id behavior. 2008-12-16 16:21:40 -08:00
Roland McGrath b4d6f0f806 Fix up bogon and missing log entries from .pmachata.threads branch. 2008-08-25 22:55:17 +00:00
Roland McGrath 59ea7f33f7 src/
2007-10-04  Roland McGrath  <roland@redhat.com>

	* readelf.c (print_archive_index): New variable.
	(options, parse_opt): Accept -c/--archive-index to set it.
	(dump_archive_index): New function.
	(process_file): Take new arg WILL_PRINT_ARCHIVE_INDEX.
	Call dump_archive_index on archives if set.
	(main): Update caller.
	(any_control_option): Give it file scope, moved out of ...
	(parse_opt): ... here.

tests/
2007-10-04  Roland McGrath  <roland@redhat.com>

	* run-readelf-test4.sh: New file.
	* Makefile.am (TESTS, EXTRA_DIST): Add it.
2007-10-04 08:50:09 +00:00
Roland McGrath 43da9895c6 libdw/
2007-04-16  Roland McGrath  <roland@redhat.com>

	* libdw.map (ELFUTILS_0.127): Add dwfl_module_address_section.

libdwfl/
2007-04-16  Roland McGrath  <roland@redhat.com>

	* derelocate.c (cache_sections): Apply bias to sh_addr.
	(compare_secrefs): Fix address comparison to avoid signed overflow.
	(find_section): New function, broken out of ...
	(dwfl_module_relocate_address): ... here, call it.
	(check_module): New function, broken out of ...
	(dwfl_module_relocate_address): ... here, call it.
	(dwfl_module_address_section): New function.
	* libdwfl.h: Declare it.

tests/
2007-04-16  Roland McGrath  <roland@redhat.com>

	* dwfl-addr-sect.c: New file.
	* Makefile.am (noinst_PROGRAMS): Add it.
	(dwfl_addr_sect_LDADD): New variable.
2007-04-16 23:13:37 +00:00
Ulrich Drepper 6258e7486e propagate from branch 'com.redhat.elfutils.roland.pending' (head e0c7abd450c9e49093cfae30af8a22782a74a403)
to branch 'com.redhat.elfutils' (head 2c784d50eee72e33972c333138a3a28df304da63)
2007-03-13 06:22:40 +00:00
Ulrich Drepper aa915fd3d7 propagate from branch 'com.redhat.elfutils.roland.pending' (head c44dcfac5b545aecb173fede31f34cb003be0173)
to branch 'com.redhat.elfutils' (head 4196d4e01486bdeb0c0632291881d1c6d7163fab)
2007-02-05 07:25:33 +00:00
Ulrich Drepper e1812e1d90 propagate from branch 'com.redhat.elfutils.roland.pending' (head 1ac619debea0e3ecfd2704e8bdc803c6c893b62a)
to branch 'com.redhat.elfutils' (head 830d38d0a2ce24911160a871963f093209e69d9e)
2006-07-12 07:46:03 +00:00
Roland McGrath 0833312829 libdw/
2006-02-22  Roland McGrath  <roland@redhat.com>

	* libdw.map: Bump to 0.120; export dwfl_version.


libdwfl/
	* dwfl_version.c: New file.
	* Makefile.am (libdwfl_a_SOURCES): Add it.
	* libdwfl.h: Declare dwfl_version.
2006-02-27 04:54:26 +00:00
Roland McGrath 50ffcbf97b 2005-12-22 Roland McGrath <roland@redhat.com>
* libdw.map: Bump to 0.119; export dwfl_linux_proc_maps_report.
2005-12-23 01:51:43 +00:00
Roland McGrath 994b489927 merge of 2cc527e6d8c8ff19dab478f7d12e58f1cfa6d6f5
and 7b542932f3e2947183b45bdbf39d448f457da9fd
2005-12-05 22:46:21 +00:00
Roland McGrath e47ab76f02 Update new test after merge. 2005-11-17 03:16:00 +00:00
Roland McGrath 6724c90d02 NEWS updates 2005-10-28 07:07:19 +00:00
Roland McGrath 07d4f2fc1c libdw/
Fixes to last changes.

tests/
2005-10-27  Roland McGrath  <roland@redhat.com>

	* run-find-prologues.sh: New file.
	* Makefile.am (TESTS, EXTRA_DIST): Add it.
2005-10-28 06:56:24 +00:00
Roland McGrath 71e15a0174 libdw/
2005-08-27  Roland McGrath  <roland@redhat.com>

	* dwarf_getscopes.c (dwarf_getscopes): Rewritten using
	__libdw_visit_scopes.

	* dwarf_getscopes_die.c: New file.
	* Makefile.am (libdw_a_SOURCES): Add it.
	* libdw.h: Declare dwarf_getscopes_die.
	* libdw.map: Bump to 0.115 and add it.

	* libdw_visit_scopes.c (__libdw_visit_scopes): Pass a struct
	containing a DIE and its parent pointer, instead of just Dwarf_Die.
	Take two functions for both preorder and postorder visitors.
	* libdwP.h: Update decl.
	(struct Dwarf_Die_Chain): New type.
	* dwarf_func_inline.c: Update uses.

	* dwarf_diename.c (dwarf_diename): Use dwarf_attr_integrate.
	Add INTDEF.
	* libdwP.h: Add INTDECL.
	* dwarf_func_name.c (dwarf_func_name): Use dwarf_diename.


src/
2005-08-27  Roland McGrath  <roland@redhat.com>

	* addr2line.c (dwarf_diename_integrate): Function removed.
	(print_dwarf_function): Use plain dwarf_diename.


tests/
2005-08-27  Roland McGrath  <roland@redhat.com>

	* run-funcscopes.sh: New file.
	* testfile25.bz2: New data file.
	* Makefile.am (TESTS, EXTRA_DIST): Add them.

2005-08-26  Roland McGrath  <roland@redhat.com>

	* addrscopes.c (dwarf_diename_integrate): Removed.
	(print_vars, handle_address): Use plain dwarf_diename.

2005-08-25  Roland McGrath  <roland@redhat.com>

	* funcscopes.c: New file.
	* Makefile.am (noinst_PROGRAMS): Add it.
	(funcscopes_LDADD): New variable.

	* run-addrscopes.sh: Add another case.
	* testfile24.bz2: New data file.
	* Makefile.am (EXTRA_DIST): Add it.

	* addrscopes.c (handle_address): Take new argument IGNORE_INLINES,
	pass it to dwarf_getscopes.
	(main): Pass it, true when '=' follows an address.
2005-08-27 10:33:26 +00:00
Roland McGrath d17fac7e89 2005-08-23 Roland McGrath <roland@redhat.com>
* dwarf_attr_integrate.c (dwarf_attr_integrate): Treat
	DW_AT_specification the same as DW_AT_abstract_origin.
2005-08-23 08:20:21 +00:00
Roland McGrath 1ecb606f5a libdw/
2005-08-15  Roland McGrath  <roland@redhat.com>

	* dwarf_func_inline.c: New file.
	* Makefile.am (libdw_a_SOURCES): Add it.
	* libdw.h: Declare dwarf_func_inline, dwarf_func_inline_instances.
	* libdw.map: Add them.

	* dwarf_func_die.c: New file.
	* Makefile.am (libdw_a_SOURCES): Add it.
	* libdw.h: Declare dwarf_func_die.
	* libdw.map: Add it.  Bump version to ELFUTILS_0.114.

tests/
2005-08-15  Roland McGrath  <roland@redhat.com>

	* dwflmodtest.c (print_instance, print_inline): New functions.
	(print_func): Call print_inline.
	(options, parse_opt): Grok -i/--inlines.
2005-08-15 09:53:04 +00:00
Roland McGrath 1838590b6a Merge libdwfl contents into libdw.so 2005-07-28 07:12:38 +00:00
Roland McGrath 366784a999 disapproval of revision f77b4caa6afc865a5be602699e3139ac76ab2c22 2005-07-28 06:20:53 +00:00
Roland McGrath 346322af23 Revert commit made on wrong branch. 2005-07-28 01:02:55 +00:00
Roland McGrath fdfa3cddad 2005-07-27 Roland McGrath <roland@redhat.com>
* libdw.map: Define an empty base version and move all symbols to
	version ELFUTILS_0.111; don't define ELFUTILS_1.0 at all yet.
2005-07-28 00:51:59 +00:00
Ulrich Drepper b08d5a8fb4 Adjust for monotone. 2005-07-26 05:00:05 +00:00