Copy libelf, libdwarf and common files from vendor/ to contrib/.
This commit is contained in:
commit
2de3b87a12
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/elftoolchain/; revision=260697
15
contrib/elftoolchain/common/Makefile
Normal file
15
contrib/elftoolchain/common/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
# $Id: Makefile 2606 2012-10-02 17:52:57Z jkoshy $
|
||||
|
||||
TOP= ..
|
||||
|
||||
INCS= elfdefinitions.h
|
||||
INCSDIR= /usr/include
|
||||
|
||||
.PHONY: all clean clobber depend obj
|
||||
|
||||
all depend obj:
|
||||
|
||||
clean clobber:
|
||||
rm -f ${CLEANFILES}
|
||||
|
||||
.include "${TOP}/mk/elftoolchain.inc.mk"
|
458
contrib/elftoolchain/common/_elftc.h
Normal file
458
contrib/elftoolchain/common/_elftc.h
Normal file
@ -0,0 +1,458 @@
|
||||
/*-
|
||||
* Copyright (c) 2009 Joseph Koshy
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: _elftc.h 2922 2013-03-17 22:53:15Z kaiwang27 $
|
||||
*/
|
||||
|
||||
/**
|
||||
** Miscellanous definitions needed by multiple components.
|
||||
**/
|
||||
|
||||
#ifndef _ELFTC_H
|
||||
#define _ELFTC_H
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(T, M) ((int) &((T*) 0) -> M)
|
||||
#endif
|
||||
|
||||
/* --QUEUE-MACROS-- [[ */
|
||||
|
||||
/*
|
||||
* Supply macros missing from <sys/queue.h>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef SLIST_FOREACH_SAFE
|
||||
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_CONCAT
|
||||
#define STAILQ_CONCAT(head1, head2) do { \
|
||||
if (!STAILQ_EMPTY((head2))) { \
|
||||
*(head1)->stqh_last = (head2)->stqh_first; \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_INIT((head2)); \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_EMPTY
|
||||
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_ENTRY
|
||||
#define STAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *stqe_next; /* next element */ \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_FIRST
|
||||
#define STAILQ_FIRST(head) ((head)->stqh_first)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_HEAD
|
||||
#define STAILQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *stqh_first; /* first element */ \
|
||||
struct type **stqh_last; /* addr of last next element */ \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_HEAD_INITIALIZER
|
||||
#define STAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).stqh_first }
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_FOREACH
|
||||
#define STAILQ_FOREACH(var, head, field) \
|
||||
for ((var) = ((head)->stqh_first); \
|
||||
(var); \
|
||||
(var) = ((var)->field.stqe_next))
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_FOREACH_SAFE
|
||||
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_INIT
|
||||
#define STAILQ_INIT(head) do { \
|
||||
(head)->stqh_first = NULL; \
|
||||
(head)->stqh_last = &(head)->stqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_INSERT_HEAD
|
||||
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \
|
||||
(head)->stqh_last = &(elm)->field.stqe_next; \
|
||||
(head)->stqh_first = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_INSERT_TAIL
|
||||
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
(elm)->field.stqe_next = NULL; \
|
||||
*(head)->stqh_last = (elm); \
|
||||
(head)->stqh_last = &(elm)->field.stqe_next; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_INSERT_AFTER
|
||||
#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\
|
||||
(head)->stqh_last = &(elm)->field.stqe_next; \
|
||||
(listelm)->field.stqe_next = (elm); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_LAST
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? \
|
||||
NULL : ((struct type *)(void *) \
|
||||
((char *)((head)->stqh_last) - offsetof(struct type, field))))
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_NEXT
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_REMOVE
|
||||
#define STAILQ_REMOVE(head, elm, type, field) do { \
|
||||
if ((head)->stqh_first == (elm)) { \
|
||||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
} else { \
|
||||
struct type *curelm = (head)->stqh_first; \
|
||||
while (curelm->field.stqe_next != (elm)) \
|
||||
curelm = curelm->field.stqe_next; \
|
||||
if ((curelm->field.stqe_next = \
|
||||
curelm->field.stqe_next->field.stqe_next) == NULL) \
|
||||
(head)->stqh_last = &(curelm)->field.stqe_next; \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef STAILQ_REMOVE_HEAD
|
||||
#define STAILQ_REMOVE_HEAD(head, field) do { \
|
||||
if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == \
|
||||
NULL) \
|
||||
(head)->stqh_last = &(head)->stqh_first; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The STAILQ_SORT macro is adapted from Simon Tatham's O(n*log(n))
|
||||
* mergesort algorithm.
|
||||
*/
|
||||
#ifndef STAILQ_SORT
|
||||
#define STAILQ_SORT(head, type, field, cmp) do { \
|
||||
STAILQ_HEAD(, type) _la, _lb; \
|
||||
struct type *_p, *_q, *_e; \
|
||||
int _i, _sz, _nmerges, _psz, _qsz; \
|
||||
\
|
||||
_sz = 1; \
|
||||
do { \
|
||||
_nmerges = 0; \
|
||||
STAILQ_INIT(&_lb); \
|
||||
while (!STAILQ_EMPTY((head))) { \
|
||||
_nmerges++; \
|
||||
STAILQ_INIT(&_la); \
|
||||
_psz = 0; \
|
||||
for (_i = 0; _i < _sz && !STAILQ_EMPTY((head)); \
|
||||
_i++) { \
|
||||
_e = STAILQ_FIRST((head)); \
|
||||
if (_e == NULL) \
|
||||
break; \
|
||||
_psz++; \
|
||||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
STAILQ_INSERT_TAIL(&_la, _e, field); \
|
||||
} \
|
||||
_p = STAILQ_FIRST(&_la); \
|
||||
_qsz = _sz; \
|
||||
_q = STAILQ_FIRST((head)); \
|
||||
while (_psz > 0 || (_qsz > 0 && _q != NULL)) { \
|
||||
if (_psz == 0) { \
|
||||
_e = _q; \
|
||||
_q = STAILQ_NEXT(_q, field); \
|
||||
STAILQ_REMOVE_HEAD((head), \
|
||||
field); \
|
||||
_qsz--; \
|
||||
} else if (_qsz == 0 || _q == NULL) { \
|
||||
_e = _p; \
|
||||
_p = STAILQ_NEXT(_p, field); \
|
||||
STAILQ_REMOVE_HEAD(&_la, field);\
|
||||
_psz--; \
|
||||
} else if (cmp(_p, _q) <= 0) { \
|
||||
_e = _p; \
|
||||
_p = STAILQ_NEXT(_p, field); \
|
||||
STAILQ_REMOVE_HEAD(&_la, field);\
|
||||
_psz--; \
|
||||
} else { \
|
||||
_e = _q; \
|
||||
_q = STAILQ_NEXT(_q, field); \
|
||||
STAILQ_REMOVE_HEAD((head), \
|
||||
field); \
|
||||
_qsz--; \
|
||||
} \
|
||||
STAILQ_INSERT_TAIL(&_lb, _e, field); \
|
||||
} \
|
||||
} \
|
||||
(head)->stqh_first = _lb.stqh_first; \
|
||||
(head)->stqh_last = _lb.stqh_last; \
|
||||
_sz *= 2; \
|
||||
} while (_nmerges > 1); \
|
||||
} while (/*CONSTCOND*/0)
|
||||
#endif
|
||||
|
||||
#ifndef TAILQ_FOREACH_SAFE
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
#endif
|
||||
|
||||
/* ]] --QUEUE-MACROS-- */
|
||||
|
||||
/*
|
||||
* VCS Ids.
|
||||
*/
|
||||
|
||||
#ifndef ELFTC_VCSID
|
||||
|
||||
#if defined(__DragonFly__)
|
||||
#define ELFTC_VCSID(ID) __RCSID(ID)
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#define ELFTC_VCSID(ID) __FBSDID(ID)
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)
|
||||
#if defined(__GNUC__)
|
||||
#define ELFTC_VCSID(ID) __asm__(".ident\t\"" ID "\"")
|
||||
#else
|
||||
#define ELFTC_VCSID(ID) /**/
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__minix)
|
||||
#if defined(__GNUC__)
|
||||
#define ELFTC_VCSID(ID) __asm__(".ident\t\"" ID "\"")
|
||||
#else
|
||||
#define ELFTC_VCSID(ID) /**/
|
||||
#endif /* __GNU__ */
|
||||
#endif
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#define ELFTC_VCSID(ID) __RCSID(ID)
|
||||
#endif
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#if defined(__GNUC__)
|
||||
#define ELFTC_VCSID(ID) __asm__(".ident\t\"" ID "\"")
|
||||
#else
|
||||
#define ELFTC_VCSID(ID) /**/
|
||||
#endif /* __GNUC__ */
|
||||
#endif
|
||||
|
||||
#endif /* ELFTC_VCSID */
|
||||
|
||||
/*
|
||||
* Provide an equivalent for getprogname(3).
|
||||
*/
|
||||
|
||||
#ifndef ELFTC_GETPROGNAME
|
||||
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__minix) || \
|
||||
defined(__NetBSD__)
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ELFTC_GETPROGNAME() getprogname()
|
||||
|
||||
#endif /* __DragonFly__ || __FreeBSD__ || __minix || __NetBSD__ */
|
||||
|
||||
|
||||
#if defined(__GLIBC__)
|
||||
|
||||
/*
|
||||
* GLIBC based systems have a global 'char *' pointer referencing
|
||||
* the executable's name.
|
||||
*/
|
||||
extern const char *program_invocation_short_name;
|
||||
|
||||
#define ELFTC_GETPROGNAME() program_invocation_short_name
|
||||
|
||||
#endif /* __GLIBC__ */
|
||||
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
|
||||
extern const char *__progname;
|
||||
|
||||
#define ELFTC_GETPROGNAME() __progname
|
||||
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
#endif /* ELFTC_GETPROGNAME */
|
||||
|
||||
|
||||
/**
|
||||
** Per-OS configuration.
|
||||
**/
|
||||
|
||||
#if defined(__DragonFly__)
|
||||
|
||||
#include <osreldate.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#define ELFTC_BYTE_ORDER _BYTE_ORDER
|
||||
#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define ELFTC_BYTE_ORDER_BIG_ENDIAN _BIG_ENDIAN
|
||||
|
||||
#define ELFTC_HAVE_MMAP 1
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__GLIBC__)
|
||||
|
||||
#include <endian.h>
|
||||
|
||||
#define ELFTC_BYTE_ORDER __BYTE_ORDER
|
||||
#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||
#define ELFTC_BYTE_ORDER_BIG_ENDIAN __BIG_ENDIAN
|
||||
|
||||
#define ELFTC_HAVE_MMAP 1
|
||||
|
||||
/*
|
||||
* Debian GNU/Linux and Debian GNU/kFreeBSD do not have strmode(3).
|
||||
*/
|
||||
#define ELFTC_HAVE_STRMODE 0
|
||||
|
||||
/* Whether we need to supply {be,le}32dec. */
|
||||
#define ELFTC_NEED_BYTEORDER_EXTENSIONS 1
|
||||
|
||||
#define roundup2 roundup
|
||||
|
||||
#endif /* __GLIBC__ */
|
||||
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
|
||||
#include <osreldate.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#define ELFTC_BYTE_ORDER _BYTE_ORDER
|
||||
#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define ELFTC_BYTE_ORDER_BIG_ENDIAN _BIG_ENDIAN
|
||||
|
||||
#define ELFTC_HAVE_MMAP 1
|
||||
#define ELFTC_HAVE_STRMODE 1
|
||||
#if __FreeBSD_version <= 900000
|
||||
#define ELFTC_BROKEN_YY_NO_INPUT 1
|
||||
#endif
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
|
||||
#if defined(__minix)
|
||||
#define ELFTC_HAVE_MMAP 0
|
||||
#endif /* __minix */
|
||||
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#define ELFTC_BYTE_ORDER _BYTE_ORDER
|
||||
#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define ELFTC_BYTE_ORDER_BIG_ENDIAN _BIG_ENDIAN
|
||||
|
||||
#define ELFTC_HAVE_MMAP 1
|
||||
#define ELFTC_HAVE_STRMODE 1
|
||||
#if __NetBSD_Version__ <= 599002100
|
||||
/* from src/doc/CHANGES: flex(1): Import flex-2.5.35 [christos 20091025] */
|
||||
/* and 5.99.21 was from Wed Oct 21 21:28:36 2009 UTC */
|
||||
# define ELFTC_BROKEN_YY_NO_INPUT 1
|
||||
#endif
|
||||
#endif /* __NetBSD __ */
|
||||
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#define ELFTC_BYTE_ORDER _BYTE_ORDER
|
||||
#define ELFTC_BYTE_ORDER_LITTLE_ENDIAN _LITTLE_ENDIAN
|
||||
#define ELFTC_BYTE_ORDER_BIG_ENDIAN _BIG_ENDIAN
|
||||
|
||||
#define ELFTC_HAVE_MMAP 1
|
||||
#define ELFTC_HAVE_STRMODE 1
|
||||
|
||||
#define ELFTC_NEED_BYTEORDER_EXTENSIONS 1
|
||||
#define roundup2 roundup
|
||||
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
#endif /* _ELFTC_H */
|
2614
contrib/elftoolchain/common/elfdefinitions.h
Normal file
2614
contrib/elftoolchain/common/elfdefinitions.h
Normal file
File diff suppressed because it is too large
Load Diff
47
contrib/elftoolchain/common/native-elf-format
Executable file
47
contrib/elftoolchain/common/native-elf-format
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id: native-elf-format 2064 2011-10-26 15:12:32Z jkoshy $
|
||||
#
|
||||
# Find the native ELF format for a host platform by compiling a
|
||||
# test object and examining the resulting object.
|
||||
#
|
||||
# This script is used if there is no easy way to determine this
|
||||
# information statically at compile time.
|
||||
|
||||
program=`basename $0`
|
||||
tmp_c=`mktemp -u nefXXXXXX`.c
|
||||
tmp_o=`echo ${tmp_c} | sed -e 's/.c$/.o/'`
|
||||
|
||||
trap "rm -f ${tmp_c} ${tmp_o}" 0 1 2 3 15
|
||||
|
||||
touch ${tmp_c}
|
||||
|
||||
echo "/* Generated by ${program} on `date` */"
|
||||
|
||||
cc -c ${tmp_c} -o ${tmp_o}
|
||||
readelf -h ${tmp_o} | awk '
|
||||
$1 ~ "Class:" {
|
||||
sub("ELF","",$2); elfclass = $2;
|
||||
}
|
||||
$1 ~ "Data:" {
|
||||
if (match($0, "little")) {
|
||||
elfdata = "LSB";
|
||||
} else {
|
||||
elfdata = "MSB";
|
||||
}
|
||||
}
|
||||
$1 ~ "Machine:" {
|
||||
if (match($0, "Intel.*386")) {
|
||||
elfarch = "EM_386";
|
||||
} else if (match($0, ".*X86-64")) {
|
||||
elfarch = "EM_X86_64";
|
||||
} else {
|
||||
elfarch = "unknown";
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("#define ELFTC_CLASS ELFCLASS%s\n", elfclass);
|
||||
printf("#define ELFTC_ARCH %s\n", elfarch);
|
||||
printf("#define ELFTC_BYTEORDER ELFDATA2%s\n", elfdata);
|
||||
}'
|
||||
|
13
contrib/elftoolchain/common/os.Linux.mk
Normal file
13
contrib/elftoolchain/common/os.Linux.mk
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Build recipes for Linux based operating systems.
|
||||
#
|
||||
# $Id: os.Linux.mk 2064 2011-10-26 15:12:32Z jkoshy $
|
||||
|
||||
_NATIVE_ELF_FORMAT = native-elf-format
|
||||
|
||||
.BEGIN: ${_NATIVE_ELF_FORMAT}.h
|
||||
|
||||
${_NATIVE_ELF_FORMAT}.h:
|
||||
${.CURDIR}/${_NATIVE_ELF_FORMAT} > ${.TARGET} || rm ${.TARGET}
|
||||
|
||||
CLEANFILES += ${_NATIVE_ELF_FORMAT}.h
|
237
contrib/elftoolchain/common/utarray.h
Normal file
237
contrib/elftoolchain/common/utarray.h
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
Copyright (c) 2008-2013, Troy D. Hanson http://uthash.sourceforge.net
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: utarray.h 2694 2012-11-24 17:11:58Z kaiwang27 $ */
|
||||
|
||||
/* a dynamic array implementation using macros
|
||||
* see http://uthash.sourceforge.net/utarray
|
||||
*/
|
||||
#ifndef UTARRAY_H
|
||||
#define UTARRAY_H
|
||||
|
||||
#define UTARRAY_VERSION 1.9.7
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define _UNUSED_ __attribute__ ((__unused__))
|
||||
#else
|
||||
#define _UNUSED_
|
||||
#endif
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
#include <string.h> /* memset, etc */
|
||||
#include <stdlib.h> /* exit */
|
||||
|
||||
#ifndef oom
|
||||
#define oom() exit(-1)
|
||||
#endif
|
||||
|
||||
typedef void (ctor_f)(void *dst, const void *src);
|
||||
typedef void (dtor_f)(void *elt);
|
||||
typedef void (init_f)(void *elt);
|
||||
typedef struct {
|
||||
size_t sz;
|
||||
init_f *init;
|
||||
ctor_f *copy;
|
||||
dtor_f *dtor;
|
||||
} UT_icd;
|
||||
|
||||
typedef struct {
|
||||
unsigned i,n;/* i: index of next available slot, n: num slots */
|
||||
UT_icd icd; /* initializer, copy and destructor functions */
|
||||
char *d; /* n slots of size icd->sz*/
|
||||
} UT_array;
|
||||
|
||||
#define utarray_init(a,_icd) do { \
|
||||
memset(a,0,sizeof(UT_array)); \
|
||||
(a)->icd=*_icd; \
|
||||
} while(0)
|
||||
|
||||
#define utarray_done(a) do { \
|
||||
if ((a)->n) { \
|
||||
if ((a)->icd.dtor) { \
|
||||
size_t _ut_i; \
|
||||
for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \
|
||||
(a)->icd.dtor(utarray_eltptr(a,_ut_i)); \
|
||||
} \
|
||||
} \
|
||||
free((a)->d); \
|
||||
} \
|
||||
(a)->n=0; \
|
||||
} while(0)
|
||||
|
||||
#define utarray_new(a,_icd) do { \
|
||||
a=(UT_array*)malloc(sizeof(UT_array)); \
|
||||
utarray_init(a,_icd); \
|
||||
} while(0)
|
||||
|
||||
#define utarray_free(a) do { \
|
||||
utarray_done(a); \
|
||||
free(a); \
|
||||
} while(0)
|
||||
|
||||
#define utarray_reserve(a,by) do { \
|
||||
if (((a)->i+by) > ((a)->n)) { \
|
||||
while(((a)->i+by) > ((a)->n)) { (a)->n = ((a)->n ? (2*(a)->n) : 8); } \
|
||||
if ( ((a)->d=(char*)realloc((a)->d, (a)->n*(a)->icd.sz)) == NULL) oom(); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define utarray_push_back(a,p) do { \
|
||||
utarray_reserve(a,1); \
|
||||
if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,(a)->i++), p); } \
|
||||
else { memcpy(_utarray_eltptr(a,(a)->i++), p, (a)->icd.sz); }; \
|
||||
} while(0)
|
||||
|
||||
#define utarray_pop_back(a) do { \
|
||||
if ((a)->icd.dtor) { (a)->icd.dtor( _utarray_eltptr(a,--((a)->i))); } \
|
||||
else { (a)->i--; } \
|
||||
} while(0)
|
||||
|
||||
#define utarray_extend_back(a) do { \
|
||||
utarray_reserve(a,1); \
|
||||
if ((a)->icd.init) { (a)->icd.init(_utarray_eltptr(a,(a)->i)); } \
|
||||
else { memset(_utarray_eltptr(a,(a)->i),0,(a)->icd.sz); } \
|
||||
(a)->i++; \
|
||||
} while(0)
|
||||
|
||||
#define utarray_len(a) ((a)->i)
|
||||
|
||||
#define utarray_eltptr(a,j) (((j) < (a)->i) ? _utarray_eltptr(a,j) : NULL)
|
||||
#define _utarray_eltptr(a,j) ((char*)((a)->d + ((a)->icd.sz*(j) )))
|
||||
|
||||
#define utarray_insert(a,p,j) do { \
|
||||
utarray_reserve(a,1); \
|
||||
if (j > (a)->i) break; \
|
||||
if ((j) < (a)->i) { \
|
||||
memmove( _utarray_eltptr(a,(j)+1), _utarray_eltptr(a,j), \
|
||||
((a)->i - (j))*((a)->icd.sz)); \
|
||||
} \
|
||||
if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,j), p); } \
|
||||
else { memcpy(_utarray_eltptr(a,j), p, (a)->icd.sz); }; \
|
||||
(a)->i++; \
|
||||
} while(0)
|
||||
|
||||
#define utarray_inserta(a,w,j) do { \
|
||||
if (utarray_len(w) == 0) break; \
|
||||
if (j > (a)->i) break; \
|
||||
utarray_reserve(a,utarray_len(w)); \
|
||||
if ((j) < (a)->i) { \
|
||||
memmove(_utarray_eltptr(a,(j)+utarray_len(w)), \
|
||||
_utarray_eltptr(a,j), \
|
||||
((a)->i - (j))*((a)->icd.sz)); \
|
||||
} \
|
||||
if ((a)->icd.copy) { \
|
||||
size_t _ut_i; \
|
||||
for(_ut_i=0;_ut_i<(w)->i;_ut_i++) { \
|
||||
(a)->icd.copy(_utarray_eltptr(a,j+_ut_i), _utarray_eltptr(w,_ut_i)); \
|
||||
} \
|
||||
} else { \
|
||||
memcpy(_utarray_eltptr(a,j), _utarray_eltptr(w,0), \
|
||||
utarray_len(w)*((a)->icd.sz)); \
|
||||
} \
|
||||
(a)->i += utarray_len(w); \
|
||||
} while(0)
|
||||
|
||||
#define utarray_resize(dst,num) do { \
|
||||
size_t _ut_i; \
|
||||
if (dst->i > (size_t)(num)) { \
|
||||
if ((dst)->icd.dtor) { \
|
||||
for(_ut_i=num; _ut_i < dst->i; _ut_i++) { \
|
||||
(dst)->icd.dtor(utarray_eltptr(dst,_ut_i)); \
|
||||
} \
|
||||
} \
|
||||
} else if (dst->i < (size_t)(num)) { \
|
||||
utarray_reserve(dst,num-dst->i); \
|
||||
if ((dst)->icd.init) { \
|
||||
for(_ut_i=dst->i; _ut_i < num; _ut_i++) { \
|
||||
(dst)->icd.init(utarray_eltptr(dst,_ut_i)); \
|
||||
} \
|
||||
} else { \
|
||||
memset(_utarray_eltptr(dst,dst->i),0,(dst)->icd.sz*(num-dst->i)); \
|
||||
} \
|
||||
} \
|
||||
dst->i = num; \
|
||||
} while(0)
|
||||
|
||||
#define utarray_concat(dst,src) do { \
|
||||
utarray_inserta((dst),(src),utarray_len(dst)); \
|
||||
} while(0)
|
||||
|
||||
#define utarray_erase(a,pos,len) do { \
|
||||
if ((a)->icd.dtor) { \
|
||||
size_t _ut_i; \
|
||||
for(_ut_i=0; _ut_i < len; _ut_i++) { \
|
||||
(a)->icd.dtor(utarray_eltptr((a),pos+_ut_i)); \
|
||||
} \
|
||||
} \
|
||||
if ((a)->i > (pos+len)) { \
|
||||
memmove( _utarray_eltptr((a),pos), _utarray_eltptr((a),pos+len), \
|
||||
(((a)->i)-(pos+len))*((a)->icd.sz)); \
|
||||
} \
|
||||
(a)->i -= (len); \
|
||||
} while(0)
|
||||
|
||||
#define utarray_renew(a,u) do { \
|
||||
if (a) utarray_clear(a); \
|
||||
else utarray_new((a),(u)); \
|
||||
} while(0)
|
||||
|
||||
#define utarray_clear(a) do { \
|
||||
if ((a)->i > 0) { \
|
||||
if ((a)->icd.dtor) { \
|
||||
size_t _ut_i; \
|
||||
for(_ut_i=0; _ut_i < (a)->i; _ut_i++) { \
|
||||
(a)->icd.dtor(utarray_eltptr(a,_ut_i)); \
|
||||
} \
|
||||
} \
|
||||
(a)->i = 0; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define utarray_sort(a,cmp) do { \
|
||||
qsort((a)->d, (a)->i, (a)->icd.sz, cmp); \
|
||||
} while(0)
|
||||
|
||||
#define utarray_find(a,v,cmp) bsearch((v),(a)->d,(a)->i,(a)->icd.sz,cmp)
|
||||
|
||||
#define utarray_front(a) (((a)->i) ? (_utarray_eltptr(a,0)) : NULL)
|
||||
#define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : (((int)((a)->i) > (utarray_eltidx(a,e)+1)) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL))
|
||||
#define utarray_prev(a,e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e) > 0) ? _utarray_eltptr(a,utarray_eltidx(a,e)-1) : NULL))
|
||||
#define utarray_back(a) (((a)->i) ? (_utarray_eltptr(a,(a)->i-1)) : NULL)
|
||||
#define utarray_eltidx(a,e) (((char*)(e) >= (char*)((a)->d)) ? (int)(((char*)(e) - (char*)((a)->d))/(a)->icd.sz) : -1)
|
||||
|
||||
/* last we pre-define a few icd for common utarrays of ints and strings */
|
||||
static void utarray_str_cpy(void *dst, const void *src) {
|
||||
char *const*_src = (char*const*)src, **_dst = (char**)dst;
|
||||
*_dst = (*_src == NULL) ? NULL : strdup(*_src);
|
||||
}
|
||||
static void utarray_str_dtor(void *elt) {
|
||||
char **eltc = (char**)elt;
|
||||
if (*eltc) free(*eltc);
|
||||
}
|
||||
static const UT_icd ut_str_icd _UNUSED_ = {sizeof(char*),NULL,utarray_str_cpy,utarray_str_dtor};
|
||||
static const UT_icd ut_int_icd _UNUSED_ = {sizeof(int),NULL,NULL,NULL};
|
||||
static const UT_icd ut_ptr_icd _UNUSED_ = {sizeof(void*),NULL,NULL,NULL};
|
||||
|
||||
|
||||
#endif /* UTARRAY_H */
|
919
contrib/elftoolchain/common/uthash.h
Normal file
919
contrib/elftoolchain/common/uthash.h
Normal file
@ -0,0 +1,919 @@
|
||||
/*
|
||||
Copyright (c) 2003-2013, Troy D. Hanson http://uthash.sourceforge.net
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: uthash.h 2682 2012-11-23 22:04:22Z kaiwang27 $ */
|
||||
|
||||
#ifndef UTHASH_H
|
||||
#define UTHASH_H
|
||||
|
||||
#include <string.h> /* memcmp,strlen */
|
||||
#include <stddef.h> /* ptrdiff_t */
|
||||
#include <stdlib.h> /* exit() */
|
||||
|
||||
/* These macros use decltype or the earlier __typeof GNU extension.
|
||||
As decltype is only available in newer compilers (VS2010 or gcc 4.3+
|
||||
when compiling c++ source) this code uses whatever method is needed
|
||||
or, for VS2008 where neither is available, uses casting workarounds. */
|
||||
#ifdef _MSC_VER /* MS compiler */
|
||||
#if _MSC_VER >= 1600 && defined(__cplusplus) /* VS2010 or newer in C++ mode */
|
||||
#define DECLTYPE(x) (decltype(x))
|
||||
#else /* VS2008 or older (or VS2010 in C mode) */
|
||||
#define NO_DECLTYPE
|
||||
#define DECLTYPE(x)
|
||||
#endif
|
||||
#else /* GNU, Sun and other compilers */
|
||||
#define DECLTYPE(x) (__typeof(x))
|
||||
#endif
|
||||
|
||||
#ifdef NO_DECLTYPE
|
||||
#define DECLTYPE_ASSIGN(dst,src) \
|
||||
do { \
|
||||
char **_da_dst = (char**)(&(dst)); \
|
||||
*_da_dst = (char*)(src); \
|
||||
} while(0)
|
||||
#else
|
||||
#define DECLTYPE_ASSIGN(dst,src) \
|
||||
do { \
|
||||
(dst) = DECLTYPE(dst)(src); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/* a number of the hash function use uint32_t which isn't defined on win32 */
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
#else
|
||||
#include <inttypes.h> /* uint32_t */
|
||||
#endif
|
||||
|
||||
#define UTHASH_VERSION 1.9.7
|
||||
|
||||
#ifndef uthash_fatal
|
||||
#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */
|
||||
#endif
|
||||
#ifndef uthash_malloc
|
||||
#define uthash_malloc(sz) malloc(sz) /* malloc fcn */
|
||||
#endif
|
||||
#ifndef uthash_free
|
||||
#define uthash_free(ptr,sz) free(ptr) /* free fcn */
|
||||
#endif
|
||||
|
||||
#ifndef uthash_noexpand_fyi
|
||||
#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */
|
||||
#endif
|
||||
#ifndef uthash_expand_fyi
|
||||
#define uthash_expand_fyi(tbl) /* can be defined to log expands */
|
||||
#endif
|
||||
|
||||
/* initial number of buckets */
|
||||
#define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */
|
||||
#define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */
|
||||
#define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */
|
||||
|
||||
/* calculate the element whose hash handle address is hhe */
|
||||
#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho)))
|
||||
|
||||
#define HASH_FIND(hh,head,keyptr,keylen,out) \
|
||||
do { \
|
||||
unsigned _hf_bkt,_hf_hashv; \
|
||||
out=NULL; \
|
||||
if (head) { \
|
||||
HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \
|
||||
if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \
|
||||
HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \
|
||||
keyptr,keylen,out); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef HASH_BLOOM
|
||||
#define HASH_BLOOM_BITLEN (1ULL << HASH_BLOOM)
|
||||
#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0)
|
||||
#define HASH_BLOOM_MAKE(tbl) \
|
||||
do { \
|
||||
(tbl)->bloom_nbits = HASH_BLOOM; \
|
||||
(tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \
|
||||
if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \
|
||||
memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \
|
||||
(tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \
|
||||
} while (0)
|
||||
|
||||
#define HASH_BLOOM_FREE(tbl) \
|
||||
do { \
|
||||
uthash_free((tbl)->bloom_bv, HASH_BLOOM_BYTELEN); \
|
||||
} while (0)
|
||||
|
||||
#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8)))
|
||||
#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8)))
|
||||
|
||||
#define HASH_BLOOM_ADD(tbl,hashv) \
|
||||
HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1)))
|
||||
|
||||
#define HASH_BLOOM_TEST(tbl,hashv) \
|
||||
HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1)))
|
||||
|
||||
#else
|
||||
#define HASH_BLOOM_MAKE(tbl)
|
||||
#define HASH_BLOOM_FREE(tbl)
|
||||
#define HASH_BLOOM_ADD(tbl,hashv)
|
||||
#define HASH_BLOOM_TEST(tbl,hashv) (1)
|
||||
#endif
|
||||
|
||||
#define HASH_MAKE_TABLE(hh,head) \
|
||||
do { \
|
||||
(head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
|
||||
sizeof(UT_hash_table)); \
|
||||
if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
|
||||
memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
|
||||
(head)->hh.tbl->tail = &((head)->hh); \
|
||||
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
|
||||
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
|
||||
(head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \
|
||||
(head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
|
||||
HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
|
||||
if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
|
||||
memset((head)->hh.tbl->buckets, 0, \
|
||||
HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
|
||||
HASH_BLOOM_MAKE((head)->hh.tbl); \
|
||||
(head)->hh.tbl->signature = HASH_SIGNATURE; \
|
||||
} while(0)
|
||||
|
||||
#define HASH_ADD(hh,head,fieldname,keylen_in,add) \
|
||||
HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add)
|
||||
|
||||
#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \
|
||||
do { \
|
||||
unsigned _ha_bkt; \
|
||||
(add)->hh.next = NULL; \
|
||||
(add)->hh.key = (char*)keyptr; \
|
||||
(add)->hh.keylen = (unsigned)keylen_in; \
|
||||
if (!(head)) { \
|
||||
head = (add); \
|
||||
(head)->hh.prev = NULL; \
|
||||
HASH_MAKE_TABLE(hh,head); \
|
||||
} else { \
|
||||
(head)->hh.tbl->tail->next = (add); \
|
||||
(add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
|
||||
(head)->hh.tbl->tail = &((add)->hh); \
|
||||
} \
|
||||
(head)->hh.tbl->num_items++; \
|
||||
(add)->hh.tbl = (head)->hh.tbl; \
|
||||
HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \
|
||||
(add)->hh.hashv, _ha_bkt); \
|
||||
HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \
|
||||
HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \
|
||||
HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \
|
||||
HASH_FSCK(hh,head); \
|
||||
} while(0)
|
||||
|
||||
#define HASH_TO_BKT( hashv, num_bkts, bkt ) \
|
||||
do { \
|
||||
bkt = ((hashv) & ((num_bkts) - 1)); \
|
||||
} while(0)
|
||||
|
||||
/* delete "delptr" from the hash table.
|
||||
* "the usual" patch-up process for the app-order doubly-linked-list.
|
||||
* The use of _hd_hh_del below deserves special explanation.
|
||||
* These used to be expressed using (delptr) but that led to a bug
|
||||
* if someone used the same symbol for the head and deletee, like
|
||||
* HASH_DELETE(hh,users,users);
|
||||
* We want that to work, but by changing the head (users) below
|
||||
* we were forfeiting our ability to further refer to the deletee (users)
|
||||
* in the patch-up process. Solution: use scratch space to
|
||||
* copy the deletee pointer, then the latter references are via that
|
||||
* scratch pointer rather than through the repointed (users) symbol.
|
||||
*/
|
||||
#define HASH_DELETE(hh,head,delptr) \
|
||||
do { \
|
||||
unsigned _hd_bkt; \
|
||||
struct UT_hash_handle *_hd_hh_del; \
|
||||
if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \
|
||||
uthash_free((head)->hh.tbl->buckets, \
|
||||
(head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
|
||||
HASH_BLOOM_FREE((head)->hh.tbl); \
|
||||
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||
head = NULL; \
|
||||
} else { \
|
||||
_hd_hh_del = &((delptr)->hh); \
|
||||
if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \
|
||||
(head)->hh.tbl->tail = \
|
||||
(UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \
|
||||
(head)->hh.tbl->hho); \
|
||||
} \
|
||||
if ((delptr)->hh.prev) { \
|
||||
((UT_hash_handle*)((ptrdiff_t)((delptr)->hh.prev) + \
|
||||
(head)->hh.tbl->hho))->next = (delptr)->hh.next; \
|
||||
} else { \
|
||||
DECLTYPE_ASSIGN(head,(delptr)->hh.next); \
|
||||
} \
|
||||
if (_hd_hh_del->next) { \
|
||||
((UT_hash_handle*)((ptrdiff_t)_hd_hh_del->next + \
|
||||
(head)->hh.tbl->hho))->prev = \
|
||||
_hd_hh_del->prev; \
|
||||
} \
|
||||
HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \
|
||||
HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \
|
||||
(head)->hh.tbl->num_items--; \
|
||||
} \
|
||||
HASH_FSCK(hh,head); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */
|
||||
#define HASH_FIND_STR(head,findstr,out) \
|
||||
HASH_FIND(hh,head,findstr,strlen(findstr),out)
|
||||
#define HASH_ADD_STR(head,strfield,add) \
|
||||
HASH_ADD(hh,head,strfield,strlen(add->strfield),add)
|
||||
#define HASH_FIND_INT(head,findint,out) \
|
||||
HASH_FIND(hh,head,findint,sizeof(int),out)
|
||||
#define HASH_ADD_INT(head,intfield,add) \
|
||||
HASH_ADD(hh,head,intfield,sizeof(int),add)
|
||||
#define HASH_FIND_PTR(head,findptr,out) \
|
||||
HASH_FIND(hh,head,findptr,sizeof(void *),out)
|
||||
#define HASH_ADD_PTR(head,ptrfield,add) \
|
||||
HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
|
||||
#define HASH_DEL(head,delptr) \
|
||||
HASH_DELETE(hh,head,delptr)
|
||||
|
||||
/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined.
|
||||
* This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined.
|
||||
*/
|
||||
#ifdef HASH_DEBUG
|
||||
#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0)
|
||||
#define HASH_FSCK(hh,head) \
|
||||
do { \
|
||||
unsigned _bkt_i; \
|
||||
unsigned _count, _bkt_count; \
|
||||
char *_prev; \
|
||||
struct UT_hash_handle *_thh; \
|
||||
if (head) { \
|
||||
_count = 0; \
|
||||
for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \
|
||||
_bkt_count = 0; \
|
||||
_thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \
|
||||
_prev = NULL; \
|
||||
while (_thh) { \
|
||||
if (_prev != (char*)(_thh->hh_prev)) { \
|
||||
HASH_OOPS("invalid hh_prev %p, actual %p\n", \
|
||||
_thh->hh_prev, _prev ); \
|
||||
} \
|
||||
_bkt_count++; \
|
||||
_prev = (char*)(_thh); \
|
||||
_thh = _thh->hh_next; \
|
||||
} \
|
||||
_count += _bkt_count; \
|
||||
if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \
|
||||
HASH_OOPS("invalid bucket count %d, actual %d\n", \
|
||||
(head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \
|
||||
} \
|
||||
} \
|
||||
if (_count != (head)->hh.tbl->num_items) { \
|
||||
HASH_OOPS("invalid hh item count %d, actual %d\n", \
|
||||
(head)->hh.tbl->num_items, _count ); \
|
||||
} \
|
||||
/* traverse hh in app order; check next/prev integrity, count */ \
|
||||
_count = 0; \
|
||||
_prev = NULL; \
|
||||
_thh = &(head)->hh; \
|
||||
while (_thh) { \
|
||||
_count++; \
|
||||
if (_prev !=(char*)(_thh->prev)) { \
|
||||
HASH_OOPS("invalid prev %p, actual %p\n", \
|
||||
_thh->prev, _prev ); \
|
||||
} \
|
||||
_prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \
|
||||
_thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \
|
||||
(head)->hh.tbl->hho) : NULL ); \
|
||||
} \
|
||||
if (_count != (head)->hh.tbl->num_items) { \
|
||||
HASH_OOPS("invalid app item count %d, actual %d\n", \
|
||||
(head)->hh.tbl->num_items, _count ); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define HASH_FSCK(hh,head)
|
||||
#endif
|
||||
|
||||
/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to
|
||||
* the descriptor to which this macro is defined for tuning the hash function.
|
||||
* The app can #include <unistd.h> to get the prototype for write(2). */
|
||||
#ifdef HASH_EMIT_KEYS
|
||||
#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \
|
||||
do { \
|
||||
unsigned _klen = fieldlen; \
|
||||
write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \
|
||||
write(HASH_EMIT_KEYS, keyptr, fieldlen); \
|
||||
} while (0)
|
||||
#else
|
||||
#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)
|
||||
#endif
|
||||
|
||||
/* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */
|
||||
#ifdef HASH_FUNCTION
|
||||
#define HASH_FCN HASH_FUNCTION
|
||||
#else
|
||||
#define HASH_FCN HASH_JEN
|
||||
#endif
|
||||
|
||||
/* The Bernstein hash function, used in Perl prior to v5.6 */
|
||||
#define HASH_BER(key,keylen,num_bkts,hashv,bkt) \
|
||||
do { \
|
||||
unsigned _hb_keylen=keylen; \
|
||||
char *_hb_key=(char*)(key); \
|
||||
(hashv) = 0; \
|
||||
while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \
|
||||
bkt = (hashv) & (num_bkts-1); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at
|
||||
* http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */
|
||||
#define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \
|
||||
do { \
|
||||
unsigned _sx_i; \
|
||||
char *_hs_key=(char*)(key); \
|
||||
hashv = 0; \
|
||||
for(_sx_i=0; _sx_i < keylen; _sx_i++) \
|
||||
hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \
|
||||
bkt = hashv & (num_bkts-1); \
|
||||
} while (0)
|
||||
|
||||
#define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \
|
||||
do { \
|
||||
unsigned _fn_i; \
|
||||
char *_hf_key=(char*)(key); \
|
||||
hashv = 2166136261UL; \
|
||||
for(_fn_i=0; _fn_i < keylen; _fn_i++) \
|
||||
hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \
|
||||
bkt = hashv & (num_bkts-1); \
|
||||
} while(0)
|
||||
|
||||
#define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \
|
||||
do { \
|
||||
unsigned _ho_i; \
|
||||
char *_ho_key=(char*)(key); \
|
||||
hashv = 0; \
|
||||
for(_ho_i=0; _ho_i < keylen; _ho_i++) { \
|
||||
hashv += _ho_key[_ho_i]; \
|
||||
hashv += (hashv << 10); \
|
||||
hashv ^= (hashv >> 6); \
|
||||
} \
|
||||
hashv += (hashv << 3); \
|
||||
hashv ^= (hashv >> 11); \
|
||||
hashv += (hashv << 15); \
|
||||
bkt = hashv & (num_bkts-1); \
|
||||
} while(0)
|
||||
|
||||
#define HASH_JEN_MIX(a,b,c) \
|
||||
do { \
|
||||
a -= b; a -= c; a ^= ( c >> 13 ); \
|
||||
b -= c; b -= a; b ^= ( a << 8 ); \
|
||||
c -= a; c -= b; c ^= ( b >> 13 ); \
|
||||
a -= b; a -= c; a ^= ( c >> 12 ); \
|
||||
b -= c; b -= a; b ^= ( a << 16 ); \
|
||||
c -= a; c -= b; c ^= ( b >> 5 ); \
|
||||
a -= b; a -= c; a ^= ( c >> 3 ); \
|
||||
b -= c; b -= a; b ^= ( a << 10 ); \
|
||||
c -= a; c -= b; c ^= ( b >> 15 ); \
|
||||
} while (0)
|
||||
|
||||
#define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \
|
||||
do { \
|
||||
unsigned _hj_i,_hj_j,_hj_k; \
|
||||
char *_hj_key=(char*)(key); \
|
||||
hashv = 0xfeedbeef; \
|
||||
_hj_i = _hj_j = 0x9e3779b9; \
|
||||
_hj_k = (unsigned)keylen; \
|
||||
while (_hj_k >= 12) { \
|
||||
_hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \
|
||||
+ ( (unsigned)_hj_key[2] << 16 ) \
|
||||
+ ( (unsigned)_hj_key[3] << 24 ) ); \
|
||||
_hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \
|
||||
+ ( (unsigned)_hj_key[6] << 16 ) \
|
||||
+ ( (unsigned)_hj_key[7] << 24 ) ); \
|
||||
hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \
|
||||
+ ( (unsigned)_hj_key[10] << 16 ) \
|
||||
+ ( (unsigned)_hj_key[11] << 24 ) ); \
|
||||
\
|
||||
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
|
||||
\
|
||||
_hj_key += 12; \
|
||||
_hj_k -= 12; \
|
||||
} \
|
||||
hashv += keylen; \
|
||||
switch ( _hj_k ) { \
|
||||
case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); \
|
||||
case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); \
|
||||
case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); \
|
||||
case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); \
|
||||
case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); \
|
||||
case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); \
|
||||
case 5: _hj_j += _hj_key[4]; \
|
||||
case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); \
|
||||
case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); \
|
||||
case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); \
|
||||
case 1: _hj_i += _hj_key[0]; \
|
||||
} \
|
||||
HASH_JEN_MIX(_hj_i, _hj_j, hashv); \
|
||||
bkt = hashv & (num_bkts-1); \
|
||||
} while(0)
|
||||
|
||||
/* The Paul Hsieh hash function */
|
||||
#undef get16bits
|
||||
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|
||||
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
|
||||
#define get16bits(d) (*((const uint16_t *) (d)))
|
||||
#endif
|
||||
|
||||
#if !defined (get16bits)
|
||||
#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
|
||||
+(uint32_t)(((const uint8_t *)(d))[0]) )
|
||||
#endif
|
||||
#define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \
|
||||
do { \
|
||||
char *_sfh_key=(char*)(key); \
|
||||
uint32_t _sfh_tmp, _sfh_len = keylen; \
|
||||
\
|
||||
int _sfh_rem = _sfh_len & 3; \
|
||||
_sfh_len >>= 2; \
|
||||
hashv = 0xcafebabe; \
|
||||
\
|
||||
/* Main loop */ \
|
||||
for (;_sfh_len > 0; _sfh_len--) { \
|
||||
hashv += get16bits (_sfh_key); \
|
||||
_sfh_tmp = (get16bits (_sfh_key+2) << 11) ^ hashv; \
|
||||
hashv = (hashv << 16) ^ _sfh_tmp; \
|
||||
_sfh_key += 2*sizeof (uint16_t); \
|
||||
hashv += hashv >> 11; \
|
||||
} \
|
||||
\
|
||||
/* Handle end cases */ \
|
||||
switch (_sfh_rem) { \
|
||||
case 3: hashv += get16bits (_sfh_key); \
|
||||
hashv ^= hashv << 16; \
|
||||
hashv ^= _sfh_key[sizeof (uint16_t)] << 18; \
|
||||
hashv += hashv >> 11; \
|
||||
break; \
|
||||
case 2: hashv += get16bits (_sfh_key); \
|
||||
hashv ^= hashv << 11; \
|
||||
hashv += hashv >> 17; \
|
||||
break; \
|
||||
case 1: hashv += *_sfh_key; \
|
||||
hashv ^= hashv << 10; \
|
||||
hashv += hashv >> 1; \
|
||||
} \
|
||||
\
|
||||
/* Force "avalanching" of final 127 bits */ \
|
||||
hashv ^= hashv << 3; \
|
||||
hashv += hashv >> 5; \
|
||||
hashv ^= hashv << 4; \
|
||||
hashv += hashv >> 17; \
|
||||
hashv ^= hashv << 25; \
|
||||
hashv += hashv >> 6; \
|
||||
bkt = hashv & (num_bkts-1); \
|
||||
} while(0)
|
||||
|
||||
#ifdef HASH_USING_NO_STRICT_ALIASING
|
||||
/* The MurmurHash exploits some CPU's (x86,x86_64) tolerance for unaligned reads.
|
||||
* For other types of CPU's (e.g. Sparc) an unaligned read causes a bus error.
|
||||
* MurmurHash uses the faster approach only on CPU's where we know it's safe.
|
||||
*
|
||||
* Note the preprocessor built-in defines can be emitted using:
|
||||
*
|
||||
* gcc -m64 -dM -E - < /dev/null (on gcc)
|
||||
* cc -## a.c (where a.c is a simple test file) (Sun Studio)
|
||||
*/
|
||||
#if (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86))
|
||||
#define MUR_GETBLOCK(p,i) p[i]
|
||||
#else /* non intel */
|
||||
#define MUR_PLUS0_ALIGNED(p) (((unsigned long)p & 0x3) == 0)
|
||||
#define MUR_PLUS1_ALIGNED(p) (((unsigned long)p & 0x3) == 1)
|
||||
#define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 0x3) == 2)
|
||||
#define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 0x3) == 3)
|
||||
#define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL))
|
||||
#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__))
|
||||
#define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24))
|
||||
#define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16))
|
||||
#define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8))
|
||||
#else /* assume little endian non-intel */
|
||||
#define MUR_THREE_ONE(p) ((((*WP(p))&0xffffff00) >> 8) | (((*(WP(p)+1))&0x000000ff) << 24))
|
||||
#define MUR_TWO_TWO(p) ((((*WP(p))&0xffff0000) >>16) | (((*(WP(p)+1))&0x0000ffff) << 16))
|
||||
#define MUR_ONE_THREE(p) ((((*WP(p))&0xff000000) >>24) | (((*(WP(p)+1))&0x00ffffff) << 8))
|
||||
#endif
|
||||
#define MUR_GETBLOCK(p,i) (MUR_PLUS0_ALIGNED(p) ? ((p)[i]) : \
|
||||
(MUR_PLUS1_ALIGNED(p) ? MUR_THREE_ONE(p) : \
|
||||
(MUR_PLUS2_ALIGNED(p) ? MUR_TWO_TWO(p) : \
|
||||
MUR_ONE_THREE(p))))
|
||||
#endif
|
||||
#define MUR_ROTL32(x,r) (((x) << (r)) | ((x) >> (32 - (r))))
|
||||
#define MUR_FMIX(_h) \
|
||||
do { \
|
||||
_h ^= _h >> 16; \
|
||||
_h *= 0x85ebca6b; \
|
||||
_h ^= _h >> 13; \
|
||||
_h *= 0xc2b2ae35l; \
|
||||
_h ^= _h >> 16; \
|
||||
} while(0)
|
||||
|
||||
#define HASH_MUR(key,keylen,num_bkts,hashv,bkt) \
|
||||
do { \
|
||||
const uint8_t *_mur_data = (const uint8_t*)(key); \
|
||||
const int _mur_nblocks = (keylen) / 4; \
|
||||
uint32_t _mur_h1 = 0xf88D5353; \
|
||||
uint32_t _mur_c1 = 0xcc9e2d51; \
|
||||
uint32_t _mur_c2 = 0x1b873593; \
|
||||
uint32_t _mur_k1 = 0; \
|
||||
const uint8_t *_mur_tail; \
|
||||
const uint32_t *_mur_blocks = (const uint32_t*)(_mur_data+_mur_nblocks*4); \
|
||||
int _mur_i; \
|
||||
for(_mur_i = -_mur_nblocks; _mur_i; _mur_i++) { \
|
||||
_mur_k1 = MUR_GETBLOCK(_mur_blocks,_mur_i); \
|
||||
_mur_k1 *= _mur_c1; \
|
||||
_mur_k1 = MUR_ROTL32(_mur_k1,15); \
|
||||
_mur_k1 *= _mur_c2; \
|
||||
\
|
||||
_mur_h1 ^= _mur_k1; \
|
||||
_mur_h1 = MUR_ROTL32(_mur_h1,13); \
|
||||
_mur_h1 = _mur_h1*5+0xe6546b64; \
|
||||
} \
|
||||
_mur_tail = (const uint8_t*)(_mur_data + _mur_nblocks*4); \
|
||||
_mur_k1=0; \
|
||||
switch((keylen) & 3) { \
|
||||
case 3: _mur_k1 ^= _mur_tail[2] << 16; \
|
||||
case 2: _mur_k1 ^= _mur_tail[1] << 8; \
|
||||
case 1: _mur_k1 ^= _mur_tail[0]; \
|
||||
_mur_k1 *= _mur_c1; \
|
||||
_mur_k1 = MUR_ROTL32(_mur_k1,15); \
|
||||
_mur_k1 *= _mur_c2; \
|
||||
_mur_h1 ^= _mur_k1; \
|
||||
} \
|
||||
_mur_h1 ^= (keylen); \
|
||||
MUR_FMIX(_mur_h1); \
|
||||
hashv = _mur_h1; \
|
||||
bkt = hashv & (num_bkts-1); \
|
||||
} while(0)
|
||||
#endif /* HASH_USING_NO_STRICT_ALIASING */
|
||||
|
||||
/* key comparison function; return 0 if keys equal */
|
||||
#define HASH_KEYCMP(a,b,len) memcmp(a,b,len)
|
||||
|
||||
/* iterate over items in a known bucket to find desired item */
|
||||
#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \
|
||||
do { \
|
||||
if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \
|
||||
else out=NULL; \
|
||||
while (out) { \
|
||||
if ((out)->hh.keylen == keylen_in) { \
|
||||
if ((HASH_KEYCMP((out)->hh.key,keyptr,keylen_in)) == 0) break; \
|
||||
} \
|
||||
if ((out)->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,(out)->hh.hh_next)); \
|
||||
else out = NULL; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* add an item to a bucket */
|
||||
#define HASH_ADD_TO_BKT(head,addhh) \
|
||||
do { \
|
||||
head.count++; \
|
||||
(addhh)->hh_next = head.hh_head; \
|
||||
(addhh)->hh_prev = NULL; \
|
||||
if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \
|
||||
(head).hh_head=addhh; \
|
||||
if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \
|
||||
&& (addhh)->tbl->noexpand != 1) { \
|
||||
HASH_EXPAND_BUCKETS((addhh)->tbl); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* remove an item from a given bucket */
|
||||
#define HASH_DEL_IN_BKT(hh,head,hh_del) \
|
||||
(head).count--; \
|
||||
if ((head).hh_head == hh_del) { \
|
||||
(head).hh_head = hh_del->hh_next; \
|
||||
} \
|
||||
if (hh_del->hh_prev) { \
|
||||
hh_del->hh_prev->hh_next = hh_del->hh_next; \
|
||||
} \
|
||||
if (hh_del->hh_next) { \
|
||||
hh_del->hh_next->hh_prev = hh_del->hh_prev; \
|
||||
}
|
||||
|
||||
/* Bucket expansion has the effect of doubling the number of buckets
|
||||
* and redistributing the items into the new buckets. Ideally the
|
||||
* items will distribute more or less evenly into the new buckets
|
||||
* (the extent to which this is true is a measure of the quality of
|
||||
* the hash function as it applies to the key domain).
|
||||
*
|
||||
* With the items distributed into more buckets, the chain length
|
||||
* (item count) in each bucket is reduced. Thus by expanding buckets
|
||||
* the hash keeps a bound on the chain length. This bounded chain
|
||||
* length is the essence of how a hash provides constant time lookup.
|
||||
*
|
||||
* The calculation of tbl->ideal_chain_maxlen below deserves some
|
||||
* explanation. First, keep in mind that we're calculating the ideal
|
||||
* maximum chain length based on the *new* (doubled) bucket count.
|
||||
* In fractions this is just n/b (n=number of items,b=new num buckets).
|
||||
* Since the ideal chain length is an integer, we want to calculate
|
||||
* ceil(n/b). We don't depend on floating point arithmetic in this
|
||||
* hash, so to calculate ceil(n/b) with integers we could write
|
||||
*
|
||||
* ceil(n/b) = (n/b) + ((n%b)?1:0)
|
||||
*
|
||||
* and in fact a previous version of this hash did just that.
|
||||
* But now we have improved things a bit by recognizing that b is
|
||||
* always a power of two. We keep its base 2 log handy (call it lb),
|
||||
* so now we can write this with a bit shift and logical AND:
|
||||
*
|
||||
* ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0)
|
||||
*
|
||||
*/
|
||||
#define HASH_EXPAND_BUCKETS(tbl) \
|
||||
do { \
|
||||
unsigned _he_bkt; \
|
||||
unsigned _he_bkt_i; \
|
||||
struct UT_hash_handle *_he_thh, *_he_hh_nxt; \
|
||||
UT_hash_bucket *_he_new_buckets, *_he_newbkt; \
|
||||
_he_new_buckets = (UT_hash_bucket*)uthash_malloc( \
|
||||
2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
|
||||
if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \
|
||||
memset(_he_new_buckets, 0, \
|
||||
2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \
|
||||
tbl->ideal_chain_maxlen = \
|
||||
(tbl->num_items >> (tbl->log2_num_buckets+1)) + \
|
||||
((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \
|
||||
tbl->nonideal_items = 0; \
|
||||
for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \
|
||||
{ \
|
||||
_he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \
|
||||
while (_he_thh) { \
|
||||
_he_hh_nxt = _he_thh->hh_next; \
|
||||
HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \
|
||||
_he_newbkt = &(_he_new_buckets[ _he_bkt ]); \
|
||||
if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \
|
||||
tbl->nonideal_items++; \
|
||||
_he_newbkt->expand_mult = _he_newbkt->count / \
|
||||
tbl->ideal_chain_maxlen; \
|
||||
} \
|
||||
_he_thh->hh_prev = NULL; \
|
||||
_he_thh->hh_next = _he_newbkt->hh_head; \
|
||||
if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \
|
||||
_he_thh; \
|
||||
_he_newbkt->hh_head = _he_thh; \
|
||||
_he_thh = _he_hh_nxt; \
|
||||
} \
|
||||
} \
|
||||
uthash_free( tbl->buckets, tbl->num_buckets*sizeof(struct UT_hash_bucket) ); \
|
||||
tbl->num_buckets *= 2; \
|
||||
tbl->log2_num_buckets++; \
|
||||
tbl->buckets = _he_new_buckets; \
|
||||
tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \
|
||||
(tbl->ineff_expands+1) : 0; \
|
||||
if (tbl->ineff_expands > 1) { \
|
||||
tbl->noexpand=1; \
|
||||
uthash_noexpand_fyi(tbl); \
|
||||
} \
|
||||
uthash_expand_fyi(tbl); \
|
||||
} while(0)
|
||||
|
||||
|
||||
/* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */
|
||||
/* Note that HASH_SORT assumes the hash handle name to be hh.
|
||||
* HASH_SRT was added to allow the hash handle name to be passed in. */
|
||||
#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn)
|
||||
#define HASH_SRT(hh,head,cmpfcn) \
|
||||
do { \
|
||||
unsigned _hs_i; \
|
||||
unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \
|
||||
struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \
|
||||
if (head) { \
|
||||
_hs_insize = 1; \
|
||||
_hs_looping = 1; \
|
||||
_hs_list = &((head)->hh); \
|
||||
while (_hs_looping) { \
|
||||
_hs_p = _hs_list; \
|
||||
_hs_list = NULL; \
|
||||
_hs_tail = NULL; \
|
||||
_hs_nmerges = 0; \
|
||||
while (_hs_p) { \
|
||||
_hs_nmerges++; \
|
||||
_hs_q = _hs_p; \
|
||||
_hs_psize = 0; \
|
||||
for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \
|
||||
_hs_psize++; \
|
||||
_hs_q = (UT_hash_handle*)((_hs_q->next) ? \
|
||||
((void*)((char*)(_hs_q->next) + \
|
||||
(head)->hh.tbl->hho)) : NULL); \
|
||||
if (! (_hs_q) ) break; \
|
||||
} \
|
||||
_hs_qsize = _hs_insize; \
|
||||
while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q )) { \
|
||||
if (_hs_psize == 0) { \
|
||||
_hs_e = _hs_q; \
|
||||
_hs_q = (UT_hash_handle*)((_hs_q->next) ? \
|
||||
((void*)((char*)(_hs_q->next) + \
|
||||
(head)->hh.tbl->hho)) : NULL); \
|
||||
_hs_qsize--; \
|
||||
} else if ( (_hs_qsize == 0) || !(_hs_q) ) { \
|
||||
_hs_e = _hs_p; \
|
||||
_hs_p = (UT_hash_handle*)((_hs_p->next) ? \
|
||||
((void*)((char*)(_hs_p->next) + \
|
||||
(head)->hh.tbl->hho)) : NULL); \
|
||||
_hs_psize--; \
|
||||
} else if (( \
|
||||
cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \
|
||||
DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \
|
||||
) <= 0) { \
|
||||
_hs_e = _hs_p; \
|
||||
_hs_p = (UT_hash_handle*)((_hs_p->next) ? \
|
||||
((void*)((char*)(_hs_p->next) + \
|
||||
(head)->hh.tbl->hho)) : NULL); \
|
||||
_hs_psize--; \
|
||||
} else { \
|
||||
_hs_e = _hs_q; \
|
||||
_hs_q = (UT_hash_handle*)((_hs_q->next) ? \
|
||||
((void*)((char*)(_hs_q->next) + \
|
||||
(head)->hh.tbl->hho)) : NULL); \
|
||||
_hs_qsize--; \
|
||||
} \
|
||||
if ( _hs_tail ) { \
|
||||
_hs_tail->next = ((_hs_e) ? \
|
||||
ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \
|
||||
} else { \
|
||||
_hs_list = _hs_e; \
|
||||
} \
|
||||
_hs_e->prev = ((_hs_tail) ? \
|
||||
ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \
|
||||
_hs_tail = _hs_e; \
|
||||
} \
|
||||
_hs_p = _hs_q; \
|
||||
} \
|
||||
_hs_tail->next = NULL; \
|
||||
if ( _hs_nmerges <= 1 ) { \
|
||||
_hs_looping=0; \
|
||||
(head)->hh.tbl->tail = _hs_tail; \
|
||||
DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \
|
||||
} \
|
||||
_hs_insize *= 2; \
|
||||
} \
|
||||
HASH_FSCK(hh,head); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* This function selects items from one hash into another hash.
|
||||
* The end result is that the selected items have dual presence
|
||||
* in both hashes. There is no copy of the items made; rather
|
||||
* they are added into the new hash through a secondary hash
|
||||
* hash handle that must be present in the structure. */
|
||||
#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \
|
||||
do { \
|
||||
unsigned _src_bkt, _dst_bkt; \
|
||||
void *_last_elt=NULL, *_elt; \
|
||||
UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \
|
||||
ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \
|
||||
if (src) { \
|
||||
for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \
|
||||
for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \
|
||||
_src_hh; \
|
||||
_src_hh = _src_hh->hh_next) { \
|
||||
_elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \
|
||||
if (cond(_elt)) { \
|
||||
_dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \
|
||||
_dst_hh->key = _src_hh->key; \
|
||||
_dst_hh->keylen = _src_hh->keylen; \
|
||||
_dst_hh->hashv = _src_hh->hashv; \
|
||||
_dst_hh->prev = _last_elt; \
|
||||
_dst_hh->next = NULL; \
|
||||
if (_last_elt_hh) { _last_elt_hh->next = _elt; } \
|
||||
if (!dst) { \
|
||||
DECLTYPE_ASSIGN(dst,_elt); \
|
||||
HASH_MAKE_TABLE(hh_dst,dst); \
|
||||
} else { \
|
||||
_dst_hh->tbl = (dst)->hh_dst.tbl; \
|
||||
} \
|
||||
HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \
|
||||
HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \
|
||||
(dst)->hh_dst.tbl->num_items++; \
|
||||
_last_elt = _elt; \
|
||||
_last_elt_hh = _dst_hh; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
HASH_FSCK(hh_dst,dst); \
|
||||
} while (0)
|
||||
|
||||
#define HASH_CLEAR(hh,head) \
|
||||
do { \
|
||||
if (head) { \
|
||||
uthash_free((head)->hh.tbl->buckets, \
|
||||
(head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
|
||||
HASH_BLOOM_FREE((head)->hh.tbl); \
|
||||
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
|
||||
(head)=NULL; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifdef NO_DECLTYPE
|
||||
#define HASH_ITER(hh,head,el,tmp) \
|
||||
for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \
|
||||
el; (el)=(tmp),(*(char**)(&(tmp)))=(char*)((tmp)?(tmp)->hh.next:NULL))
|
||||
#else
|
||||
#define HASH_ITER(hh,head,el,tmp) \
|
||||
for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \
|
||||
el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL))
|
||||
#endif
|
||||
|
||||
/* obtain a count of items in the hash */
|
||||
#define HASH_COUNT(head) HASH_CNT(hh,head)
|
||||
#define HASH_CNT(hh,head) ((head)?((head)->hh.tbl->num_items):0)
|
||||
|
||||
typedef struct UT_hash_bucket {
|
||||
struct UT_hash_handle *hh_head;
|
||||
unsigned count;
|
||||
|
||||
/* expand_mult is normally set to 0. In this situation, the max chain length
|
||||
* threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If
|
||||
* the bucket's chain exceeds this length, bucket expansion is triggered).
|
||||
* However, setting expand_mult to a non-zero value delays bucket expansion
|
||||
* (that would be triggered by additions to this particular bucket)
|
||||
* until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH.
|
||||
* (The multiplier is simply expand_mult+1). The whole idea of this
|
||||
* multiplier is to reduce bucket expansions, since they are expensive, in
|
||||
* situations where we know that a particular bucket tends to be overused.
|
||||
* It is better to let its chain length grow to a longer yet-still-bounded
|
||||
* value, than to do an O(n) bucket expansion too often.
|
||||
*/
|
||||
unsigned expand_mult;
|
||||
|
||||
} UT_hash_bucket;
|
||||
|
||||
/* random signature used only to find hash tables in external analysis */
|
||||
#define HASH_SIGNATURE 0xa0111fe1
|
||||
#define HASH_BLOOM_SIGNATURE 0xb12220f2
|
||||
|
||||
typedef struct UT_hash_table {
|
||||
UT_hash_bucket *buckets;
|
||||
unsigned num_buckets, log2_num_buckets;
|
||||
unsigned num_items;
|
||||
struct UT_hash_handle *tail; /* tail hh in app order, for fast append */
|
||||
ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */
|
||||
|
||||
/* in an ideal situation (all buckets used equally), no bucket would have
|
||||
* more than ceil(#items/#buckets) items. that's the ideal chain length. */
|
||||
unsigned ideal_chain_maxlen;
|
||||
|
||||
/* nonideal_items is the number of items in the hash whose chain position
|
||||
* exceeds the ideal chain maxlen. these items pay the penalty for an uneven
|
||||
* hash distribution; reaching them in a chain traversal takes >ideal steps */
|
||||
unsigned nonideal_items;
|
||||
|
||||
/* ineffective expands occur when a bucket doubling was performed, but
|
||||
* afterward, more than half the items in the hash had nonideal chain
|
||||
* positions. If this happens on two consecutive expansions we inhibit any
|
||||
* further expansion, as it's not helping; this happens when the hash
|
||||
* function isn't a good fit for the key domain. When expansion is inhibited
|
||||
* the hash will still work, albeit no longer in constant time. */
|
||||
unsigned ineff_expands, noexpand;
|
||||
|
||||
uint32_t signature; /* used only to find hash tables in external analysis */
|
||||
#ifdef HASH_BLOOM
|
||||
uint32_t bloom_sig; /* used only to test bloom exists in external analysis */
|
||||
uint8_t *bloom_bv;
|
||||
char bloom_nbits;
|
||||
#endif
|
||||
|
||||
} UT_hash_table;
|
||||
|
||||
typedef struct UT_hash_handle {
|
||||
struct UT_hash_table *tbl;
|
||||
void *prev; /* prev element in app order */
|
||||
void *next; /* next element in app order */
|
||||
struct UT_hash_handle *hh_prev; /* previous hh in bucket order */
|
||||
struct UT_hash_handle *hh_next; /* next hh in bucket order */
|
||||
void *key; /* ptr to enclosing struct's key */
|
||||
unsigned keylen; /* enclosing struct's key len */
|
||||
unsigned hashv; /* result of hash-fcn(key) */
|
||||
} UT_hash_handle;
|
||||
|
||||
#endif /* UTHASH_H */
|
324
contrib/elftoolchain/libdwarf/Makefile
Normal file
324
contrib/elftoolchain/libdwarf/Makefile
Normal file
@ -0,0 +1,324 @@
|
||||
# $Id: Makefile 2937 2013-04-27 04:48:23Z jkoshy $
|
||||
|
||||
TOP= ${.CURDIR}/..
|
||||
|
||||
LIB= dwarf
|
||||
|
||||
SRCS= \
|
||||
dwarf_abbrev.c \
|
||||
dwarf_arange.c \
|
||||
dwarf_attr.c \
|
||||
dwarf_attrval.c \
|
||||
dwarf_cu.c \
|
||||
dwarf_dealloc.c \
|
||||
dwarf_die.c \
|
||||
dwarf_dump.c \
|
||||
dwarf_errmsg.c \
|
||||
dwarf_finish.c \
|
||||
dwarf_form.c \
|
||||
dwarf_frame.c \
|
||||
dwarf_funcs.c \
|
||||
dwarf_init.c \
|
||||
dwarf_lineno.c \
|
||||
dwarf_loclist.c \
|
||||
dwarf_macinfo.c \
|
||||
dwarf_pro_arange.c \
|
||||
dwarf_pro_attr.c \
|
||||
dwarf_pro_die.c \
|
||||
dwarf_pro_expr.c \
|
||||
dwarf_pro_finish.c \
|
||||
dwarf_pro_frame.c \
|
||||
dwarf_pro_funcs.c \
|
||||
dwarf_pro_init.c \
|
||||
dwarf_pro_lineno.c \
|
||||
dwarf_pro_macinfo.c \
|
||||
dwarf_pro_pubnames.c \
|
||||
dwarf_pro_reloc.c \
|
||||
dwarf_pro_sections.c \
|
||||
dwarf_pro_types.c \
|
||||
dwarf_pro_vars.c \
|
||||
dwarf_pro_weaks.c \
|
||||
dwarf_pubnames.c \
|
||||
dwarf_pubtypes.c \
|
||||
dwarf_ranges.c \
|
||||
dwarf_reloc.c \
|
||||
dwarf_seterror.c \
|
||||
dwarf_str.c \
|
||||
dwarf_types.c \
|
||||
dwarf_vars.c \
|
||||
dwarf_weaks.c \
|
||||
libdwarf.c \
|
||||
libdwarf_abbrev.c \
|
||||
libdwarf_arange.c \
|
||||
libdwarf_attr.c \
|
||||
libdwarf_die.c \
|
||||
libdwarf_error.c \
|
||||
libdwarf_elf_access.c \
|
||||
libdwarf_elf_init.c \
|
||||
libdwarf_frame.c \
|
||||
libdwarf_info.c \
|
||||
libdwarf_init.c \
|
||||
libdwarf_lineno.c \
|
||||
libdwarf_loc.c \
|
||||
libdwarf_loclist.c \
|
||||
libdwarf_macinfo.c \
|
||||
libdwarf_nametbl.c \
|
||||
libdwarf_ranges.c \
|
||||
libdwarf_reloc.c \
|
||||
libdwarf_rw.c \
|
||||
libdwarf_sections.c \
|
||||
libdwarf_str.c
|
||||
|
||||
INCS= dwarf.h libdwarf.h
|
||||
INCSDIR= /usr/include
|
||||
|
||||
GENSRCS= dwarf_pubnames.c dwarf_pubtypes.c dwarf_weaks.c \
|
||||
dwarf_funcs.c dwarf_vars.c dwarf_types.c \
|
||||
dwarf_pro_pubnames.c dwarf_pro_weaks.c \
|
||||
dwarf_pro_funcs.c dwarf_pro_types.c \
|
||||
dwarf_pro_vars.c
|
||||
CLEANFILES= ${GENSRCS}
|
||||
|
||||
SHLIB_MAJOR= 3
|
||||
|
||||
WARNS?= 6
|
||||
|
||||
LDADD+= -lelf
|
||||
|
||||
MAN= dwarf.3 \
|
||||
dwarf_add_arange.3 \
|
||||
dwarf_add_AT_comp_dir.3 \
|
||||
dwarf_add_AT_const_value_string.3 \
|
||||
dwarf_add_AT_dataref.3 \
|
||||
dwarf_add_AT_flag.3 \
|
||||
dwarf_add_AT_location_expr.3 \
|
||||
dwarf_add_AT_name.3 \
|
||||
dwarf_add_AT_producer.3 \
|
||||
dwarf_add_AT_ref_address.3 \
|
||||
dwarf_add_AT_reference.3 \
|
||||
dwarf_add_AT_signed_const.3 \
|
||||
dwarf_add_AT_string.3 \
|
||||
dwarf_add_AT_targ_address.3 \
|
||||
dwarf_add_die_to_debug.3 \
|
||||
dwarf_add_directory_decl.3 \
|
||||
dwarf_add_expr_addr.3 \
|
||||
dwarf_add_expr_gen.3 \
|
||||
dwarf_add_fde_inst.3 \
|
||||
dwarf_add_file_decl.3 \
|
||||
dwarf_add_frame_cie.3 \
|
||||
dwarf_add_frame_fde.3 \
|
||||
dwarf_add_funcname.3 \
|
||||
dwarf_add_line_entry.3 \
|
||||
dwarf_add_pubname.3 \
|
||||
dwarf_add_typename.3 \
|
||||
dwarf_add_varname.3 \
|
||||
dwarf_add_weakname.3 \
|
||||
dwarf_attr.3 \
|
||||
dwarf_attrlist.3 \
|
||||
dwarf_attrval_signed.3 \
|
||||
dwarf_child.3 \
|
||||
dwarf_dealloc.3 \
|
||||
dwarf_def_macro.3 \
|
||||
dwarf_die_abbrev_code.3 \
|
||||
dwarf_die_link.3 \
|
||||
dwarf_diename.3 \
|
||||
dwarf_dieoffset.3 \
|
||||
dwarf_end_macro_file.3 \
|
||||
dwarf_errmsg.3 \
|
||||
dwarf_errno.3 \
|
||||
dwarf_expand_frame_instructions.3 \
|
||||
dwarf_expr_current_offset.3 \
|
||||
dwarf_expr_into_block.3 \
|
||||
dwarf_fde_cfa_offset.3 \
|
||||
dwarf_find_macro_value_start.3 \
|
||||
dwarf_finish.3 \
|
||||
dwarf_formaddr.3 \
|
||||
dwarf_formblock.3 \
|
||||
dwarf_formexprloc.3 \
|
||||
dwarf_formflag.3 \
|
||||
dwarf_formref.3 \
|
||||
dwarf_formsig8.3 \
|
||||
dwarf_formstring.3 \
|
||||
dwarf_formudata.3 \
|
||||
dwarf_get_abbrev.3 \
|
||||
dwarf_get_abbrev_children_flag.3 \
|
||||
dwarf_get_abbrev_code.3 \
|
||||
dwarf_get_abbrev_entry.3 \
|
||||
dwarf_get_abbrev_tag.3 \
|
||||
dwarf_get_address_size.3 \
|
||||
dwarf_get_arange.3 \
|
||||
dwarf_get_arange_info.3 \
|
||||
dwarf_get_aranges.3 \
|
||||
dwarf_get_AT_name.3 \
|
||||
dwarf_get_cie_index.3 \
|
||||
dwarf_get_cie_info.3 \
|
||||
dwarf_get_cie_of_fde.3 \
|
||||
dwarf_get_cu_die_offset.3 \
|
||||
dwarf_get_elf.3 \
|
||||
dwarf_get_fde_at_pc.3 \
|
||||
dwarf_get_fde_info_for_all_regs.3 \
|
||||
dwarf_get_fde_info_for_all_regs3.3 \
|
||||
dwarf_get_fde_info_for_cfa_reg3.3 \
|
||||
dwarf_get_fde_info_for_reg.3 \
|
||||
dwarf_get_fde_info_for_reg3.3 \
|
||||
dwarf_get_fde_instr_bytes.3 \
|
||||
dwarf_get_fde_list.3 \
|
||||
dwarf_get_fde_n.3 \
|
||||
dwarf_get_fde_range.3 \
|
||||
dwarf_get_form_class.3 \
|
||||
dwarf_get_funcs.3 \
|
||||
dwarf_get_globals.3 \
|
||||
dwarf_get_loclist_entry.3 \
|
||||
dwarf_get_macro_details.3 \
|
||||
dwarf_get_pubtypes.3 \
|
||||
dwarf_get_ranges.3 \
|
||||
dwarf_get_relocation_info.3 \
|
||||
dwarf_get_relocation_info_count.3 \
|
||||
dwarf_get_section_bytes.3 \
|
||||
dwarf_get_str.3 \
|
||||
dwarf_get_types.3 \
|
||||
dwarf_get_vars.3 \
|
||||
dwarf_get_weaks.3 \
|
||||
dwarf_hasattr.3 \
|
||||
dwarf_hasform.3 \
|
||||
dwarf_highpc.3 \
|
||||
dwarf_init.3 \
|
||||
dwarf_lineno.3 \
|
||||
dwarf_lne_end_sequence.3 \
|
||||
dwarf_lne_set_address.3 \
|
||||
dwarf_loclist.3 \
|
||||
dwarf_loclist_from_expr.3 \
|
||||
dwarf_new_die.3 \
|
||||
dwarf_new_expr.3 \
|
||||
dwarf_new_fde.3 \
|
||||
dwarf_next_cu_header.3 \
|
||||
dwarf_object_init.3 \
|
||||
dwarf_producer_init.3 \
|
||||
dwarf_producer_set_isa.3 \
|
||||
dwarf_reset_section_bytes.3 \
|
||||
dwarf_seterrarg.3 \
|
||||
dwarf_set_frame_cfa_value.3 \
|
||||
dwarf_set_reloc_application.3 \
|
||||
dwarf_srcfiles.3 \
|
||||
dwarf_srclines.3 \
|
||||
dwarf_start_macro_file.3 \
|
||||
dwarf_tag.3 \
|
||||
dwarf_transform_to_disk_form.3 \
|
||||
dwarf_undef_macro.3 \
|
||||
dwarf_vendor_ext.3 \
|
||||
dwarf_whatattr.3
|
||||
|
||||
MLINKS+= \
|
||||
dwarf_add_AT_const_value_string.3 dwarf_add_AT_const_value_signedint.3 \
|
||||
dwarf_add_AT_const_value_string.3 dwarf_add_AT_const_value_unsignedint.3 \
|
||||
dwarf_add_AT_signed_const.3 dwarf_add_AT_unsigned_const.3 \
|
||||
dwarf_add_AT_targ_address.3 dwarf_add_AT_targ_address_b.3 \
|
||||
dwarf_add_arange.3 dwarf_add_arange_b.3 \
|
||||
dwarf_add_expr_addr.3 dwarf_add_expr_addr_b.3 \
|
||||
dwarf_add_frame_fde.3 dwarf_add_frame_fde_b.3 \
|
||||
dwarf_attrval_signed.3 dwarf_attrval_flag.3 \
|
||||
dwarf_attrval_signed.3 dwarf_attrval_string.3 \
|
||||
dwarf_attrval_signed.3 dwarf_attrval_unsigned.3 \
|
||||
dwarf_child.3 dwarf_offdie.3 \
|
||||
dwarf_child.3 dwarf_siblingof.3 \
|
||||
dwarf_dealloc.3 dwarf_fde_cie_list_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_funcs_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_globals_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_pubtypes_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_types_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_vars_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_weaks_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_ranges_dealloc.3 \
|
||||
dwarf_dealloc.3 dwarf_srclines_dealloc.3 \
|
||||
dwarf_init.3 dwarf_elf_init.3 \
|
||||
dwarf_dieoffset.3 dwarf_die_CU_offset.3 \
|
||||
dwarf_dieoffset.3 dwarf_die_CU_offset_range.3 \
|
||||
dwarf_dieoffset.3 dwarf_get_cu_die_offset_given_cu_header_offset.3 \
|
||||
dwarf_finish.3 dwarf_object_finish.3 \
|
||||
dwarf_formref.3 dwarf_global_formref.3 \
|
||||
dwarf_formudata.3 dwarf_formsdata.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_ACCESS_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_ATE_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_CC_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_CFA_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_CHILDREN_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_DS_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_DSC_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_EH_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_END_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_FORM_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_ID_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_INL_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_LANG_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_LNE_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_LNS_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_MACINFO_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_OP_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_ORD_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_TAG_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_VIRTUALITY_name.3 \
|
||||
dwarf_get_AT_name.3 dwarf_get_VIS_name.3 \
|
||||
dwarf_get_cu_die_offset.3 dwarf_get_arange_cu_header_offset.3 \
|
||||
dwarf_get_fde_list.3 dwarf_get_fde_list_eh.3 \
|
||||
dwarf_get_funcs.3 dwarf_func_die_offset.3 \
|
||||
dwarf_get_funcs.3 dwarf_func_cu_offset.3 \
|
||||
dwarf_get_funcs.3 dwarf_func_name_offsets.3 \
|
||||
dwarf_get_funcs.3 dwarf_funcname.3 \
|
||||
dwarf_get_globals.3 dwarf_global_die_offset.3 \
|
||||
dwarf_get_globals.3 dwarf_global_cu_offset.3 \
|
||||
dwarf_get_globals.3 dwarf_global_name_offsets.3 \
|
||||
dwarf_get_globals.3 dwarf_globname.3 \
|
||||
dwarf_get_pubtypes.3 dwarf_pubtype_die_offset.3 \
|
||||
dwarf_get_pubtypes.3 dwarf_pubtype_cu_offset.3 \
|
||||
dwarf_get_pubtypes.3 dwarf_pubtype_name_offsets.3 \
|
||||
dwarf_get_pubtypes.3 dwarf_pubtypename.3 \
|
||||
dwarf_get_ranges.3 dwarf_get_ranges_a.3 \
|
||||
dwarf_get_types.3 dwarf_type_die_offset.3 \
|
||||
dwarf_get_types.3 dwarf_type_cu_offset.3 \
|
||||
dwarf_get_types.3 dwarf_type_name_offsets.3 \
|
||||
dwarf_get_types.3 dwarf_typename.3 \
|
||||
dwarf_get_vars.3 dwarf_var_die_offset.3 \
|
||||
dwarf_get_vars.3 dwarf_var_cu_offset.3 \
|
||||
dwarf_get_vars.3 dwarf_var_name_offsets.3 \
|
||||
dwarf_get_vars.3 dwarf_varname.3 \
|
||||
dwarf_get_weaks.3 dwarf_weak_die_offset.3 \
|
||||
dwarf_get_weaks.3 dwarf_weak_cu_offset.3 \
|
||||
dwarf_get_weaks.3 dwarf_weak_name_offsets.3 \
|
||||
dwarf_get_weaks.3 dwarf_weakname.3 \
|
||||
dwarf_hasform.3 dwarf_whatform.3 \
|
||||
dwarf_hasform.3 dwarf_whatform_direct.3 \
|
||||
dwarf_highpc.3 dwarf_arrayorder.3 \
|
||||
dwarf_highpc.3 dwarf_bitoffset.3 \
|
||||
dwarf_highpc.3 dwarf_bitsize.3 \
|
||||
dwarf_highpc.3 dwarf_bytesize.3 \
|
||||
dwarf_highpc.3 dwarf_lowpc.3 \
|
||||
dwarf_highpc.3 dwarf_srclang.3 \
|
||||
dwarf_lineno.3 dwarf_lineaddr.3 \
|
||||
dwarf_lineno.3 dwarf_linebeginstatement.3 \
|
||||
dwarf_lineno.3 dwarf_lineblock.3 \
|
||||
dwarf_lineno.3 dwarf_lineendsequence.3 \
|
||||
dwarf_lineno.3 dwarf_lineoff.3 \
|
||||
dwarf_lineno.3 dwarf_linesrc.3 \
|
||||
dwarf_lineno.3 dwarf_line_srcfileno.3 \
|
||||
dwarf_loclist.3 dwarf_loclist_n.3 \
|
||||
dwarf_loclist_from_expr.3 dwarf_loclist_from_expr_a.3 \
|
||||
dwarf_producer_init.3 dwarf_producer_init_b.3 \
|
||||
dwarf_seterrarg.3 dwarf_seterrhand.3 \
|
||||
dwarf_set_frame_cfa_value.3 dwarf_set_frame_rule_initial_value.3 \
|
||||
dwarf_set_frame_cfa_value.3 dwarf_set_frame_rule_table_size.3 \
|
||||
dwarf_set_frame_cfa_value.3 dwarf_set_frame_same_value.3 \
|
||||
dwarf_set_frame_cfa_value.3 dwarf_set_frame_undefined_value.3
|
||||
|
||||
dwarf_pubnames.c: dwarf_nametbl.m4 dwarf_pubnames.m4
|
||||
dwarf_pubtypes.c: dwarf_nametbl.m4 dwarf_pubtypes.m4
|
||||
dwarf_weaks.c: dwarf_nametbl.m4 dwarf_weaks.m4
|
||||
dwarf_funcs.c: dwarf_nametbl.m4 dwarf_funcs.m4
|
||||
dwarf_vars.c: dwarf_nametbl.m4 dwarf_vars.m4
|
||||
dwarf_types.c: dwarf_nametbl.m4 dwarf_types.m4
|
||||
dwarf_pro_pubnames.c: dwarf_pro_nametbl.m4 dwarf_pro_pubnames.m4
|
||||
dwarf_pro_weaks.c: dwarf_pro_nametbl.m4 dwarf_pro_weaks.m4
|
||||
dwarf_pro_funcs.c: dwarf_pro_nametbl.m4 dwarf_pro_funcs.m4
|
||||
dwarf_pro_types.c: dwarf_pro_nametbl.m4 dwarf_pro_types.m4
|
||||
dwarf_pro_vars.c: dwarf_pro_nametbl.m4 dwarf_pro_vars.m4
|
||||
|
||||
.include "${TOP}/mk/elftoolchain.lib.mk"
|
228
contrib/elftoolchain/libdwarf/Version.map
Normal file
228
contrib/elftoolchain/libdwarf/Version.map
Normal file
@ -0,0 +1,228 @@
|
||||
/* $Id: Version.map 2576 2012-09-13 09:16:11Z jkoshy $ */
|
||||
|
||||
R1.0 {
|
||||
global:
|
||||
dwarf_add_AT_comp_dir;
|
||||
dwarf_add_AT_const_value_signedint;
|
||||
dwarf_add_AT_const_value_string;
|
||||
dwarf_add_AT_const_value_unsignedint;
|
||||
dwarf_add_AT_dataref;
|
||||
dwarf_add_AT_flag;
|
||||
dwarf_add_AT_location_expr;
|
||||
dwarf_add_AT_name;
|
||||
dwarf_add_AT_producer;
|
||||
dwarf_add_AT_ref_address;
|
||||
dwarf_add_AT_reference;
|
||||
dwarf_add_AT_signed_const;
|
||||
dwarf_add_AT_string;
|
||||
dwarf_add_AT_targ_address;
|
||||
dwarf_add_AT_targ_address_b;
|
||||
dwarf_add_AT_unsigned_const;
|
||||
dwarf_add_arange;
|
||||
dwarf_add_arange_b;
|
||||
dwarf_add_die_to_debug;
|
||||
dwarf_add_directory_decl;
|
||||
dwarf_add_expr_addr;
|
||||
dwarf_add_expr_addr_b;
|
||||
dwarf_add_expr_gen;
|
||||
dwarf_add_fde_inst;
|
||||
dwarf_add_file_decl;
|
||||
dwarf_add_frame_cie;
|
||||
dwarf_add_frame_fde;
|
||||
dwarf_add_frame_fde_b;
|
||||
dwarf_add_funcname;
|
||||
dwarf_add_line_entry;
|
||||
dwarf_add_pubname;
|
||||
dwarf_add_typename;
|
||||
dwarf_add_varname;
|
||||
dwarf_add_weakname;
|
||||
dwarf_arrayorder;
|
||||
dwarf_attr;
|
||||
dwarf_attrlist;
|
||||
dwarf_attrval_flag;
|
||||
dwarf_attrval_signed;
|
||||
dwarf_attrval_string;
|
||||
dwarf_attrval_unsigned;
|
||||
dwarf_bitoffset;
|
||||
dwarf_bitsize;
|
||||
dwarf_bytesize;
|
||||
dwarf_child;
|
||||
dwarf_dealloc;
|
||||
dwarf_def_macro;
|
||||
dwarf_die_CU_offset;
|
||||
dwarf_die_CU_offset_range;
|
||||
dwarf_die_abbrev_code;
|
||||
dwarf_die_link;
|
||||
dwarf_diename;
|
||||
dwarf_dieoffset;
|
||||
dwarf_elf_init;
|
||||
dwarf_end_macro_file;
|
||||
dwarf_errmsg_;
|
||||
dwarf_expand_frame_instructions;
|
||||
dwarf_expr_current_offset;
|
||||
dwarf_expr_into_block;
|
||||
dwarf_fde_cfa_offset;
|
||||
dwarf_fde_cie_list_dealloc;
|
||||
dwarf_find_macro_value_start;
|
||||
dwarf_finish;
|
||||
dwarf_formaddr;
|
||||
dwarf_formblock;
|
||||
dwarf_formexprloc;
|
||||
dwarf_formflag;
|
||||
dwarf_formref;
|
||||
dwarf_formsdata;
|
||||
dwarf_formsig8;
|
||||
dwarf_formstring;
|
||||
dwarf_formudata;
|
||||
dwarf_func_cu_offset;
|
||||
dwarf_func_die_offset;
|
||||
dwarf_func_name_offsets;
|
||||
dwarf_funcname;
|
||||
dwarf_funcs_dealloc;
|
||||
dwarf_get_ACCESS_name;
|
||||
dwarf_get_ATE_name;
|
||||
dwarf_get_AT_name;
|
||||
dwarf_get_CC_name;
|
||||
dwarf_get_CFA_name;
|
||||
dwarf_get_CHILDREN_name;
|
||||
dwarf_get_DSC_name;
|
||||
dwarf_get_DS_name;
|
||||
dwarf_get_EH_name;
|
||||
dwarf_get_END_name;
|
||||
dwarf_get_FORM_name;
|
||||
dwarf_get_ID_name;
|
||||
dwarf_get_INL_name;
|
||||
dwarf_get_LANG_name;
|
||||
dwarf_get_LNE_name;
|
||||
dwarf_get_LNS_name;
|
||||
dwarf_get_MACINFO_name;
|
||||
dwarf_get_OP_name;
|
||||
dwarf_get_ORD_name;
|
||||
dwarf_get_TAG_name;
|
||||
dwarf_get_VIRTUALITY_name;
|
||||
dwarf_get_VIS_name;
|
||||
dwarf_get_abbrev;
|
||||
dwarf_get_abbrev_children_flag;
|
||||
dwarf_get_abbrev_code;
|
||||
dwarf_get_abbrev_entry;
|
||||
dwarf_get_abbrev_tag;
|
||||
dwarf_get_address_size;
|
||||
dwarf_get_arange;
|
||||
dwarf_get_arange_cu_header_offset;
|
||||
dwarf_get_arange_info;
|
||||
dwarf_get_aranges;
|
||||
dwarf_get_cie_index;
|
||||
dwarf_get_cie_info;
|
||||
dwarf_get_cie_of_fde;
|
||||
dwarf_get_cu_die_offset;
|
||||
dwarf_get_cu_die_offset_given_cu_header_offset;
|
||||
dwarf_get_elf;
|
||||
dwarf_get_fde_at_pc;
|
||||
dwarf_get_fde_info_for_all_regs3;
|
||||
dwarf_get_fde_info_for_all_regs;
|
||||
dwarf_get_fde_info_for_cfa_reg3;
|
||||
dwarf_get_fde_info_for_reg3;
|
||||
dwarf_get_fde_info_for_reg;
|
||||
dwarf_get_fde_instr_bytes;
|
||||
dwarf_get_fde_list;
|
||||
dwarf_get_fde_list_eh;
|
||||
dwarf_get_fde_n;
|
||||
dwarf_get_fde_range;
|
||||
dwarf_get_form_class;
|
||||
dwarf_get_funcs;
|
||||
dwarf_get_globals;
|
||||
dwarf_get_loclist_entry;
|
||||
dwarf_get_macro_details;
|
||||
dwarf_get_pubtypes;
|
||||
dwarf_get_ranges;
|
||||
dwarf_get_ranges_a;
|
||||
dwarf_get_relocation_info;
|
||||
dwarf_get_relocation_info_count;
|
||||
dwarf_get_section_bytes;
|
||||
dwarf_get_str;
|
||||
dwarf_get_types;
|
||||
dwarf_get_vars;
|
||||
dwarf_get_weaks;
|
||||
dwarf_global_cu_offset;
|
||||
dwarf_global_die_offset;
|
||||
dwarf_global_formref;
|
||||
dwarf_global_name_offsets;
|
||||
dwarf_globals_dealloc;
|
||||
dwarf_globname;
|
||||
dwarf_hasattr;
|
||||
dwarf_hasform;
|
||||
dwarf_highpc;
|
||||
dwarf_init;
|
||||
dwarf_line_srcfileno;
|
||||
dwarf_lineaddr;
|
||||
dwarf_linebeginstatement;
|
||||
dwarf_lineblock;
|
||||
dwarf_lineendsequence;
|
||||
dwarf_lineno;
|
||||
dwarf_lineoff;
|
||||
dwarf_linesrc;
|
||||
dwarf_lne_end_sequence;
|
||||
dwarf_lne_set_address;
|
||||
dwarf_loclist;
|
||||
dwarf_loclist_from_expr;
|
||||
dwarf_loclist_from_expr_a;
|
||||
dwarf_loclist_n;
|
||||
dwarf_lowpc;
|
||||
dwarf_new_die;
|
||||
dwarf_new_expr;
|
||||
dwarf_new_fde;
|
||||
dwarf_next_cu_header;
|
||||
dwarf_next_cu_header_b;
|
||||
dwarf_object_finish;
|
||||
dwarf_object_init;
|
||||
dwarf_offdie;
|
||||
dwarf_producer_finish;
|
||||
dwarf_producer_init;
|
||||
dwarf_producer_init_b;
|
||||
dwarf_producer_set_isa;
|
||||
dwarf_pubtype_cu_offset;
|
||||
dwarf_pubtype_die_offset;
|
||||
dwarf_pubtype_name_offsets;
|
||||
dwarf_pubtypename;
|
||||
dwarf_pubtypes_dealloc;
|
||||
dwarf_ranges_dealloc;
|
||||
dwarf_reset_section_bytes;
|
||||
dwarf_set_frame_cfa_value;
|
||||
dwarf_set_frame_rule_initial_value;
|
||||
dwarf_set_frame_rule_table_size;
|
||||
dwarf_set_frame_same_value;
|
||||
dwarf_set_frame_undefined_value;
|
||||
dwarf_set_reloc_application;
|
||||
dwarf_seterrarg;
|
||||
dwarf_seterrhand;
|
||||
dwarf_siblingof;
|
||||
dwarf_srcfiles;
|
||||
dwarf_srclang;
|
||||
dwarf_srclines;
|
||||
dwarf_srclines_dealloc;
|
||||
dwarf_start_macro_file;
|
||||
dwarf_tag;
|
||||
dwarf_transform_to_disk_form;
|
||||
dwarf_type_cu_offset;
|
||||
dwarf_type_die_offset;
|
||||
dwarf_type_name_offsets;
|
||||
dwarf_typename;
|
||||
dwarf_types_dealloc;
|
||||
dwarf_undef_macro;
|
||||
dwarf_var_cu_offset;
|
||||
dwarf_var_die_offset;
|
||||
dwarf_var_name_offsets;
|
||||
dwarf_varname;
|
||||
dwarf_vars_dealloc;
|
||||
dwarf_vendor_ext;
|
||||
dwarf_weak_cu_offset;
|
||||
dwarf_weak_die_offset;
|
||||
dwarf_weak_name_offsets;
|
||||
dwarf_weakname;
|
||||
dwarf_weaks_dealloc;
|
||||
dwarf_whatattr;
|
||||
dwarf_whatform;
|
||||
dwarf_whatform_direct;
|
||||
local:
|
||||
*;
|
||||
};
|
658
contrib/elftoolchain/libdwarf/_libdwarf.h
Normal file
658
contrib/elftoolchain/libdwarf/_libdwarf.h
Normal file
@ -0,0 +1,658 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* Copyright (c) 2009-2011 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: _libdwarf.h 2075 2011-10-27 03:47:28Z jkoshy $
|
||||
*/
|
||||
|
||||
#ifndef __LIBDWARF_H_
|
||||
#define __LIBDWARF_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gelf.h>
|
||||
#include "dwarf.h"
|
||||
#include "libdwarf.h"
|
||||
#include "uthash.h"
|
||||
|
||||
#include "_elftc.h"
|
||||
|
||||
#define DWARF_DIE_HASH_SIZE 8191
|
||||
|
||||
struct _libdwarf_globals {
|
||||
Dwarf_Handler errhand;
|
||||
Dwarf_Ptr errarg;
|
||||
int applyrela;
|
||||
};
|
||||
|
||||
extern struct _libdwarf_globals _libdwarf;
|
||||
|
||||
#define _DWARF_SET_ERROR(_d, _e, _err, _elf_err) \
|
||||
_dwarf_set_error(_d, _e, _err, _elf_err, __func__, __LINE__)
|
||||
#define DWARF_SET_ERROR(_d, _e, _err) \
|
||||
_DWARF_SET_ERROR(_d, _e, _err, 0)
|
||||
#define DWARF_SET_ELF_ERROR(_d, _e) \
|
||||
_DWARF_SET_ERROR(_d, _e, DW_DLE_ELF, elf_errno())
|
||||
|
||||
/*
|
||||
* Convenient macros for producer bytes stream generation.
|
||||
*/
|
||||
#define WRITE_VALUE(value, bytes) \
|
||||
dbg->write_alloc(&ds->ds_data, &ds->ds_cap, &ds->ds_size, \
|
||||
(value), (bytes), error)
|
||||
#define WRITE_ULEB128(value) \
|
||||
_dwarf_write_uleb128_alloc(&ds->ds_data, &ds->ds_cap, \
|
||||
&ds->ds_size, (value), error)
|
||||
#define WRITE_SLEB128(value) \
|
||||
_dwarf_write_sleb128_alloc(&ds->ds_data, &ds->ds_cap, \
|
||||
&ds->ds_size, (value), error)
|
||||
#define WRITE_STRING(string) \
|
||||
_dwarf_write_string_alloc(&ds->ds_data, &ds->ds_cap, \
|
||||
&ds->ds_size, (string), error)
|
||||
#define WRITE_BLOCK(blk, size) \
|
||||
_dwarf_write_block_alloc(&ds->ds_data, &ds->ds_cap, \
|
||||
&ds->ds_size, (blk), (size), error)
|
||||
#define WRITE_PADDING(byte, cnt) \
|
||||
_dwarf_write_padding_alloc(&ds->ds_data, &ds->ds_cap, \
|
||||
&ds->ds_size, (byte), (cnt), error)
|
||||
#define RCHECK(expr) \
|
||||
do { \
|
||||
ret = expr; \
|
||||
if (ret != DW_DLE_NONE) \
|
||||
goto gen_fail; \
|
||||
} while(0)
|
||||
|
||||
|
||||
struct _Dwarf_AttrDef {
|
||||
uint64_t ad_attrib; /* DW_AT_XXX */
|
||||
uint64_t ad_form; /* DW_FORM_XXX */
|
||||
uint64_t ad_offset; /* Offset in abbrev section. */
|
||||
STAILQ_ENTRY(_Dwarf_AttrDef) ad_next; /* Next attribute define. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Attribute {
|
||||
Dwarf_Die at_die; /* Ptr to containing DIE. */
|
||||
Dwarf_Die at_refdie; /* Ptr to reference DIE. */
|
||||
uint64_t at_offset; /* Offset in info section. */
|
||||
uint64_t at_attrib; /* DW_AT_XXX */
|
||||
uint64_t at_form; /* DW_FORM_XXX */
|
||||
int at_indirect; /* Has indirect form. */
|
||||
union {
|
||||
uint64_t u64; /* Unsigned value. */
|
||||
int64_t s64; /* Signed value. */
|
||||
char *s; /* String. */
|
||||
uint8_t *u8p; /* Block data. */
|
||||
} u[2]; /* Value. */
|
||||
Dwarf_Block at_block; /* Block. */
|
||||
Dwarf_Locdesc *at_ld; /* at value is locdesc. */
|
||||
Dwarf_P_Expr at_expr; /* at value is expr. */
|
||||
uint64_t at_relsym; /* Relocation symbol index. */
|
||||
const char *at_relsec; /* Rel. to dwarf section. */
|
||||
STAILQ_ENTRY(_Dwarf_Attribute) at_next; /* Next attribute. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Abbrev {
|
||||
uint64_t ab_entry; /* Abbrev entry. */
|
||||
uint64_t ab_tag; /* Tag: DW_TAG_ */
|
||||
uint8_t ab_children; /* DW_CHILDREN_no or DW_CHILDREN_yes */
|
||||
uint64_t ab_offset; /* Offset in abbrev section. */
|
||||
uint64_t ab_length; /* Length of this abbrev entry. */
|
||||
uint64_t ab_atnum; /* Number of attribute defines. */
|
||||
UT_hash_handle ab_hh; /* Uthash handle. */
|
||||
STAILQ_HEAD(, _Dwarf_AttrDef) ab_attrdef; /* List of attribute defs. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Die {
|
||||
Dwarf_Die die_parent; /* Parent DIE. */
|
||||
Dwarf_Die die_child; /* First child DIE. */
|
||||
Dwarf_Die die_left; /* Left sibling DIE. */
|
||||
Dwarf_Die die_right; /* Right sibling DIE. */
|
||||
uint64_t die_offset; /* DIE offset in section. */
|
||||
uint64_t die_next_off; /* Next DIE offset in section. */
|
||||
uint64_t die_abnum; /* Abbrev number. */
|
||||
Dwarf_Abbrev die_ab; /* Abbrev pointer. */
|
||||
Dwarf_Tag die_tag; /* DW_TAG_ */
|
||||
Dwarf_Debug die_dbg; /* Dwarf_Debug pointer. */
|
||||
Dwarf_CU die_cu; /* Compilation unit pointer. */
|
||||
char *die_name; /* Ptr to the name string. */
|
||||
Dwarf_Attribute *die_attrarray; /* Array of attributes. */
|
||||
STAILQ_HEAD(, _Dwarf_Attribute) die_attr; /* List of attributes. */
|
||||
STAILQ_ENTRY(_Dwarf_Die) die_pro_next; /* Next die in pro-die list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Loclist {
|
||||
Dwarf_Locdesc **ll_ldlist; /* Array of Locdesc pointer. */
|
||||
int ll_ldlen; /* Number of Locdesc. */
|
||||
Dwarf_Unsigned ll_offset; /* Offset in .debug_loc section. */
|
||||
Dwarf_Unsigned ll_length; /* Length (in bytes) of the loclist. */
|
||||
TAILQ_ENTRY(_Dwarf_Loclist) ll_next; /* Next loclist in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_P_Expr_Entry {
|
||||
Dwarf_Loc ee_loc; /* Location expression. */
|
||||
Dwarf_Unsigned ee_sym; /* Optional related reloc sym index. */
|
||||
STAILQ_ENTRY(_Dwarf_P_Expr_Entry) ee_next; /* Next entry in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_P_Expr {
|
||||
Dwarf_Debug pe_dbg; /* Dwarf_Debug pointer. */
|
||||
uint8_t *pe_block; /* Expression block data. */
|
||||
int pe_invalid; /* Block data is up-to-date or not. */
|
||||
Dwarf_Unsigned pe_length; /* Length of the block. */
|
||||
STAILQ_HEAD(, _Dwarf_P_Expr_Entry) pe_eelist; /* List of entries. */
|
||||
STAILQ_ENTRY(_Dwarf_P_Expr) pe_next; /* Next expr in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Line {
|
||||
Dwarf_LineInfo ln_li; /* Ptr to line info. */
|
||||
Dwarf_Addr ln_addr; /* Line address. */
|
||||
Dwarf_Unsigned ln_symndx; /* Symbol index for relocation. */
|
||||
Dwarf_Unsigned ln_fileno; /* File number. */
|
||||
Dwarf_Unsigned ln_lineno; /* Line number. */
|
||||
Dwarf_Signed ln_column; /* Column number. */
|
||||
Dwarf_Bool ln_bblock; /* Basic block flag. */
|
||||
Dwarf_Bool ln_stmt; /* Begin statement flag. */
|
||||
Dwarf_Bool ln_endseq; /* End sequence flag. */
|
||||
STAILQ_ENTRY(_Dwarf_Line) ln_next; /* Next line in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_LineFile {
|
||||
char *lf_fname; /* Filename. */
|
||||
char *lf_fullpath; /* Full pathname of the file. */
|
||||
Dwarf_Unsigned lf_dirndx; /* Dir index. */
|
||||
Dwarf_Unsigned lf_mtime; /* Modification time. */
|
||||
Dwarf_Unsigned lf_size; /* File size. */
|
||||
STAILQ_ENTRY(_Dwarf_LineFile) lf_next; /* Next file in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_LineInfo {
|
||||
Dwarf_Unsigned li_length; /* Length of line info data. */
|
||||
Dwarf_Half li_version; /* Version of line info. */
|
||||
Dwarf_Unsigned li_hdrlen; /* Length of line info header. */
|
||||
Dwarf_Small li_minlen; /* Minimum instrutction length. */
|
||||
Dwarf_Small li_defstmt; /* Default value of is_stmt. */
|
||||
int8_t li_lbase; /* Line base for special opcode. */
|
||||
Dwarf_Small li_lrange; /* Line range for special opcode. */
|
||||
Dwarf_Small li_opbase; /* Fisrt std opcode number. */
|
||||
Dwarf_Small *li_oplen; /* Array of std opcode len. */
|
||||
char **li_incdirs; /* Array of include dirs. */
|
||||
Dwarf_Unsigned li_inclen; /* Length of inc dir array. */
|
||||
char **li_lfnarray; /* Array of file names. */
|
||||
Dwarf_Unsigned li_lflen; /* Length of filename array. */
|
||||
STAILQ_HEAD(, _Dwarf_LineFile) li_lflist; /* List of files. */
|
||||
Dwarf_Line *li_lnarray; /* Array of lines. */
|
||||
Dwarf_Unsigned li_lnlen; /* Length of the line array. */
|
||||
STAILQ_HEAD(, _Dwarf_Line) li_lnlist; /* List of lines. */
|
||||
};
|
||||
|
||||
struct _Dwarf_NamePair {
|
||||
Dwarf_NameTbl np_nt; /* Ptr to containing name table. */
|
||||
Dwarf_Die np_die; /* Ptr to Ref. Die. */
|
||||
Dwarf_Unsigned np_offset; /* Offset in CU. */
|
||||
char *np_name; /* Object/Type name. */
|
||||
STAILQ_ENTRY(_Dwarf_NamePair) np_next; /* Next pair in the list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_NameTbl {
|
||||
Dwarf_Unsigned nt_length; /* Name lookup table length. */
|
||||
Dwarf_Half nt_version; /* Name lookup table version. */
|
||||
Dwarf_CU nt_cu; /* Ptr to Ref. CU. */
|
||||
Dwarf_Off nt_cu_offset; /* Ref. CU offset in .debug_info */
|
||||
Dwarf_Unsigned nt_cu_length; /* Ref. CU length. */
|
||||
STAILQ_HEAD(, _Dwarf_NamePair) nt_nplist; /* List of offset+name pairs. */
|
||||
STAILQ_ENTRY(_Dwarf_NameTbl) nt_next; /* Next name table in the list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_NameSec {
|
||||
STAILQ_HEAD(, _Dwarf_NameTbl) ns_ntlist; /* List of name tables. */
|
||||
Dwarf_NamePair *ns_array; /* Array of pairs of all tables. */
|
||||
Dwarf_Unsigned ns_len; /* Length of the pair array. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Fde {
|
||||
Dwarf_Debug fde_dbg; /* Ptr to containing dbg. */
|
||||
Dwarf_Cie fde_cie; /* Ptr to associated CIE. */
|
||||
Dwarf_FrameSec fde_fs; /* Ptr to containing .debug_frame. */
|
||||
Dwarf_Ptr fde_addr; /* Ptr to start of the FDE. */
|
||||
Dwarf_Unsigned fde_offset; /* Offset of the FDE. */
|
||||
Dwarf_Unsigned fde_length; /* Length of the FDE. */
|
||||
Dwarf_Unsigned fde_cieoff; /* Offset of associated CIE. */
|
||||
Dwarf_Unsigned fde_initloc; /* Initial location. */
|
||||
Dwarf_Unsigned fde_adrange; /* Address range. */
|
||||
Dwarf_Unsigned fde_auglen; /* Augmentation length. */
|
||||
uint8_t *fde_augdata; /* Augmentation data. */
|
||||
uint8_t *fde_inst; /* Instructions. */
|
||||
Dwarf_Unsigned fde_instlen; /* Length of instructions. */
|
||||
Dwarf_Unsigned fde_instcap; /* Capacity of inst buffer. */
|
||||
Dwarf_Unsigned fde_symndx; /* Symbol index for relocation. */
|
||||
Dwarf_Unsigned fde_esymndx; /* End symbol index for relocation. */
|
||||
Dwarf_Addr fde_eoff; /* Offset from the end symbol. */
|
||||
STAILQ_ENTRY(_Dwarf_Fde) fde_next; /* Next FDE in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Cie {
|
||||
Dwarf_Debug cie_dbg; /* Ptr to containing dbg. */
|
||||
Dwarf_Unsigned cie_index; /* Index of the CIE. */
|
||||
Dwarf_Unsigned cie_offset; /* Offset of the CIE. */
|
||||
Dwarf_Unsigned cie_length; /* Length of the CIE. */
|
||||
Dwarf_Half cie_version; /* CIE version. */
|
||||
uint8_t *cie_augment; /* CIE augmentation (UTF-8). */
|
||||
Dwarf_Unsigned cie_ehdata; /* Optional EH Data. */
|
||||
Dwarf_Unsigned cie_caf; /* Code alignment factor. */
|
||||
Dwarf_Signed cie_daf; /* Data alignment factor. */
|
||||
Dwarf_Unsigned cie_ra; /* Return address register. */
|
||||
Dwarf_Unsigned cie_auglen; /* Augmentation length. */
|
||||
uint8_t *cie_augdata; /* Augmentation data; */
|
||||
uint8_t cie_fde_encode; /* FDE PC start/range encode. */
|
||||
Dwarf_Ptr cie_initinst; /* Initial instructions. */
|
||||
Dwarf_Unsigned cie_instlen; /* Length of init instructions. */
|
||||
STAILQ_ENTRY(_Dwarf_Cie) cie_next; /* Next CIE in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_FrameSec {
|
||||
STAILQ_HEAD(, _Dwarf_Cie) fs_cielist; /* List of CIE. */
|
||||
STAILQ_HEAD(, _Dwarf_Fde) fs_fdelist; /* List of FDE. */
|
||||
Dwarf_Cie *fs_ciearray; /* Array of CIE. */
|
||||
Dwarf_Unsigned fs_cielen; /* Length of CIE array. */
|
||||
Dwarf_Fde *fs_fdearray; /* Array of FDE.*/
|
||||
Dwarf_Unsigned fs_fdelen; /* Length of FDE array. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Arange {
|
||||
Dwarf_ArangeSet ar_as; /* Ptr to the set it belongs to. */
|
||||
Dwarf_Unsigned ar_address; /* Start PC. */
|
||||
Dwarf_Unsigned ar_range; /* PC range. */
|
||||
Dwarf_Unsigned ar_symndx; /* First symbol index for reloc. */
|
||||
Dwarf_Unsigned ar_esymndx; /* Second symbol index for reloc. */
|
||||
Dwarf_Addr ar_eoff; /* Offset from second symbol. */
|
||||
STAILQ_ENTRY(_Dwarf_Arange) ar_next; /* Next arange in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_ArangeSet {
|
||||
Dwarf_Unsigned as_length; /* Length of the arange set. */
|
||||
Dwarf_Half as_version; /* Version of the arange set. */
|
||||
Dwarf_Off as_cu_offset; /* Offset of associated CU. */
|
||||
Dwarf_CU as_cu; /* Ptr to associated CU. */
|
||||
Dwarf_Small as_addrsz; /* Target address size. */
|
||||
Dwarf_Small as_segsz; /* Target segment size. */
|
||||
STAILQ_HEAD (, _Dwarf_Arange) as_arlist; /* List of ae entries. */
|
||||
STAILQ_ENTRY(_Dwarf_ArangeSet) as_next; /* Next set in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_MacroSet {
|
||||
Dwarf_Macro_Details *ms_mdlist; /* Array of macinfo entries. */
|
||||
Dwarf_Unsigned ms_cnt; /* Length of the array. */
|
||||
STAILQ_ENTRY(_Dwarf_MacroSet) ms_next; /* Next set in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_Rangelist {
|
||||
Dwarf_CU rl_cu; /* Ptr to associated CU. */
|
||||
Dwarf_Unsigned rl_offset; /* Offset of the rangelist. */
|
||||
Dwarf_Ranges *rl_rgarray; /* Array of ranges. */
|
||||
Dwarf_Unsigned rl_rglen; /* Length of the ranges array. */
|
||||
STAILQ_ENTRY(_Dwarf_Rangelist) rl_next; /* Next rangelist in list. */
|
||||
};
|
||||
|
||||
struct _Dwarf_CU {
|
||||
Dwarf_Debug cu_dbg; /* Ptr to containing dbg. */
|
||||
Dwarf_Off cu_offset; /* Offset to the this CU. */
|
||||
uint32_t cu_length; /* Length of CU data. */
|
||||
uint16_t cu_length_size; /* Size in bytes of the length field. */
|
||||
uint16_t cu_version; /* DWARF version. */
|
||||
uint64_t cu_abbrev_offset; /* Offset into .debug_abbrev. */
|
||||
uint64_t cu_abbrev_offset_cur; /* Current abbrev offset. */
|
||||
int cu_abbrev_loaded; /* Abbrev table parsed. */
|
||||
uint64_t cu_abbrev_cnt; /* Abbrev entry count. */
|
||||
uint64_t cu_lineno_offset; /* Offset into .debug_lineno. */
|
||||
uint8_t cu_pointer_size;/* Number of bytes in pointer. */
|
||||
uint8_t cu_dwarf_size; /* CU section dwarf size. */
|
||||
Dwarf_Off cu_next_offset; /* Offset to the next CU. */
|
||||
uint64_t cu_1st_offset; /* First DIE offset. */
|
||||
int cu_pass2; /* Two pass DIE traverse. */
|
||||
Dwarf_LineInfo cu_lineinfo; /* Ptr to Dwarf_LineInfo. */
|
||||
Dwarf_Abbrev cu_abbrev_hash; /* Abbrev hash table. */
|
||||
STAILQ_ENTRY(_Dwarf_CU) cu_next; /* Next compilation unit. */
|
||||
};
|
||||
|
||||
typedef struct _Dwarf_Section {
|
||||
const char *ds_name; /* Section name. */
|
||||
Dwarf_Small *ds_data; /* Section data. */
|
||||
Dwarf_Unsigned ds_addr; /* Section virtual addr. */
|
||||
Dwarf_Unsigned ds_size; /* Section size. */
|
||||
} Dwarf_Section;
|
||||
|
||||
typedef struct _Dwarf_P_Section {
|
||||
char *ds_name; /* Section name. */
|
||||
Dwarf_Small *ds_data; /* Section data. */
|
||||
Dwarf_Unsigned ds_size; /* Section size. */
|
||||
Dwarf_Unsigned ds_cap; /* Section capacity. */
|
||||
Dwarf_Unsigned ds_ndx; /* ELF section index. */
|
||||
Dwarf_Unsigned ds_symndx; /* Section symbol index. (for reloc) */
|
||||
STAILQ_ENTRY(_Dwarf_P_Section) ds_next; /* Next section in the list. */
|
||||
} *Dwarf_P_Section;
|
||||
|
||||
typedef struct _Dwarf_Rel_Entry {
|
||||
unsigned char dre_type; /* Reloc type. */
|
||||
unsigned char dre_length; /* Reloc storage unit length. */
|
||||
Dwarf_Unsigned dre_offset; /* Reloc storage unit offset. */
|
||||
Dwarf_Unsigned dre_addend; /* Reloc addend. */
|
||||
Dwarf_Unsigned dre_symndx; /* Reloc symbol index. */
|
||||
const char *dre_secname; /* Refer to some debug section. */
|
||||
STAILQ_ENTRY(_Dwarf_Rel_Entry) dre_next; /* Next reloc entry. */
|
||||
} *Dwarf_Rel_Entry;
|
||||
|
||||
typedef struct _Dwarf_Rel_Section {
|
||||
struct _Dwarf_P_Section *drs_ds; /* Ptr to actual reloc ELF section. */
|
||||
struct _Dwarf_P_Section *drs_ref; /* Which debug section it refers. */
|
||||
struct Dwarf_Relocation_Data_s *drs_drd; /* Reloc data array. */
|
||||
STAILQ_HEAD(, _Dwarf_Rel_Entry) drs_dre; /* Reloc entry list. */
|
||||
Dwarf_Unsigned drs_drecnt; /* Count of entries. */
|
||||
Dwarf_Unsigned drs_size; /* Size of ELF section in bytes. */
|
||||
int drs_addend; /* Elf_Rel or Elf_Rela */
|
||||
STAILQ_ENTRY(_Dwarf_Rel_Section) drs_next; /* Next reloc section. */
|
||||
} *Dwarf_Rel_Section;
|
||||
|
||||
typedef struct {
|
||||
Elf_Data *ed_data;
|
||||
void *ed_alloc;
|
||||
} Dwarf_Elf_Data;
|
||||
|
||||
typedef struct {
|
||||
Elf *eo_elf;
|
||||
GElf_Ehdr eo_ehdr;
|
||||
GElf_Shdr *eo_shdr;
|
||||
Dwarf_Elf_Data *eo_data;
|
||||
Dwarf_Unsigned eo_seccnt;
|
||||
size_t eo_strndx;
|
||||
Dwarf_Obj_Access_Methods eo_methods;
|
||||
} Dwarf_Elf_Object;
|
||||
|
||||
struct _Dwarf_Debug {
|
||||
Dwarf_Obj_Access_Interface *dbg_iface;
|
||||
Dwarf_Section *dbg_section; /* Dwarf section list. */
|
||||
Dwarf_Section *dbg_info_sec; /* Pointer to info section. */
|
||||
Dwarf_Off dbg_info_off; /* Current info section offset. */
|
||||
Dwarf_Unsigned dbg_seccnt; /* Total number of dwarf sections. */
|
||||
int dbg_mode; /* Access mode. */
|
||||
int dbg_pointer_size; /* Object address size. */
|
||||
int dbg_offset_size; /* DWARF offset size. */
|
||||
int dbg_info_loaded; /* Flag indicating all CU loaded. */
|
||||
Dwarf_Half dbg_machine; /* ELF machine architecture. */
|
||||
Dwarf_Handler dbg_errhand; /* Error handler. */
|
||||
Dwarf_Ptr dbg_errarg; /* Argument to the error handler. */
|
||||
STAILQ_HEAD(, _Dwarf_CU) dbg_cu;/* List of compilation units. */
|
||||
Dwarf_CU dbg_cu_current; /* Ptr to the current CU. */
|
||||
TAILQ_HEAD(, _Dwarf_Loclist) dbg_loclist; /* List of location list. */
|
||||
Dwarf_NameSec dbg_globals; /* Ptr to pubnames lookup section. */
|
||||
Dwarf_NameSec dbg_pubtypes; /* Ptr to pubtypes lookup section. */
|
||||
Dwarf_NameSec dbg_weaks; /* Ptr to weaknames lookup section. */
|
||||
Dwarf_NameSec dbg_funcs; /* Ptr to static funcs lookup sect. */
|
||||
Dwarf_NameSec dbg_vars; /* Ptr to static vars lookup sect. */
|
||||
Dwarf_NameSec dbg_types; /* Ptr to types lookup section. */
|
||||
Dwarf_FrameSec dbg_frame; /* Ptr to .debug_frame section. */
|
||||
Dwarf_FrameSec dbg_eh_frame; /* Ptr to .eh_frame section. */
|
||||
STAILQ_HEAD(, _Dwarf_ArangeSet) dbg_aslist; /* List of arange set. */
|
||||
Dwarf_Arange *dbg_arange_array; /* Array of arange. */
|
||||
Dwarf_Unsigned dbg_arange_cnt; /* Length of the arange array. */
|
||||
char *dbg_strtab; /* Dwarf string table. */
|
||||
Dwarf_Unsigned dbg_strtab_cap; /* Dwarf string table capacity. */
|
||||
Dwarf_Unsigned dbg_strtab_size; /* Dwarf string table size. */
|
||||
STAILQ_HEAD(, _Dwarf_MacroSet) dbg_mslist; /* List of macro set. */
|
||||
STAILQ_HEAD(, _Dwarf_Rangelist) dbg_rllist; /* List of rangelist. */
|
||||
uint64_t (*read)(uint8_t *, uint64_t *, int);
|
||||
void (*write)(uint8_t *, uint64_t *, uint64_t, int);
|
||||
int (*write_alloc)(uint8_t **, uint64_t *, uint64_t *,
|
||||
uint64_t, int, Dwarf_Error *);
|
||||
uint64_t (*decode)(uint8_t **, int);
|
||||
|
||||
Dwarf_Half dbg_frame_rule_table_size;
|
||||
Dwarf_Half dbg_frame_rule_initial_value;
|
||||
Dwarf_Half dbg_frame_cfa_value;
|
||||
Dwarf_Half dbg_frame_same_value;
|
||||
Dwarf_Half dbg_frame_undefined_value;
|
||||
|
||||
Dwarf_Regtable3 *dbg_internal_reg_table;
|
||||
|
||||
/*
|
||||
* Fields used by libdwarf producer.
|
||||
*/
|
||||
|
||||
Dwarf_Unsigned dbgp_flags;
|
||||
Dwarf_Unsigned dbgp_isa;
|
||||
Dwarf_Callback_Func dbgp_func;
|
||||
Dwarf_Callback_Func_b dbgp_func_b;
|
||||
Dwarf_Die dbgp_root_die;
|
||||
STAILQ_HEAD(, _Dwarf_Die) dbgp_dielist;
|
||||
STAILQ_HEAD(, _Dwarf_P_Expr) dbgp_pelist;
|
||||
Dwarf_LineInfo dbgp_lineinfo;
|
||||
Dwarf_ArangeSet dbgp_as;
|
||||
Dwarf_Macro_Details *dbgp_mdlist;
|
||||
Dwarf_Unsigned dbgp_mdcnt;
|
||||
STAILQ_HEAD(, _Dwarf_Cie) dbgp_cielist;
|
||||
STAILQ_HEAD(, _Dwarf_Fde) dbgp_fdelist;
|
||||
Dwarf_Unsigned dbgp_cielen;
|
||||
Dwarf_Unsigned dbgp_fdelen;
|
||||
Dwarf_NameTbl dbgp_pubs;
|
||||
Dwarf_NameTbl dbgp_weaks;
|
||||
Dwarf_NameTbl dbgp_funcs;
|
||||
Dwarf_NameTbl dbgp_types;
|
||||
Dwarf_NameTbl dbgp_vars;
|
||||
STAILQ_HEAD(, _Dwarf_P_Section) dbgp_seclist;
|
||||
Dwarf_Unsigned dbgp_seccnt;
|
||||
Dwarf_P_Section dbgp_secpos;
|
||||
Dwarf_P_Section dbgp_info;
|
||||
STAILQ_HEAD(, _Dwarf_Rel_Section) dbgp_drslist;
|
||||
Dwarf_Unsigned dbgp_drscnt;
|
||||
Dwarf_Rel_Section dbgp_drspos;
|
||||
};
|
||||
|
||||
/*
|
||||
* Internal function prototypes.
|
||||
*/
|
||||
|
||||
int _dwarf_abbrev_add(Dwarf_CU, uint64_t, uint64_t, uint8_t,
|
||||
uint64_t, Dwarf_Abbrev *, Dwarf_Error *);
|
||||
void _dwarf_abbrev_cleanup(Dwarf_CU);
|
||||
int _dwarf_abbrev_find(Dwarf_CU, uint64_t, Dwarf_Abbrev *,
|
||||
Dwarf_Error *);
|
||||
int _dwarf_abbrev_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
int _dwarf_abbrev_parse(Dwarf_Debug, Dwarf_CU, Dwarf_Unsigned *,
|
||||
Dwarf_Abbrev *, Dwarf_Error *);
|
||||
int _dwarf_add_AT_dataref(Dwarf_P_Debug, Dwarf_P_Die, Dwarf_Half,
|
||||
Dwarf_Unsigned, Dwarf_Unsigned, const char *,
|
||||
Dwarf_P_Attribute *, Dwarf_Error *);
|
||||
int _dwarf_add_string_attr(Dwarf_P_Die, Dwarf_P_Attribute *,
|
||||
Dwarf_Half, char *, Dwarf_Error *);
|
||||
int _dwarf_alloc(Dwarf_Debug *, int, Dwarf_Error *);
|
||||
void _dwarf_arange_cleanup(Dwarf_Debug);
|
||||
int _dwarf_arange_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
int _dwarf_arange_init(Dwarf_Debug, Dwarf_Error *);
|
||||
void _dwarf_arange_pro_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_attr_alloc(Dwarf_Die, Dwarf_Attribute *, Dwarf_Error *);
|
||||
Dwarf_Attribute _dwarf_attr_find(Dwarf_Die, Dwarf_Half);
|
||||
int _dwarf_attr_gen(Dwarf_P_Debug, Dwarf_P_Section, Dwarf_Rel_Section,
|
||||
Dwarf_CU, Dwarf_Die, int, Dwarf_Error *);
|
||||
int _dwarf_attr_init(Dwarf_Debug, Dwarf_Section *, uint64_t *, int,
|
||||
Dwarf_CU, Dwarf_Die, Dwarf_AttrDef, uint64_t, int,
|
||||
Dwarf_Error *);
|
||||
int _dwarf_attrdef_add(Dwarf_Debug, Dwarf_Abbrev, uint64_t,
|
||||
uint64_t, uint64_t, Dwarf_AttrDef *, Dwarf_Error *);
|
||||
uint64_t _dwarf_decode_lsb(uint8_t **, int);
|
||||
uint64_t _dwarf_decode_msb(uint8_t **, int);
|
||||
int64_t _dwarf_decode_sleb128(uint8_t **);
|
||||
uint64_t _dwarf_decode_uleb128(uint8_t **);
|
||||
void _dwarf_deinit(Dwarf_Debug);
|
||||
int _dwarf_die_alloc(Dwarf_Debug, Dwarf_Die *, Dwarf_Error *);
|
||||
int _dwarf_die_count_links(Dwarf_P_Die, Dwarf_P_Die,
|
||||
Dwarf_P_Die, Dwarf_P_Die);
|
||||
Dwarf_Die _dwarf_die_find(Dwarf_Die, Dwarf_Unsigned);
|
||||
int _dwarf_die_gen(Dwarf_P_Debug, Dwarf_CU, Dwarf_Rel_Section,
|
||||
Dwarf_Error *);
|
||||
void _dwarf_die_link(Dwarf_P_Die, Dwarf_P_Die, Dwarf_P_Die,
|
||||
Dwarf_P_Die, Dwarf_P_Die);
|
||||
int _dwarf_die_parse(Dwarf_Debug, Dwarf_Section *, Dwarf_CU, int,
|
||||
uint64_t, uint64_t, Dwarf_Die *, int, Dwarf_Error *);
|
||||
void _dwarf_die_pro_cleanup(Dwarf_P_Debug);
|
||||
void _dwarf_elf_deinit(Dwarf_Debug);
|
||||
int _dwarf_elf_init(Dwarf_Debug, Elf *, Dwarf_Error *);
|
||||
int _dwarf_elf_load_section(void *, Dwarf_Half, Dwarf_Small **,
|
||||
int *);
|
||||
Dwarf_Endianness _dwarf_elf_get_byte_order(void *);
|
||||
Dwarf_Small _dwarf_elf_get_length_size(void *);
|
||||
Dwarf_Small _dwarf_elf_get_pointer_size(void *);
|
||||
Dwarf_Unsigned _dwarf_elf_get_section_count(void *);
|
||||
int _dwarf_elf_get_section_info(void *, Dwarf_Half,
|
||||
Dwarf_Obj_Access_Section *, int *);
|
||||
void _dwarf_expr_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_expr_into_block(Dwarf_P_Expr, Dwarf_Error *);
|
||||
Dwarf_Section *_dwarf_find_section(Dwarf_Debug, const char *);
|
||||
void _dwarf_frame_cleanup(Dwarf_Debug);
|
||||
int _dwarf_frame_fde_add_inst(Dwarf_P_Fde, Dwarf_Small,
|
||||
Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Error *);
|
||||
int _dwarf_frame_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
int _dwarf_frame_get_fop(Dwarf_Debug, uint8_t *, Dwarf_Unsigned,
|
||||
Dwarf_Frame_Op **, Dwarf_Signed *, Dwarf_Error *);
|
||||
int _dwarf_frame_get_internal_table(Dwarf_Fde, Dwarf_Addr,
|
||||
Dwarf_Regtable3 **, Dwarf_Addr *, Dwarf_Error *);
|
||||
int _dwarf_frame_interal_table_init(Dwarf_Debug, Dwarf_Error *);
|
||||
void _dwarf_frame_params_init(Dwarf_Debug);
|
||||
void _dwarf_frame_pro_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_frame_regtable_copy(Dwarf_Debug, Dwarf_Regtable3 **,
|
||||
Dwarf_Regtable3 *, Dwarf_Error *);
|
||||
int _dwarf_frame_section_load(Dwarf_Debug, Dwarf_Error *);
|
||||
int _dwarf_frame_section_load_eh(Dwarf_Debug, Dwarf_Error *);
|
||||
int _dwarf_generate_sections(Dwarf_P_Debug, Dwarf_Error *);
|
||||
Dwarf_Unsigned _dwarf_get_reloc_type(Dwarf_P_Debug, int);
|
||||
int _dwarf_get_reloc_size(Dwarf_Debug, Dwarf_Unsigned);
|
||||
void _dwarf_info_cleanup(Dwarf_Debug);
|
||||
int _dwarf_info_first_cu(Dwarf_Debug, Dwarf_Error *);
|
||||
int _dwarf_info_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
int _dwarf_info_load(Dwarf_Debug, int, Dwarf_Error *);
|
||||
int _dwarf_info_next_cu(Dwarf_Debug, Dwarf_Error *);
|
||||
void _dwarf_info_pro_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_init(Dwarf_Debug, Dwarf_Unsigned, Dwarf_Handler,
|
||||
Dwarf_Ptr, Dwarf_Error *);
|
||||
int _dwarf_lineno_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
int _dwarf_lineno_init(Dwarf_Die, uint64_t, Dwarf_Error *);
|
||||
void _dwarf_lineno_cleanup(Dwarf_LineInfo);
|
||||
void _dwarf_lineno_pro_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_loc_fill_locdesc(Dwarf_Debug, Dwarf_Locdesc *, uint8_t *,
|
||||
uint64_t, uint8_t, Dwarf_Error *);
|
||||
int _dwarf_loc_fill_locexpr(Dwarf_Debug, Dwarf_Locdesc **,
|
||||
uint8_t *, uint64_t, uint8_t, Dwarf_Error *);
|
||||
int _dwarf_loc_add(Dwarf_Die, Dwarf_Attribute, Dwarf_Error *);
|
||||
int _dwarf_loc_expr_add_atom(Dwarf_Debug, uint8_t *, uint8_t *,
|
||||
Dwarf_Small, Dwarf_Unsigned, Dwarf_Unsigned, int *,
|
||||
Dwarf_Error *);
|
||||
int _dwarf_loclist_find(Dwarf_Debug, Dwarf_CU, uint64_t,
|
||||
Dwarf_Loclist *, Dwarf_Error *);
|
||||
void _dwarf_loclist_cleanup(Dwarf_Debug);
|
||||
void _dwarf_loclist_free(Dwarf_Loclist);
|
||||
int _dwarf_loclist_add(Dwarf_Debug, Dwarf_CU, uint64_t,
|
||||
Dwarf_Loclist *, Dwarf_Error *);
|
||||
void _dwarf_macinfo_cleanup(Dwarf_Debug);
|
||||
int _dwarf_macinfo_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
int _dwarf_macinfo_init(Dwarf_Debug, Dwarf_Error *);
|
||||
void _dwarf_macinfo_pro_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_nametbl_init(Dwarf_Debug, Dwarf_NameSec *,
|
||||
Dwarf_Section *, Dwarf_Error *);
|
||||
void _dwarf_nametbl_cleanup(Dwarf_NameSec *);
|
||||
int _dwarf_nametbl_gen(Dwarf_P_Debug, const char *, Dwarf_NameTbl,
|
||||
Dwarf_Error *);
|
||||
void _dwarf_nametbl_pro_cleanup(Dwarf_NameTbl *);
|
||||
int _dwarf_pro_callback(Dwarf_P_Debug, char *, int, Dwarf_Unsigned,
|
||||
Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
|
||||
Dwarf_Unsigned *, int *);
|
||||
Dwarf_P_Section _dwarf_pro_find_section(Dwarf_P_Debug, const char *);
|
||||
int _dwarf_ranges_add(Dwarf_Debug, Dwarf_CU, uint64_t,
|
||||
Dwarf_Rangelist *, Dwarf_Error *);
|
||||
void _dwarf_ranges_cleanup(Dwarf_Debug);
|
||||
int _dwarf_ranges_find(Dwarf_Debug, uint64_t, Dwarf_Rangelist *);
|
||||
uint64_t _dwarf_read_lsb(uint8_t *, uint64_t *, int);
|
||||
uint64_t _dwarf_read_msb(uint8_t *, uint64_t *, int);
|
||||
int64_t _dwarf_read_sleb128(uint8_t *, uint64_t *);
|
||||
uint64_t _dwarf_read_uleb128(uint8_t *, uint64_t *);
|
||||
char *_dwarf_read_string(void *, Dwarf_Unsigned, uint64_t *);
|
||||
uint8_t *_dwarf_read_block(void *, uint64_t *, uint64_t);
|
||||
int _dwarf_reloc_section_finalize(Dwarf_P_Debug, Dwarf_Rel_Section,
|
||||
Dwarf_Error *);
|
||||
int _dwarf_reloc_entry_add(Dwarf_P_Debug, Dwarf_Rel_Section,
|
||||
Dwarf_P_Section, unsigned char, unsigned char,
|
||||
Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
|
||||
const char *, Dwarf_Error *);
|
||||
int _dwarf_reloc_entry_add_pair(Dwarf_P_Debug, Dwarf_Rel_Section,
|
||||
Dwarf_P_Section, unsigned char, Dwarf_Unsigned,
|
||||
Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
|
||||
Dwarf_Unsigned, Dwarf_Error *);
|
||||
void _dwarf_reloc_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_reloc_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
int _dwarf_reloc_section_gen(Dwarf_P_Debug, Dwarf_Rel_Section,
|
||||
Dwarf_Error *);
|
||||
int _dwarf_reloc_section_init(Dwarf_P_Debug, Dwarf_Rel_Section *,
|
||||
Dwarf_P_Section, Dwarf_Error *);
|
||||
void _dwarf_reloc_section_free(Dwarf_P_Debug, Dwarf_Rel_Section *);
|
||||
void _dwarf_section_cleanup(Dwarf_P_Debug);
|
||||
int _dwarf_section_callback(Dwarf_P_Debug, Dwarf_P_Section,
|
||||
Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
|
||||
Dwarf_Unsigned, Dwarf_Error *);
|
||||
void _dwarf_section_free(Dwarf_P_Debug, Dwarf_P_Section *);
|
||||
int _dwarf_section_init(Dwarf_P_Debug, Dwarf_P_Section *,
|
||||
const char *, int, Dwarf_Error *);
|
||||
void _dwarf_set_error(Dwarf_Debug, Dwarf_Error *, int, int,
|
||||
const char *, int);
|
||||
int _dwarf_strtab_add(Dwarf_Debug, char *, uint64_t *,
|
||||
Dwarf_Error *);
|
||||
void _dwarf_strtab_cleanup(Dwarf_Debug);
|
||||
int _dwarf_strtab_gen(Dwarf_P_Debug, Dwarf_Error *);
|
||||
char *_dwarf_strtab_get_table(Dwarf_Debug);
|
||||
int _dwarf_strtab_init(Dwarf_Debug, Dwarf_Error *);
|
||||
void _dwarf_write_block(void *, uint64_t *, uint8_t *, uint64_t);
|
||||
int _dwarf_write_block_alloc(uint8_t **, uint64_t *, uint64_t *,
|
||||
uint8_t *, uint64_t, Dwarf_Error *);
|
||||
void _dwarf_write_lsb(uint8_t *, uint64_t *, uint64_t, int);
|
||||
int _dwarf_write_lsb_alloc(uint8_t **, uint64_t *, uint64_t *,
|
||||
uint64_t, int, Dwarf_Error *);
|
||||
void _dwarf_write_msb(uint8_t *, uint64_t *, uint64_t, int);
|
||||
int _dwarf_write_msb_alloc(uint8_t **, uint64_t *, uint64_t *,
|
||||
uint64_t, int, Dwarf_Error *);
|
||||
void _dwarf_write_padding(void *, uint64_t *, uint8_t, uint64_t);
|
||||
int _dwarf_write_padding_alloc(uint8_t **, uint64_t *, uint64_t *,
|
||||
uint8_t, uint64_t, Dwarf_Error *);
|
||||
void _dwarf_write_string(void *, uint64_t *, char *);
|
||||
int _dwarf_write_string_alloc(uint8_t **, uint64_t *, uint64_t *,
|
||||
char *, Dwarf_Error *);
|
||||
int _dwarf_write_sleb128(uint8_t *, uint8_t *, int64_t);
|
||||
int _dwarf_write_sleb128_alloc(uint8_t **, uint64_t *, uint64_t *,
|
||||
int64_t, Dwarf_Error *);
|
||||
int _dwarf_write_uleb128(uint8_t *, uint8_t *, uint64_t);
|
||||
int _dwarf_write_uleb128_alloc(uint8_t **, uint64_t *, uint64_t *,
|
||||
uint64_t, Dwarf_Error *);
|
||||
|
||||
#endif /* !__LIBDWARF_H_ */
|
727
contrib/elftoolchain/libdwarf/dwarf.3
Normal file
727
contrib/elftoolchain/libdwarf/dwarf.3
Normal file
@ -0,0 +1,727 @@
|
||||
.\" Copyright (c) 2011 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: dwarf.3 2075 2011-10-27 03:47:28Z jkoshy $
|
||||
.\"
|
||||
.Dd September 17, 2011
|
||||
.Os
|
||||
.Dt DWARF 3
|
||||
.Sh NAME
|
||||
.Nm dwarf
|
||||
.Nd access debugging information in object files
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Sh DESCRIPTION
|
||||
.Pp
|
||||
The
|
||||
.Lb libdwarf
|
||||
provides functions that allow an application to read and write debugging
|
||||
information in object files.
|
||||
The format of debugging information accessible through this API
|
||||
is defined by the DWARF standard, see
|
||||
.Xr dwarf 4 .
|
||||
.Pp
|
||||
The
|
||||
.Xr DWARF 3
|
||||
API has two parts:
|
||||
.Bl -bullet
|
||||
.It
|
||||
A consumer API set allows applications to read existing debug information
|
||||
in a program object.
|
||||
The functions that comprise the DWARF consumer API are described in
|
||||
the section
|
||||
.Sx "DWARF Consumer API"
|
||||
below.
|
||||
.It
|
||||
A producer API set that allows applications to add debug information
|
||||
to a program object.
|
||||
The functions that comprise the DWARF producer API are described in
|
||||
the section
|
||||
.Sx "DWARF Producer API"
|
||||
below.
|
||||
.El
|
||||
.Pp
|
||||
Each function referenced below is further described in its own manual page.
|
||||
.Ss Namespace use
|
||||
The DWARF library uses the following prefixes:
|
||||
.Pp
|
||||
.Bl -tag -width ".Li Dwarf_*" -compact
|
||||
.It Li DWARF_*
|
||||
Used for error numbers and constants.
|
||||
.It Li DW_*
|
||||
Used for constants.
|
||||
.It Li Dwarf_*
|
||||
Used for types.
|
||||
.It Li dwarf_*
|
||||
Used for functions and macros that make up the API.
|
||||
.El
|
||||
.Ss Data Types
|
||||
The DWARF(3) API uses the following data types:
|
||||
.Pp
|
||||
.Bl -tag -width ".Vt Dwarf_Unsigned" -compact
|
||||
.It Vt Dwarf_Abbrev
|
||||
Describes DWARF abbreviations.
|
||||
.It Vt Dwarf_Addr
|
||||
A program address in the target object.
|
||||
.It Vt Dwarf_Arange
|
||||
Describes address ranges.
|
||||
.It Vt Dwarf_Attribute , Vt Dwarf_P_Attribute
|
||||
Describes attributes of debugging information entries.
|
||||
.It Vt Dwarf_Bool
|
||||
Used for boolean states.
|
||||
.It Vt Dwarf_Cie , Vt Dwarf_P_Cie
|
||||
Describes call information that is common to several frames.
|
||||
.It Vt Dwarf_Debug , Vt Dwarf_P_Debug
|
||||
An opaque type describing a debug context.
|
||||
.It Vt Dwarf_Die , Vt Dwarf_P_Die
|
||||
A debugging information entry.
|
||||
.It Vt Dwarf_Fde , Vt Dwarf_P_Fde
|
||||
A frame descriptor.
|
||||
.It Vt Dwarf_Func
|
||||
A descriptor representing a function.
|
||||
.It Vt Dwarf_Global
|
||||
A descriptor representing a global name.
|
||||
.It Vt Dwarf_Half
|
||||
A 16-bit wide unsigned numeric type.
|
||||
.It Vt Dwarf_Handler
|
||||
A pointer to an error handling function.
|
||||
.It Vt Dwarf_Line
|
||||
A descriptor for a source line.
|
||||
.It Vt Dwarf_Off
|
||||
An unsigned file offset, corresponding to an
|
||||
.Vt off_t
|
||||
type supported by the underlying operating system.
|
||||
.It Vt Dwarf_P_Expr
|
||||
A descriptor for a location expression.
|
||||
.It Vt Dwarf_Ptr
|
||||
A virtual address used by an application.
|
||||
.It Vt Dwarf_Signed
|
||||
A 64-bit wide signed numeric type.
|
||||
.It Vt Dwarf_Small
|
||||
An 8-bit wide unsigned numeric type.
|
||||
.It Vt Dwarf_Type
|
||||
A descriptor representing a user-specified type.
|
||||
.It Vt Dwarf_Unsigned
|
||||
A 64-bit wide unsigned numeric type.
|
||||
.It Vt Dwarf_Var
|
||||
A descriptor representing a static variable.
|
||||
.It Vt Dwarf_Weak
|
||||
A descriptor representing a weak name.
|
||||
.El
|
||||
.Ss Error Handling
|
||||
.Pp
|
||||
Library functions that encounter an error will return with a value
|
||||
other than
|
||||
.Dv DW_DLV_OK .
|
||||
.Pp
|
||||
The
|
||||
.Lb libdwarf
|
||||
allows applications to specify three levels of error handling:
|
||||
.Bl -enum -compact
|
||||
.It
|
||||
Most library functions take a parameter of type
|
||||
.Vt Dwarf_Error
|
||||
that specifies a location to store an error descriptor in
|
||||
case of an error.
|
||||
If an error occurs during the execution on an API, and if this
|
||||
parameter is non-NULL, then an error descriptor is written to the
|
||||
location specified.
|
||||
.It
|
||||
Otherwise, if the error parameter was NULL, but if an error handler
|
||||
was defined for the debug context in use using
|
||||
.Xr dwarf_init 3
|
||||
or
|
||||
.Xr dwarf_seterrhand 3 ,
|
||||
then the library will invoke the specified error handler with an error
|
||||
descriptor as argument.
|
||||
.It
|
||||
Otherwise, if a library wide error handler was specified using
|
||||
.Xr dwarf_seterrhand 3 ,
|
||||
it is called.
|
||||
.El
|
||||
.Pp
|
||||
Error descriptors may be used with
|
||||
.Xr dwarf_errmsg 3
|
||||
or
|
||||
.Xr dwarf_errno 3 .
|
||||
.Sh The DWARF Consumer API
|
||||
The DWARF consumer API permits applications to read DWARF information in
|
||||
an object file.
|
||||
.Pp
|
||||
The major functional groups of functions in the consumer API are listed
|
||||
below.
|
||||
.Pp
|
||||
.Bl -tag -compact -width "CCCC"
|
||||
.It Abbreviations
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_abbrev
|
||||
Retrieve abbreviation information at a given offset.
|
||||
.It Fn dwarf_get_abbrev_children_flag
|
||||
Check if an abbreviation has child elements.
|
||||
.It Fn dwarf_get_abbrev_code
|
||||
Retrieve the abbreviation code for an abbreviation entry descriptor.
|
||||
.It Fn dwarf_get_abbrev_entry
|
||||
Retrieve abbreviation information for an abbreviation entry
|
||||
descriptor.
|
||||
.It Fn dwarf_get_abbrev_tag
|
||||
Retrieve the tag for an abbreviation entry.
|
||||
.El
|
||||
.It Addresses
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_address_size
|
||||
Return the number of bytes needed to represent an address.
|
||||
.It Fn dwarf_get_arange
|
||||
Search for an address range descriptor covering an address.
|
||||
.It Fn dwarf_get_arange_cu_header_offset
|
||||
Retrieve the offsets associated with an address range descriptor.
|
||||
.It Fn dwarf_get_arange_info
|
||||
Extract address range information from a descriptor.
|
||||
.It Fn dwarf_get_aranges
|
||||
Retrieve program address space mappings.
|
||||
.It Fn dwarf_get_cu_die_offset
|
||||
Retrieve the offset associated with a compilation unit for an address
|
||||
range descriptor.
|
||||
.It Fn dwarf_get_ranges , Fn dwarf_get_ranges_a
|
||||
Retrieve information about non-contiguous address ranges for
|
||||
a debugging information entry.
|
||||
.El
|
||||
.It Attributes
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_arrayorder
|
||||
Retrieve the value of a
|
||||
.Dv DW_AT_ordering
|
||||
attribute.
|
||||
.It Fn dwarf_attr
|
||||
Retrieve an attribute descriptor.
|
||||
.It Fn dwarf_attrlist
|
||||
Retrieve attribute descriptors for a debugging information entry.
|
||||
.It Fn dwarf_attrval_flag
|
||||
Retrieve a
|
||||
.Dv DW_AT_FORM_flag
|
||||
value.
|
||||
.It Fn dwarf_attrval_signed
|
||||
Retrieve an attribute's value as a signed integral quantity.
|
||||
.It Fn dwarf_attrval_string
|
||||
Retrieve an attribute's value as a NUL-terminated string.
|
||||
.It Fn dwarf_attrval_unsigned
|
||||
Retrieve an attribute's value as an unsigned integral quantity.
|
||||
.It Fn dwarf_bitoffset ,
|
||||
Retrieve the value of a
|
||||
.Dv DW_AT_bit_offset
|
||||
attribute.
|
||||
.It Fn dwarf_bitsize ,
|
||||
Retrieve the value of a
|
||||
.Dv DW_AT_bit_size
|
||||
attribute.
|
||||
.It Fn dwarf_bytesize
|
||||
Retrieve the value of a
|
||||
.Dv DW_AT_byte_size
|
||||
attribute.
|
||||
.It Fn dwarf_formaddr
|
||||
Return the value of an
|
||||
.Dv ADDRESS Ns - Ns
|
||||
class attribute.
|
||||
.It Fn dwarf_formblock
|
||||
Return the value of a
|
||||
.Dv BLOCK Ns - Ns
|
||||
class attribute
|
||||
.It Fn dwarf_formexprloc
|
||||
Return information about a location expression.
|
||||
.It Fn dwarf_formflag
|
||||
Retrieve information about a
|
||||
.Dv BOOLEAN Ns - Ns
|
||||
class attribute.
|
||||
.It Fn dwarf_formref , Fn dwarf_global_formref
|
||||
Retrieve offsets for
|
||||
.Dv REFERENCE Ns - Ns
|
||||
class attributes.
|
||||
.It Fn dwarf_formsdata , Fn dwarf_formudata
|
||||
Retrieve the value of a
|
||||
.Dv CONSTANT Ns - Ns
|
||||
class attribute.
|
||||
.It Fn dwarf_formsig8
|
||||
Return the type signature for a DWARF type.
|
||||
.It Fn dwarf_formstring
|
||||
Retrieve information about a
|
||||
.Dv STRING Ns - Ns
|
||||
class attribute.
|
||||
.It Fn dwarf_get_form_class
|
||||
Retrieve the form class for an attribute.
|
||||
.It Fn dwarf_hasattr
|
||||
Check for the presence of an attribute.
|
||||
.It Fn dwarf_hasform
|
||||
Check if an attribute has the given form.
|
||||
.It Fn dwarf_whatattr
|
||||
Retrieve the attribute code for an attribute.
|
||||
.It Fn dwarf_whatform , Fn dwarf_whatform_direct
|
||||
Retrieve the form of an attribute.
|
||||
.El
|
||||
.It Call Information Entries and Frame Descriptor Entries
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_cie_index
|
||||
Retrieve the index for a CIE descriptor.
|
||||
.It Fn dwarf_get_cie_info
|
||||
Retrieve information from a CIE descriptor.
|
||||
.It Fn dwarf_get_cie_of_fde
|
||||
Retrieve a CIE descriptor.
|
||||
.It Fn dwarf_get_fde_at_pc
|
||||
Retrieve an FDE descriptor for an address.
|
||||
.It Fn dwarf_get_fde_info_for_all_regs
|
||||
Retrieve register rule row.
|
||||
.It Fn dwarf_get_fde_info_for_all_regs3
|
||||
Retrieve register rule row (revised API).
|
||||
.It Fn dwarf_get_fde_info_for_cfa_reg3
|
||||
Retrieve a CFA register rule.
|
||||
.It Fn dwarf_get_fde_info_for_reg
|
||||
Retrieve a register rule.
|
||||
.It Fn dwarf_get_fde_info_for_reg3
|
||||
Retrieve a register rule (revised API).
|
||||
.It Fn dwarf_get_fde_instr_bytes
|
||||
Retrieve instructions from an FDE descriptor.
|
||||
.It Fn dwarf_get_fde_list , Fn dwarf_get_fde_list_eh
|
||||
Retrieve frame information.
|
||||
.It Fn dwarf_get_fde_n
|
||||
Retrieve an FDE descriptor.
|
||||
.It Fn dwarf_get_fde_range
|
||||
Retrieve range information from an FDE descriptor.
|
||||
.El
|
||||
.It Compilation Units
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_cu_die_offset_given_cu_header_offset
|
||||
Retrieve the offset of the debugging information entry for a
|
||||
compilation unit.
|
||||
.It Fn dwarf_next_cu_header , Fn dwarf_next_cu_header_b
|
||||
Step through compilation units in a debug context.
|
||||
.El
|
||||
.It Debugging Information Entries
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_child
|
||||
Returns the child of a debugging information entry.
|
||||
.It Fn dwarf_die_abbrev_code
|
||||
Returns the abbreviation code for a debugging information entry.
|
||||
.It Fn dwarf_die_CU_offset , Fn dwarf_die_CU_offset_range
|
||||
Retrieve offsets and lengths for a compilation unit.
|
||||
.It Fn dwarf_diename
|
||||
Returns the
|
||||
.Dv DW_AT_name
|
||||
attribute for a debugging information entry.
|
||||
.It Fn dwarf_dieoffset
|
||||
Retrieves the offset for a debugging information entry.
|
||||
.It Fn dwarf_highpc
|
||||
Return the highest PC value for a debugging information entry.
|
||||
.It Fn dwarf_lowpc
|
||||
Return the lowest PC value for a debugging information entry.
|
||||
.It Fn dwarf_offdie
|
||||
Retrieve a debugging information entry given an offset.
|
||||
.It Fn dwarf_siblingof
|
||||
Retrieve the sibling descriptor for a debugging information entry.
|
||||
.It Fn dwarf_srclang
|
||||
Retrive the source language attribute for a debugging information
|
||||
entry.
|
||||
.It Fn dwarf_tag
|
||||
Retrieve the tag for a debugging information entry.
|
||||
.El
|
||||
.It Functions
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_func_cu_offset
|
||||
Retrieves the offset for the compilation unit for a function.
|
||||
.It Fn dwarf_func_die_offset
|
||||
Retrieves the offset for the debugging information entry for a
|
||||
function.
|
||||
.It Fn dwarf_funcname
|
||||
Retrieves the name of a function.
|
||||
.It Fn dwarf_func_name_offsets
|
||||
Retrieve both the name and offsets for a function.
|
||||
.It Fn dwarf_get_funcs
|
||||
Retrieve information about static functions.
|
||||
.El
|
||||
.It Globals
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_globals
|
||||
Retrieve a list of globals.
|
||||
.It Fn dwarf_global_cu_offset
|
||||
Return the offset for compilation unit for a global.
|
||||
.It Fn dwarf_global_die_offset
|
||||
Return the offset for the debugging information entry for a global.
|
||||
.It Fn dwarf_global_name_offsets
|
||||
Return the name and offsets for a global.
|
||||
.It Fn dwarf_globname
|
||||
Return the name for a global.
|
||||
.El
|
||||
.It Initialization and Finalization
|
||||
Functions
|
||||
.Fn dwarf_elf_init
|
||||
and
|
||||
.Fn dwarf_init
|
||||
may be used for initialization.
|
||||
The function
|
||||
.Fn dwarf_finish
|
||||
may be used to release resources.
|
||||
.Pp
|
||||
The functions
|
||||
.Fn dwarf_object_init
|
||||
and
|
||||
.Fn dwarf_object_finish
|
||||
allow an application to specify alternate low-level file access
|
||||
routines.
|
||||
.It Line Numbers
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_lineaddr
|
||||
Retrieve the program address for a source line.
|
||||
.It Fn dwarf_linebeginstatement
|
||||
Check if a source line corresponds to the beginning of a statement.
|
||||
.It Fn dwarf_lineblock
|
||||
Check if a source line corresponds to the start of a basic block.
|
||||
.It Fn dwarf_lineendsequence
|
||||
Check if the source line corresponds to the end of a sequence of
|
||||
instructions.
|
||||
.It Fn dwarf_lineno
|
||||
Retrieve the line number for a line descriptor.
|
||||
.It Fn dwarf_lineoff
|
||||
Retrieve the column number for a line descriptor.
|
||||
.It Fn dwarf_linesrc
|
||||
Retrieve the source file for a line descriptor.
|
||||
.It Fn dwarf_line_srcfileno
|
||||
Retrieve the index of the source file for a line descriptor.
|
||||
.It Fn dwarf_srcfiles
|
||||
Retrieve source files for a compilation unit.
|
||||
.It Fn dwarf_srclines
|
||||
Return line number information for a compilation unit.
|
||||
.El
|
||||
.It Location Lists
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_loclist_entry
|
||||
Retrieve a location list entry.
|
||||
.It Fn dwarf_loclist , Fn dwarf_loclist_n
|
||||
Retrieve location expressions.
|
||||
.It Fn dwarf_loclist_from_expr , Fn dwarf_loclist_from_expr_a
|
||||
Translate a location expression into a location descriptor.
|
||||
.El
|
||||
.It Error Handling
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_errmsg
|
||||
Retrieve a human-readable error message.
|
||||
.It Fn dwarf_errno
|
||||
Retrieve an error number from an error descriptor.
|
||||
.It Fn dwarf_seterrarg
|
||||
Set the argument passed to a callback error handler.
|
||||
.It Fn dwarf_seterrhand
|
||||
Set the callback handler to be called in case of an error.
|
||||
.El
|
||||
.It Frame Handling
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_expand_frame_instructions
|
||||
Translate frame instruction bytes.
|
||||
.It Fn dwarf_set_frame_cfa_value
|
||||
Set the CFA parameter for the internal register rule table.
|
||||
.It Fn dwarf_set_frame_rule_initial_value
|
||||
Set the initial value of the register rules in the internal register
|
||||
rule table.
|
||||
.It Fn dwarf_set_frame_rule_table_size
|
||||
Set the maximum number of columns in the register rule table.
|
||||
.It Fn dwarf_set_frame_same_value
|
||||
Set the register number representing the
|
||||
.Dq "same value"
|
||||
rule.
|
||||
.It Fn dwarf_set_frame_undefined_value
|
||||
Set the register number representing the
|
||||
.Dq "undefined"
|
||||
rule.
|
||||
.El
|
||||
.It Macros
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_find_macro_value_start
|
||||
Return the macro value part of a macro string.
|
||||
.It Fn dwarf_get_macro_details
|
||||
Retrieve macro information.
|
||||
.El
|
||||
.It Memory Management
|
||||
In the DWARF consumer API, the rules for memory management differ
|
||||
between functions.
|
||||
In some cases, the memory areas returned to the application by the
|
||||
library are freed by calling specific API functions.
|
||||
In others, the deallocation function
|
||||
.Fn dwarf_dealloc
|
||||
suffices.
|
||||
The individual manual pages for the API's functions document the
|
||||
specific memory management rules to be followed.
|
||||
.Pp
|
||||
The function
|
||||
.Fn dwarf_dealloc
|
||||
is used to mark memory arenas as unused.
|
||||
Additionally, the following functions release specific types of
|
||||
DWARF resources:
|
||||
.Fn dwarf_fde_cie_list_dealloc ,
|
||||
.Fn dwarf_funcs_dealloc ,
|
||||
.Fn dwarf_globals_dealloc ,
|
||||
.Fn dwarf_pubtypes_dealloc ,
|
||||
.Fn dwarf_ranges_dealloc ,
|
||||
.Fn dwarf_srclines_dealloc ,
|
||||
.Fn dwarf_types_dealloc ,
|
||||
.Fn dwarf_vars_dealloc ,
|
||||
and
|
||||
.Fn dwarf_weaks_dealloc .
|
||||
.It Symbol Constants
|
||||
The following functions may be used to return symbolic names
|
||||
for DWARF constants:
|
||||
.Fn dwarf_get_ACCESS_name ,
|
||||
.Fn dwarf_get_AT_name ,
|
||||
.Fn dwarf_get_ATE_name ,
|
||||
.Fn dwarf_get_CC_name ,
|
||||
.Fn dwarf_get_CFA_name ,
|
||||
.Fn dwarf_get_CHILDREN_name ,
|
||||
.Fn dwarf_get_DS_name ,
|
||||
.Fn dwarf_get_DSC_name ,
|
||||
.Fn dwarf_get_EH_name ,
|
||||
.Fn dwarf_get_END_name ,
|
||||
.Fn dwarf_get_FORM_name ,
|
||||
.Fn dwarf_get_ID_name ,
|
||||
.Fn dwarf_get_INL_name ,
|
||||
.Fn dwarf_get_LANG_name ,
|
||||
.Fn dwarf_get_LNE_name ,
|
||||
.Fn dwarf_get_LNS_name ,
|
||||
.Fn dwarf_get_MACINFO_name ,
|
||||
.Fn dwarf_get_OP_name ,
|
||||
.Fn dwarf_get_ORD_name ,
|
||||
.Fn dwarf_get_TAG_name ,
|
||||
.Fn dwarf_get_VIRTUALITY_name ,
|
||||
and
|
||||
.Fn dwarf_get_VIS_name .
|
||||
.It Types
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_pubtypes , Fn dwarf_get_types
|
||||
Retrieve descriptors for user-defined types.
|
||||
.It Fn dwarf_pubtype_cu_offset , Fn dwarf_type_cu_offset
|
||||
Return the offset for the compilation unit for a type.
|
||||
.It Fn dwarf_pubtype_die_offset , Fn dwarf_type_die_offset
|
||||
Return the offset for the debugging information entry for a type.
|
||||
.It Fn dwarf_pubtypename , Fn dwarf_typename
|
||||
Retrieve the name of a type.
|
||||
.It Fn dwarf_pubtype_name_offsets , Fn dwarf_type_name_offsets
|
||||
Retrieve the name and offsets for a type.
|
||||
.El
|
||||
.It Variables
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_vars
|
||||
Retrieve descriptors for static variables.
|
||||
.It Fn dwarf_var_cu_offset
|
||||
Return the offset for the compilation unit for a variable.
|
||||
.It Fn dwarf_var_die_offset
|
||||
Return the offset for the debugging information entry for a variable.
|
||||
.It Fn dwarf_varname
|
||||
Retrieve the name of a variable.
|
||||
.It Fn dwarf_var_name_offsets
|
||||
Retrieve the name and offsets for a variable.
|
||||
.El
|
||||
.It Weak Symbols
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_weaks
|
||||
Retrieve information about weak symbols.
|
||||
.It Fn dwarf_weak_cu_offset
|
||||
Return the offset for the compilation unit for a weak symbol.
|
||||
.It Fn dwarf_weak_die_offset
|
||||
Return the offset for the debugging information entry for a weak symbol.
|
||||
.It Fn dwarf_weakname
|
||||
Retrieve the name of a weak symbol.
|
||||
.It Fn dwarf_weak_name_offsets
|
||||
Retrieve the name and offsets for a weak symbol.
|
||||
.El
|
||||
.It Miscellaneous
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_elf
|
||||
Retrieve the ELF descriptor for a debug context, see
|
||||
.Xr elf 3 .
|
||||
.It Fn dwarf_get_str
|
||||
Retrieve a NUL-terminated string from the DWARF string section.
|
||||
.It Fn dwarf_set_reloc_application
|
||||
Control whether relocations are to be handled by
|
||||
.Lb libdwarf .
|
||||
.El
|
||||
.El
|
||||
.Sh The DWARF Producer API
|
||||
The DWARF producer API permits applications to add DWARF information to
|
||||
an object file.
|
||||
.Pp
|
||||
The major functional groups of functions in the producer API are listed
|
||||
below.
|
||||
.Bl -tag -width "CCCC"
|
||||
.It Attribute Management
|
||||
The following functions are used to attach attributes to a debugging
|
||||
information entry:
|
||||
.Fn dwarf_add_AT_comp_dir ,
|
||||
.Fn dwarf_add_AT_const_value_signedint ,
|
||||
.Fn dwarf_add_AT_const_value_string ,
|
||||
.Fn dwarf_add_AT_const_value_unsignedint ,
|
||||
.Fn dwarf_add_AT_dataref ,
|
||||
.Fn dwarf_add_AT_flag ,
|
||||
.Fn dwarf_add_AT_location_expr ,
|
||||
.Fn dwarf_add_AT_name ,
|
||||
.Fn dwarf_add_AT_producer ,
|
||||
.Fn dwarf_add_AT_ref_address ,
|
||||
.Fn dwarf_add_AT_reference ,
|
||||
.Fn dwarf_add_AT_signed_const ,
|
||||
.Fn dwarf_add_AT_string ,
|
||||
.Fn dwarf_add_AT_targ_address ,
|
||||
.Fn dwarf_add_AT_targ_address_b
|
||||
and
|
||||
.Fn dwarf_add_AT_unsigned_const .
|
||||
.It Debugging Information Entry Management
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_add_die_to_debug
|
||||
Set the root debugging information entry for a DWARF producer instance.
|
||||
.It Fn dwarf_die_link
|
||||
Links debugging information entries.
|
||||
.It Fn dwarf_new_die
|
||||
Allocate a new debugging information entry.
|
||||
.El
|
||||
.It Initialization and Finalization
|
||||
The functions
|
||||
.Fn dwarf_producer_init
|
||||
and
|
||||
.Fn dwarf_producer_init_b
|
||||
are used to initialize a producer instance.
|
||||
.Pp
|
||||
When done, applications release resources using the function
|
||||
.Fn dwarf_producer_finish .
|
||||
.It Relocations and Sections
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_get_relocation_info
|
||||
Retrieve a relocation array from a producer instance.
|
||||
.It Fn dwarf_get_relocation_info_count
|
||||
Return the number of relocation arrays for a producer instance.
|
||||
.It Fn dwarf_get_section_bytes
|
||||
Retrieve the ELF byte stream for a section.
|
||||
.It Fn dwarf_reset_section_bytes
|
||||
Reset internal state for a producer instance.
|
||||
.It Fn dwarf_transform_to_disk_form
|
||||
Prepare byte streams for writing out.
|
||||
.El
|
||||
.It Macros
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_def_macro
|
||||
Add a macro definition.
|
||||
.It Fn dwarf_end_macro_file , Fn dwarf_start_macro_file
|
||||
Record macro file related information.
|
||||
.It Fn dwarf_undef_macro
|
||||
Note the removal of a macro definition.
|
||||
.It Fn dwarf_vendor_ext
|
||||
Enables storing macro information as specified in the DWARF standard.
|
||||
.El
|
||||
.It Symbols, Expressions, Addresses and Offsets
|
||||
.Bl -tag -compact
|
||||
.It Fn dwarf_add_arange , Fn dwarf_add_arange_b
|
||||
Add address range information.
|
||||
.It Fn dwarf_add_directory_decl
|
||||
Add information about an include directory to a producer instance.
|
||||
.It Fn dwarf_add_fde_inst
|
||||
Add an operation to a frame descriptor entry.
|
||||
.It Fn dwarf_add_file_decl
|
||||
Add information about a source file to a producer instance.
|
||||
.It Fn dwarf_add_frame_cie
|
||||
Add call information to a frame descriptor.
|
||||
.It Fn dwarf_add_frame_fde , Fn dwarf_add_frame_fde_b
|
||||
Link a frame descriptor to a producer instance.
|
||||
.It Fn dwarf_add_funcname
|
||||
Add information about a function to a producer instance.
|
||||
.It Fn dwarf_add_line_entry
|
||||
Record mapping information between machine addresses and a source line.
|
||||
.It Fn dwarf_add_expr_addr , Fn dwarf_add_expr_addr_b
|
||||
Add a
|
||||
.Dv DW_OP_addr
|
||||
opcode to a location expression.
|
||||
.It Fn dwarf_add_expr_gen
|
||||
Add an operator to a location expression.
|
||||
.It Fn dwarf_add_pubname
|
||||
Add information about a global name to a producer instance.
|
||||
.It Fn dwarf_add_typename
|
||||
Add information about a type to a producer instance.
|
||||
.It Fn dwarf_add_varname
|
||||
Add information about a static variable to a producer instance.
|
||||
.It Fn dwarf_add_weakname
|
||||
Add information about a weak symbol to a producer instance.
|
||||
.It Fn dwarf_expr_current_offset
|
||||
Retrieve the current size of a location expression.
|
||||
.It Fn dwarf_expr_into_block
|
||||
Convert a location expression into a byte stream.
|
||||
.It Fn dwarf_fde_cfa_offset
|
||||
Append a
|
||||
.Dv DW_CFA_offset
|
||||
operation to a frame descriptor.
|
||||
.It Fn dwarf_lne_end_sequence , Fn dwarf_lne_set_address
|
||||
Note address ranges for source lines.
|
||||
.It Fn dwarf_new_expr
|
||||
Allocate a location expression descriptor.
|
||||
.It Fn dwarf_new_fde
|
||||
Allocate a frame descriptor.
|
||||
.El
|
||||
.It Miscellaneous
|
||||
The function
|
||||
.Fn dwarf_producer_set_isa
|
||||
sets the instruction set architecture for the producer instance.
|
||||
.El
|
||||
.Sh COMPATIBILITY
|
||||
This implementation is believed to be source compatible with the
|
||||
SGI/GNU DWARF(3) library, version 20110113.
|
||||
.Pp
|
||||
Known differences with the SGI/GNU library include:
|
||||
.Bl -bullet -compact
|
||||
.It
|
||||
The memory management scheme used differs, in a backward-compatible
|
||||
way.
|
||||
See
|
||||
.Sx Memory Management
|
||||
above, for coding guidelines for portable applications.
|
||||
.It
|
||||
There is provision for setting a library-wide error handler in
|
||||
addition to the per-debug context handlers supported by the SGI/GNU
|
||||
API, see the subsection
|
||||
.Sx Error Handling
|
||||
above.
|
||||
.It
|
||||
The following API is an extension:
|
||||
.Fn dwarf_producer_set_isa .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr elf 3
|
||||
.Sh STANDARDS
|
||||
The DWARF standard is defined by
|
||||
.Rs
|
||||
.%T "The DWARF Debugging Information Format"
|
||||
.%V "Version 4"
|
||||
.%O "http://www.dwarfstd.org/"
|
||||
.Re
|
||||
.Sh HISTORY
|
||||
The DWARF(3) API originated at Silicon Graphics Inc.
|
||||
.Pp
|
||||
A BSD-licensed implementation of a subset of the API was written by
|
||||
.An "John Birrell" Aq jb@FreeBSD.org
|
||||
for the FreeBSD project.
|
||||
The implementation was subsequently revised and completed by
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
||||
.Pp
|
||||
Manual pages for this implementation were written by
|
||||
.An "Joseph Koshy" Aq jkoshy@users.sourceforge.net
|
||||
and
|
||||
.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
|
544
contrib/elftoolchain/libdwarf/dwarf.h
Normal file
544
contrib/elftoolchain/libdwarf/dwarf.h
Normal file
@ -0,0 +1,544 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
*notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
*notice, this list of conditions and the following disclaimer in the
|
||||
*documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED.IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: dwarf.h 2075 2011-10-27 03:47:28Z jkoshy $
|
||||
*/
|
||||
|
||||
#ifndef _DWARF_H_
|
||||
#define _DWARF_H_
|
||||
|
||||
#define DW_TAG_array_type 0x01
|
||||
#define DW_TAG_class_type 0x02
|
||||
#define DW_TAG_entry_point 0x03
|
||||
#define DW_TAG_enumeration_type 0x04
|
||||
#define DW_TAG_formal_parameter 0x05
|
||||
#define DW_TAG_imported_declaration 0x08
|
||||
#define DW_TAG_label 0x0a
|
||||
#define DW_TAG_lexical_block 0x0b
|
||||
#define DW_TAG_member 0x0d
|
||||
#define DW_TAG_pointer_type 0x0f
|
||||
#define DW_TAG_reference_type 0x10
|
||||
#define DW_TAG_compile_unit 0x11
|
||||
#define DW_TAG_string_type 0x12
|
||||
#define DW_TAG_structure_type 0x13
|
||||
#define DW_TAG_subroutine_type 0x15
|
||||
#define DW_TAG_typedef 0x16
|
||||
#define DW_TAG_union_type 0x17
|
||||
#define DW_TAG_unspecified_parameters 0x18
|
||||
#define DW_TAG_variant 0x19
|
||||
#define DW_TAG_common_block 0x1a
|
||||
#define DW_TAG_common_inclusion 0x1b
|
||||
#define DW_TAG_inheritance 0x1c
|
||||
#define DW_TAG_inlined_subroutine 0x1d
|
||||
#define DW_TAG_module 0x1e
|
||||
#define DW_TAG_ptr_to_member_type 0x1f
|
||||
#define DW_TAG_set_type 0x20
|
||||
#define DW_TAG_subrange_type 0x21
|
||||
#define DW_TAG_with_stmt 0x22
|
||||
#define DW_TAG_access_declaration 0x23
|
||||
#define DW_TAG_base_type 0x24
|
||||
#define DW_TAG_catch_block 0x25
|
||||
#define DW_TAG_const_type 0x26
|
||||
#define DW_TAG_constant 0x27
|
||||
#define DW_TAG_enumerator 0x28
|
||||
#define DW_TAG_friend 0x2a
|
||||
#define DW_TAG_namelist 0x2b
|
||||
#define DW_TAG_namelist_item 0x2c
|
||||
#define DW_TAG_packed_type 0x2d
|
||||
#define DW_TAG_subprogram 0x2e
|
||||
#define DW_TAG_template_type_parameter 0x2f
|
||||
#define DW_TAG_template_type_param 0x2f
|
||||
#define DW_TAG_template_value_parameter 0x30
|
||||
#define DW_TAG_template_value_param 0x30
|
||||
#define DW_TAG_thrown_type 0x31
|
||||
#define DW_TAG_try_block 0x32
|
||||
#define DW_TAG_variant_part 0x33
|
||||
#define DW_TAG_variable 0x34
|
||||
#define DW_TAG_volatile_type 0x35
|
||||
#define DW_TAG_dwarf_procedure 0x36
|
||||
#define DW_TAG_restrict_type 0x37
|
||||
#define DW_TAG_interface_type 0x38
|
||||
#define DW_TAG_namespace 0x39
|
||||
#define DW_TAG_imported_module 0x3a
|
||||
#define DW_TAG_unspecified_type 0x3b
|
||||
#define DW_TAG_partial_unit 0x3c
|
||||
#define DW_TAG_imported_unit 0x3d
|
||||
#define DW_TAG_condition 0x3f
|
||||
#define DW_TAG_shared_type 0x40
|
||||
#define DW_TAG_type_unit 0x41
|
||||
#define DW_TAG_rvalue_reference_type 0x42
|
||||
#define DW_TAG_template_alias 0x43
|
||||
#define DW_TAG_lo_user 0x4080
|
||||
#define DW_TAG_hi_user 0xffff
|
||||
|
||||
#define DW_CHILDREN_no 0x00
|
||||
#define DW_CHILDREN_yes 0x01
|
||||
|
||||
#define DW_AT_sibling 0x01
|
||||
#define DW_AT_location 0x02
|
||||
#define DW_AT_name 0x03
|
||||
#define DW_AT_ordering 0x09
|
||||
#define DW_AT_subscr_data 0x0a
|
||||
#define DW_AT_byte_size 0x0b
|
||||
#define DW_AT_bit_offset 0x0c
|
||||
#define DW_AT_bit_size 0x0d
|
||||
#define DW_AT_element_list 0x0f
|
||||
#define DW_AT_stmt_list 0x10
|
||||
#define DW_AT_low_pc 0x11
|
||||
#define DW_AT_high_pc 0x12
|
||||
#define DW_AT_language 0x13
|
||||
#define DW_AT_member 0x14
|
||||
#define DW_AT_discr 0x15
|
||||
#define DW_AT_discr_value 0x16
|
||||
#define DW_AT_visibility 0x17
|
||||
#define DW_AT_import 0x18
|
||||
#define DW_AT_string_length 0x19
|
||||
#define DW_AT_common_reference 0x1a
|
||||
#define DW_AT_comp_dir 0x1b
|
||||
#define DW_AT_const_value 0x1c
|
||||
#define DW_AT_containing_type 0x1d
|
||||
#define DW_AT_default_value 0x1e
|
||||
#define DW_AT_inline 0x20
|
||||
#define DW_AT_is_optional 0x21
|
||||
#define DW_AT_lower_bound 0x22
|
||||
#define DW_AT_producer 0x25
|
||||
#define DW_AT_prototyped 0x27
|
||||
#define DW_AT_return_addr 0x2a
|
||||
#define DW_AT_start_scope 0x2c
|
||||
#define DW_AT_bit_stride 0x2e
|
||||
#define DW_AT_stride_size 0x2e
|
||||
#define DW_AT_upper_bound 0x2f
|
||||
#define DW_AT_abstract_origin 0x31
|
||||
#define DW_AT_accessibility 0x32
|
||||
#define DW_AT_address_class 0x33
|
||||
#define DW_AT_artificial 0x34
|
||||
#define DW_AT_base_types 0x35
|
||||
#define DW_AT_calling_convention 0x36
|
||||
#define DW_AT_count 0x37
|
||||
#define DW_AT_data_member_location 0x38
|
||||
#define DW_AT_decl_column 0x39
|
||||
#define DW_AT_decl_file 0x3a
|
||||
#define DW_AT_decl_line 0x3b
|
||||
#define DW_AT_declaration 0x3c
|
||||
#define DW_AT_discr_list 0x3d
|
||||
#define DW_AT_encoding 0x3e
|
||||
#define DW_AT_external 0x3f
|
||||
#define DW_AT_frame_base 0x40
|
||||
#define DW_AT_friend 0x41
|
||||
#define DW_AT_identifier_case 0x42
|
||||
#define DW_AT_macro_info 0x43
|
||||
#define DW_AT_namelist_item 0x44
|
||||
#define DW_AT_priority 0x45
|
||||
#define DW_AT_segment 0x46
|
||||
#define DW_AT_specification 0x47
|
||||
#define DW_AT_static_link 0x48
|
||||
#define DW_AT_type 0x49
|
||||
#define DW_AT_use_location 0x4a
|
||||
#define DW_AT_variable_parameter 0x4b
|
||||
#define DW_AT_virtuality 0x4c
|
||||
#define DW_AT_vtable_elem_location 0x4d
|
||||
#define DW_AT_allocated 0x4e
|
||||
#define DW_AT_associated 0x4f
|
||||
#define DW_AT_data_location 0x50
|
||||
#define DW_AT_byte_stride 0x51
|
||||
#define DW_AT_entry_pc 0x52
|
||||
#define DW_AT_use_UTF8 0x53
|
||||
#define DW_AT_extension 0x54
|
||||
#define DW_AT_ranges 0x55
|
||||
#define DW_AT_trampoline 0x56
|
||||
#define DW_AT_call_column 0x57
|
||||
#define DW_AT_call_file 0x58
|
||||
#define DW_AT_call_line 0x59
|
||||
#define DW_AT_description 0x5a
|
||||
#define DW_AT_binary_scale 0x5b
|
||||
#define DW_AT_decimal_scale 0x5c
|
||||
#define DW_AT_small 0x5d
|
||||
#define DW_AT_decimal_sign 0x5e
|
||||
#define DW_AT_digit_count 0x5f
|
||||
#define DW_AT_picture_string 0x60
|
||||
#define DW_AT_mutable 0x61
|
||||
#define DW_AT_threads_scaled 0x62
|
||||
#define DW_AT_explicit 0x63
|
||||
#define DW_AT_object_pointer 0x64
|
||||
#define DW_AT_endianity 0x65
|
||||
#define DW_AT_elemental 0x66
|
||||
#define DW_AT_pure 0x67
|
||||
#define DW_AT_recursive 0x68
|
||||
#define DW_AT_signature 0x69
|
||||
#define DW_AT_main_subprogram 0x6a
|
||||
#define DW_AT_data_bit_offset 0x6b
|
||||
#define DW_AT_const_expr 0x6c
|
||||
#define DW_AT_enum_class 0x6d
|
||||
#define DW_AT_linkage_name 0x6e
|
||||
#define DW_AT_lo_user 0x2000
|
||||
#define DW_AT_hi_user 0x3fff
|
||||
|
||||
#define DW_FORM_addr 0x01
|
||||
#define DW_FORM_block2 0x03
|
||||
#define DW_FORM_block4 0x04
|
||||
#define DW_FORM_data2 0x05
|
||||
#define DW_FORM_data4 0x06
|
||||
#define DW_FORM_data8 0x07
|
||||
#define DW_FORM_string 0x08
|
||||
#define DW_FORM_block 0x09
|
||||
#define DW_FORM_block1 0x0a
|
||||
#define DW_FORM_data1 0x0b
|
||||
#define DW_FORM_flag 0x0c
|
||||
#define DW_FORM_sdata 0x0d
|
||||
#define DW_FORM_strp 0x0e
|
||||
#define DW_FORM_udata 0x0f
|
||||
#define DW_FORM_ref_addr 0x10
|
||||
#define DW_FORM_ref1 0x11
|
||||
#define DW_FORM_ref2 0x12
|
||||
#define DW_FORM_ref4 0x13
|
||||
#define DW_FORM_ref8 0x14
|
||||
#define DW_FORM_ref_udata 0x15
|
||||
#define DW_FORM_indirect 0x16
|
||||
#define DW_FORM_sec_offset 0x17
|
||||
#define DW_FORM_exprloc 0x18
|
||||
#define DW_FORM_flag_present 0x19
|
||||
#define DW_FORM_ref_sig8 0x20
|
||||
|
||||
#define DW_OP_addr 0x03
|
||||
#define DW_OP_deref 0x06
|
||||
#define DW_OP_const1u 0x08
|
||||
#define DW_OP_const1s 0x09
|
||||
#define DW_OP_const2u 0x0a
|
||||
#define DW_OP_const2s 0x0b
|
||||
#define DW_OP_const4u 0x0c
|
||||
#define DW_OP_const4s 0x0d
|
||||
#define DW_OP_const8u 0x0e
|
||||
#define DW_OP_const8s 0x0f
|
||||
#define DW_OP_constu 0x10
|
||||
#define DW_OP_consts 0x11
|
||||
#define DW_OP_dup 0x12
|
||||
#define DW_OP_drop 0x13
|
||||
#define DW_OP_over 0x14
|
||||
#define DW_OP_pick 0x15
|
||||
#define DW_OP_swap 0x16
|
||||
#define DW_OP_rot 0x17
|
||||
#define DW_OP_xderef 0x18
|
||||
#define DW_OP_abs 0x19
|
||||
#define DW_OP_and 0x1a
|
||||
#define DW_OP_div 0x1b
|
||||
#define DW_OP_minus 0x1c
|
||||
#define DW_OP_mod 0x1d
|
||||
#define DW_OP_mul 0x1e
|
||||
#define DW_OP_neg 0x1f
|
||||
#define DW_OP_not 0x20
|
||||
#define DW_OP_or 0x21
|
||||
#define DW_OP_plus 0x22
|
||||
#define DW_OP_plus_uconst 0x23
|
||||
#define DW_OP_shl 0x24
|
||||
#define DW_OP_shr 0x25
|
||||
#define DW_OP_shra 0x26
|
||||
#define DW_OP_xor 0x27
|
||||
#define DW_OP_bra 0x28
|
||||
#define DW_OP_eq 0x29
|
||||
#define DW_OP_ge 0x2a
|
||||
#define DW_OP_gt 0x2b
|
||||
#define DW_OP_le 0x2c
|
||||
#define DW_OP_lt 0x2d
|
||||
#define DW_OP_ne 0x2e
|
||||
#define DW_OP_skip 0x2f
|
||||
#define DW_OP_lit0 0x30
|
||||
#define DW_OP_lit1 0x31
|
||||
#define DW_OP_lit2 0x32
|
||||
#define DW_OP_lit3 0x33
|
||||
#define DW_OP_lit4 0x34
|
||||
#define DW_OP_lit5 0x35
|
||||
#define DW_OP_lit6 0x36
|
||||
#define DW_OP_lit7 0x37
|
||||
#define DW_OP_lit8 0x38
|
||||
#define DW_OP_lit9 0x39
|
||||
#define DW_OP_lit10 0x3a
|
||||
#define DW_OP_lit11 0x3b
|
||||
#define DW_OP_lit12 0x3c
|
||||
#define DW_OP_lit13 0x3d
|
||||
#define DW_OP_lit14 0x3e
|
||||
#define DW_OP_lit15 0x3f
|
||||
#define DW_OP_lit16 0x40
|
||||
#define DW_OP_lit17 0x41
|
||||
#define DW_OP_lit18 0x42
|
||||
#define DW_OP_lit19 0x43
|
||||
#define DW_OP_lit20 0x44
|
||||
#define DW_OP_lit21 0x45
|
||||
#define DW_OP_lit22 0x46
|
||||
#define DW_OP_lit23 0x47
|
||||
#define DW_OP_lit24 0x48
|
||||
#define DW_OP_lit25 0x49
|
||||
#define DW_OP_lit26 0x4a
|
||||
#define DW_OP_lit27 0x4b
|
||||
#define DW_OP_lit28 0x4c
|
||||
#define DW_OP_lit29 0x4d
|
||||
#define DW_OP_lit30 0x4e
|
||||
#define DW_OP_lit31 0x4f
|
||||
#define DW_OP_reg0 0x50
|
||||
#define DW_OP_reg1 0x51
|
||||
#define DW_OP_reg2 0x52
|
||||
#define DW_OP_reg3 0x53
|
||||
#define DW_OP_reg4 0x54
|
||||
#define DW_OP_reg5 0x55
|
||||
#define DW_OP_reg6 0x56
|
||||
#define DW_OP_reg7 0x57
|
||||
#define DW_OP_reg8 0x58
|
||||
#define DW_OP_reg9 0x59
|
||||
#define DW_OP_reg10 0x5a
|
||||
#define DW_OP_reg11 0x5b
|
||||
#define DW_OP_reg12 0x5c
|
||||
#define DW_OP_reg13 0x5d
|
||||
#define DW_OP_reg14 0x5e
|
||||
#define DW_OP_reg15 0x5f
|
||||
#define DW_OP_reg16 0x60
|
||||
#define DW_OP_reg17 0x61
|
||||
#define DW_OP_reg18 0x62
|
||||
#define DW_OP_reg19 0x63
|
||||
#define DW_OP_reg20 0x64
|
||||
#define DW_OP_reg21 0x65
|
||||
#define DW_OP_reg22 0x66
|
||||
#define DW_OP_reg23 0x67
|
||||
#define DW_OP_reg24 0x68
|
||||
#define DW_OP_reg25 0x69
|
||||
#define DW_OP_reg26 0x6a
|
||||
#define DW_OP_reg27 0x6b
|
||||
#define DW_OP_reg28 0x6c
|
||||
#define DW_OP_reg29 0x6d
|
||||
#define DW_OP_reg30 0x6e
|
||||
#define DW_OP_reg31 0x6f
|
||||
#define DW_OP_breg0 0x70
|
||||
#define DW_OP_breg1 0x71
|
||||
#define DW_OP_breg2 0x72
|
||||
#define DW_OP_breg3 0x73
|
||||
#define DW_OP_breg4 0x74
|
||||
#define DW_OP_breg5 0x75
|
||||
#define DW_OP_breg6 0x76
|
||||
#define DW_OP_breg7 0x77
|
||||
#define DW_OP_breg8 0x78
|
||||
#define DW_OP_breg9 0x79
|
||||
#define DW_OP_breg10 0x7a
|
||||
#define DW_OP_breg11 0x7b
|
||||
#define DW_OP_breg12 0x7c
|
||||
#define DW_OP_breg13 0x7d
|
||||
#define DW_OP_breg14 0x7e
|
||||
#define DW_OP_breg15 0x7f
|
||||
#define DW_OP_breg16 0x80
|
||||
#define DW_OP_breg17 0x81
|
||||
#define DW_OP_breg18 0x82
|
||||
#define DW_OP_breg19 0x83
|
||||
#define DW_OP_breg20 0x84
|
||||
#define DW_OP_breg21 0x85
|
||||
#define DW_OP_breg22 0x86
|
||||
#define DW_OP_breg23 0x87
|
||||
#define DW_OP_breg24 0x88
|
||||
#define DW_OP_breg25 0x89
|
||||
#define DW_OP_breg26 0x8a
|
||||
#define DW_OP_breg27 0x8b
|
||||
#define DW_OP_breg28 0x8c
|
||||
#define DW_OP_breg29 0x8d
|
||||
#define DW_OP_breg30 0x8e
|
||||
#define DW_OP_breg31 0x8f
|
||||
#define DW_OP_regx 0x90
|
||||
#define DW_OP_fbreg 0x91
|
||||
#define DW_OP_bregx 0x92
|
||||
#define DW_OP_piece 0x93
|
||||
#define DW_OP_deref_size 0x94
|
||||
#define DW_OP_xderef_size 0x95
|
||||
#define DW_OP_nop 0x96
|
||||
#define DW_OP_push_object_address 0x97
|
||||
#define DW_OP_call2 0x98
|
||||
#define DW_OP_call4 0x99
|
||||
#define DW_OP_call_ref 0x9a
|
||||
#define DW_OP_form_tls_address 0x9b
|
||||
#define DW_OP_call_frame_cfa 0x9c
|
||||
#define DW_OP_bit_piece 0x9d
|
||||
#define DW_OP_implicit_value 0x9e
|
||||
#define DW_OP_stack_value 0x9f
|
||||
#define DW_OP_lo_user 0xe0
|
||||
#define DW_OP_GNU_push_tls_address 0xe0
|
||||
#define DW_OP_hi_user 0xff
|
||||
|
||||
#define DW_ATE_address 0x1
|
||||
#define DW_ATE_boolean 0x2
|
||||
#define DW_ATE_complex_float 0x3
|
||||
#define DW_ATE_float 0x4
|
||||
#define DW_ATE_signed 0x5
|
||||
#define DW_ATE_signed_char 0x6
|
||||
#define DW_ATE_unsigned 0x7
|
||||
#define DW_ATE_unsigned_char 0x8
|
||||
#define DW_ATE_imaginary_float 0x9
|
||||
#define DW_ATE_packed_decimal 0xa
|
||||
#define DW_ATE_numeric_string 0xb
|
||||
#define DW_ATE_edited 0xc
|
||||
#define DW_ATE_signed_fixed 0xd
|
||||
#define DW_ATE_unsigned_fixed 0xe
|
||||
#define DW_ATE_decimal_float 0xf
|
||||
#define DW_ATE_lo_user 0x80
|
||||
#define DW_ATE_hi_user 0xff
|
||||
|
||||
#define DW_ACCESS_public 0x01
|
||||
#define DW_ACCESS_protected 0x02
|
||||
#define DW_ACCESS_private 0x03
|
||||
|
||||
#define DW_END_default 0x00
|
||||
#define DW_END_big 0x01
|
||||
#define DW_END_little 0x02
|
||||
#define DW_END_lo_user 0x40
|
||||
#define DW_END_high_user 0xff
|
||||
|
||||
#define DW_VIS_local 0x01
|
||||
#define DW_VIS_exported 0x02
|
||||
#define DW_VIS_qualified 0x03
|
||||
|
||||
#define DW_VIRTUALITY_none 0x00
|
||||
#define DW_VIRTUALITY_virtual 0x01
|
||||
#define DW_VIRTUALITY_pure_virtual 0x02
|
||||
|
||||
#define DW_LANG_C89 0x0001
|
||||
#define DW_LANG_C 0x0002
|
||||
#define DW_LANG_Ada83 0x0003
|
||||
#define DW_LANG_C_plus_plus 0x0004
|
||||
#define DW_LANG_Cobol74 0x0005
|
||||
#define DW_LANG_Cobol85 0x0006
|
||||
#define DW_LANG_Fortran77 0x0007
|
||||
#define DW_LANG_Fortran90 0x0008
|
||||
#define DW_LANG_Pascal83 0x0009
|
||||
#define DW_LANG_Modula2 0x000a
|
||||
#define DW_LANG_Java 0x000b
|
||||
#define DW_LANG_C99 0x000c
|
||||
#define DW_LANG_Ada95 0x000d
|
||||
#define DW_LANG_Fortran95 0x000e
|
||||
#define DW_LANG_PLI 0x000f
|
||||
#define DW_LANG_ObjC 0x0010
|
||||
#define DW_LANG_ObjC_plus_plus 0x0011
|
||||
#define DW_LANG_UPC 0x0012
|
||||
#define DW_LANG_D 0x0013
|
||||
#define DW_LANG_lo_user 0x8000
|
||||
#define DW_LANG_hi_user 0xffff
|
||||
|
||||
#define DW_ID_case_sensitive 0x00
|
||||
#define DW_ID_up_case 0x01
|
||||
#define DW_ID_down_case 0x02
|
||||
#define DW_ID_case_insensitive 0x03
|
||||
|
||||
#define DW_CC_normal 0x01
|
||||
#define DW_CC_program 0x02
|
||||
#define DW_CC_nocall 0x03
|
||||
#define DW_CC_lo_user 0x40
|
||||
#define DW_CC_hi_user 0xff
|
||||
|
||||
#define DW_INL_not_inlined 0x00
|
||||
#define DW_INL_inlined 0x01
|
||||
#define DW_INL_declared_not_inlined 0x02
|
||||
#define DW_INL_declared_inlined 0x03
|
||||
|
||||
#define DW_ORD_row_major 0x00
|
||||
#define DW_ORD_col_major 0x01
|
||||
|
||||
#define DW_DS_unsigned 0x01
|
||||
#define DW_DS_leading_overpunch 0x02
|
||||
#define DW_DS_trailing_overpunch 0x03
|
||||
#define DW_DS_leading_separate 0x04
|
||||
#define DW_DS_trailing_separate 0x05
|
||||
|
||||
#define DW_DSC_label 0x00
|
||||
#define DW_DSC_range 0x01
|
||||
|
||||
#define DW_LNS_copy 0x01
|
||||
#define DW_LNS_advance_pc 0x02
|
||||
#define DW_LNS_advance_line 0x03
|
||||
#define DW_LNS_set_file 0x04
|
||||
#define DW_LNS_set_column 0x05
|
||||
#define DW_LNS_negate_stmt 0x06
|
||||
#define DW_LNS_set_basic_block 0x07
|
||||
#define DW_LNS_const_add_pc 0x08
|
||||
#define DW_LNS_fixed_advance_pc 0x09
|
||||
#define DW_LNS_set_prologue_end 0x0a
|
||||
#define DW_LNS_set_epilogue_begin 0x0b
|
||||
#define DW_LNS_set_isa 0x0c
|
||||
|
||||
#define DW_LNE_end_sequence 0x01
|
||||
#define DW_LNE_set_address 0x02
|
||||
#define DW_LNE_define_file 0x03
|
||||
#define DW_LNE_lo_user 0x80
|
||||
#define DW_LNE_hi_user 0xff
|
||||
|
||||
#define DW_MACINFO_define 0x01
|
||||
#define DW_MACINFO_undef 0x02
|
||||
#define DW_MACINFO_start_file 0x03
|
||||
#define DW_MACINFO_end_file 0x04
|
||||
#define DW_MACINFO_vendor_ext 0xff
|
||||
|
||||
#define DW_CFA_advance_loc 0x40
|
||||
#define DW_CFA_offset 0x80
|
||||
#define DW_CFA_restore 0xc0
|
||||
#define DW_CFA_extended 0
|
||||
|
||||
#define DW_CFA_nop 0x00
|
||||
#define DW_CFA_set_loc 0x01
|
||||
#define DW_CFA_advance_loc1 0x02
|
||||
#define DW_CFA_advance_loc2 0x03
|
||||
#define DW_CFA_advance_loc4 0x04
|
||||
#define DW_CFA_offset_extended 0x05
|
||||
#define DW_CFA_restore_extended 0x06
|
||||
#define DW_CFA_undefined 0x07
|
||||
#define DW_CFA_same_value 0x08
|
||||
#define DW_CFA_register 0x09
|
||||
#define DW_CFA_remember_state 0x0a
|
||||
#define DW_CFA_restore_state 0x0b
|
||||
#define DW_CFA_def_cfa 0x0c
|
||||
#define DW_CFA_def_cfa_register 0x0d
|
||||
#define DW_CFA_def_cfa_offset 0x0e
|
||||
#define DW_CFA_def_cfa_expression 0x0f
|
||||
#define DW_CFA_expression 0x10
|
||||
#define DW_CFA_offset_extended_sf 0x11
|
||||
#define DW_CFA_def_cfa_sf 0x12
|
||||
#define DW_CFA_def_cfa_offset_sf 0x13
|
||||
#define DW_CFA_val_offset 0x14
|
||||
#define DW_CFA_val_offset_sf 0x15
|
||||
#define DW_CFA_val_expression 0x16
|
||||
#define DW_CFA_lo_user 0x1c
|
||||
#define DW_CFA_high_user 0x3f
|
||||
|
||||
/*
|
||||
* LSB(Linux Standard Base) extension to DWARF2.
|
||||
*/
|
||||
|
||||
#define DW_EH_PE_absptr 0x00
|
||||
#define DW_EH_PE_uleb128 0x01
|
||||
#define DW_EH_PE_udata2 0x02
|
||||
#define DW_EH_PE_udata4 0x03
|
||||
#define DW_EH_PE_udata8 0x04
|
||||
#define DW_EH_PE_sleb128 0x09
|
||||
#define DW_EH_PE_sdata2 0x0a
|
||||
#define DW_EH_PE_sdata4 0x0b
|
||||
#define DW_EH_PE_sdata8 0x0c
|
||||
#define DW_EH_PE_pcrel 0x10
|
||||
#define DW_EH_PE_textrel 0x20
|
||||
#define DW_EH_PE_datarel 0x30
|
||||
#define DW_EH_PE_funcrel 0x40
|
||||
#define DW_EH_PE_aligned 0x50
|
||||
#define DW_EH_PE_omit 0xff
|
||||
|
||||
#endif /* !_DWARF_H_ */
|
136
contrib/elftoolchain/libdwarf/dwarf_abbrev.c
Normal file
136
contrib/elftoolchain/libdwarf/dwarf_abbrev.c
Normal file
@ -0,0 +1,136 @@
|
||||
/*-
|
||||
* Copyright (c) 2009,2011 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_abbrev.c 2072 2011-10-27 03:26:49Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_get_abbrev(Dwarf_Debug dbg, Dwarf_Unsigned offset,
|
||||
Dwarf_Abbrev *return_abbrev, Dwarf_Unsigned *length,
|
||||
Dwarf_Unsigned *attr_count, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Abbrev ab;
|
||||
int ret;
|
||||
|
||||
if (dbg == NULL || return_abbrev == NULL || length == NULL ||
|
||||
attr_count == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
ret = _dwarf_abbrev_parse(dbg, NULL, &offset, &ab, error);
|
||||
if (ret != DW_DLE_NONE) {
|
||||
if (ret == DW_DLE_NO_ENTRY) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
} else
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_abbrev = ab;
|
||||
*length = ab->ab_length;
|
||||
*attr_count = ab->ab_atnum;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_abbrev_tag(Dwarf_Abbrev abbrev, Dwarf_Half *return_tag,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (abbrev == NULL || return_tag == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_tag = (Dwarf_Half) abbrev->ab_tag;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_abbrev_code(Dwarf_Abbrev abbrev, Dwarf_Unsigned *return_code,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (abbrev == NULL || return_code == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_code = abbrev->ab_entry;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_abbrev_children_flag(Dwarf_Abbrev abbrev, Dwarf_Signed *return_flag,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (abbrev == NULL || return_flag == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_flag = (Dwarf_Signed) abbrev->ab_children;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_abbrev_entry(Dwarf_Abbrev abbrev, Dwarf_Signed ndx,
|
||||
Dwarf_Half *attr_num, Dwarf_Signed *form, Dwarf_Off *offset,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_AttrDef ad;
|
||||
int i;
|
||||
|
||||
if (abbrev == NULL || attr_num == NULL || form == NULL ||
|
||||
offset == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (ndx < 0 || (uint64_t) ndx >= abbrev->ab_atnum) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
ad = STAILQ_FIRST(&abbrev->ab_attrdef);
|
||||
for (i = 0; i < ndx && ad != NULL; i++)
|
||||
ad = STAILQ_NEXT(ad, ad_next);
|
||||
|
||||
assert(ad != NULL);
|
||||
|
||||
*attr_num = ad->ad_attrib;
|
||||
*form = ad->ad_form;
|
||||
*offset = ad->ad_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
99
contrib/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
Normal file
99
contrib/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
Normal file
@ -0,0 +1,99 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_comp_dir.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_COMP_DIR 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_comp_dir
|
||||
.Nd create and attach a DW_AT_comp_dir attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_comp_dir
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *dir"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_comp_dir
|
||||
creates a
|
||||
.Dv DW_AT_comp_dir
|
||||
attribute descriptor and attaches it to the debugging information
|
||||
entry referenced by argument
|
||||
.Ar die .
|
||||
The created attribute will have DWARF form
|
||||
.Dv DW_FORM_strp .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dir
|
||||
should point to a NUL-terminated string which will become the value of
|
||||
the created attribute.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_comp_dir
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_comp_dir
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_comp_dir
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar die
|
||||
or
|
||||
.Ar dir
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_const_value_string 3 ,
|
||||
.Xr dwarf_add_AT_name 3 ,
|
||||
.Xr dwarf_add_AT_producer 3 ,
|
||||
.Xr dwarf_add_AT_string 3 ,
|
||||
.Xr dwarf_new_die 3
|
126
contrib/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
Normal file
126
contrib/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
Normal file
@ -0,0 +1,126 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_const_value_string.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_CONST_VALUE_STRING 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_const_value_signedint ,
|
||||
.Nm dwarf_add_AT_const_value_string ,
|
||||
.Nm dwarf_add_AT_const_value_unsignedint
|
||||
.Nd create and attach a DW_AT_const_value attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_const_value_signedint
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Signed value"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_const_value_string
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *str"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_const_value_unsignedint
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Unsigned value"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions create a
|
||||
.Dv DW_AT_const_value
|
||||
attribute descriptor and attach it to the debugging information entry
|
||||
referenced by argument
|
||||
.Ar die .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_AT_const_value_signedint
|
||||
creates a
|
||||
.Dv DW_AT_const_value
|
||||
attribute descriptor containing the signed value specified by argument
|
||||
.Ar value .
|
||||
The created attribute descriptor will have DWARF form
|
||||
.Dv DW_FORM_sdata .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_AT_const_value_unsignedint
|
||||
creates a
|
||||
.Dv DW_AT_const_value
|
||||
attribute descriptor containing the unsigned value specified by
|
||||
argument
|
||||
.Ar value .
|
||||
The created attribute descriptor will have DWARF form
|
||||
.Dv DW_FORM_udata .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_AT_const_value_string
|
||||
creates a
|
||||
.Dv DW_AT_const_value
|
||||
attribute descriptor containing the string pointed to by the
|
||||
NUL-terminated argument
|
||||
.Ar str .
|
||||
The created attribute descriptor will have DWARF form
|
||||
.Dv DW_FORM_strp .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used by these functions to store error
|
||||
information in case of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions return the created attribute descriptor.
|
||||
In case of an error, these functions return
|
||||
.Dv DW_DLV_BADADDR
|
||||
and set the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar die
|
||||
or
|
||||
.Ar str
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during execution.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_name 3 ,
|
||||
.Xr dwarf_add_AT_signed_const 3 ,
|
||||
.Xr dwarf_add_AT_string 3 ,
|
||||
.Xr dwarf_add_AT_unsigned_const 3 ,
|
||||
.Xr dwarf_new_die 3
|
122
contrib/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
Normal file
122
contrib/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
Normal file
@ -0,0 +1,122 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_dataref.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_DATAREF 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_dataref
|
||||
.Nd create an attribute descriptor for a relocatable address
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_P_Attribute"
|
||||
.Fo dwarf_add_AT_dataref
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Unsigned pc_value"
|
||||
.Fa "Dwarf_Unsigned sym_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_dataref
|
||||
creates an attribute descriptor for a relocatable address and attaches
|
||||
it to the debugging information entry referenced by argument
|
||||
.Ar die .
|
||||
.Pp
|
||||
If flag
|
||||
.Dv DW_DLC_SIZE_64
|
||||
is set, the address value will be 8 bytes in size and of the DWARF form
|
||||
.Dv DW_FORM_data8 .
|
||||
Otherwise, the address value will be 4 bytes in size and of the DWARF form
|
||||
.Dv DW_FORM_data4 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
specifies the attribute code of the created attribute descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc_value
|
||||
specifies the value of the relocatable address.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar sym_index
|
||||
specifies the ELF symbol index of the symbol to be used for
|
||||
relocation.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_dataref
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_dataref
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_dataref
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar die
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_reference 3 ,
|
||||
.Xr dwarf_add_AT_ref_address 3 ,
|
||||
.Xr dwarf_add_AT_signed_const 3 ,
|
||||
.Xr dwarf_add_AT_unsigned_const 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
115
contrib/elftoolchain/libdwarf/dwarf_add_AT_flag.3
Normal file
115
contrib/elftoolchain/libdwarf/dwarf_add_AT_flag.3
Normal file
@ -0,0 +1,115 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_flag.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_FLAG 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_flag
|
||||
.Nd create and attach a flag attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_flag
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Small flag"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_flag
|
||||
creates an attribute descriptor belonging to the
|
||||
.Sq flag
|
||||
class, and attaches it to the debugging information entry referenced
|
||||
by argument
|
||||
.Ar die .
|
||||
The created attribute descriptor will have DWARF form
|
||||
.Dv DW_FORM_flag .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
should specify the attribute code for the new attribute descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar flag
|
||||
should specify the value of the new attribute descriptor.
|
||||
A zero value is treated as
|
||||
.Sq false
|
||||
and a non-zero value as
|
||||
.Sq true .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_flag
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_flag
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_flag
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar die
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_signed_const 3 ,
|
||||
.Xr dwarf_add_AT_unsigned_const 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
120
contrib/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
Normal file
120
contrib/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
Normal file
@ -0,0 +1,120 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_location_expr.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 5, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_LOCATION_EXPR 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_location_expr
|
||||
.Nd create an attribute descriptor for a location expression
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_P_Attribute"
|
||||
.Fo dwarf_add_AT_location_expr
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_P_Expr loc_expr"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_location_expr
|
||||
creates an attribute descriptor for a location expression and attaches
|
||||
it to the debugging information entry referenced by argument
|
||||
.Ar die .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
specifies the attribute code of the created attribute descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar loc_expr
|
||||
should reference a location expression descriptor allocated using
|
||||
.Xr dwarf_new_expr 3 .
|
||||
.Pp
|
||||
The attribute created by function
|
||||
.Fn dwarf_add_AT_location_expr
|
||||
will have one of the DWARF forms
|
||||
.Dv DW_FORM_block ,
|
||||
.Dv DW_FORM_block1 ,
|
||||
.Dv DW_FORM_block2
|
||||
or
|
||||
.Dv DW_FORM_block4 ,
|
||||
depending on the size of the byte stream generated by the location
|
||||
expression descriptor referenced by argument
|
||||
.Ar loc_expr .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used by to store error information in case of
|
||||
an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_location_expr
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_location_expr
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_location_expr
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar loc_expr
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_new_expr 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
99
contrib/elftoolchain/libdwarf/dwarf_add_AT_name.3
Normal file
99
contrib/elftoolchain/libdwarf/dwarf_add_AT_name.3
Normal file
@ -0,0 +1,99 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_name.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_NAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_name
|
||||
.Nd create and attach a DW_AT_name attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_name
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_name
|
||||
creates a
|
||||
.Dv DW_AT_name
|
||||
attribute descriptor and attaches it to the debugging information
|
||||
entry referenced by argument
|
||||
.Ar die .
|
||||
The created attribute will have DWARF form
|
||||
.Dv DW_FORM_strp .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string which will become the value of
|
||||
the created attribute.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_name
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_name
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_name
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar die
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
this function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_comp_dir 3 ,
|
||||
.Xr dwarf_add_AT_const_value_string 3 ,
|
||||
.Xr dwarf_add_AT_producer 3 ,
|
||||
.Xr dwarf_add_AT_string 3 ,
|
||||
.Xr dwarf_new_die 3
|
99
contrib/elftoolchain/libdwarf/dwarf_add_AT_producer.3
Normal file
99
contrib/elftoolchain/libdwarf/dwarf_add_AT_producer.3
Normal file
@ -0,0 +1,99 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_producer.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_PRODUCER 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_producer
|
||||
.Nd create and attach a DW_AT_producer attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_producer
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *producer"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_producer
|
||||
creates a
|
||||
.Dv DW_AT_producer
|
||||
attribute descriptor and attaches it to the debugging information
|
||||
entry referenced by argument
|
||||
.Ar die .
|
||||
The created attribute will have DWARF form
|
||||
.Dv DW_FORM_strp .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar producer
|
||||
should point to a NUL-terminated string which will become the value of
|
||||
the created attribute.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_producer
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_producer
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_producer
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar die
|
||||
or
|
||||
.Ar producer
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
the function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_comp_dir 3 ,
|
||||
.Xr dwarf_add_AT_const_value_string 3 ,
|
||||
.Xr dwarf_add_AT_name 3 ,
|
||||
.Xr dwarf_add_AT_string 3 ,
|
||||
.Xr dwarf_new_die 3
|
117
contrib/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
Normal file
117
contrib/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
Normal file
@ -0,0 +1,117 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_ref_address.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 7, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_REF_ADDRESS 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_ref_address
|
||||
.Nd create a reference class attribute descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_P_Attribute"
|
||||
.Fo dwarf_add_AT_ref_address
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Unsigned pc_value"
|
||||
.Fa "Dwarf_Unsigned sym_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_ref_address
|
||||
creates a
|
||||
.Sq reference
|
||||
class attribute descriptor containing a relocatable address value.
|
||||
The created attribute will use DWARF form
|
||||
.Dv DW_FORM_ref_addr .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
specifies the attribute code of the created attribute.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc_value
|
||||
contains a relocatable address which will become the value of the
|
||||
created attribute.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar sym_index
|
||||
should specify the ELF symbol index of the symbol to be used when
|
||||
relocating the address value.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_ref_address
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_ref_address
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_ref_address
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar die
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during execution.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_dataref 3 ,
|
||||
.Xr dwarf_add_AT_reference 3 ,
|
||||
.Xr dwarf_add_AT_signed_const 3 ,
|
||||
.Xr dwarf_add_AT_unsigned_const 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
117
contrib/elftoolchain/libdwarf/dwarf_add_AT_reference.3
Normal file
117
contrib/elftoolchain/libdwarf/dwarf_add_AT_reference.3
Normal file
@ -0,0 +1,117 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_reference.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_REFERENCE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_reference
|
||||
.Nd create and attach an attribute that references another DIE
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_P_Attribute"
|
||||
.Fo dwarf_add_AT_reference
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_P_Die ref_die"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_reference
|
||||
creates an attribute descriptor that references another debugging
|
||||
information entry in the same compilation unit.
|
||||
The attribute will be of DWARF form
|
||||
.Dv DW_FORM_ref4
|
||||
or
|
||||
.Dv DW_FORM_ref8
|
||||
depending on the target address size, and will contain the
|
||||
section-relative offset of the referenced debugging information entry
|
||||
as its value.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
should specify the attribute code of the created attribute descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ref_die
|
||||
should hold the debugging information entry descriptor that
|
||||
the attribute should refer to.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_reference
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_reference
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_reference
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar ref_die
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
the function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_dataref 3 ,
|
||||
.Xr dwarf_add_AT_ref_address 3 ,
|
||||
.Xr dwarf_add_AT_signed_const 3 ,
|
||||
.Xr dwarf_add_AT_unsigned_const 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
131
contrib/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
Normal file
131
contrib/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
Normal file
@ -0,0 +1,131 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_signed_const.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_SIGNED_CONST 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_signed_const ,
|
||||
.Nm dwarf_add_AT_unsigned_const
|
||||
.Nd create and attach constant class attributes
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_signed_const
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Signed value"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_unsigned_const
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Unsigned value"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions create attribute descriptors belonging to the
|
||||
.Sq constant
|
||||
class
|
||||
and attach them to the debugging information entry referenced by
|
||||
argument
|
||||
.Ar die .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
specifies the attribute code of the created attribute descriptor.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_AT_signed_const
|
||||
creates an attribute descriptor with the signed value specified in
|
||||
argument
|
||||
.Ar value .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_AT_unsigned_const
|
||||
creates an attribute descriptor with the unsigned value specified in
|
||||
argument
|
||||
.Ar value .
|
||||
.Pp
|
||||
The attribute created by these function will have one of the
|
||||
DWARF forms
|
||||
.Dv DW_FORM_data1 ,
|
||||
.Dv DW_FORM_data2 ,
|
||||
.Dv DW_FORM_data4
|
||||
or
|
||||
.Dv DW_FORM_data8 ,
|
||||
depending on the size of the value specified in argument
|
||||
.Ar value .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used by these functions to store error
|
||||
information in case of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions return the created attribute descriptor.
|
||||
In case of an error, these functions return
|
||||
.Dv DW_DLV_BADADDR
|
||||
and set the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar die
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during execution.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_const_value_signedint 3 ,
|
||||
.Xr dwarf_add_AT_const_value_unsignedint 3 ,
|
||||
.Xr dwarf_add_AT_dataref 3 ,
|
||||
.Xr dwarf_add_AT_ref_address 3 ,
|
||||
.Xr dwarf_add_AT_targ_address_b 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
114
contrib/elftoolchain/libdwarf/dwarf_add_AT_string.3
Normal file
114
contrib/elftoolchain/libdwarf/dwarf_add_AT_string.3
Normal file
@ -0,0 +1,114 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_string.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_STRING 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_string
|
||||
.Nd create and attach a string class attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_string
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "char *str"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_string
|
||||
creates an attribute descriptor belonging to the
|
||||
.Sq string
|
||||
class and attaches it to the debugging information entry referenced by
|
||||
argument
|
||||
.Ar die .
|
||||
The created attribute descriptor will have DWARF form
|
||||
.Dv DW_FORM_strp .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
should specify the attribute code for the created attribute
|
||||
descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar str
|
||||
should hold a pointer to a NUL-terminated string which will become the
|
||||
value of the created attribute descriptor.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_AT_string
|
||||
returns the created attribute descriptor.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_AT_string
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_AT_string
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar str
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
the function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_const_value_string 3 ,
|
||||
.Xr dwarf_add_AT_name 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
137
contrib/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
Normal file
137
contrib/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
Normal file
@ -0,0 +1,137 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_AT_targ_address.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_AT_TARG_ADDRESS 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_AT_targ_address ,
|
||||
.Nm dwarf_add_AT_targ_address_b
|
||||
.Nd create and attach address class attributes
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_targ_address
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Unsigned pc_value"
|
||||
.Fa "Dwarf_Signed sym_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft Dwarf_P_Attribute
|
||||
.Fo dwarf_add_AT_targ_address_b
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Unsigned pc_value"
|
||||
.Fa "Dwarf_Unsigned sym_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_AT_targ_address_b
|
||||
creates an attribute descriptor belonging to the
|
||||
.Sq address
|
||||
class and attaches it to the debugging information entry referenced by
|
||||
argument
|
||||
.Ar die .
|
||||
.Pp
|
||||
The created attribute descriptor will have DWARF form
|
||||
.Dv DW_FORM_addr .
|
||||
If flag
|
||||
.Dv DW_DLC_SIZE_64
|
||||
is set on the producer instance, the attribute value will be 8 bytes
|
||||
in size.
|
||||
Otherwise the attribute value will be 4 bytes in size.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should reference a debugging information entry allocated using
|
||||
.Xr dwarf_new_die 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
should specify the attribute code of the created attribute descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc_value
|
||||
should hold a relocatable address value which will become the value of
|
||||
the created attribute descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar sym_index
|
||||
should specify the ELF symbol index of the symbol to be used for
|
||||
relocating the address value.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_AT_targ_address
|
||||
is deprecated.
|
||||
It is similar to function
|
||||
.Fn dwarf_add_AT_targ_address_b
|
||||
except that it cannot handle all possible symbol index values.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions return the created attribute descriptor.
|
||||
In case of an error, these functions return
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar die
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during execution.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_const_value_unsignedint 3 ,
|
||||
.Xr dwarf_add_AT_dataref 3 ,
|
||||
.Xr dwarf_add_AT_ref_address 3 ,
|
||||
.Xr dwarf_add_AT_signed_const 3 ,
|
||||
.Xr dwarf_add_AT_unsigned_const 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
151
contrib/elftoolchain/libdwarf/dwarf_add_arange.3
Normal file
151
contrib/elftoolchain/libdwarf/dwarf_add_arange.3
Normal file
@ -0,0 +1,151 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_arange.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 18, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_ARANGE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_arange ,
|
||||
.Nm dwarf_add_arange_b
|
||||
.Nd add address range information to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_arange
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_Addr start"
|
||||
.Fa "Dwarf_Unsigned length"
|
||||
.Fa "Dwarf_Signed symbol_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_arange_b
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_Addr start"
|
||||
.Fa "Dwarf_Unsigned length"
|
||||
.Fa "Dwarf_Unsigned symbol_index"
|
||||
.Fa "Dwarf_Unsigned end_symbol_index"
|
||||
.Fa "Dwarf_Addr offset_from_end_symbol"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_arange_b
|
||||
adds an address range entry to a producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar start
|
||||
specifies the relocatable start address of the address range.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar length
|
||||
specifies the length of the address range.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar symbol_index
|
||||
specifies the ELF symbol index of the first symbol to be used for
|
||||
relocation.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar end_symbol_index
|
||||
specifies the ELF symbol index of the second symbol to be used for
|
||||
relocation.
|
||||
.Bl -bullet
|
||||
.It
|
||||
If argument
|
||||
.Ar end_symbol_index
|
||||
is not 0, the
|
||||
.Dv DW_DLC_SYMBOLIC_RELOCATIONS
|
||||
flag should have been set on the DWARF producer instance.
|
||||
The address value specified by argument
|
||||
.Ar start
|
||||
will be treated as an offset value from the first symbol,
|
||||
and the argument
|
||||
.Ar offset_from_end_symbol
|
||||
should hold an offset value from the second symbol.
|
||||
Application code can retrieve the relocation entries for the
|
||||
symbol pair by calling function
|
||||
.Xr dwarf_get_relocation_info 3 .
|
||||
The relocation entry for the first symbol will have type
|
||||
.Dv dwarf_drt_first_of_length_pair
|
||||
and the relocation entry for the second symbol will have type
|
||||
.Dv dwarf_drt_second_of_length_pair .
|
||||
.It
|
||||
If argument
|
||||
.Ar end_symbol_index
|
||||
is 0, argument
|
||||
.Ar offset_from_end_symbol
|
||||
will be ignored and only one symbol is used for relocation.
|
||||
.El
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_arange
|
||||
is deprecated.
|
||||
It is similar to function
|
||||
.Fn dwarf_add_arange_b
|
||||
except that it cannot handle all possible symbol index values
|
||||
and supports only one relocation symbol.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions return a non-zero value.
|
||||
In case of an error, these functions return 0 and set
|
||||
the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar dbg
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar end_symbol_index
|
||||
was non-zero, but the flag
|
||||
.Dv DW_DLC_SYMBOLIC_RELOCATIONS
|
||||
was not set on the producer instance.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_relocation_info 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
95
contrib/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
Normal file
95
contrib/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
Normal file
@ -0,0 +1,95 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_die_to_debug.3 2938 2013-04-27 05:09:17Z jkoshy $
|
||||
.\"
|
||||
.Dd August 21, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_DIE_TO_DEBUG 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_die_to_debug
|
||||
.Nd set the root debugging information entry
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_Unsigned
|
||||
.Fo dwarf_add_die_to_debug
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die first_die"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_die_to_debug
|
||||
sets the root debugging information entry of a DWARF producer
|
||||
instance.
|
||||
All debugging information entries linked to the root entry will also
|
||||
be added to the producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar first_die
|
||||
should hold the debugging information entry which will become
|
||||
the root DIE.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_die_to_debug
|
||||
returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_die_to_debug
|
||||
returns
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_die_to_debug
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar first_die
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_die_link 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
97
contrib/elftoolchain/libdwarf/dwarf_add_directory_decl.3
Normal file
97
contrib/elftoolchain/libdwarf/dwarf_add_directory_decl.3
Normal file
@ -0,0 +1,97 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_directory_decl.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 17, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_DIRECTORY_DECL 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_directory_decl
|
||||
.Nd add a directory name to a producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_directory_decl
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_directory_decl
|
||||
adds a source directory name to a producer instance and returns the
|
||||
index value generated for the directory name.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point a NUL-terminated string containing the name of
|
||||
the directory.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_directory_decl
|
||||
returns the index value generated for the directory.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_directory_decl
|
||||
returns
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_directory_decl
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_file_decl 3 ,
|
||||
.Xr dwarf_add_line_entry 3 ,
|
||||
.Xr dwarf_lne_end_sequence 3 ,
|
||||
.Xr dwarf_lne_set_address 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
111
contrib/elftoolchain/libdwarf/dwarf_add_expr_addr.3
Normal file
111
contrib/elftoolchain/libdwarf/dwarf_add_expr_addr.3
Normal file
@ -0,0 +1,111 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_expr_addr.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_EXPR_ADDR 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_expr_addr ,
|
||||
.Nm dwarf_add_expr_addr_b
|
||||
.Nd add a DW_OP_addr location expression
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_expr_addr
|
||||
.Fa "Dwarf_P_Expr expr"
|
||||
.Fa "Dwarf_Unsigned address"
|
||||
.Fa "Dwarf_Signed sym_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_expr_addr_b
|
||||
.Fa "Dwarf_P_Expr expr"
|
||||
.Fa "Dwarf_Unsigned address"
|
||||
.Fa "Dwarf_Unsigned sym_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_expr_addr_b
|
||||
adds a
|
||||
.Dv DW_OP_addr
|
||||
location expression to the location expression descriptor referenced
|
||||
by argument
|
||||
.Ar expr .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar expr
|
||||
should reference a location expression descriptor allocated using
|
||||
the function
|
||||
.Xr dwarf_new_expr 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar address
|
||||
specifies the operand, a relocatable address value.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar sym_index
|
||||
specifies the ELF symbol index of the symbol to be used for
|
||||
relocation.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_expr_addr
|
||||
is deprecated.
|
||||
It is similar to function
|
||||
.Fn dwarf_add_expr_addr_b
|
||||
except that it cannot handle all possible symbol index values.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions return the size in bytes of the location
|
||||
expression byte stream generated.
|
||||
In case of an error, these functions return
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and set the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar expr
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
the function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_location_expr 3 ,
|
||||
.Xr dwarf_add_expr_gen 3 ,
|
||||
.Xr dwarf_expr_current_offset 3 ,
|
||||
.Xr dwarf_expr_into_block 3 ,
|
||||
.Xr dwarf_new_expr 3
|
118
contrib/elftoolchain/libdwarf/dwarf_add_expr_gen.3
Normal file
118
contrib/elftoolchain/libdwarf/dwarf_add_expr_gen.3
Normal file
@ -0,0 +1,118 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_expr_gen.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_EXPR_GEN 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_expr_gen
|
||||
.Nd add an operator to a location expression descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_expr_gen
|
||||
.Fa "Dwarf_P_Expr expr"
|
||||
.Fa "Dwarf_Small opcode"
|
||||
.Fa "Dwarf_Unsigned val1"
|
||||
.Fa "Dwarf_Unsigned val2"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_expr_gen
|
||||
adds a location expression operator to the location expression
|
||||
descriptor referenced by argument
|
||||
.Ar expr .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar expr
|
||||
should reference a location expression descriptor allocated using
|
||||
the function
|
||||
.Xr dwarf_new_expr 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar opcode
|
||||
specifies the operation code of the location expression operator.
|
||||
Valid values for this argument are those denoted by the
|
||||
.Dv DW_OP_ Ns *
|
||||
constants defined in
|
||||
.In libdwarf.h .
|
||||
.Pp
|
||||
To generate a
|
||||
.Dv DW_OP_addr
|
||||
operation, application code should instead use
|
||||
.Xr dwarf_add_expr_addr_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar val1
|
||||
specifies the first operand of the location expression operator.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar val2
|
||||
specifies the second operand of the location expression operator.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_expr_gen
|
||||
returns the size in bytes of the location expression byte stream
|
||||
generated.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_expr_gen
|
||||
returns
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_expr_gen
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_LOC_EXPR_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar expr
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_LOC_EXPR_BAD
|
||||
The operation code specified in argument
|
||||
.Ar opcode
|
||||
was invalid.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
the function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_location_expr 3 ,
|
||||
.Xr dwarf_add_expr_addr 3 ,
|
||||
.Xr dwarf_add_expr_addr_b 3 ,
|
||||
.Xr dwarf_expr_current_offset 3 ,
|
||||
.Xr dwarf_expr_into_block 3 ,
|
||||
.Xr dwarf_new_expr 3
|
113
contrib/elftoolchain/libdwarf/dwarf_add_fde_inst.3
Normal file
113
contrib/elftoolchain/libdwarf/dwarf_add_fde_inst.3
Normal file
@ -0,0 +1,113 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_fde_inst.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 26, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_FDE_INST 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_fde_inst
|
||||
.Nd add a call frame instruction to a DWARF frame descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_P_Fde"
|
||||
.Fo dwarf_add_fde_inst
|
||||
.Fa "Dwarf_P_Fde fde"
|
||||
.Fa "Dwarf_Small op"
|
||||
.Fa "Dwarf_Unsigned val1"
|
||||
.Fa "Dwarf_Unsigned val2"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_fde_inst
|
||||
adds a call frame instruction to the DWARF frame descriptor
|
||||
referenced by argument
|
||||
.Ar fde .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a frame descriptor allocated using
|
||||
.Xr dwarf_new_fde 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar op
|
||||
specifies the operator for the frame instruction.
|
||||
The DWARF standard defines the set of legal values for this argument.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar val1
|
||||
specifies the first operand of the frame instruction.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar val2
|
||||
specifies the second operand of the frame instruction.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_fde_inst
|
||||
returns the frame descriptor given in argument
|
||||
.Ar fde .
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_fde_inst
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_fde_inst
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_FRAME_INSTR_EXEC_ERROR"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar fde
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_FRAME_INSTR_EXEC_ERROR
|
||||
The frame instruction operator specified in argument
|
||||
.Ar op
|
||||
was invalid.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_frame_fde 3 ,
|
||||
.Xr dwarf_add_frame_fde_b 3 ,
|
||||
.Xr dwarf_add_frame_cie 3 ,
|
||||
.Xr dwarf_fde_cfa_offset 3 ,
|
||||
.Xr dwarf_new_fde 3
|
||||
.Rs
|
||||
.%T "The DWARF Debugging Information Format"
|
||||
.%V "Version 4"
|
||||
.%O "http://www.dwarfstd.org/"
|
||||
.Re
|
122
contrib/elftoolchain/libdwarf/dwarf_add_file_decl.3
Normal file
122
contrib/elftoolchain/libdwarf/dwarf_add_file_decl.3
Normal file
@ -0,0 +1,122 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_file_decl.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 17, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_FILE_DECL 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_file_decl
|
||||
.Nd add a source file entry to a producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_file_decl
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Unsigned dirndx"
|
||||
.Fa "Dwarf_Unsigned mtime"
|
||||
.Fa "Dwarf_Unsigned size"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_file_decl
|
||||
adds a source file entry to a producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string containing the name of
|
||||
the source file.
|
||||
.Pp
|
||||
If the file name in argument
|
||||
.Ar name
|
||||
is not a fully qualified pathname, argument
|
||||
.Ar dirndx
|
||||
should specify the index of the directory where the source file resides.
|
||||
Otherwise, argument
|
||||
.Ar dirndx
|
||||
should be 0.
|
||||
Valid directory indices are those returned by the function
|
||||
.Xr dwarf_add_directory_decl 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar mtime
|
||||
specifies the time when the file was last modified.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar size
|
||||
specifies the size of the file in bytes.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_file_decl
|
||||
returns the index value generated for the source file.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_file_decl
|
||||
returns
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_file_decl
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
The length of the NUL-teminated string pointed to by argument
|
||||
.Ar name
|
||||
was 0.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_directory_decl 3 ,
|
||||
.Xr dwarf_add_line_entry 3 ,
|
||||
.Xr dwarf_lne_end_sequence 3 ,
|
||||
.Xr dwarf_lne_set_address 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
124
contrib/elftoolchain/libdwarf/dwarf_add_frame_cie.3
Normal file
124
contrib/elftoolchain/libdwarf/dwarf_add_frame_cie.3
Normal file
@ -0,0 +1,124 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_frame_cie.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 26, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_FRAME_CIE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_frame_cie
|
||||
.Nd add a call frame common information entry to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_frame_cie
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "char *augmenter"
|
||||
.Fa "Dwarf_Small caf"
|
||||
.Fa "Dwarf_Small daf"
|
||||
.Fa "Dwarf_Small ra"
|
||||
.Fa "Dwarf_Ptr initinst"
|
||||
.Fa "Dwarf_Unsigned initlen"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_frame_cie
|
||||
adds a DWARF call frame common information entry (CIE) to a producer
|
||||
instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar augmenter
|
||||
should point to a NUL-terminated augmentation string for the common
|
||||
information entry.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar caf
|
||||
specifies the code alignment factor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar daf
|
||||
specifies the data alignment factor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ra
|
||||
specifies the column number used for the return address register.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar initinst
|
||||
should point to a byte stream containing the initial instructions
|
||||
for the common information entry.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar initlen
|
||||
should hold the length in bytes of the byte stream pointed to by
|
||||
argument
|
||||
.Ar initinst .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_frame_cie
|
||||
returns the index value of the created common information entry.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_frame_cie
|
||||
returns
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_frame_cie
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar dbg
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_fde_inst 3 ,
|
||||
.Xr dwarf_add_frame_fde 3 ,
|
||||
.Xr dwarf_add_frame_fde_b 3 ,
|
||||
.Xr dwarf_fde_cfa_offset 3 ,
|
||||
.Xr dwarf_new_fde 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
201
contrib/elftoolchain/libdwarf/dwarf_add_frame_fde.3
Normal file
201
contrib/elftoolchain/libdwarf/dwarf_add_frame_fde.3
Normal file
@ -0,0 +1,201 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_frame_fde.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 26, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_FRAME_FDE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_frame_fde
|
||||
.Nd add a call frame descriptor to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_frame_fde
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Fde fde"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Unsigned cie"
|
||||
.Fa "Dwarf_Addr virt_addr"
|
||||
.Fa "Dwarf_Unsigned code_len"
|
||||
.Fa "Dwarf_Unsigned symbol_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_frame_fde_b
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Fde fde"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_Unsigned cie"
|
||||
.Fa "Dwarf_Addr virt_addr"
|
||||
.Fa "Dwarf_Unsigned code_len"
|
||||
.Fa "Dwarf_Unsigned symbol_index"
|
||||
.Fa "Dwarf_Unsigned end_symbol_index"
|
||||
.Fa "Dwarf_Addr offset_from_end_sym"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_frame_fde_b
|
||||
adds the call frame descriptor referenced by argument
|
||||
.Ar fde
|
||||
to a producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a frame descriptor allocated using
|
||||
.Xr dwarf_new_fde 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
is ignored by this implementation of the
|
||||
.Lb libdwarf .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar cie
|
||||
specifies the index of call frame common information entry for
|
||||
the frame descriptor.
|
||||
Valid indices are those returned by the function
|
||||
.Xr dwarf_add_frame_cie 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar symbol_index
|
||||
specifies the ELF symbol index of the first symbol to be used for
|
||||
relocation.
|
||||
.Pp
|
||||
The meaning of the arguments
|
||||
.Ar virt_addr ,
|
||||
.Ar code_len
|
||||
and
|
||||
.Ar offset_from_end_sym
|
||||
depend on the value of argument
|
||||
.Ar end_symbol_index :
|
||||
.Bl -bullet
|
||||
.It
|
||||
If the argument
|
||||
.Ar end_symbol_index
|
||||
is zero, the argument
|
||||
.Ar virt_addr
|
||||
specifies the relocatable address of the start of the function
|
||||
associated with the frame descriptor, the argument
|
||||
.Ar code_len
|
||||
specifies the size in bytes of the machine instructions for this
|
||||
function, the argument
|
||||
.Ar symbol_index
|
||||
specifies the ELF symbol to be used for relocating the address in
|
||||
argument
|
||||
.Ar virt_addr ,
|
||||
and the argument
|
||||
.Ar offset_from_end_symbol
|
||||
is ignored.
|
||||
.It
|
||||
If the argument
|
||||
.Ar end_symbol_index
|
||||
is non-zero, it specifies the ELF symbol index of the second symbol to
|
||||
be used for relocation.
|
||||
In this case, the argument
|
||||
.Ar virt_addr
|
||||
specifies an offset from the relocatable symbol specified by argument
|
||||
.Ar symbol_index ,
|
||||
the argument
|
||||
.Ar offset_from_end_symbol
|
||||
should specify an offset from the symbol named by the argument
|
||||
.Ar end_symbol_index ,
|
||||
and the argument
|
||||
.Ar code_len
|
||||
will be ignored.
|
||||
The
|
||||
.Dv DW_DLC_SYMBOLIC_RELOCATIONS
|
||||
flag should also have been set on the DWARF producer instance.
|
||||
.Pp
|
||||
Application code can retrieve the relocation entries for the symbol
|
||||
pair by calling function
|
||||
.Xr dwarf_get_relocation_info 3 .
|
||||
The relocation entry for the first symbol will have type
|
||||
.Dv dwarf_drt_first_of_length_pair
|
||||
and the relocation entry for the second symbol will have type
|
||||
.Dv dwarf_drt_second_of_length_pair .
|
||||
.El
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_add_frame_fde
|
||||
is similar to function
|
||||
.Fn dwarf_add_frame_fde_b
|
||||
except that it supports only one relocation symbol.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions return the index value for
|
||||
the added frame descriptor.
|
||||
In case of an error, these functions return
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and set the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar fde
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
The frame descriptor referenced by argument
|
||||
.Ar fde
|
||||
did not belong to the producer instance referenced by argument
|
||||
.Ar dbg .
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
The common information entry index specified by argument
|
||||
.Ar cie
|
||||
was invalid.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar end_symbol_index
|
||||
was non-zero, but the flag
|
||||
.Dv DW_DLC_SYMBOLIC_RELOCATIONS
|
||||
was not set on the producer instance.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_fde_inst 3 ,
|
||||
.Xr dwarf_add_frame_cie 3 ,
|
||||
.Xr dwarf_fde_cfa_offset 3 ,
|
||||
.Xr dwarf_get_relocation_info 3 ,
|
||||
.Xr dwarf_new_fde 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
103
contrib/elftoolchain/libdwarf/dwarf_add_funcname.3
Normal file
103
contrib/elftoolchain/libdwarf/dwarf_add_funcname.3
Normal file
@ -0,0 +1,103 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_funcname.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 24, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_FUNCNAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_funcname
|
||||
.Nd add information about a static function to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_funcname
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_funcname
|
||||
adds information about a static function to a DWARF producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
specifies the debugging information entry associated with the static
|
||||
function.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string containing the name
|
||||
of the static function.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_funcname
|
||||
returns a non-zero value.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_funcname
|
||||
returns 0 and sets
|
||||
the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_funcname
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_pubname 3 ,
|
||||
.Xr dwarf_add_typename 3 ,
|
||||
.Xr dwarf_add_varname 3 ,
|
||||
.Xr dwarf_add_weakname 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
163
contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
Normal file
163
contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
Normal file
@ -0,0 +1,163 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_line_entry.3 2953 2013-06-30 20:21:38Z kaiwang27 $
|
||||
.\"
|
||||
.Dd June 30, 2013
|
||||
.Os
|
||||
.Dt DWARF_ADD_LINE_ENTRY 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_line_entry
|
||||
.Nd add a line number information entry to a producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_line_entry
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_Unsigned filendx"
|
||||
.Fa "Dwarf_Addr off"
|
||||
.Fa "Dwarf_Unsigned lineno"
|
||||
.Fa "Dwarf_Signed column"
|
||||
.Fa "Dwarf_Bool is_stmt"
|
||||
.Fa "Dwarf_Bool basic_block"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_line_entry
|
||||
adds a line number information entry to a DWARF producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar filendx
|
||||
specifies the index of the source file that contains the source line
|
||||
in question.
|
||||
Valid source file indices are those returned by the function
|
||||
.Xr dwarf_add_file_decl 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar off
|
||||
specifies a relocatable program address. The ELF symbol to be used
|
||||
for relocation is set by a prior call to the function
|
||||
.Xr dwarf_lne_set_address 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar lineno
|
||||
specifies the line number of the source line.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar column
|
||||
specifies the column number within the source line.
|
||||
.Pp
|
||||
If the argument
|
||||
.Ar is_stmt
|
||||
is set to true, it indicates that the instruction at the address
|
||||
specified by argument
|
||||
.Ar off
|
||||
is a recommended breakpoint location, i.e., the first instruction in
|
||||
the instruction sequence generated by the source line.
|
||||
.Pp
|
||||
If the argument
|
||||
.Ar basic_block
|
||||
is set to true, it indicates that the instruction at the address
|
||||
specified by argument
|
||||
.Ar off
|
||||
is the first instruction of a basic block.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_line_entry
|
||||
returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_line_entry
|
||||
returns
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_line_entry
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar dbg
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
The function
|
||||
.Xr dwarf_lne_set_address 3
|
||||
was not called before calling this function.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh EXAMPLE
|
||||
To add line number information to the producer instance, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_P_Debug dbg;
|
||||
Dwarf_Error de;
|
||||
Dwarf_Unsigned dir, filendx;
|
||||
|
||||
/* ... assume dbg refers to a DWARF producer instance ... */
|
||||
|
||||
dir = dwarf_add_directory_decl(dbg, "/home/foo", &de);
|
||||
if (dir == DW_DLV_NOCOUNT)
|
||||
errx(EXIT_FAILURE, "dwarf_add_directory_decl failed: %s",
|
||||
dwarf_errmsg(-1));
|
||||
|
||||
filendx = dwarf_add_file_decl(dbg, "bar.c", dir, 0, 1234, &de);
|
||||
if (filendx == DW_DLV_NOCOUNT)
|
||||
errx(EXIT_FAILURE, "dwarf_add_file_decl failed: %s",
|
||||
dwarf_errmsg(-1));
|
||||
|
||||
if (dwarf_lne_set_address(dbg, 0x4012b0, 12, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_lne_set_address failed: %s",
|
||||
dwarf_errmsg(-1));
|
||||
|
||||
if (dwarf_add_line_entry(dbg, filendx, 10, 258, 0, 1, 1, &de) !=
|
||||
DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_add_line_entry failed: %s",
|
||||
dwarf_errmsg(-1));
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_directory_decl 3 ,
|
||||
.Xr dwarf_add_file_decl 3 ,
|
||||
.Xr dwarf_lne_end_sequence 3 ,
|
||||
.Xr dwarf_lne_set_address 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
103
contrib/elftoolchain/libdwarf/dwarf_add_pubname.3
Normal file
103
contrib/elftoolchain/libdwarf/dwarf_add_pubname.3
Normal file
@ -0,0 +1,103 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_pubname.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 24, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_PUBNAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_pubname
|
||||
.Nd add information about a global object to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_pubname
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_pubname
|
||||
adds information about a global object to a DWARF producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
specifies the debugging information entry associated with the global
|
||||
object.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string containing the name
|
||||
of the global object.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_pubname
|
||||
returns a non-zero value.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_pubname
|
||||
returns 0 and sets
|
||||
the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_pubname
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_funcname 3 ,
|
||||
.Xr dwarf_add_typename 3 ,
|
||||
.Xr dwarf_add_varname 3 ,
|
||||
.Xr dwarf_add_weakname 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
103
contrib/elftoolchain/libdwarf/dwarf_add_typename.3
Normal file
103
contrib/elftoolchain/libdwarf/dwarf_add_typename.3
Normal file
@ -0,0 +1,103 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_typename.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 24, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_TYPENAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_typename
|
||||
.Nd add information about a user-defined type to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_typename
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_typename
|
||||
adds information about a user-defined type to a DWARF producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
specifies the debugging information entry associated with the
|
||||
user-defined type.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string containing the name
|
||||
of the user-defined type.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_typename
|
||||
returns a non-zero value.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_typename
|
||||
returns 0 and sets
|
||||
the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_typename
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_funcname 3 ,
|
||||
.Xr dwarf_add_pubname 3 ,
|
||||
.Xr dwarf_add_varname 3 ,
|
||||
.Xr dwarf_add_weakname 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
103
contrib/elftoolchain/libdwarf/dwarf_add_varname.3
Normal file
103
contrib/elftoolchain/libdwarf/dwarf_add_varname.3
Normal file
@ -0,0 +1,103 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_varname.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 24, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_VARNAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_varname
|
||||
.Nd add information about a static variable to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_varname
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_varname
|
||||
adds information about a static variable to a DWARF producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
specifies the debugging information entry associated with the static
|
||||
variable.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string containing the name
|
||||
of the static variable.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_varname
|
||||
returns a non-zero value.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_varname
|
||||
returns 0 and sets
|
||||
the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_varname
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_funcname 3 ,
|
||||
.Xr dwarf_add_pubname 3 ,
|
||||
.Xr dwarf_add_typename 3 ,
|
||||
.Xr dwarf_add_weakname 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
103
contrib/elftoolchain/libdwarf/dwarf_add_weakname.3
Normal file
103
contrib/elftoolchain/libdwarf/dwarf_add_weakname.3
Normal file
@ -0,0 +1,103 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_add_weakname.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd September 24, 2011
|
||||
.Os
|
||||
.Dt DWARF_ADD_WEAKNAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_add_weakname
|
||||
.Nd add information about a weak object to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_add_weakname
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "char *name"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_add_weakname
|
||||
adds information about a weak object to a DWARF producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
specifies the debugging information entry associated with the weak
|
||||
object.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string containing the name
|
||||
of the weak object.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_add_weakname
|
||||
returns a non-zero value.
|
||||
In case of an error, function
|
||||
.Fn dwarf_add_weakname
|
||||
returns 0 and sets
|
||||
the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_add_weakname
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_funcname 3 ,
|
||||
.Xr dwarf_add_pubname 3 ,
|
||||
.Xr dwarf_add_typename 3 ,
|
||||
.Xr dwarf_add_varname 3 ,
|
||||
.Xr dwarf_new_die 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3
|
171
contrib/elftoolchain/libdwarf/dwarf_arange.c
Normal file
171
contrib/elftoolchain/libdwarf/dwarf_arange.c
Normal file
@ -0,0 +1,171 @@
|
||||
/*-
|
||||
* Copyright (c) 2009,2011 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_arange.c 2072 2011-10-27 03:26:49Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_get_aranges(Dwarf_Debug dbg, Dwarf_Arange **arlist,
|
||||
Dwarf_Signed *ret_arange_cnt, Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (dbg == NULL || arlist == NULL || ret_arange_cnt == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (dbg->dbg_arange_cnt == 0) {
|
||||
if (_dwarf_arange_init(dbg, error) != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
if (dbg->dbg_arange_cnt == 0) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
assert(dbg->dbg_arange_array != NULL);
|
||||
|
||||
*arlist = dbg->dbg_arange_array;
|
||||
*ret_arange_cnt = dbg->dbg_arange_cnt;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_arange(Dwarf_Arange *arlist, Dwarf_Unsigned arange_cnt,
|
||||
Dwarf_Addr addr, Dwarf_Arange *ret_arange, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Arange ar;
|
||||
Dwarf_Debug dbg;
|
||||
int i;
|
||||
|
||||
if (arlist == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
dbg = (*arlist)->ar_as->as_cu->cu_dbg;
|
||||
|
||||
if (ret_arange == NULL || arange_cnt == 0) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
for (i = 0; (Dwarf_Unsigned)i < arange_cnt; i++) {
|
||||
ar = arlist[i];
|
||||
if (addr >= ar->ar_address && addr < ar->ar_address +
|
||||
ar->ar_range) {
|
||||
*ret_arange = ar;
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
}
|
||||
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_cu_die_offset(Dwarf_Arange ar, Dwarf_Off *ret_offset,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_CU cu;
|
||||
Dwarf_ArangeSet as;
|
||||
|
||||
if (ar == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
as = ar->ar_as;
|
||||
assert(as != NULL);
|
||||
cu = as->as_cu;
|
||||
assert(cu != NULL);
|
||||
|
||||
if (ret_offset == NULL) {
|
||||
DWARF_SET_ERROR(cu->cu_dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*ret_offset = cu->cu_1st_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_arange_cu_header_offset(Dwarf_Arange ar, Dwarf_Off *ret_offset,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_ArangeSet as;
|
||||
|
||||
if (ar == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
as = ar->ar_as;
|
||||
assert(as != NULL);
|
||||
|
||||
if (ret_offset == NULL) {
|
||||
DWARF_SET_ERROR(as->as_cu->cu_dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*ret_offset = as->as_cu_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_arange_info(Dwarf_Arange ar, Dwarf_Addr *start,
|
||||
Dwarf_Unsigned *length, Dwarf_Off *cu_die_offset, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_CU cu;
|
||||
Dwarf_ArangeSet as;
|
||||
|
||||
if (ar == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
as = ar->ar_as;
|
||||
assert(as != NULL);
|
||||
cu = as->as_cu;
|
||||
assert(cu != NULL);
|
||||
|
||||
if (start == NULL || length == NULL ||
|
||||
cu_die_offset == NULL) {
|
||||
DWARF_SET_ERROR(cu->cu_dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*start = ar->ar_address;
|
||||
*length = ar->ar_range;
|
||||
*cu_die_offset = cu->cu_1st_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
119
contrib/elftoolchain/libdwarf/dwarf_attr.3
Normal file
119
contrib/elftoolchain/libdwarf/dwarf_attr.3
Normal file
@ -0,0 +1,119 @@
|
||||
.\" Copyright (c) 2010 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_attr.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd April 8, 2010
|
||||
.Os
|
||||
.Dt DWARF_ATTR 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_attr
|
||||
.Nd retrieve an attribute descriptor associated with a DWARF debugging information entry
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_attr
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Attribute *atp"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_attr
|
||||
retrieves the attribute descriptor for an attribute associated
|
||||
with the DWARF debugging information entry descriptor in
|
||||
argument
|
||||
.Ar die .
|
||||
.Pp
|
||||
DWARF attribute descriptors are represented by value of the opaque
|
||||
type
|
||||
.Vt Dwarf_Attribute ,
|
||||
see
|
||||
.Xr dwarf 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
names the desired DWARF attribute.
|
||||
Legal values for argument
|
||||
.Ar attr
|
||||
are those denoted by the
|
||||
.Dv DW_AT_*
|
||||
constants in the DWARF specification.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar atp
|
||||
points to a location into which the returned attribute descriptor
|
||||
will be written.
|
||||
The returned descriptor may then be passed to the form query functions in the
|
||||
.Xr dwarf 3
|
||||
API set to access the data associated with the attribute.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is non-NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_attr
|
||||
returns
|
||||
.Dv DW_DLV_OK on success.
|
||||
.Pp
|
||||
If the debugging information entry descriptor denoted by argument
|
||||
.Ar die
|
||||
does not contain the named attribute, the function returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
and sets argument
|
||||
.Ar err .
|
||||
For other errors, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_attr
|
||||
can fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar die
|
||||
or
|
||||
.Ar atp
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
Argument
|
||||
.Ar die
|
||||
had no attribute corresponding to the value
|
||||
in argument
|
||||
.Ar attr .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attrlist 3 ,
|
||||
.Xr dwarf_hasattr 3 ,
|
||||
.Xr dwarf_hasform 3 ,
|
||||
.Xr dwarf_whatattr 3 ,
|
||||
.Xr dwarf_whatform 3
|
275
contrib/elftoolchain/libdwarf/dwarf_attr.c
Normal file
275
contrib/elftoolchain/libdwarf/dwarf_attr.c
Normal file
@ -0,0 +1,275 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* Copyright (c) 2009 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_attr.c 2072 2011-10-27 03:26:49Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_attr(Dwarf_Die die, Dwarf_Half attr, Dwarf_Attribute *atp,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Attribute at;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || atp == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, attr)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*atp = at;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_attrlist(Dwarf_Die die, Dwarf_Attribute **attrbuf,
|
||||
Dwarf_Signed *attrcount, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
int i;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || attrbuf == NULL || attrcount == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (die->die_ab->ab_atnum == 0) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*attrcount = die->die_ab->ab_atnum;
|
||||
|
||||
if (die->die_attrarray != NULL) {
|
||||
*attrbuf = die->die_attrarray;
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
if ((die->die_attrarray = malloc(*attrcount * sizeof(Dwarf_Attribute)))
|
||||
== NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
for (i = 0, at = STAILQ_FIRST(&die->die_attr);
|
||||
i < *attrcount && at != NULL; i++, at = STAILQ_NEXT(at, at_next))
|
||||
die->die_attrarray[i] = at;
|
||||
|
||||
*attrbuf = die->die_attrarray;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_hasattr(Dwarf_Die die, Dwarf_Half attr, Dwarf_Bool *ret_bool,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_bool == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*ret_bool = (_dwarf_attr_find(die, attr) != NULL);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_lowpc(Dwarf_Die die, Dwarf_Addr *ret_lowpc, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_lowpc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_low_pc)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_lowpc = at->u[0].u64;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_highpc(Dwarf_Die die, Dwarf_Addr *ret_highpc, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_highpc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_high_pc)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_highpc = at->u[0].u64;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_bytesize(Dwarf_Die die, Dwarf_Unsigned *ret_size, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_size == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_byte_size)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_size = at->u[0].u64;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_bitsize(Dwarf_Die die, Dwarf_Unsigned *ret_size, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_size == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_bit_size)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_size = at->u[0].u64;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_bitoffset(Dwarf_Die die, Dwarf_Unsigned *ret_size, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_size == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_bit_offset)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_size = at->u[0].u64;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_srclang(Dwarf_Die die, Dwarf_Unsigned *ret_lang, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_lang == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_language)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_lang = at->u[0].u64;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_arrayorder(Dwarf_Die die, Dwarf_Unsigned *ret_order, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_order == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_ordering)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_order = at->u[0].u64;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
146
contrib/elftoolchain/libdwarf/dwarf_attrlist.3
Normal file
146
contrib/elftoolchain/libdwarf/dwarf_attrlist.3
Normal file
@ -0,0 +1,146 @@
|
||||
.\" Copyright (c) 2010 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_attrlist.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_ATTRLIST 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_attrlist
|
||||
.Nd retrieve DWARF attribute descriptors
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_attrlist
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Attribute **attrbuf"
|
||||
.Fa "Dwarf_Signed *attrcount"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_attrlist
|
||||
retrieves the DWARF attribute descriptors associated with a
|
||||
debugging information entry descriptor in argument
|
||||
.Ar die .
|
||||
The descriptors are returned as an array of values of the opaque type
|
||||
.Vt Dwarf_Attribute .
|
||||
The data associated with each returned attribute descriptor may be
|
||||
queried using the form query functions in the
|
||||
.Xr dwarf 3
|
||||
API set.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attrbuf
|
||||
points to a location that will hold a pointer to the returned
|
||||
array of DWARF attribute descriptors.
|
||||
Argument
|
||||
.Ar attrcount
|
||||
points to a location that will hold the number of descriptors in
|
||||
the returned array.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is non-NULL, it is used to return an error descriptor in case of an
|
||||
error.
|
||||
.Ss Memory Management
|
||||
In the current implementation, the memory allocated for each DWARF
|
||||
attribute descriptor and for the returned array of descriptors is
|
||||
managed by the library and the application does not need to explicitly
|
||||
free the returned pointers.
|
||||
However, for compatibility with other implementations of the
|
||||
.Xr dwarf 3
|
||||
API, the application is permitted to pass the pointers returned by to
|
||||
the
|
||||
.Fn dwarf_dealloc
|
||||
function.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_attrlist
|
||||
returns
|
||||
.Dv DW_DLV_OK on success.
|
||||
.Pp
|
||||
If the debugging information entry descriptor denoted by argument
|
||||
.Ar die
|
||||
does not contain any attribute, the function returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
and sets argument
|
||||
.Ar err .
|
||||
For other errors, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh EXAMPLES
|
||||
To retrieve the attribute list for a DWARF debugging information
|
||||
entry use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Die dw_die;
|
||||
Dwarf_Error dw_e;
|
||||
Dwarf_Unsigned dw_count;
|
||||
Dwarf_Attribute *dw_attributes;
|
||||
int error, i;
|
||||
|
||||
\&... variable dw_die contains a reference to the DIE of interest ...
|
||||
|
||||
/* Retrieve the attribute list from the DIE. */
|
||||
if ((error = dwarf_attrlist(dw_die, &dw_attributes, &dw_count,
|
||||
&dw_e)) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_attrlist: %s", dwarf_errmsg(dw_e));
|
||||
|
||||
/* Process the attribute list. */
|
||||
for (i = 0; i < dw_count; ++i) {
|
||||
/* Use the returned pointers in dw_attributes[i] here. */
|
||||
}
|
||||
.Ed
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_diename
|
||||
can fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Arguments
|
||||
.Ar die ,
|
||||
.Ar attrbuf ,
|
||||
or
|
||||
.Ar attrcount
|
||||
were NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
Argument
|
||||
.Ar die
|
||||
had no attributes.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_dealloc 3 ,
|
||||
.Xr dwarf_hasattr 3 ,
|
||||
.Xr dwarf_hasform 3 ,
|
||||
.Xr dwarf_whatattr 3 ,
|
||||
.Xr dwarf_whatform 3
|
210
contrib/elftoolchain/libdwarf/dwarf_attrval.c
Normal file
210
contrib/elftoolchain/libdwarf/dwarf_attrval.c
Normal file
@ -0,0 +1,210 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_attrval.c 2072 2011-10-27 03:26:49Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_attrval_flag(Dwarf_Die die, Dwarf_Half attr, Dwarf_Bool *valp, Dwarf_Error *err)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || valp == NULL) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*valp = 0;
|
||||
|
||||
if ((at = _dwarf_attr_find(die, attr)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_flag:
|
||||
*valp = (Dwarf_Bool) (!!at->u[0].u64);
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_attrval_string(Dwarf_Die die, Dwarf_Half attr, const char **strp, Dwarf_Error *err)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || strp == NULL) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*strp = NULL;
|
||||
|
||||
if ((at = _dwarf_attr_find(die, attr)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_strp:
|
||||
*strp = at->u[1].s;
|
||||
break;
|
||||
case DW_FORM_string:
|
||||
*strp = at->u[0].s;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_attrval_signed(Dwarf_Die die, Dwarf_Half attr, Dwarf_Signed *valp, Dwarf_Error *err)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || valp == NULL) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*valp = 0;
|
||||
|
||||
if ((at = _dwarf_attr_find(die, attr)) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_data1:
|
||||
*valp = (int8_t) at->u[0].s64;
|
||||
break;
|
||||
case DW_FORM_data2:
|
||||
*valp = (int16_t) at->u[0].s64;
|
||||
break;
|
||||
case DW_FORM_data4:
|
||||
*valp = (int32_t) at->u[0].s64;
|
||||
case DW_FORM_data8:
|
||||
case DW_FORM_sdata:
|
||||
*valp = at->u[0].s64;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_attrval_unsigned(Dwarf_Die die, Dwarf_Half attr, Dwarf_Unsigned *valp, Dwarf_Error *err)
|
||||
{
|
||||
Dwarf_Attribute at;
|
||||
Dwarf_Die die1;
|
||||
Dwarf_Unsigned val;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || valp == NULL) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*valp = 0;
|
||||
|
||||
if ((at = _dwarf_attr_find(die, attr)) == NULL && attr != DW_AT_type) {
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
die1 = NULL;
|
||||
if (at == NULL &&
|
||||
(at = _dwarf_attr_find(die, DW_AT_abstract_origin)) != NULL) {
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_ref1:
|
||||
case DW_FORM_ref2:
|
||||
case DW_FORM_ref4:
|
||||
case DW_FORM_ref8:
|
||||
case DW_FORM_ref_udata:
|
||||
val = at->u[0].u64;
|
||||
if ((die1 = _dwarf_die_find(die, val)) == NULL ||
|
||||
(at = _dwarf_attr_find(die1, attr)) == NULL) {
|
||||
if (die1 != NULL)
|
||||
dwarf_dealloc(dbg, die1, DW_DLA_DIE);
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_addr:
|
||||
case DW_FORM_data1:
|
||||
case DW_FORM_data2:
|
||||
case DW_FORM_data4:
|
||||
case DW_FORM_data8:
|
||||
case DW_FORM_udata:
|
||||
case DW_FORM_ref1:
|
||||
case DW_FORM_ref2:
|
||||
case DW_FORM_ref4:
|
||||
case DW_FORM_ref8:
|
||||
case DW_FORM_ref_udata:
|
||||
*valp = at->u[0].u64;
|
||||
break;
|
||||
default:
|
||||
if (die1 != NULL)
|
||||
dwarf_dealloc(dbg, die1, DW_DLA_DIE);
|
||||
DWARF_SET_ERROR(dbg, err, DW_DLE_ATTR_FORM_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (die1 != NULL)
|
||||
dwarf_dealloc(dbg, die1, DW_DLA_DIE);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
205
contrib/elftoolchain/libdwarf/dwarf_attrval_signed.3
Normal file
205
contrib/elftoolchain/libdwarf/dwarf_attrval_signed.3
Normal file
@ -0,0 +1,205 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_attrval_signed.3 2072 2011-10-27 03:26:49Z jkoshy $
|
||||
.\"
|
||||
.Dd January 29, 2011
|
||||
.Os
|
||||
.Dt DWARF_ATTRVAL_SIGNED 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_attrval_flag ,
|
||||
.Nm dwarf_attrval_signed ,
|
||||
.Nm dwarf_attrval_string ,
|
||||
.Nm dwarf_attrval_unsigned
|
||||
.Nd retrieve the value of an attribute within a DWARF debugging information entry
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_attrval_flag
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Bool *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_attrval_signed
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Signed *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_attrval_string
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "const char **ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_attrval_unsigned
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Half attr"
|
||||
.Fa "Dwarf_Unsigned *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions search the debugging information entry referenced
|
||||
by argument
|
||||
.Ar die
|
||||
for the attribute named by argument
|
||||
.Ar attr .
|
||||
If the named attribute is found, the functions set the location
|
||||
pointed to by argument
|
||||
.Ar ret
|
||||
to the value of the attribute.
|
||||
The argument
|
||||
.Ar err ,
|
||||
if non NULL,
|
||||
will be used to return an error descriptor in case of an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_attrval_flag
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to 1 if the attribute named by argument
|
||||
.Ar attr
|
||||
has a non-zero value, or to 0 otherwise.
|
||||
The form of the attribute named by argument
|
||||
.Ar attr
|
||||
must be
|
||||
.Dv DW_FORM_flag .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_attrval_signed
|
||||
stores the value for the attribute named by argument
|
||||
.Ar attr ,
|
||||
into the location pointed to by argument
|
||||
.Ar ret .
|
||||
The attribute's value is treated as a signed integral quantity and is
|
||||
sign-extended as needed.
|
||||
The attribute named by the argument
|
||||
.Ar attr
|
||||
must belong to the
|
||||
.Dv CONSTANT
|
||||
class and must have one of the following forms:
|
||||
.Dv DW_FORM_data1 ,
|
||||
.Dv DW_FORM_data2 ,
|
||||
.Dv DW_FORM_data4 ,
|
||||
.Dv DW_FORM_data8
|
||||
or
|
||||
.Dv DW_FORM_sdata .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_attrval_string
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to a pointer to a NUL-terminated string that is the value of the
|
||||
attribute named by argument
|
||||
.Ar attr .
|
||||
The form of the attribute must be one of
|
||||
.Dv DW_FORM_string
|
||||
or
|
||||
.Dv DW_FORM_strp .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_attrval_unsigned
|
||||
stores the value for the attribute named by argument
|
||||
.Ar attr
|
||||
into the location pointed to by argument
|
||||
.Ar ret .
|
||||
The attribute's value is treated as an unsigned integral quantity, and
|
||||
is zero-extended as needed.
|
||||
The named attribute must belong to one of the
|
||||
.Dv CONSTANT ,
|
||||
.Dv ADDRESS
|
||||
or
|
||||
.Dv REFERENCE
|
||||
classes and must have one of the following forms:
|
||||
.Dv DW_FORM_addr ,
|
||||
.Dv DW_FORM_data1 ,
|
||||
.Dv DW_FORM_data2 ,
|
||||
.Dv DW_FORM_data4 ,
|
||||
.Dv DW_FORM_data8 ,
|
||||
.Dv DW_FORM_udata ,
|
||||
.Dv DW_FORM_ref1 ,
|
||||
.Dv DW_FORM_ref2 ,
|
||||
.Dv DW_FORM_ref4 ,
|
||||
.Dv DW_FORM_ref8 ,
|
||||
or
|
||||
.Dv DW_FORM_ref_udata .
|
||||
.Pp
|
||||
If the attribute named by argument
|
||||
.Ar attr
|
||||
is not present in the debugging information entry referenced by
|
||||
argument
|
||||
.Ar die ,
|
||||
and if a
|
||||
.Dv DW_AT_abstract_origin
|
||||
attribute is present in the debugging information entry,
|
||||
function
|
||||
.Fn dwarf_attrval_unsigned
|
||||
will search for the named attribute in the debugging information entry
|
||||
referenced by the
|
||||
.Dv DW_AT_abstract_origin
|
||||
attribute.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions returns
|
||||
.Dv DW_DLV_OK .
|
||||
If the named attribute was not found in the specified debugging
|
||||
information entry descriptor these functions return
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
and set argument
|
||||
.Ar err .
|
||||
For other errors, these functions return
|
||||
.Dv DW_DLV_ERROR
|
||||
and set argument
|
||||
.Ar err .
|
||||
.Sh COMPATIBILITY
|
||||
These functions are extensions added by this implementation of the
|
||||
DWARF(3) API.
|
||||
.Sh ERRORS
|
||||
These functions may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of the arguments
|
||||
.Va die
|
||||
or
|
||||
.Va ret
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
Argument
|
||||
.Ar die
|
||||
did not contain an attribute corresponding to the value in argument
|
||||
.Ar attr .
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute named by argument
|
||||
.Ar attr
|
||||
was not of a permitted form.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_hasattr 3
|
202
contrib/elftoolchain/libdwarf/dwarf_child.3
Normal file
202
contrib/elftoolchain/libdwarf/dwarf_child.3
Normal file
@ -0,0 +1,202 @@
|
||||
.\" Copyright (c) 2010 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_child.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_CHILD 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_child ,
|
||||
.Nm dwarf_siblingof ,
|
||||
.Nm dwarf_offdie
|
||||
.Nd retrieve DWARF Debugging Information Entry descriptors
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fn dwarf_child "Dwarf_Die die" "Dwarf_Die *ret_die" "Dwarf_Error *err"
|
||||
.Ft int
|
||||
.Fo dwarf_siblingof
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Die *ret_die"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_offdie
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Off offset"
|
||||
.Fa "Dwarf_Die *ret_die"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions are used to retrieve and traverse DWARF
|
||||
Debugging Information Entry (DIE) descriptors associated with
|
||||
a compilation unit.
|
||||
These descriptors are arranged in the form of a tree, traversable
|
||||
using
|
||||
.Dq child
|
||||
and
|
||||
.Dq sibling
|
||||
links; see
|
||||
.Xr dwarf 3
|
||||
for more information.
|
||||
DWARF Debugging Information Entry descriptors are represented
|
||||
by the
|
||||
.Vt Dwarf_Die
|
||||
opaque type.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_child
|
||||
retrieves the child of descriptor denoted by argument
|
||||
.Ar die ,
|
||||
and stores it in the location pointed to by argument
|
||||
.Ar ret_die .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_siblingof
|
||||
retrieves the sibling of the descriptor denoted by argument
|
||||
.Ar die ,
|
||||
and stores it in the location pointed to by argument
|
||||
.Ar ret_die .
|
||||
If argument
|
||||
.Ar die
|
||||
is NULL, the first debugging information entry descriptor for the
|
||||
current compilation unit will be returned.
|
||||
This function and function
|
||||
.Fn dwarf_child
|
||||
may be used together to traverse the tree of debugging information
|
||||
entry descriptors for a compilation unit.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_offdie
|
||||
retrieves the debugging information entry descriptor at global offset
|
||||
.Ar offset
|
||||
in the
|
||||
.Dq .debug_info
|
||||
section of the object associated with argument
|
||||
.Ar dbg .
|
||||
The returned descriptor is written to the location pointed to by argument
|
||||
.Ar ret_die .
|
||||
.Ss Memory Management
|
||||
The memory area used for the
|
||||
.Vt Dwarf_Die
|
||||
descriptor returned in argument
|
||||
.Ar ret_die
|
||||
is allocated by the
|
||||
.Lb libdwarf .
|
||||
Application code should use function
|
||||
.Fn dwarf_dealloc
|
||||
with the allocation type
|
||||
.Dv DW_DLA_DIE
|
||||
to free the memory area when the
|
||||
.Vt Dwarf_Die
|
||||
descriptor is no longer needed.
|
||||
.Sh RETURN VALUES
|
||||
These functions return the following values:
|
||||
.Bl -tag -width ".Bq Er DW_DLV_NO_ENTRY"
|
||||
.It Bq Er DW_DLV_OK
|
||||
The call succeeded.
|
||||
.It Bq Er DW_DLV_ERROR
|
||||
The requested operation failed.
|
||||
Additional information about the error encountered will be recorded in
|
||||
argument
|
||||
.Ar err ,
|
||||
if it is not NULL.
|
||||
.It Bq Er DW_DLV_NO_ENTRY
|
||||
For functions
|
||||
.Fn dwarf_child
|
||||
and
|
||||
.Fn dwarf_siblingof ,
|
||||
the descriptor denoted by argument
|
||||
.Ar die
|
||||
did not have a child or sibling.
|
||||
For function
|
||||
.Fn dwarf_offdie ,
|
||||
there was no debugging information entry at the offset specified by
|
||||
argument
|
||||
.Ar offset .
|
||||
.El
|
||||
.Sh ERRORS
|
||||
These functions may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_DIE_NO_CU_CONTEXT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Arguments
|
||||
.Ar dbg ,
|
||||
.Ar die
|
||||
or
|
||||
.Ar ret_die
|
||||
were NULL.
|
||||
.It Bq Er DW_DLE_DIE_NO_CU_CONTEXT
|
||||
Argument
|
||||
.Ar dbg
|
||||
was not associated with a compilation unit.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
The descriptor denoted by argument
|
||||
.Ar die
|
||||
had no child or sibling, or there was no DWARF debugging information
|
||||
entry at the offset specified by argument
|
||||
.Va offset .
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
To retrieve the first DWARF Debugging Information Entry descriptor for
|
||||
the first compilation unit associated with a
|
||||
.Vt Dwarf_Debug
|
||||
instance, and to traverse all its children, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Die die, die0;
|
||||
Dwarf_Error de;
|
||||
|
||||
\&... allocate dbg using dwarf_init() etc ...
|
||||
|
||||
if (dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL, NULL, &de) !=
|
||||
DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_next_cu_header: %s",
|
||||
dwarf_errmsg(de));
|
||||
|
||||
/* Get the first DIE for the current compilation unit. */
|
||||
die = NULL;
|
||||
if (dwarf_siblingof(dbg, die, &die0, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_siblingof: %s", dwarf_errmsg(de));
|
||||
|
||||
/* Get the first child of this DIE. */
|
||||
die = die0;
|
||||
if (dwarf_child(die, &die0, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_child: %s", dwarf_errmsg(de));
|
||||
|
||||
/* Get the rest of children. */
|
||||
do {
|
||||
die = die0;
|
||||
if (dwarf_siblingof(dbg, die, &die0, &de) == DW_DLV_ERROR)
|
||||
errx(EXIT_FAILURE, "dwarf_siblingof: %s",
|
||||
dwarf_errmsg(de));
|
||||
} while (die0 != NULL);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_errmsg 3 ,
|
||||
.Xr dwarf_next_cu_header 3
|
99
contrib/elftoolchain/libdwarf/dwarf_cu.c
Normal file
99
contrib/elftoolchain/libdwarf/dwarf_cu.c
Normal file
@ -0,0 +1,99 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_cu.c 2072 2011-10-27 03:26:49Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_next_cu_header_b(Dwarf_Debug dbg, Dwarf_Unsigned *cu_length,
|
||||
Dwarf_Half *cu_version, Dwarf_Off *cu_abbrev_offset,
|
||||
Dwarf_Half *cu_pointer_size, Dwarf_Half *cu_offset_size,
|
||||
Dwarf_Half *cu_extension_size, Dwarf_Unsigned *cu_next_offset,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_CU cu;
|
||||
int ret;
|
||||
|
||||
if (dbg == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (dbg->dbg_cu_current == NULL)
|
||||
ret = _dwarf_info_first_cu(dbg, error);
|
||||
else
|
||||
ret = _dwarf_info_next_cu(dbg, error);
|
||||
|
||||
if (ret == DW_DLE_NO_ENTRY) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
} else if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
if (dbg->dbg_cu_current == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
cu = dbg->dbg_cu_current;
|
||||
|
||||
if (cu_length)
|
||||
*cu_length = cu->cu_length;
|
||||
if (cu_version)
|
||||
*cu_version = cu->cu_version;
|
||||
if (cu_abbrev_offset)
|
||||
*cu_abbrev_offset = (Dwarf_Off) cu->cu_abbrev_offset;
|
||||
if (cu_pointer_size)
|
||||
*cu_pointer_size = cu->cu_pointer_size;
|
||||
if (cu_offset_size) {
|
||||
if (cu->cu_length_size == 4)
|
||||
*cu_offset_size = 4;
|
||||
else
|
||||
*cu_offset_size = 8;
|
||||
}
|
||||
if (cu_extension_size) {
|
||||
if (cu->cu_length_size == 4)
|
||||
*cu_extension_size = 0;
|
||||
else
|
||||
*cu_extension_size = 4;
|
||||
}
|
||||
if (cu_next_offset)
|
||||
*cu_next_offset = dbg->dbg_cu_current->cu_next_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_next_cu_header(Dwarf_Debug dbg, Dwarf_Unsigned *cu_length,
|
||||
Dwarf_Half *cu_version, Dwarf_Off *cu_abbrev_offset,
|
||||
Dwarf_Half *cu_pointer_size, Dwarf_Unsigned *cu_next_offset,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
|
||||
return (dwarf_next_cu_header_b(dbg, cu_length, cu_version,
|
||||
cu_abbrev_offset, cu_pointer_size, NULL, NULL, cu_next_offset,
|
||||
error));
|
||||
}
|
203
contrib/elftoolchain/libdwarf/dwarf_dealloc.3
Normal file
203
contrib/elftoolchain/libdwarf/dwarf_dealloc.3
Normal file
@ -0,0 +1,203 @@
|
||||
.\" Copyright (c) 2009-2011 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: dwarf_dealloc.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd July 23, 2011
|
||||
.Os
|
||||
.Dt DWARF_DEALLOC 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_dealloc ,
|
||||
.Nm dwarf_fde_cie_list_dealloc ,
|
||||
.Nm dwarf_funcs_dealloc ,
|
||||
.Nm dwarf_globals_dealloc ,
|
||||
.Nm dwarf_pubtypes_dealloc ,
|
||||
.Nm dwarf_ranges_dealloc ,
|
||||
.Nm dwarf_srclines_dealloc ,
|
||||
.Nm dwarf_types_dealloc ,
|
||||
.Nm dwarf_vars_dealloc ,
|
||||
.Nm dwarf_weaks_dealloc
|
||||
.Nd release resources
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft void
|
||||
.Fo dwarf_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Ptr ptr"
|
||||
.Fa "Dwarf_Unsigned type"
|
||||
.Fc
|
||||
.Fo dwarf_fde_cie_list_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Cie *cie_list"
|
||||
.Fa "Dwarf_Signed cie_count"
|
||||
.Fa "Dwarf_Fde *fde_list"
|
||||
.Fa "Dwarf_Signed fde_count"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_funcs_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Func *funcs"
|
||||
.Fa "Dwarf_Signed funccount"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_globals_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Global *globals"
|
||||
.Fa "Dwarf_Signed globalcount"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_pubtypes_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Type *pubtypes"
|
||||
.Fa "Dwarf_Signed pubtypecount"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_ranges_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Ranges *ranges"
|
||||
.Fa "Dwarf_Signed rangecount"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_srclines_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Line *lines"
|
||||
.Fa "Dwarf_Signed linecount"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_types_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Type *types"
|
||||
.Fa "Dwarf_Signed typecount"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_vars_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Var *vars"
|
||||
.Fa "Dwarf_Signed varcount"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo dwarf_weaks_dealloc
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Weak *weaks"
|
||||
.Fa "Dwarf_Signed weakcount"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
The function
|
||||
.Fn dwarf_dealloc
|
||||
is used by applications to indicate that memory areas returned by
|
||||
.Lb libdwarf
|
||||
may be safely disposed off.
|
||||
Due to the way memory is managed in the current implementation, the
|
||||
use of
|
||||
.Fn dwarf_dealloc
|
||||
is only necessary for a small set of DWARF types.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a valid debugging context allocated using
|
||||
.Xr dwarf_init 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ptr
|
||||
should point to an object or memory area obtained by a prior call
|
||||
to a DWARF(3) function.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar type
|
||||
indicates the type of object being deallocated.
|
||||
The indicated type must match that of the object being passed in
|
||||
argument
|
||||
.Ar ptr .
|
||||
Valid values for the
|
||||
.Ar type
|
||||
argument are:
|
||||
.Bl -tag -width ".Dv DW_DLA_FRAME_BLOCK"
|
||||
.It Dv DW_DLA_ABBREV
|
||||
An object of type
|
||||
.Vt Dwarf_Abbrev ,
|
||||
as returned by a call to the function
|
||||
.Xr dwarf_get_abbrev 3 .
|
||||
.It Dv DW_DLA_DIE
|
||||
An object of type
|
||||
.Vt Dwarf_Die ,
|
||||
as returned by calls to the functions
|
||||
.Xr dwarf_child 3 ,
|
||||
.Xr dwarf_offdie 3
|
||||
or
|
||||
.Xr dwarf_siblingof 3 .
|
||||
.It Dv DW_DLA_FRAME_BLOCK
|
||||
An array of objects of type
|
||||
.Vt Dwarf_Frame_op ,
|
||||
as returned by a call to the function
|
||||
.Xr dwarf_expand_frame_instructions 3 .
|
||||
.El
|
||||
.Pp
|
||||
Calls to
|
||||
.Fn dwarf_dealloc
|
||||
with other values for argument
|
||||
.Ar type
|
||||
are no-ops in this implementation.
|
||||
.Pp
|
||||
The functions
|
||||
.Fn dwarf_fde_cie_list_dealloc ,
|
||||
.Fn dwarf_funcs_dealloc ,
|
||||
.Fn dwarf_globals_dealloc ,
|
||||
.Fn dwarf_pubtypes_dealloc ,
|
||||
.Fn dwarf_ranges_dealloc ,
|
||||
.Fn dwarf_srclines_dealloc ,
|
||||
.Fn dwarf_types_dealloc ,
|
||||
.Fn dwarf_vars_dealloc
|
||||
and
|
||||
.Fn dwarf_weaks_dealloc
|
||||
are provided for compatibility with other implementations of the
|
||||
DWARF(3) API.
|
||||
Due to the way memory is managed in the current implementation, these
|
||||
functions are effectively no-ops.
|
||||
.Pp
|
||||
See
|
||||
.Xr dwarf 3
|
||||
for more information about the memory management scheme in this
|
||||
implementation of the DWARF(3) API.
|
||||
.Sh RETURN VALUES
|
||||
Functions
|
||||
.Fn dwarf_dealloc ,
|
||||
.Fn dwarf_fde_cie_list_dealloc ,
|
||||
.Fn dwarf_funcs_dealloc ,
|
||||
.Fn dwarf_globals_dealloc ,
|
||||
.Fn dwarf_pubtypes_dealloc ,
|
||||
.Fn dwarf_ranges_dealloc ,
|
||||
.Fn dwarf_srclines_dealloc ,
|
||||
.Fn dwarf_types_dealloc ,
|
||||
.Fn dwarf_vars_dealloc
|
||||
and
|
||||
.Fn dwarf_weaks_dealloc
|
||||
have no return value.
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_child 3 ,
|
||||
.Xr dwarf_expand_frame_instructions 3 ,
|
||||
.Xr dwarf_get_abbrev 3 ,
|
||||
.Xr dwarf_offdie 3 ,
|
||||
.Xr dwarf_siblingof 3
|
117
contrib/elftoolchain/libdwarf/dwarf_dealloc.c
Normal file
117
contrib/elftoolchain/libdwarf/dwarf_dealloc.c
Normal file
@ -0,0 +1,117 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_dealloc.c 2073 2011-10-27 03:30:47Z jkoshy $");
|
||||
|
||||
void
|
||||
dwarf_dealloc(Dwarf_Debug dbg, Dwarf_Ptr p, Dwarf_Unsigned alloc_type)
|
||||
{
|
||||
Dwarf_Abbrev ab;
|
||||
Dwarf_AttrDef ad, tad;
|
||||
Dwarf_Attribute at, tat;
|
||||
Dwarf_Die die;
|
||||
|
||||
/*
|
||||
* This libdwarf implementation does not use the SGI/libdwarf
|
||||
* style of memory allocation. In most cases it does not copy
|
||||
* things to return to the client, so the client does not need
|
||||
* to remember to free them. The remaining cases are handled
|
||||
* below.
|
||||
*/
|
||||
|
||||
(void) dbg;
|
||||
|
||||
if (alloc_type == DW_DLA_LIST || alloc_type == DW_DLA_FRAME_BLOCK ||
|
||||
alloc_type == DW_DLA_LOC_BLOCK || alloc_type == DW_DLA_LOCDESC)
|
||||
free(p);
|
||||
else if (alloc_type == DW_DLA_ABBREV) {
|
||||
ab = p;
|
||||
STAILQ_FOREACH_SAFE(ad, &ab->ab_attrdef, ad_next, tad) {
|
||||
STAILQ_REMOVE(&ab->ab_attrdef, ad, _Dwarf_AttrDef,
|
||||
ad_next);
|
||||
free(ad);
|
||||
}
|
||||
free(ab);
|
||||
} else if (alloc_type == DW_DLA_DIE) {
|
||||
die = p;
|
||||
STAILQ_FOREACH_SAFE(at, &die->die_attr, at_next, tat) {
|
||||
STAILQ_REMOVE(&die->die_attr, at,
|
||||
_Dwarf_Attribute, at_next);
|
||||
if (at->at_ld != NULL)
|
||||
free(at->at_ld);
|
||||
free(at);
|
||||
}
|
||||
if (die->die_attrarray)
|
||||
free(die->die_attrarray);
|
||||
free(die);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dwarf_srclines_dealloc(Dwarf_Debug dbg, Dwarf_Line *linebuf,
|
||||
Dwarf_Signed count)
|
||||
{
|
||||
/*
|
||||
* In this libdwarf implementation, line information remains
|
||||
* associated with the DIE for a compilation unit for the
|
||||
* lifetime of the DIE. The client does not need to free
|
||||
* the memory returned by `dwarf_srclines()`.
|
||||
*/
|
||||
|
||||
(void) dbg; (void) linebuf; (void) count;
|
||||
}
|
||||
|
||||
void
|
||||
dwarf_ranges_dealloc(Dwarf_Debug dbg, Dwarf_Ranges *ranges,
|
||||
Dwarf_Signed range_count)
|
||||
{
|
||||
/*
|
||||
* In this libdwarf implementation, ranges information is
|
||||
* kept by a STAILQ inside Dwarf_Debug object. The client
|
||||
* does not need to free the memory returned by
|
||||
* `dwarf_get_ranges()` or `dwarf_get_ranges_a()`.
|
||||
*/
|
||||
|
||||
(void) dbg; (void) ranges; (void) range_count;
|
||||
}
|
||||
|
||||
void
|
||||
dwarf_fde_cie_list_dealloc(Dwarf_Debug dbg, Dwarf_Cie *cie_list,
|
||||
Dwarf_Signed cie_count, Dwarf_Fde *fde_list, Dwarf_Signed fde_count)
|
||||
{
|
||||
/*
|
||||
* In this implementation, FDE and CIE information is managed
|
||||
* as part of the Dwarf_Debug object. The client does not need
|
||||
* to explicitly free these memory arenas.
|
||||
*/
|
||||
(void) dbg;
|
||||
(void) cie_list;
|
||||
(void) cie_count;
|
||||
(void) fde_list;
|
||||
(void) fde_count;
|
||||
}
|
129
contrib/elftoolchain/libdwarf/dwarf_def_macro.3
Normal file
129
contrib/elftoolchain/libdwarf/dwarf_def_macro.3
Normal file
@ -0,0 +1,129 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_def_macro.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_DEF_MACRO 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_def_macro
|
||||
.Nd add a macro definition to a DWARF producer instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "int"
|
||||
.Fo dwarf_def_macro
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_Unsigned lineno"
|
||||
.Fa "char *name"
|
||||
.Fa "char *value"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_def_macro
|
||||
adds a macro definition to a DWARF producer instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar lineno
|
||||
specifies the line number of the source line where the macro is
|
||||
defined.
|
||||
A line number of zero is used for macros that are defined
|
||||
before any source file is read.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar name
|
||||
should point to a NUL-terminated string containing the name
|
||||
of the macro.
|
||||
For function-like macros this parameter should also include
|
||||
parentheses and parameter names if any.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar value
|
||||
should point to a NUL-terminated string containing the value
|
||||
of the macro.
|
||||
If the macro doesn't have a value, argument
|
||||
.Ar value
|
||||
should be set to NULL.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_def_macro
|
||||
returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, function
|
||||
.Fn dwarf_def_macro
|
||||
returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh EXAMPLE
|
||||
To record the fact that a macro named
|
||||
.Dv _STDIO_H_
|
||||
was defined at line 20 of the current macro file, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_P_Debug dbg;
|
||||
Dwarf_Error de;
|
||||
|
||||
/* ... Assume 'dbg' refers to a DWARF producer instance... */
|
||||
if (dwarf_def_macro(dbg, 20, "_STDIO_H_", NULL, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_def_macro failed: %s",
|
||||
dwarf_errmsg(-1));
|
||||
.Ed
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_def_macro
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_end_macro_file 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3 ,
|
||||
.Xr dwarf_start_macro_file 3 ,
|
||||
.Xr dwarf_undef_macro 3 ,
|
||||
.Xr dwarf_vendor_ext 3
|
335
contrib/elftoolchain/libdwarf/dwarf_die.c
Normal file
335
contrib/elftoolchain/libdwarf/dwarf_die.c
Normal file
@ -0,0 +1,335 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* Copyright (c) 2009,2011 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_die.c 2073 2011-10-27 03:30:47Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_child(Dwarf_Die die, Dwarf_Die *ret_die, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_CU cu;
|
||||
int ret;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_die == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (die->die_ab->ab_children == DW_CHILDREN_no)
|
||||
return (DW_DLE_NO_ENTRY);
|
||||
|
||||
dbg = die->die_dbg;
|
||||
cu = die->die_cu;
|
||||
ret = _dwarf_die_parse(die->die_dbg, dbg->dbg_info_sec, cu,
|
||||
cu->cu_dwarf_size, die->die_next_off, cu->cu_next_offset,
|
||||
ret_die, 0, error);
|
||||
|
||||
if (ret == DW_DLE_NO_ENTRY) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
} else if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_siblingof(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Die *ret_die,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_CU cu;
|
||||
Dwarf_Attribute at;
|
||||
uint64_t offset;
|
||||
int ret, search_sibling;
|
||||
|
||||
if (dbg == NULL || ret_die == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if ((cu = dbg->dbg_cu_current) == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_DIE_NO_CU_CONTEXT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
/* Application requests the first DIE in this CU. */
|
||||
if (die == NULL)
|
||||
return (dwarf_offdie(dbg, cu->cu_1st_offset, ret_die,
|
||||
error));
|
||||
|
||||
/*
|
||||
* If the DIE doesn't have any children, its sibling sits next
|
||||
* right to it.
|
||||
*/
|
||||
search_sibling = 0;
|
||||
if (die->die_ab->ab_children == DW_CHILDREN_no)
|
||||
offset = die->die_next_off;
|
||||
else {
|
||||
/*
|
||||
* Look for DW_AT_sibling attribute for the offset of
|
||||
* its sibling.
|
||||
*/
|
||||
if ((at = _dwarf_attr_find(die, DW_AT_sibling)) != NULL) {
|
||||
if (at->at_form != DW_FORM_ref_addr)
|
||||
offset = at->u[0].u64 + cu->cu_offset;
|
||||
else
|
||||
offset = at->u[0].u64;
|
||||
} else {
|
||||
offset = die->die_next_off;
|
||||
search_sibling = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ret = _dwarf_die_parse(die->die_dbg, dbg->dbg_info_sec, cu,
|
||||
cu->cu_dwarf_size, offset, cu->cu_next_offset, ret_die,
|
||||
search_sibling, error);
|
||||
|
||||
if (ret == DW_DLE_NO_ENTRY) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
} else if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
_dwarf_search_die_within_cu(Dwarf_Debug dbg, Dwarf_CU cu, Dwarf_Off offset,
|
||||
Dwarf_Die *ret_die, Dwarf_Error *error)
|
||||
{
|
||||
|
||||
assert(dbg != NULL && cu != NULL && ret_die != NULL);
|
||||
|
||||
return (_dwarf_die_parse(dbg, dbg->dbg_info_sec, cu, cu->cu_dwarf_size,
|
||||
offset, cu->cu_next_offset, ret_die, 0, error));
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_offdie(Dwarf_Debug dbg, Dwarf_Off offset, Dwarf_Die *ret_die,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_CU cu;
|
||||
int ret;
|
||||
|
||||
if (dbg == NULL || ret_die == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
/* First search the current CU. */
|
||||
if (dbg->dbg_cu_current != NULL) {
|
||||
cu = dbg->dbg_cu_current;
|
||||
if (offset > cu->cu_offset && offset < cu->cu_next_offset) {
|
||||
ret = _dwarf_search_die_within_cu(dbg, cu, offset,
|
||||
ret_die, error);
|
||||
if (ret == DW_DLE_NO_ENTRY) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
} else if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
}
|
||||
|
||||
/* Search other CUs. */
|
||||
ret = _dwarf_info_load(dbg, 1, error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) {
|
||||
if (offset < cu->cu_offset || offset > cu->cu_next_offset)
|
||||
continue;
|
||||
ret = _dwarf_search_die_within_cu(dbg, cu, offset,
|
||||
ret_die, error);
|
||||
if (ret == DW_DLE_NO_ENTRY) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
} else if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_tag(Dwarf_Die die, Dwarf_Half *tag, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || tag == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
assert(die->die_ab != NULL);
|
||||
|
||||
*tag = (Dwarf_Half) die->die_ab->ab_tag;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_dieoffset(Dwarf_Die die, Dwarf_Off *ret_offset, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_offset == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*ret_offset = die->die_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_die_CU_offset(Dwarf_Die die, Dwarf_Off *ret_offset, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_CU cu;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_offset == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
cu = die->die_cu;
|
||||
assert(cu != NULL);
|
||||
|
||||
*ret_offset = die->die_offset - cu->cu_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_die_CU_offset_range(Dwarf_Die die, Dwarf_Off *cu_offset,
|
||||
Dwarf_Off *cu_length, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_CU cu;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || cu_offset == NULL || cu_length == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
cu = die->die_cu;
|
||||
assert(cu != NULL);
|
||||
|
||||
*cu_offset = cu->cu_offset;
|
||||
*cu_length = cu->cu_length + cu->cu_length_size;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_diename(Dwarf_Die die, char **ret_name, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = die != NULL ? die->die_dbg : NULL;
|
||||
|
||||
if (die == NULL || ret_name == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (die->die_name == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_name = die->die_name;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_die_abbrev_code(Dwarf_Die die)
|
||||
{
|
||||
|
||||
assert(die != NULL);
|
||||
|
||||
return (die->die_abnum);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_cu_die_offset_given_cu_header_offset(Dwarf_Debug dbg,
|
||||
Dwarf_Off in_cu_header_offset, Dwarf_Off *out_cu_die_offset,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_CU cu;
|
||||
|
||||
if (dbg == NULL || out_cu_die_offset == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
STAILQ_FOREACH(cu, &dbg->dbg_cu, cu_next) {
|
||||
if (cu->cu_offset == in_cu_header_offset) {
|
||||
*out_cu_die_offset = cu->cu_1st_offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cu == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_address_size(Dwarf_Debug dbg, Dwarf_Half *addr_size,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (dbg == NULL || addr_size == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*addr_size = dbg->dbg_pointer_size;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
55
contrib/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
Normal file
55
contrib/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
Normal file
@ -0,0 +1,55 @@
|
||||
.\" Copyright (c) 2010 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_die_abbrev_code.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd April 14, 2010
|
||||
.Os
|
||||
.Dt DWARF_DIE_ABBREV_CODE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_die_abbrev_code
|
||||
.Nd retrieve the abbreviation code for a DWARF debugging information entry
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fn dwarf_die_abbrev_code "Dwarf_Die die"
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_die_abbrev_code
|
||||
returns the abbreviation code for the debugging information entry descriptor
|
||||
referenced by argument
|
||||
.Ar die .
|
||||
Argument
|
||||
.Ar die
|
||||
should be a valid pointer to a value of type
|
||||
.Vt Dwarf_Die .
|
||||
.Sh RETURN VALUES
|
||||
The function returns an integral value.
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_diename 3 ,
|
||||
.Xr dwarf_dieoffset 3 ,
|
||||
.Xr dwarf_tag 3
|
118
contrib/elftoolchain/libdwarf/dwarf_die_link.3
Normal file
118
contrib/elftoolchain/libdwarf/dwarf_die_link.3
Normal file
@ -0,0 +1,118 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_die_link.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd September 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_DIE_LINK 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_die_link
|
||||
.Nd link a debugging information entry
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft Dwarf_P_Die
|
||||
.Fo dwarf_die_link
|
||||
.Fa "Dwarf_P_Die die"
|
||||
.Fa "Dwarf_P_Die parent"
|
||||
.Fa "Dwarf_P_Die child"
|
||||
.Fa "Dwarf_P_Die left"
|
||||
.Fa "Dwarf_P_Die right"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_die_link
|
||||
links debugging information entries together.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar die
|
||||
should specify the debugging information entry to be updated.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar parent
|
||||
specifies the new parent link for the debugging information entry.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar child
|
||||
specifies the new first child link for the debugging information entry.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar left
|
||||
specifies the new left sibling link for the debugging information entry.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar right
|
||||
specifies the new right sibling link for the debugging information entry.
|
||||
.Pp
|
||||
Only one of arguments
|
||||
.Ar parent ,
|
||||
.Ar child ,
|
||||
.Ar left
|
||||
and
|
||||
.Ar right
|
||||
is allowed to be non-NULL.
|
||||
Existing links to parent, child, left or right debugging information
|
||||
entries, if any, will be unlinked before the specified link is
|
||||
established.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_die_link
|
||||
returns the debugging information entry provided in argument
|
||||
.Ar die .
|
||||
In case of an error, function
|
||||
.Fn dwarf_die_link
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
The function
|
||||
.Fn dwarf_die_link
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar die
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
More than one of the arguments
|
||||
.Ar parent ,
|
||||
.Ar child ,
|
||||
.Ar left
|
||||
and
|
||||
.Ar right
|
||||
were non-NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_die_to_debug 3 ,
|
||||
.Xr dwarf_new_die 3
|
90
contrib/elftoolchain/libdwarf/dwarf_diename.3
Normal file
90
contrib/elftoolchain/libdwarf/dwarf_diename.3
Normal file
@ -0,0 +1,90 @@
|
||||
.\" Copyright (c) 2010 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_diename.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd March 31, 2010
|
||||
.Os
|
||||
.Dt DWARF_DIENAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_diename
|
||||
.Nd retrieve the name associated with a debugging information entry
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fn dwarf_diename "Dwarf_Die die" "char **ret_name" "Dwarf_Error *err"
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_diename
|
||||
retrieves a pointer to the NUL-terminated string associated with the
|
||||
.Dv DW_AT_name
|
||||
attribute of the debugging information entry descriptor referenced by
|
||||
argument
|
||||
.Ar die .
|
||||
If the pointer was successfully retrieved, it is stored in the location
|
||||
pointed to by argument
|
||||
.Ar ret_name .
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_diename
|
||||
returns
|
||||
.Dv DW_DLV_OK on success.
|
||||
.Pp
|
||||
If the debugging information entry descriptor denoted by argument
|
||||
.Ar die
|
||||
does not contain a
|
||||
.Dv DW_AT_name
|
||||
attribute, the function returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
and sets argument
|
||||
.Ar err .
|
||||
For other errors, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_diename
|
||||
can fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar die
|
||||
or
|
||||
.Ar ret_name
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
Argument
|
||||
.Ar die
|
||||
had no
|
||||
.Dv DW_AT_name
|
||||
attribute.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_tag 3 ,
|
||||
.Xr dwarf_dieoffset 3 ,
|
||||
.Xr dwarf_die_abbrev_code 3
|
172
contrib/elftoolchain/libdwarf/dwarf_dieoffset.3
Normal file
172
contrib/elftoolchain/libdwarf/dwarf_dieoffset.3
Normal file
@ -0,0 +1,172 @@
|
||||
.\" Copyright (c) 2010 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_dieoffset.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd April 17, 2010
|
||||
.Os
|
||||
.Dt DWARF_DIEOFFSET 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_die_CU_offset ,
|
||||
.Nm dwarf_die_CU_offset_range ,
|
||||
.Nm dwarf_dieoffset ,
|
||||
.Nm dwarf_get_cu_die_offset_given_cu_header_offset
|
||||
.Nd return offsets of DWARF debugging information entries
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_die_CU_offset
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Off *ret_offset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_die_CU_offset_range
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Off *cu_offset"
|
||||
.Fa "Dwarf_Off *cu_length"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_dieoffset
|
||||
.Fa "Dwarf_Die die"
|
||||
.Fa "Dwarf_Off *ret_offset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_cu_die_offset_given_cu_header_offset
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Off in_cu_header_offset"
|
||||
.Fa "Dwarf_Off *out_cu_die_offset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions are used to retrieve offsets for DWARF debugging
|
||||
information entries.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_die_CU_offset
|
||||
returns the offset of the debugging information entry referenced by
|
||||
argument
|
||||
.Ar die
|
||||
relative to the start of its containing compilation unit.
|
||||
Argument
|
||||
.Ar ret_offset
|
||||
should point to the location that is to hold the returned offset.
|
||||
If argument
|
||||
.Ar err
|
||||
is non-NULL, it will be used to return an error descriptor in case of
|
||||
an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_die_CU_offset_range
|
||||
returns the section-relative offset and length of the compilation unit
|
||||
containing the debugging information entry referenced by argument
|
||||
.Ar die .
|
||||
Argument
|
||||
.Ar cu_offset
|
||||
should point to a location that will hold the returned offset.
|
||||
Argument
|
||||
.Ar cu_length
|
||||
should point to a location that will hold the returned length of the
|
||||
compilation unit.
|
||||
If argument
|
||||
.Ar err
|
||||
is non-NULL, it will be used to return an error descriptor in case of
|
||||
an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_dieoffset
|
||||
retrieves the section-relative offset of the debugging information
|
||||
entry referenced by argument
|
||||
.Ar die .
|
||||
Argument
|
||||
.Ar ret_offset
|
||||
should point to a location that is to hold the returned
|
||||
section-relative offset.
|
||||
If argument
|
||||
.Ar err
|
||||
is non-NULL, it will be used to return an error descriptor in case of
|
||||
an error.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_get_cu_die_offset_given_cu_header_offset
|
||||
returns the offset for the debugging information entry for a
|
||||
compilation unit, given an offset to the header of the compilation
|
||||
unit.
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a valid debugging context allocated using
|
||||
.Xr dwarf_init 3 .
|
||||
Argument
|
||||
.Ar in_cu_header_offset
|
||||
contains the offset to the start of a compilation unit.
|
||||
Argument
|
||||
.Ar out_cu_die_offset
|
||||
points to a location that will hold the returned offset.
|
||||
If argument
|
||||
.Ar err
|
||||
is non-NULL, it will be used to return an error descriptor in case of
|
||||
an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, these functions return
|
||||
.Dv DW_DLV_ERROR
|
||||
and set argument
|
||||
.Ar err .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_get_cu_die_offset_given_cu_header_offset
|
||||
returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
and sets argument
|
||||
.Ar err
|
||||
if there is no compilation unit located at the
|
||||
offset specified in argument
|
||||
.Ar in_cu_header_offset .
|
||||
.Sh ERRORS
|
||||
These functions may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Va cu_length ,
|
||||
.Va cu_offset ,
|
||||
.Va dbg ,
|
||||
.Va die ,
|
||||
.Va out_cu_die_offset
|
||||
or
|
||||
.Va ret_offset
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
Argument
|
||||
.Ar in_cu_header_offset
|
||||
specified an unknown offset.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_next_cu_header 3 ,
|
||||
.Xr dwarf_offdie 3
|
1292
contrib/elftoolchain/libdwarf/dwarf_dump.c
Normal file
1292
contrib/elftoolchain/libdwarf/dwarf_dump.c
Normal file
File diff suppressed because it is too large
Load Diff
90
contrib/elftoolchain/libdwarf/dwarf_end_macro_file.3
Normal file
90
contrib/elftoolchain/libdwarf/dwarf_end_macro_file.3
Normal file
@ -0,0 +1,90 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_end_macro_file.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd September 25, 2011
|
||||
.Os
|
||||
.Dt DWARF_END_MACRO_FILE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_end_macro_file
|
||||
.Nd mark the end of the current source file inclusion
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "int"
|
||||
.Fo dwarf_end_macro_file
|
||||
.Fa "Dwarf_P_Debug dbg"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fa
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_end_macro_file
|
||||
marks the end of the current source file inclusion.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF producer instance allocated using
|
||||
.Xr dwarf_producer_init 3
|
||||
or
|
||||
.Xr dwarf_producer_init_b 3 .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_end_macro_file
|
||||
returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, function
|
||||
.Fn dwarf_end_macro_file
|
||||
returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_end_macro_file
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar dbg
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_def_macro 3 ,
|
||||
.Xr dwarf_producer_init 3 ,
|
||||
.Xr dwarf_producer_init_b 3 ,
|
||||
.Xr dwarf_start_macro_file 3 ,
|
||||
.Xr dwarf_undef_macro 3 ,
|
||||
.Xr dwarf_vendor_ext 3
|
67
contrib/elftoolchain/libdwarf/dwarf_errmsg.3
Normal file
67
contrib/elftoolchain/libdwarf/dwarf_errmsg.3
Normal file
@ -0,0 +1,67 @@
|
||||
.\" Copyright (c) 2009 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: dwarf_errmsg.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd December 12, 2009
|
||||
.Os
|
||||
.Dt DWARF_ERRMSG 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_errmsg
|
||||
.Nd retrieve a human-readable string corresponding to a
|
||||
.Vt Dwarf_Error
|
||||
instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "const char *"
|
||||
.Fn dwarf_errmsg "Dwarf_Error err"
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_errmsg
|
||||
returns a
|
||||
.Dv NUL Ns - Ns
|
||||
terminated string for the error denoted by
|
||||
argument
|
||||
.Ar err .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar err
|
||||
should be a valid handle to a
|
||||
.Vt Dwarf_Error
|
||||
instance.
|
||||
.Sh Memory Management
|
||||
The returned pointer should not be freed using
|
||||
.Xr free 3
|
||||
or
|
||||
.Xr dwarf_dealloc 3 .
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_errmsg
|
||||
returns a pointer to a
|
||||
.Dv NUL Ns - Ns
|
||||
terminated string.
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_errno 3
|
90
contrib/elftoolchain/libdwarf/dwarf_errmsg.c
Normal file
90
contrib/elftoolchain/libdwarf/dwarf_errmsg.c
Normal file
@ -0,0 +1,90 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_errmsg.c 2576 2012-09-13 09:16:11Z jkoshy $");
|
||||
|
||||
const char *_libdwarf_errors[] = {
|
||||
#define DEFINE_ERROR(N,S) [DW_DLE_##N] = S
|
||||
DEFINE_ERROR(NONE, "No Error"),
|
||||
DEFINE_ERROR(ERROR, "An error"),
|
||||
DEFINE_ERROR(NO_ENTRY, "No entry found"),
|
||||
DEFINE_ERROR(ARGUMENT, "Invalid argument"),
|
||||
DEFINE_ERROR(DEBUG_INFO_NULL, "Debug info NULL"),
|
||||
DEFINE_ERROR(MEMORY, "Insufficient memory"),
|
||||
DEFINE_ERROR(ELF, "ELF error"),
|
||||
DEFINE_ERROR(CU_LENGTH_ERROR, "Invalid compilation unit data"),
|
||||
DEFINE_ERROR(VERSION_STAMP_ERROR, "Unsupported version"),
|
||||
DEFINE_ERROR(DEBUG_ABBREV_NULL, "Abbrev not found"),
|
||||
DEFINE_ERROR(DIE_NO_CU_CONTEXT, "No current compilation unit"),
|
||||
DEFINE_ERROR(LOC_EXPR_BAD, "Invalid location expression"),
|
||||
DEFINE_ERROR(EXPR_LENGTH_BAD, "Invalid DWARF expression length"),
|
||||
DEFINE_ERROR(DEBUG_LOC_SECTION_SHORT, "Loclist section too short"),
|
||||
DEFINE_ERROR(ATTR_FORM_BAD, "Invalid attribute form"),
|
||||
DEFINE_ERROR(DEBUG_LINE_LENGTH_BAD, "Line info section too short"),
|
||||
DEFINE_ERROR(LINE_FILE_NUM_BAD, "Invalid file number."),
|
||||
DEFINE_ERROR(DIR_INDEX_BAD, "Invalid dir index."),
|
||||
DEFINE_ERROR(DEBUG_FRAME_LENGTH_BAD, "Frame section too short"),
|
||||
DEFINE_ERROR(NO_CIE_FOR_FDE, "FDE without corresponding CIE"),
|
||||
DEFINE_ERROR(FRAME_AUGMENTATION_UNKNOWN, "Unknown CIE augmentation"),
|
||||
DEFINE_ERROR(FRAME_INSTR_EXEC_ERROR, "Frame instruction exec error"),
|
||||
DEFINE_ERROR(FRAME_VERSION_BAD, "Unsupported frame section version"),
|
||||
DEFINE_ERROR(FRAME_TABLE_COL_BAD, "Invalid table column value"),
|
||||
DEFINE_ERROR(DF_REG_NUM_TOO_HIGH, "Register number too large"),
|
||||
DEFINE_ERROR(PC_NOT_IN_FDE_RANGE, "PC requested not in the FDE range"),
|
||||
DEFINE_ERROR(ARANGE_OFFSET_BAD, "Invalid address range offset"),
|
||||
DEFINE_ERROR(DEBUG_MACRO_INCONSISTENT, "Invalid macinfo data"),
|
||||
DEFINE_ERROR(ELF_SECT_ERR, "Application callback failed"),
|
||||
DEFINE_ERROR(NUM, "Unknown DWARF error")
|
||||
#undef DEFINE_ERROR
|
||||
};
|
||||
|
||||
const char *
|
||||
dwarf_errmsg_(Dwarf_Error *error)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if (error == NULL)
|
||||
return NULL;
|
||||
|
||||
if (error->err_error < 0 || error->err_error >= DW_DLE_NUM)
|
||||
return _libdwarf_errors[DW_DLE_NUM];
|
||||
else if (error->err_error == DW_DLE_NONE)
|
||||
return _libdwarf_errors[DW_DLE_NONE];
|
||||
else
|
||||
p = _libdwarf_errors[error->err_error];
|
||||
|
||||
if (error->err_error == DW_DLE_ELF)
|
||||
snprintf(error->err_msg, sizeof(error->err_msg),
|
||||
"ELF error : %s [%s(%d)]", elf_errmsg(error->err_elferror),
|
||||
error->err_func, error->err_line);
|
||||
else
|
||||
snprintf(error->err_msg, sizeof(error->err_msg),
|
||||
"%s [%s(%d)]", p, error->err_func, error->err_line);
|
||||
|
||||
return (const char *) error->err_msg;
|
||||
}
|
58
contrib/elftoolchain/libdwarf/dwarf_errno.3
Normal file
58
contrib/elftoolchain/libdwarf/dwarf_errno.3
Normal file
@ -0,0 +1,58 @@
|
||||
.\" Copyright (c) 2009,2010 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: dwarf_errno.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd March 25, 2010
|
||||
.Os
|
||||
.Dt DWARF_ERRNO 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_errno
|
||||
.Nd retrieve the error number corresponding to a
|
||||
.Vt Dwarf_Error
|
||||
instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fn dwarf_errno "Dwarf_Error err"
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_errno
|
||||
returns the error number associated with a
|
||||
.Vt Dwarf_Error
|
||||
instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar err
|
||||
should be a valid handle to a
|
||||
.Vt Dwarf_Error
|
||||
instance.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_errno
|
||||
returns an integral value.
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_errmsg 3
|
182
contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
Normal file
182
contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
Normal file
@ -0,0 +1,182 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_expand_frame_instructions.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_EXPAND_FRAME_INSTRUCTIONS 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_expand_frame_instructions
|
||||
.Nd expand frame instructions
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_expand_frame_instructions
|
||||
.Fa "Dwarf_Cie cie"
|
||||
.Fa "Dwarf_Ptr instructions"
|
||||
.Fa "Dwarf_Unsigned len"
|
||||
.Fa "Dwarf_Frame_Op **ret_ops"
|
||||
.Fa "Dwarf_Signed *ret_opcnt"
|
||||
.Fa "Dwarf_Error *error"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_expand_frame_instructions
|
||||
translates DWARF frame instruction bytes into an array of
|
||||
.Vt Dwarf_Frame_Op
|
||||
descriptors.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar cie
|
||||
should reference the CIE descriptor associated with the instructions
|
||||
to be translated.
|
||||
.Pp
|
||||
Arugment
|
||||
.Ar instructions
|
||||
should point to an array of frame instruction bytes, as
|
||||
returned by the functions
|
||||
.Xr dwarf_get_cie_info 3
|
||||
or
|
||||
.Xr dwarf_get_fde_instr_bytes 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar len
|
||||
should specify the number of the frame instruction bytes to be
|
||||
translated.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret_ops
|
||||
should point to a location that will be set to a pointer to
|
||||
an array of translated
|
||||
.Vt Dwarf_Frame_Op
|
||||
descriptors.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret_opcnt
|
||||
should point to a location that will hold the total number of the
|
||||
returned descriptors.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Ss Memory Management
|
||||
The memory area used for the descriptor array returned in argument
|
||||
.Ar ret_ops
|
||||
is allocated by
|
||||
.Lb libdwarf .
|
||||
Application code should use function
|
||||
.Xr dwarf_dealloc 3
|
||||
with type
|
||||
.Dv DW_DLA_FRAME_BLOCK
|
||||
to free the memory area when the descriptor array is no longer needed.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_expand_frame_instructions
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_expand_frame_instructions
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar cie ,
|
||||
.Ar instructions ,
|
||||
.Ar ret_ops
|
||||
or
|
||||
.Ar ret_opcnt
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar len
|
||||
was 0.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
this function.
|
||||
.It Bq Er DW_DLE_FRAME_INSTR_EXEC_ERROR
|
||||
An unknown instruction was found in the instruction bytes provided
|
||||
in argument
|
||||
.Ar instructions .
|
||||
.El
|
||||
.Sh EXAMPLE
|
||||
To retrieve and expand the frame instructions for a given FDE
|
||||
descriptor, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Dbg dbg;
|
||||
Dwarf_Cie cie;
|
||||
Dwarf_Fde fde;
|
||||
Dwarf_Ptr fde_inst;
|
||||
Dwarf_Unsigned fde_instlen;
|
||||
Dwarf_Frame_Op *ops;
|
||||
Dwarf_Signed opcnt;
|
||||
Dwarf_Error de;
|
||||
|
||||
/* ... assuming `dbg` references a valid DWARF debugging context,
|
||||
`fde` references a valid FDE descriptor and `cie` holds the CIE
|
||||
descriptor associated with the FDE descriptor ... */
|
||||
|
||||
if (dwarf_get_fde_instr_bytes(fde, &fde_inst, &fde_instlen,
|
||||
&de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_get_fde_instr_bytes failed: %s",
|
||||
dwarf_errmsg(de));
|
||||
|
||||
if (dwarf_expand_frame_instructions(cie, fde_inst, fde_instlen,
|
||||
&ops, &opcnt, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE,
|
||||
"dwarf_expand_frame_instructions failed: %s",
|
||||
dwarf_errmsg(de));
|
||||
|
||||
for (i = 0; i < opcnt; i++) {
|
||||
/* ... use ops[i] ... */
|
||||
}
|
||||
|
||||
/* Free the memory area when no longer needed. */
|
||||
dwarf_dealloc(dbg, ops, DW_DLA_FRAME_BLOCK);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_frame_instructions_dealloc 3 ,
|
||||
.Xr dwarf_get_cie_info 3 ,
|
||||
.Xr dwarf_get_cie_index 3 ,
|
||||
.Xr dwarf_get_cie_of_fde ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg3 3 ,
|
||||
.Xr dwarf_get_fde_instr_bytes 3 ,
|
||||
.Xr dwarf_get_fde_list 3 ,
|
||||
.Xr dwarf_get_fde_list_eh 3 ,
|
||||
.Xr dwarf_get_fde_n 3
|
84
contrib/elftoolchain/libdwarf/dwarf_expr_current_offset.3
Normal file
84
contrib/elftoolchain/libdwarf/dwarf_expr_current_offset.3
Normal file
@ -0,0 +1,84 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_expr_current_offset.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd September 13, 2011
|
||||
.Os
|
||||
.Dt DWARF_EXPR_CURRENT_OFFSET 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_expr_current_offset
|
||||
.Nd retrieve the number of bytes in a location expression stream
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Unsigned"
|
||||
.Fo dwarf_expr_current_offset
|
||||
.Fa "Dwarf_P_Expr expr"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_expr_current_offset
|
||||
returns the size in bytes of the stream representation of a location
|
||||
expression.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar expr
|
||||
should reference a location expression descriptor allocated using
|
||||
.Xr dwarf_new_expr 3 .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_expr_current_offset
|
||||
returns the size in bytes of the location descriptor's stream
|
||||
representation.
|
||||
In case of an error, function
|
||||
.Fn dwarf_expr_current_offset
|
||||
returns
|
||||
.Dv DW_DLV_NOCOUNT
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_expr_current_offset
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar expr
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_expr_addr 3 ,
|
||||
.Xr dwarf_add_expr_addr_b 3 ,
|
||||
.Xr dwarf_add_expr_gen 3 ,
|
||||
.Xr dwarf_expr_into_block 3 ,
|
||||
.Xr dwarf_new_expr 3
|
94
contrib/elftoolchain/libdwarf/dwarf_expr_into_block.3
Normal file
94
contrib/elftoolchain/libdwarf/dwarf_expr_into_block.3
Normal file
@ -0,0 +1,94 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_expr_into_block.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd September 13, 2011
|
||||
.Os
|
||||
.Dt DWARF_EXPR_INTO_BLOCK 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_expr_into_block
|
||||
.Nd retrieve the byte stream for a location expression
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_Addr"
|
||||
.Fo dwarf_expr_into_block
|
||||
.Fa "Dwarf_P_Expr expr"
|
||||
.Fa "Dwarf_Unsigned *length"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_expr_into_block
|
||||
retrieves the byte stream representation of a location expression.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar expr
|
||||
should reference a location expression descriptor allocated using
|
||||
.Xr dwarf_new_expr 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar length
|
||||
should point to a location which will hold the size in bytes of
|
||||
the retrieved byte stream.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_expr_into_block
|
||||
returns the address of the first byte of the generated byte stream.
|
||||
In case of an error, function
|
||||
.Fn dwarf_expr_into_block
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_expr_into_block
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar expr
|
||||
or
|
||||
.Ar length
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of
|
||||
the function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_AT_location_expr 3 ,
|
||||
.Xr dwarf_add_expr_addr 3 ,
|
||||
.Xr dwarf_add_expr_addr_b 3 ,
|
||||
.Xr dwarf_add_expr_gen 3 ,
|
||||
.Xr dwarf_expr_current_offset 3 ,
|
||||
.Xr dwarf_new_expr 3
|
99
contrib/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
Normal file
99
contrib/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
Normal file
@ -0,0 +1,99 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_fde_cfa_offset.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd September 26, 2011
|
||||
.Os
|
||||
.Dt DWARF_FDE_CFA_OFFSET 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_fde_cfa_offset
|
||||
.Nd add a DW_CFA_offset frame instruction to a DWARF frame descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft "Dwarf_P_Fde"
|
||||
.Fo dwarf_fde_cfa_offset
|
||||
.Fa "Dwarf_P_Fde fde"
|
||||
.Fa "Dwarf_Unsigned reg"
|
||||
.Fa "Dwarf_Signed offset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_fde_cfa_offset
|
||||
appends a
|
||||
.Dv DW_CFA_offset
|
||||
frame instruction to the frame descriptor referenced by argument
|
||||
.Ar fde .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a frame descriptor allocated using
|
||||
.Xr dwarf_new_fde 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar reg
|
||||
specifies the register operand for the frame instruction.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar offset
|
||||
specifies the offset operand for the frame instruction.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_fde_cfa_offset
|
||||
returns the frame descriptor given in argument
|
||||
.Ar fde .
|
||||
In case of an error, function
|
||||
.Fn dwarf_fde_cfa_offset
|
||||
returns
|
||||
.Dv DW_DLV_BADADDR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_fde_cfa_offset
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar fde
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_MEMORY
|
||||
An out of memory condition was encountered during the execution of the
|
||||
function.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_add_fde_inst 3 ,
|
||||
.Xr dwarf_add_frame_fde 3 ,
|
||||
.Xr dwarf_add_frame_fde_b 3 ,
|
||||
.Xr dwarf_add_frame_cie 3 ,
|
||||
.Xr dwarf_new_fde 3
|
68
contrib/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
Normal file
68
contrib/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
Normal file
@ -0,0 +1,68 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_find_macro_value_start.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd March 26, 2011
|
||||
.Os
|
||||
.Dt DWARF_FIND_MACRO_VALUE_START 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_find_macro_value_start
|
||||
.Nd return the address of the first byte of a macro value
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft char *
|
||||
.Fo dwarf_find_macro_value_start
|
||||
.Fa "char *macro_string"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Given a DWARF macro string, function
|
||||
.Fn dwarf_find_macro_value_start
|
||||
returns a pointer to the first byte of the macro value part of the
|
||||
macro string.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar macro_string
|
||||
should be a NUL-terminated string conforming to the macro format
|
||||
defined in the DWARF standard; see
|
||||
.Xr dwarf 4 .
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_find_macro_value_start
|
||||
returns a pointer to the first byte of the macro value.
|
||||
If the macro value part was not found, function
|
||||
.Fn dwarf_find_macro_value_start
|
||||
returns a pointer to the NUL-byte terminating argument
|
||||
.Ar macro_string .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_find_macro_value_start
|
||||
returns NULL if argument
|
||||
.Ar macro_string
|
||||
was NULL.
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_macro_details 3
|
140
contrib/elftoolchain/libdwarf/dwarf_finish.3
Normal file
140
contrib/elftoolchain/libdwarf/dwarf_finish.3
Normal file
@ -0,0 +1,140 @@
|
||||
.\" Copyright (c) 2009,2011 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: dwarf_finish.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_FINISH 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_finish ,
|
||||
.Nm dwarf_object_finish
|
||||
.Nd free resources associated with a debug descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fn dwarf_finish "Dwarf_Debug dbg" "Dwarf_Error *err"
|
||||
.Ft int
|
||||
.Fn dwarf_object_finish "Dwarf_Debug dbg" "Dwarf_Error *err"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn dwarf_finish
|
||||
and
|
||||
.Fn dwarf_object_finish
|
||||
functions are used to release the resources associated with a debug
|
||||
descriptor allocated by a prior call to
|
||||
.Xr dwarf_init 3
|
||||
and
|
||||
.Xr dwarf_object_init 3
|
||||
respectively.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
denotes a valid
|
||||
.Vt Dwarf_Debug
|
||||
instance.
|
||||
Argument
|
||||
.Ar err
|
||||
will be used to record error information in case of an error.
|
||||
.Pp
|
||||
After a call to
|
||||
.Fn dwarf_finish
|
||||
or
|
||||
.Fn dwarf_object_finish ,
|
||||
the argument
|
||||
.Ar dbg
|
||||
will be invalid and should not be used further.
|
||||
.Pp
|
||||
For
|
||||
.Vt Dwarf_Debug
|
||||
descriptors opened using
|
||||
.Xr dwarf_init 3 ,
|
||||
the application would need to explicitly release the
|
||||
.Vt Elf
|
||||
instance associated with the descriptor by first retrieving
|
||||
the instance using
|
||||
.Xr dwarf_get_elf 3
|
||||
and closing it using
|
||||
.Xr elf_end 3 .
|
||||
.Sh RETURN VALUES
|
||||
These functions return
|
||||
.Dv DW_DLV_OK
|
||||
if successful.
|
||||
In case of an error, the functions return
|
||||
.Dv DW_DLV_ERROR
|
||||
and record additional information in argument
|
||||
.Ar err .
|
||||
.Sh EXAMPLES
|
||||
To deallocate a
|
||||
.Vt Dwarf_Debug
|
||||
instance allocated using
|
||||
.Xr dwarf_elf_init 3
|
||||
use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Error de;
|
||||
|
||||
if (dwarf_finish(dbg, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de));
|
||||
.Ed
|
||||
.Pp
|
||||
To deallocate a
|
||||
.Vt Dwarf_Debug
|
||||
instance allocated using
|
||||
.Xr dwarf_object_init 3
|
||||
use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Error de;
|
||||
|
||||
if (dwarf_object_finish(dbg, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_object_finish: %s",
|
||||
dwarf_errmsg(de));
|
||||
.Ed
|
||||
.Pp
|
||||
To deallocate a
|
||||
.Vt Dwarf_Debug
|
||||
instance allocated using
|
||||
.Xr dwarf_init 3
|
||||
use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dward_Error de;
|
||||
Elf *e;
|
||||
|
||||
if (dwarf_get_elf(dbg, &e, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_get_elf: %s", dwarf_errmsg(&de));
|
||||
|
||||
if (dwarf_finish(dbg, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_finish: %s", dwarf_errmsg(de));
|
||||
|
||||
(void) elf_end(e);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr elf_end 3 ,
|
||||
.Xr dwarf_elf_init 3 ,
|
||||
.Xr dwarf_get_elf 3 ,
|
||||
.Xr dwarf_init 3 ,
|
||||
.Xr dwarf_object_init 3
|
61
contrib/elftoolchain/libdwarf/dwarf_finish.c
Normal file
61
contrib/elftoolchain/libdwarf/dwarf_finish.c
Normal file
@ -0,0 +1,61 @@
|
||||
/*-
|
||||
* Copyright (c) 2009 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_finish.c 2073 2011-10-27 03:30:47Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_finish(Dwarf_Debug dbg, Dwarf_Error *error)
|
||||
{
|
||||
(void) error; /* unused */
|
||||
|
||||
if (dbg == NULL)
|
||||
return (DW_DLV_OK);
|
||||
|
||||
_dwarf_deinit(dbg);
|
||||
_dwarf_elf_deinit(dbg);
|
||||
|
||||
free(dbg);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
dwarf_object_finish(Dwarf_Debug dbg, Dwarf_Error *error)
|
||||
{
|
||||
(void) error; /* unused */
|
||||
|
||||
if (dbg == NULL)
|
||||
return (DW_DLV_OK);
|
||||
|
||||
_dwarf_deinit(dbg);
|
||||
|
||||
free(dbg);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
480
contrib/elftoolchain/libdwarf/dwarf_form.c
Normal file
480
contrib/elftoolchain/libdwarf/dwarf_form.c
Normal file
@ -0,0 +1,480 @@
|
||||
/*-
|
||||
* Copyright (c) 2007 John Birrell (jb@freebsd.org)
|
||||
* Copyright (c) 2009,2010 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_form.c 2073 2011-10-27 03:30:47Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_hasform(Dwarf_Attribute at, Dwarf_Half form, Dwarf_Bool *return_hasform,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_hasform == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_hasform = (at->at_form == form);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_whatform(Dwarf_Attribute at, Dwarf_Half *return_form, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_form == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_form = at->at_form;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_whatform_direct(Dwarf_Attribute at, Dwarf_Half *return_form,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_form == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (at->at_indirect)
|
||||
*return_form = DW_FORM_indirect;
|
||||
else
|
||||
*return_form = (Dwarf_Half) at->at_form;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_whatattr(Dwarf_Attribute at, Dwarf_Half *return_attr, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_attr == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_attr = (Dwarf_Half) at->at_attrib;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formref(Dwarf_Attribute at, Dwarf_Off *return_offset, Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_offset == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_ref1:
|
||||
case DW_FORM_ref2:
|
||||
case DW_FORM_ref4:
|
||||
case DW_FORM_ref8:
|
||||
case DW_FORM_ref_udata:
|
||||
*return_offset = (Dwarf_Off) at->u[0].u64;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_global_formref(Dwarf_Attribute at, Dwarf_Off *return_offset,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_offset == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_ref_addr:
|
||||
case DW_FORM_sec_offset:
|
||||
*return_offset = (Dwarf_Off) at->u[0].u64;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
case DW_FORM_ref1:
|
||||
case DW_FORM_ref2:
|
||||
case DW_FORM_ref4:
|
||||
case DW_FORM_ref8:
|
||||
case DW_FORM_ref_udata:
|
||||
*return_offset = (Dwarf_Off) at->u[0].u64 +
|
||||
at->at_die->die_cu->cu_offset;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formaddr(Dwarf_Attribute at, Dwarf_Addr *return_addr, Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_addr == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (at->at_form == DW_FORM_addr) {
|
||||
*return_addr = at->u[0].u64;
|
||||
ret = DW_DLV_OK;
|
||||
} else {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formflag(Dwarf_Attribute at, Dwarf_Bool *return_bool, Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_bool == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (at->at_form == DW_FORM_flag ||
|
||||
at->at_form == DW_FORM_flag_present) {
|
||||
*return_bool = (Dwarf_Bool) (!!at->u[0].u64);
|
||||
ret = DW_DLV_OK;
|
||||
} else {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formudata(Dwarf_Attribute at, Dwarf_Unsigned *return_uvalue,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_uvalue == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_data1:
|
||||
case DW_FORM_data2:
|
||||
case DW_FORM_data4:
|
||||
case DW_FORM_data8:
|
||||
case DW_FORM_udata:
|
||||
*return_uvalue = at->u[0].u64;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formsdata(Dwarf_Attribute at, Dwarf_Signed *return_svalue,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_svalue == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_data1:
|
||||
*return_svalue = (int8_t) at->u[0].s64;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
case DW_FORM_data2:
|
||||
*return_svalue = (int16_t) at->u[0].s64;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
case DW_FORM_data4:
|
||||
*return_svalue = (int32_t) at->u[0].s64;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
case DW_FORM_data8:
|
||||
case DW_FORM_sdata:
|
||||
*return_svalue = at->u[0].s64;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formblock(Dwarf_Attribute at, Dwarf_Block **return_block,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_block == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_block:
|
||||
case DW_FORM_block1:
|
||||
case DW_FORM_block2:
|
||||
case DW_FORM_block4:
|
||||
*return_block = &at->at_block;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formsig8(Dwarf_Attribute at, Dwarf_Sig8 *return_sig8, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_sig8 == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (at->at_form != DW_FORM_ref_sig8) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
assert(at->u[0].u64 == 8);
|
||||
memcpy(return_sig8->signature, at->u[1].u8p, at->u[0].u64);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formexprloc(Dwarf_Attribute at, Dwarf_Unsigned *return_exprlen,
|
||||
Dwarf_Ptr *return_expr, Dwarf_Error *error)
|
||||
{
|
||||
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_exprlen == NULL || return_expr == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (at->at_form != DW_FORM_exprloc) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*return_exprlen = at->u[0].u64;
|
||||
*return_expr = (void *) at->u[1].u8p;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_formstring(Dwarf_Attribute at, char **return_string,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
int ret;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = at != NULL ? at->at_die->die_dbg : NULL;
|
||||
|
||||
if (at == NULL || return_string == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
switch (at->at_form) {
|
||||
case DW_FORM_string:
|
||||
*return_string = (char *) at->u[0].s;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
case DW_FORM_strp:
|
||||
*return_string = (char *) at->u[1].s;
|
||||
ret = DW_DLV_OK;
|
||||
break;
|
||||
default:
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ATTR_FORM_BAD);
|
||||
ret = DW_DLV_ERROR;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
enum Dwarf_Form_Class
|
||||
dwarf_get_form_class(Dwarf_Half dwversion, Dwarf_Half attr,
|
||||
Dwarf_Half offset_size, Dwarf_Half form)
|
||||
{
|
||||
|
||||
switch (form) {
|
||||
case DW_FORM_addr:
|
||||
return (DW_FORM_CLASS_ADDRESS);
|
||||
case DW_FORM_block:
|
||||
case DW_FORM_block1:
|
||||
case DW_FORM_block2:
|
||||
case DW_FORM_block4:
|
||||
return (DW_FORM_CLASS_BLOCK);
|
||||
case DW_FORM_string:
|
||||
case DW_FORM_strp:
|
||||
return (DW_FORM_CLASS_STRING);
|
||||
case DW_FORM_flag:
|
||||
case DW_FORM_flag_present:
|
||||
return (DW_FORM_CLASS_FLAG);
|
||||
case DW_FORM_ref_addr:
|
||||
case DW_FORM_ref_sig8:
|
||||
case DW_FORM_ref_udata:
|
||||
case DW_FORM_ref1:
|
||||
case DW_FORM_ref2:
|
||||
case DW_FORM_ref4:
|
||||
case DW_FORM_ref8:
|
||||
return (DW_FORM_CLASS_REFERENCE);
|
||||
case DW_FORM_exprloc:
|
||||
return (DW_FORM_CLASS_EXPRLOC);
|
||||
case DW_FORM_data1:
|
||||
case DW_FORM_data2:
|
||||
case DW_FORM_sdata:
|
||||
case DW_FORM_udata:
|
||||
return (DW_FORM_CLASS_CONSTANT);
|
||||
case DW_FORM_data4:
|
||||
case DW_FORM_data8:
|
||||
if (dwversion > 3)
|
||||
return (DW_FORM_CLASS_CONSTANT);
|
||||
if (form == DW_FORM_data4 && offset_size != 4)
|
||||
return (DW_FORM_CLASS_CONSTANT);
|
||||
if (form == DW_FORM_data8 && offset_size != 8)
|
||||
return (DW_FORM_CLASS_CONSTANT);
|
||||
/* FALLTHROUGH */
|
||||
case DW_FORM_sec_offset:
|
||||
/*
|
||||
* DW_FORM_data4 and DW_FORM_data8 can be used as
|
||||
* offset/pointer before DWARF4. Newly added
|
||||
* DWARF4 form DW_FORM_sec_offset intents to replace
|
||||
* DW_FORM_data{4,8} for this purpose. Anyway, to
|
||||
* determine the actual class for these forms, we need
|
||||
* to also look at the attribute number.
|
||||
*/
|
||||
switch (attr) {
|
||||
case DW_AT_location:
|
||||
case DW_AT_string_length:
|
||||
case DW_AT_return_addr:
|
||||
case DW_AT_data_member_location:
|
||||
case DW_AT_frame_base:
|
||||
case DW_AT_segment:
|
||||
case DW_AT_static_link:
|
||||
case DW_AT_use_location:
|
||||
case DW_AT_vtable_elem_location:
|
||||
return (DW_FORM_CLASS_LOCLISTPTR);
|
||||
case DW_AT_stmt_list:
|
||||
return (DW_FORM_CLASS_LINEPTR);
|
||||
case DW_AT_start_scope:
|
||||
case DW_AT_ranges:
|
||||
return (DW_FORM_CLASS_RANGELISTPTR);
|
||||
case DW_AT_macro_info:
|
||||
return (DW_FORM_CLASS_MACPTR);
|
||||
default:
|
||||
if (form == DW_FORM_data4 || form == DW_FORM_data8)
|
||||
return (DW_FORM_CLASS_CONSTANT);
|
||||
else
|
||||
return (DW_FORM_CLASS_UNKNOWN);
|
||||
}
|
||||
default:
|
||||
return (DW_FORM_CLASS_UNKNOWN);
|
||||
}
|
||||
}
|
97
contrib/elftoolchain/libdwarf/dwarf_formaddr.3
Normal file
97
contrib/elftoolchain/libdwarf/dwarf_formaddr.3
Normal file
@ -0,0 +1,97 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formaddr.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd July 23, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMADDR 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formaddr
|
||||
.Nd return the value of an ADDRESS class attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formaddr
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Addr *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_formaddr
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to the address represented by the attribute referenced
|
||||
by argument
|
||||
.Ar attr .
|
||||
The form of argument
|
||||
.Ar attr
|
||||
must be
|
||||
.Dv DW_FORM_addr .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formaddr
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_formblock
|
||||
may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar attr
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of form
|
||||
.Dv DW_FORM_addr .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formblock 3 ,
|
||||
.Xr dwarf_formflag 3 ,
|
||||
.Xr dwarf_formref 3 ,
|
||||
.Xr dwarf_formsdata 3 ,
|
||||
.Xr dwarf_formsig8 3 ,
|
||||
.Xr dwarf_formstring 3 ,
|
||||
.Xr dwarf_formudata 3 ,
|
||||
.Xr dwarf_hasattr 3
|
109
contrib/elftoolchain/libdwarf/dwarf_formblock.3
Normal file
109
contrib/elftoolchain/libdwarf/dwarf_formblock.3
Normal file
@ -0,0 +1,109 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formblock.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd July 23, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMBLOCK 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formblock
|
||||
.Nd return the value of a BLOCK attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formblock
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Block **ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_formblock
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to a pointer to a
|
||||
.Vt Dwarf_Block
|
||||
structure containing the value of the attribute referenced
|
||||
by argument
|
||||
.Ar attr .
|
||||
The form of argument
|
||||
.Ar attr
|
||||
must be one of
|
||||
.Dv DW_FORM_block ,
|
||||
.Dv DW_FORM_block1 ,
|
||||
.Dv DW_FORM_block2
|
||||
or
|
||||
.Dv DW_FORM_block4 .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Ss Memory Management
|
||||
The memory area referenced by the returned pointer is managed by
|
||||
the DWARF(3) library.
|
||||
The application should not attempt to free this memory
|
||||
area.
|
||||
Portable code may indicate that the memory area is to be freed by
|
||||
by using
|
||||
.Xr dwarf_dealloc 3 .
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formblock
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_formblock
|
||||
may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar attr
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of a permitted kind.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formflag 3 ,
|
||||
.Xr dwarf_formref 3 ,
|
||||
.Xr dwarf_formsdata 3 ,
|
||||
.Xr dwarf_formsig8 3 ,
|
||||
.Xr dwarf_formstring 3 ,
|
||||
.Xr dwarf_formudata 3 ,
|
||||
.Xr dwarf_hasattr 3
|
109
contrib/elftoolchain/libdwarf/dwarf_formexprloc.3
Normal file
109
contrib/elftoolchain/libdwarf/dwarf_formexprloc.3
Normal file
@ -0,0 +1,109 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formexprloc.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd July 25, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMEXPRLOC 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formexprloc
|
||||
.Nd return information about a location expression
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formexprloc
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Unsigned *retlen"
|
||||
.Fa "Dwarf_Ptr *retexpr"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_formexprloc
|
||||
allows an application to retrieve the length and the bytes of a
|
||||
DWARF location expression.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr
|
||||
should reference a DWARF attribute of the form
|
||||
.Dv DW_FORM_exprloc .
|
||||
Argument
|
||||
.Ar retlen
|
||||
should point to a location that will be set to the length of the
|
||||
location expression.
|
||||
Argument
|
||||
.Ar retexpr
|
||||
should point to a location that will be set to a pointer to the
|
||||
content of the location expression itself.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Ss Memory Management
|
||||
The application should not attempt to free the memory
|
||||
area referenced by the pointer returned in argument
|
||||
.Ar retexpr .
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formexprloc
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_formexprloc
|
||||
may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of arguments
|
||||
.Ar attr ,
|
||||
.Ar retlen
|
||||
or
|
||||
.Ar retexpr
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of form
|
||||
.Dv DW_FORM_exprloc .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formblock 3 ,
|
||||
.Xr dwarf_formflag 3 ,
|
||||
.Xr dwarf_formref 3 ,
|
||||
.Xr dwarf_formsdata 3 ,
|
||||
.Xr dwarf_formsig8 3 ,
|
||||
.Xr dwarf_formstring 3 ,
|
||||
.Xr dwarf_formudata 3 ,
|
||||
.Xr dwarf_hasattr 3
|
97
contrib/elftoolchain/libdwarf/dwarf_formflag.3
Normal file
97
contrib/elftoolchain/libdwarf/dwarf_formflag.3
Normal file
@ -0,0 +1,97 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formflag.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd June 21, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMFLAG 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formflag
|
||||
.Nd return the value of a BOOLEAN class attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formflag
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Bool *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_formflag
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to 1 if the attribute referenced by argument
|
||||
.Ar attr
|
||||
has a non-zero value, or 0 otherwise.
|
||||
The form of argument
|
||||
.Ar attr
|
||||
must be one of
|
||||
.Dv DW_FORM_flag
|
||||
or
|
||||
.Dv DW_FORM_flag_present .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formflag
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_formflag
|
||||
may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar attr
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of a permitted kind.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formblock 3 ,
|
||||
.Xr dwarf_formref 3 ,
|
||||
.Xr dwarf_formsdata 3 ,
|
||||
.Xr dwarf_formsig8 3 ,
|
||||
.Xr dwarf_formstring 3 ,
|
||||
.Xr dwarf_formudata 3 ,
|
||||
.Xr dwarf_hasattr 3
|
136
contrib/elftoolchain/libdwarf/dwarf_formref.3
Normal file
136
contrib/elftoolchain/libdwarf/dwarf_formref.3
Normal file
@ -0,0 +1,136 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formref.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd June 21, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMREF 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formref ,
|
||||
.Nm dwarf_global_formref
|
||||
.Nd retrieve offsets for REFERENCE class attributes
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formref
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Off *retoffset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_global_formref
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Off *retoffset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions return the offsets associated with a DWARF attribute
|
||||
descriptor.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_formref
|
||||
returns the compilation unit relative offset of the descriptor
|
||||
referenced by argument
|
||||
.Ar attr
|
||||
in the location pointed to by argument
|
||||
.Ar retoffset .
|
||||
Argument
|
||||
.Ar attr
|
||||
must be a reference that is local to a compilation unit.
|
||||
Permitted forms for argument
|
||||
.Ar attr
|
||||
are
|
||||
.Dv DW_FORM_ref1 ,
|
||||
.Dv DW_FORM_ref2 ,
|
||||
.Dv DW_FORM_ref4 ,
|
||||
.Dv DW_FORM_ref8
|
||||
and
|
||||
.Dv DW_FORM_ref_udata .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_global_formref
|
||||
returns the section-relative offset of the descriptor referenced by
|
||||
argument
|
||||
.Ar attr
|
||||
in the location pointed to by argument
|
||||
.Ar retoffset .
|
||||
Argument
|
||||
.Ar attr
|
||||
should be a legal
|
||||
.Sy REFERENCE
|
||||
class form.
|
||||
Permitted forms for argument
|
||||
.Ar attr
|
||||
are:
|
||||
.Dv DW_FORM_ref_addr ,
|
||||
.Dv DW_FORM_ref_udata ,
|
||||
.Dv DW_FORM_ref1 ,
|
||||
.Dv DW_FORM_ref2 ,
|
||||
.Dv DW_FORM_ref4 ,
|
||||
.Dv DW_FORM_ref8
|
||||
and
|
||||
.Dv DW_FORM_sec_offset .
|
||||
The returned offset is relative to the start of the
|
||||
.Dq .debug_info
|
||||
ELF section.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
These functions return
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, these functions return
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar attr
|
||||
or
|
||||
.Ar retoffset
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of a permitted kind.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formblock 3 ,
|
||||
.Xr dwarf_formflag 3 ,
|
||||
.Xr dwarf_formsdata 3 ,
|
||||
.Xr dwarf_formsig8 3 ,
|
||||
.Xr dwarf_formstring 3 ,
|
||||
.Xr dwarf_formudata 3 ,
|
||||
.Xr dwarf_hasattr 3
|
96
contrib/elftoolchain/libdwarf/dwarf_formsig8.3
Normal file
96
contrib/elftoolchain/libdwarf/dwarf_formsig8.3
Normal file
@ -0,0 +1,96 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formsig8.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd July 24, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMSIG8 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formsig8
|
||||
.Nd return the 64-bit type signature for a DWARF type
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formsig8
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Sig8 *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_formsig8
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to the 64-bit type signature that is the value of
|
||||
the attribute referenced by argument
|
||||
.Ar attr .
|
||||
The form of argument
|
||||
.Ar attr
|
||||
must be
|
||||
.Dv DW_FORM_ref_sig8 .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formsig8
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_formsig8
|
||||
may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar attr
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of a permitted kind.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formflag 3 ,
|
||||
.Xr dwarf_formref 3 ,
|
||||
.Xr dwarf_formsdata 3 ,
|
||||
.Xr dwarf_formstring 3 ,
|
||||
.Xr dwarf_formudata 3 ,
|
||||
.Xr dwarf_hasattr 3
|
||||
.Sh HISTORY
|
||||
Type signatures were added in version 4 of the DWARF specification.
|
101
contrib/elftoolchain/libdwarf/dwarf_formstring.3
Normal file
101
contrib/elftoolchain/libdwarf/dwarf_formstring.3
Normal file
@ -0,0 +1,101 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formstring.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd July 24, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMSTRING 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formstring
|
||||
.Nd return the value of a STRING class attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formstring
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "char **ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_formstring
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to a pointer to a NUL-terminated string containing
|
||||
the value of the attribute referenced by argument
|
||||
.Ar attr .
|
||||
The form of argument
|
||||
.Ar attr
|
||||
must be one of
|
||||
.Dv DW_FORM_string
|
||||
or
|
||||
.Dv DW_FORM_strp .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Ss Memory Management
|
||||
The memory area referenced by the returned pointer is managed by
|
||||
the DWARF(3) library.
|
||||
The application should not attempt to directly free this memory
|
||||
area.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_formstring
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_formstring
|
||||
may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar attr
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of a permitted kind.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formblock 3 ,
|
||||
.Xr dwarf_formref 3 ,
|
||||
.Xr dwarf_formsdata 3 ,
|
||||
.Xr dwarf_formsig8 3 ,
|
||||
.Xr dwarf_formudata 3 ,
|
||||
.Xr dwarf_hasattr 3
|
122
contrib/elftoolchain/libdwarf/dwarf_formudata.3
Normal file
122
contrib/elftoolchain/libdwarf/dwarf_formudata.3
Normal file
@ -0,0 +1,122 @@
|
||||
.\" Copyright (c) 2010 Joseph Koshy
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_formudata.3 2073 2011-10-27 03:30:47Z jkoshy $
|
||||
.\"
|
||||
.Dd June 21, 2010
|
||||
.Os
|
||||
.Dt DWARF_FORMUDATA 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_formudata ,
|
||||
.Nm dwarf_formsdata
|
||||
.Nd return the value of a CONSTANT class attribute
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_formudata
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Unsigned *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_formsdata
|
||||
.Fa "Dwarf_Attribute attr"
|
||||
.Fa "Dwarf_Signed *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions return the value associated with a DWARF attribute
|
||||
describing a constant.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_formudata
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to the value of the attribute referenced by argument
|
||||
.Ar attr ,
|
||||
treating the value as an unsigned quantity.
|
||||
Argument
|
||||
.Ar attr
|
||||
must have one of the following forms:
|
||||
.Dv DW_FORM_data1 ,
|
||||
.Dv DW_FORM_data2 ,
|
||||
.Dv DW_FORM_data4 ,
|
||||
.Dv DW_FORM_data8
|
||||
and
|
||||
.Dv DW_FORM_udata .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_formsdata
|
||||
sets the location pointed to by argument
|
||||
.Ar ret
|
||||
to the value of the attribute referenced by argument
|
||||
.Ar attr ,
|
||||
appropriately sign extended.
|
||||
Argument
|
||||
.Ar attr
|
||||
must have one of the following forms:
|
||||
.Dv DW_FORM_data1 ,
|
||||
.Dv DW_FORM_data2 ,
|
||||
.Dv DW_FORM_data4 ,
|
||||
.Dv DW_FORM_data8
|
||||
and
|
||||
.Dv DW_FORM_sdata .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
These functions return
|
||||
.Dv DW_DLV_OK
|
||||
on success.
|
||||
In case of an error, they return
|
||||
.Dv DW_DLV_ERROR
|
||||
and set argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions may fail with the following errors:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar attr
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ATTR_FORM_BAD
|
||||
The attribute referenced by argument
|
||||
.Ar attr
|
||||
was not of a permitted kind.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_attr 3 ,
|
||||
.Xr dwarf_formblock 3 ,
|
||||
.Xr dwarf_formflag 3 ,
|
||||
.Xr dwarf_formref 3 ,
|
||||
.Xr dwarf_formsig8 3 ,
|
||||
.Xr dwarf_formstring 3 ,
|
||||
.Xr dwarf_hasattr 3
|
603
contrib/elftoolchain/libdwarf/dwarf_frame.c
Normal file
603
contrib/elftoolchain/libdwarf/dwarf_frame.c
Normal file
@ -0,0 +1,603 @@
|
||||
/*-
|
||||
* Copyright (c) 2009,2011 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_frame.c 2073 2011-10-27 03:30:47Z jkoshy $");
|
||||
|
||||
int
|
||||
dwarf_get_fde_list(Dwarf_Debug dbg, Dwarf_Cie **cie_list,
|
||||
Dwarf_Signed *cie_count, Dwarf_Fde **fde_list, Dwarf_Signed *fde_count,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (dbg == NULL || cie_list == NULL || cie_count == NULL ||
|
||||
fde_list == NULL || fde_count == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (dbg->dbg_internal_reg_table == NULL) {
|
||||
if (_dwarf_frame_interal_table_init(dbg, error) != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (dbg->dbg_frame == NULL) {
|
||||
if (_dwarf_frame_section_load(dbg, error) != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
if (dbg->dbg_frame == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
if (dbg->dbg_frame->fs_ciearray == NULL ||
|
||||
dbg->dbg_frame->fs_fdearray == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*cie_list = dbg->dbg_frame->fs_ciearray;
|
||||
*cie_count = dbg->dbg_frame->fs_cielen;
|
||||
*fde_list = dbg->dbg_frame->fs_fdearray;
|
||||
*fde_count = dbg->dbg_frame->fs_fdelen;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_list_eh(Dwarf_Debug dbg, Dwarf_Cie **cie_list,
|
||||
Dwarf_Signed *cie_count, Dwarf_Fde **fde_list, Dwarf_Signed *fde_count,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (dbg == NULL || cie_list == NULL || cie_count == NULL ||
|
||||
fde_list == NULL || fde_count == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (dbg->dbg_internal_reg_table == NULL) {
|
||||
if (_dwarf_frame_interal_table_init(dbg, error) != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (dbg->dbg_eh_frame == NULL) {
|
||||
if (_dwarf_frame_section_load_eh(dbg, error) != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
if (dbg->dbg_eh_frame == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
if (dbg->dbg_eh_frame->fs_ciearray == NULL ||
|
||||
dbg->dbg_eh_frame->fs_fdearray == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*cie_list = dbg->dbg_eh_frame->fs_ciearray;
|
||||
*cie_count = dbg->dbg_eh_frame->fs_cielen;
|
||||
*fde_list = dbg->dbg_eh_frame->fs_fdearray;
|
||||
*fde_count = dbg->dbg_eh_frame->fs_fdelen;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_n(Dwarf_Fde *fdelist, Dwarf_Unsigned fde_index,
|
||||
Dwarf_Fde *ret_fde, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_FrameSec fs;
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = fdelist != NULL ? (*fdelist)->fde_dbg : NULL;
|
||||
|
||||
if (fdelist == NULL || ret_fde == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
fs = fdelist[0]->fde_fs;
|
||||
assert(fs != NULL);
|
||||
|
||||
if (fde_index >= fs->fs_fdelen) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
*ret_fde = fdelist[fde_index];
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_at_pc(Dwarf_Fde *fdelist, Dwarf_Addr pc, Dwarf_Fde *ret_fde,
|
||||
Dwarf_Addr *lopc, Dwarf_Addr *hipc, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_FrameSec fs;
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Fde fde;
|
||||
int i;
|
||||
|
||||
dbg = fdelist != NULL ? (*fdelist)->fde_dbg : NULL;
|
||||
|
||||
if (fdelist == NULL || ret_fde == NULL || lopc == NULL ||
|
||||
hipc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
fs = fdelist[0]->fde_fs;
|
||||
assert(fs != NULL);
|
||||
|
||||
for (i = 0; (Dwarf_Unsigned)i < fs->fs_fdelen; i++) {
|
||||
fde = fdelist[i];
|
||||
if (pc >= fde->fde_initloc && pc < fde->fde_initloc +
|
||||
fde->fde_adrange) {
|
||||
*ret_fde = fde;
|
||||
*lopc = fde->fde_initloc;
|
||||
*hipc = fde->fde_initloc + fde->fde_adrange - 1;
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
}
|
||||
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
|
||||
return (DW_DLV_NO_ENTRY);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_cie_of_fde(Dwarf_Fde fde, Dwarf_Cie *ret_cie, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || ret_cie == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*ret_cie = fde->fde_cie;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_range(Dwarf_Fde fde, Dwarf_Addr *low_pc, Dwarf_Unsigned *func_len,
|
||||
Dwarf_Ptr *fde_bytes, Dwarf_Unsigned *fde_byte_len, Dwarf_Off *cie_offset,
|
||||
Dwarf_Signed *cie_index, Dwarf_Off *fde_offset, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || low_pc == NULL || func_len == NULL ||
|
||||
fde_bytes == NULL || fde_byte_len == NULL || cie_offset == NULL ||
|
||||
cie_index == NULL || fde_offset == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*low_pc = fde->fde_initloc;
|
||||
*func_len = fde->fde_adrange;
|
||||
*fde_bytes = fde->fde_addr;
|
||||
*fde_byte_len = fde->fde_length;
|
||||
*cie_offset = fde->fde_cieoff;
|
||||
*cie_index = fde->fde_cie->cie_index;
|
||||
*fde_offset = fde->fde_offset;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_cie_info(Dwarf_Cie cie, Dwarf_Unsigned *bytes_in_cie,
|
||||
Dwarf_Small *version, char **augmenter, Dwarf_Unsigned *caf,
|
||||
Dwarf_Unsigned *daf, Dwarf_Half *ra, Dwarf_Ptr *initinst,
|
||||
Dwarf_Unsigned *inst_len, Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (cie == NULL || bytes_in_cie == NULL || version == NULL ||
|
||||
augmenter == NULL || caf == NULL || daf == NULL || ra == NULL ||
|
||||
initinst == NULL || inst_len == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*bytes_in_cie = cie->cie_length;
|
||||
*version = cie->cie_version;
|
||||
*augmenter = (char *) cie->cie_augment;
|
||||
*caf = cie->cie_caf;
|
||||
*daf = cie->cie_daf;
|
||||
*ra = cie->cie_ra;
|
||||
*initinst = cie->cie_initinst;
|
||||
*inst_len = cie->cie_instlen;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_cie_index(Dwarf_Cie cie, Dwarf_Signed *cie_index, Dwarf_Error *error)
|
||||
{
|
||||
|
||||
if (cie == NULL || cie_index == NULL) {
|
||||
DWARF_SET_ERROR(NULL, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*cie_index = cie->cie_index;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_instr_bytes(Dwarf_Fde fde, Dwarf_Ptr *ret_inst,
|
||||
Dwarf_Unsigned *ret_len, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || ret_inst == NULL || ret_len == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*ret_inst = fde->fde_inst;
|
||||
*ret_len = fde->fde_instlen;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
#define RL rt->rt3_rules[table_column]
|
||||
#define CFA rt->rt3_cfa_rule
|
||||
|
||||
int
|
||||
dwarf_get_fde_info_for_reg(Dwarf_Fde fde, Dwarf_Half table_column,
|
||||
Dwarf_Addr pc_requested, Dwarf_Signed *offset_relevant,
|
||||
Dwarf_Signed *register_num, Dwarf_Signed *offset, Dwarf_Addr *row_pc,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Regtable3 *rt;
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Addr pc;
|
||||
int ret;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || offset_relevant == NULL || register_num == NULL ||
|
||||
offset == NULL || row_pc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (pc_requested < fde->fde_initloc ||
|
||||
pc_requested >= fde->fde_initloc + fde->fde_adrange) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
|
||||
error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
if (table_column == dbg->dbg_frame_cfa_value) {
|
||||
/* Application ask for CFA. */
|
||||
*offset_relevant = CFA.dw_offset_relevant;
|
||||
*register_num = CFA.dw_regnum;
|
||||
*offset = CFA.dw_offset_or_block_len;
|
||||
} else {
|
||||
/* Application ask for normal registers. */
|
||||
if (table_column >= dbg->dbg_frame_rule_table_size ||
|
||||
table_column >= DW_REG_TABLE_SIZE) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_FRAME_TABLE_COL_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*offset_relevant = RL.dw_offset_relevant;
|
||||
*register_num = RL.dw_regnum;
|
||||
*offset = RL.dw_offset_or_block_len;
|
||||
}
|
||||
|
||||
*row_pc = pc;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_info_for_all_regs(Dwarf_Fde fde, Dwarf_Addr pc_requested,
|
||||
Dwarf_Regtable *reg_table, Dwarf_Addr *row_pc, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Regtable3 *rt;
|
||||
Dwarf_Addr pc;
|
||||
Dwarf_Half cfa;
|
||||
int i, ret;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || reg_table == NULL || row_pc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
assert(dbg != NULL);
|
||||
|
||||
if (pc_requested < fde->fde_initloc ||
|
||||
pc_requested >= fde->fde_initloc + fde->fde_adrange) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
|
||||
error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
/*
|
||||
* Copy the CFA rule to the column intended for holding the CFA,
|
||||
* if it's within the range of regtable.
|
||||
*/
|
||||
cfa = dbg->dbg_frame_cfa_value;
|
||||
if (cfa < DW_REG_TABLE_SIZE) {
|
||||
reg_table->rules[cfa].dw_offset_relevant =
|
||||
CFA.dw_offset_relevant;
|
||||
reg_table->rules[cfa].dw_regnum = CFA.dw_regnum;
|
||||
reg_table->rules[cfa].dw_offset = CFA.dw_offset_or_block_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy other columns.
|
||||
*/
|
||||
for (i = 0; i < DW_REG_TABLE_SIZE && i < dbg->dbg_frame_rule_table_size;
|
||||
i++) {
|
||||
|
||||
/* Do not overwrite CFA column */
|
||||
if (i == cfa)
|
||||
continue;
|
||||
|
||||
reg_table->rules[i].dw_offset_relevant =
|
||||
rt->rt3_rules[i].dw_offset_relevant;
|
||||
reg_table->rules[i].dw_regnum = rt->rt3_rules[i].dw_regnum;
|
||||
reg_table->rules[i].dw_offset =
|
||||
rt->rt3_rules[i].dw_offset_or_block_len;
|
||||
}
|
||||
|
||||
*row_pc = pc;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_info_for_reg3(Dwarf_Fde fde, Dwarf_Half table_column,
|
||||
Dwarf_Addr pc_requested, Dwarf_Small *value_type,
|
||||
Dwarf_Signed *offset_relevant, Dwarf_Signed *register_num,
|
||||
Dwarf_Signed *offset_or_block_len, Dwarf_Ptr *block_ptr,
|
||||
Dwarf_Addr *row_pc, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Regtable3 *rt;
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Addr pc;
|
||||
int ret;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || value_type == NULL || offset_relevant == NULL ||
|
||||
register_num == NULL || offset_or_block_len == NULL ||
|
||||
block_ptr == NULL || row_pc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (pc_requested < fde->fde_initloc ||
|
||||
pc_requested >= fde->fde_initloc + fde->fde_adrange) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
|
||||
error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
if (table_column >= dbg->dbg_frame_rule_table_size) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_FRAME_TABLE_COL_BAD);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
*value_type = RL.dw_value_type;
|
||||
*offset_relevant = RL.dw_offset_relevant;
|
||||
*register_num = RL.dw_regnum;
|
||||
*offset_or_block_len = RL.dw_offset_or_block_len;
|
||||
*block_ptr = RL.dw_block_ptr;
|
||||
*row_pc = pc;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_get_fde_info_for_cfa_reg3(Dwarf_Fde fde, Dwarf_Addr pc_requested,
|
||||
Dwarf_Small *value_type, Dwarf_Signed *offset_relevant,
|
||||
Dwarf_Signed *register_num, Dwarf_Signed *offset_or_block_len,
|
||||
Dwarf_Ptr *block_ptr, Dwarf_Addr *row_pc, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Regtable3 *rt;
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Addr pc;
|
||||
int ret;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || value_type == NULL || offset_relevant == NULL ||
|
||||
register_num == NULL || offset_or_block_len == NULL ||
|
||||
block_ptr == NULL || row_pc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
if (pc_requested < fde->fde_initloc ||
|
||||
pc_requested >= fde->fde_initloc + fde->fde_adrange) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
|
||||
error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
*value_type = CFA.dw_value_type;
|
||||
*offset_relevant = CFA.dw_offset_relevant;
|
||||
*register_num = CFA.dw_regnum;
|
||||
*offset_or_block_len = CFA.dw_offset_or_block_len;
|
||||
*block_ptr = CFA.dw_block_ptr;
|
||||
*row_pc = pc;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
#undef RL
|
||||
#undef CFA
|
||||
|
||||
int
|
||||
dwarf_get_fde_info_for_all_regs3(Dwarf_Fde fde, Dwarf_Addr pc_requested,
|
||||
Dwarf_Regtable3 *reg_table, Dwarf_Addr *row_pc, Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Regtable3 *rt;
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Addr pc;
|
||||
int ret;
|
||||
|
||||
dbg = fde != NULL ? fde->fde_dbg : NULL;
|
||||
|
||||
if (fde == NULL || reg_table == NULL || reg_table->rt3_rules == NULL ||
|
||||
row_pc == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
assert(dbg != NULL);
|
||||
|
||||
if (pc_requested < fde->fde_initloc ||
|
||||
pc_requested >= fde->fde_initloc + fde->fde_adrange) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_PC_NOT_IN_FDE_RANGE);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
ret = _dwarf_frame_get_internal_table(fde, pc_requested, &rt, &pc,
|
||||
error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
ret = _dwarf_frame_regtable_copy(dbg, ®_table, rt, error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
*row_pc = pc;
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
int
|
||||
dwarf_expand_frame_instructions(Dwarf_Cie cie, Dwarf_Ptr instruction,
|
||||
Dwarf_Unsigned len, Dwarf_Frame_Op **ret_oplist, Dwarf_Signed *ret_opcnt,
|
||||
Dwarf_Error *error)
|
||||
{
|
||||
Dwarf_Debug dbg;
|
||||
int ret;
|
||||
|
||||
dbg = cie != NULL ? cie->cie_dbg : NULL;
|
||||
|
||||
if (cie == NULL || instruction == NULL || len == 0 ||
|
||||
ret_oplist == NULL || ret_opcnt == NULL) {
|
||||
DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
|
||||
return (DW_DLV_ERROR);
|
||||
}
|
||||
|
||||
ret = _dwarf_frame_get_fop(dbg, instruction, len, ret_oplist, ret_opcnt,
|
||||
error);
|
||||
if (ret != DW_DLE_NONE)
|
||||
return (DW_DLV_ERROR);
|
||||
|
||||
return (DW_DLV_OK);
|
||||
}
|
||||
|
||||
Dwarf_Half
|
||||
dwarf_set_frame_rule_table_size(Dwarf_Debug dbg, Dwarf_Half value)
|
||||
{
|
||||
Dwarf_Half old_value;
|
||||
|
||||
old_value = dbg->dbg_frame_rule_table_size;
|
||||
dbg->dbg_frame_rule_table_size = value;
|
||||
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
Dwarf_Half
|
||||
dwarf_set_frame_rule_initial_value(Dwarf_Debug dbg, Dwarf_Half value)
|
||||
{
|
||||
Dwarf_Half old_value;
|
||||
|
||||
old_value = dbg->dbg_frame_rule_initial_value;
|
||||
dbg->dbg_frame_rule_initial_value = value;
|
||||
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
Dwarf_Half
|
||||
dwarf_set_frame_cfa_value(Dwarf_Debug dbg, Dwarf_Half value)
|
||||
{
|
||||
Dwarf_Half old_value;
|
||||
|
||||
old_value = dbg->dbg_frame_cfa_value;
|
||||
dbg->dbg_frame_cfa_value = value;
|
||||
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
Dwarf_Half
|
||||
dwarf_set_frame_same_value(Dwarf_Debug dbg, Dwarf_Half value)
|
||||
{
|
||||
Dwarf_Half old_value;
|
||||
|
||||
old_value = dbg->dbg_frame_same_value;
|
||||
dbg->dbg_frame_same_value = value;
|
||||
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
Dwarf_Half
|
||||
dwarf_set_frame_undefined_value(Dwarf_Debug dbg, Dwarf_Half value)
|
||||
{
|
||||
Dwarf_Half old_value;
|
||||
|
||||
old_value = dbg->dbg_frame_undefined_value;
|
||||
dbg->dbg_frame_undefined_value = value;
|
||||
|
||||
return (old_value);
|
||||
}
|
36
contrib/elftoolchain/libdwarf/dwarf_funcs.m4
Normal file
36
contrib/elftoolchain/libdwarf/dwarf_funcs.m4
Normal file
@ -0,0 +1,36 @@
|
||||
/*-
|
||||
* Copyright (c) 2009 Kai Wang
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "_libdwarf.h"
|
||||
|
||||
ELFTC_VCSID("$Id: dwarf_funcs.m4 2073 2011-10-27 03:30:47Z jkoshy $");
|
||||
|
||||
/* WARNING: GENERATED FROM __file__. */
|
||||
|
||||
divert(-1)
|
||||
include(SRCDIR`/dwarf_nametbl.m4')
|
||||
divert(0)
|
||||
MAKE_NAMETBL_API(func,Func,func,static_func)
|
258
contrib/elftoolchain/libdwarf/dwarf_get_AT_name.3
Normal file
258
contrib/elftoolchain/libdwarf/dwarf_get_AT_name.3
Normal file
@ -0,0 +1,258 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_AT_name.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd April 22, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_AT_NAME 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_ACCESS_name ,
|
||||
.Nm dwarf_get_AT_name ,
|
||||
.Nm dwarf_get_ATE_name ,
|
||||
.Nm dwarf_get_CC_name ,
|
||||
.Nm dwarf_get_CFA_name ,
|
||||
.Nm dwarf_get_CHILDREN_name ,
|
||||
.Nm dwarf_get_DS_name ,
|
||||
.Nm dwarf_get_DSC_name ,
|
||||
.Nm dwarf_get_EH_name ,
|
||||
.Nm dwarf_get_END_name ,
|
||||
.Nm dwarf_get_FORM_name ,
|
||||
.Nm dwarf_get_ID_name ,
|
||||
.Nm dwarf_get_INL_name ,
|
||||
.Nm dwarf_get_LANG_name ,
|
||||
.Nm dwarf_get_LNE_name ,
|
||||
.Nm dwarf_get_LNS_name ,
|
||||
.Nm dwarf_get_MACINFO_name ,
|
||||
.Nm dwarf_get_OP_name ,
|
||||
.Nm dwarf_get_ORD_name ,
|
||||
.Nm dwarf_get_TAG_name ,
|
||||
.Nm dwarf_get_VIRTUALITY_name ,
|
||||
.Nm dwarf_get_VIS_name
|
||||
.Nd retrieve the symbolic names of DWARF constants
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_ACCESS_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_AT_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_ATE_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_CC_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_CFA_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_CHILDREN_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_DS_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_DSC_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_EH_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_END_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_FORM_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_ID_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_INL_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_LANG_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_LNE_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_LNS_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_MACINFO_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_OP_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_ORD_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_TAG_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_VIRTUALITY_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_VIS_name
|
||||
.Fa "unsigned val"
|
||||
.Fa "char **str"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions return the symbolic name of a numeric DWARF constant.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar val
|
||||
specifies the numeric value whose symbolic name is desired.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar str
|
||||
should point to a location which will hold the returned
|
||||
NUL-terminated string containing the symbolic name of the
|
||||
specified value.
|
||||
.Pp
|
||||
The list of functions and the DWARF constants that they accept are:
|
||||
.Pp
|
||||
.Bl -tag -width ".Fn dwarf_get_VIRTUALITY_name" -compact
|
||||
.It Fn dwarf_get_ACCESS_name
|
||||
.Dv DW_ACCESS_*
|
||||
constants.
|
||||
.It Fn dwarf_get_AT_name
|
||||
.Dv DW_AT_*
|
||||
constants.
|
||||
.It Fn dwarf_get_ATE_name
|
||||
.Dv DW_ATE_*
|
||||
constants.
|
||||
.It Fn dwarf_get_CC_name
|
||||
.Dv DW_CC_*
|
||||
constants.
|
||||
.It Fn dwarf_get_CFA_name
|
||||
.Dv DW_CFA_*
|
||||
constants.
|
||||
.It Fn dwarf_get_CHILDREN_name
|
||||
.Dv DW_CHILDREN_*
|
||||
constants.
|
||||
.It Fn dwarf_get_DS_name
|
||||
.Dv DW_DS_*
|
||||
constants.
|
||||
.It Fn dwarf_get_DSC_name
|
||||
.Dv DW_DSC_*
|
||||
constants.
|
||||
.It Fn dwarf_get_EH_name
|
||||
.Dv DW_EH_PE_*
|
||||
constants.
|
||||
.It Fn dwarf_get_END_name
|
||||
.Dv DW_END_*
|
||||
constants.
|
||||
.It Fn dwarf_get_FORM_name
|
||||
.Dv DW_FORM_*
|
||||
constants.
|
||||
.It Fn dwarf_get_ID_name
|
||||
.Dv DW_ID_*
|
||||
constants.
|
||||
.It Fn dwarf_get_INL_name
|
||||
.Dv DW_INL_*
|
||||
constants.
|
||||
.It Fn dwarf_get_LANG_name
|
||||
.Dv DW_LANG_*
|
||||
constants.
|
||||
.It Fn dwarf_get_LNE_name
|
||||
.Dv DW_LNE_*
|
||||
constants.
|
||||
.It Fn dwarf_get_LNS_name
|
||||
.Dv DW_LNS_*
|
||||
constants.
|
||||
.It Fn dwarf_get_MACINFO_name
|
||||
.Dv DW_MACINFO_*
|
||||
constants.
|
||||
.It Fn dwarf_get_OP_name
|
||||
.Dv DW_OP_*
|
||||
constants.
|
||||
.It Fn dwarf_get_ORD_name
|
||||
.Dv DW_ORD_*
|
||||
constants.
|
||||
.It Fn dwarf_get_TAG_name
|
||||
.Dv DW_TAG_*
|
||||
constants.
|
||||
.It Fn dwarf_get_VIRTUALITY_name
|
||||
.Dv DW_VIRTUALITY_*
|
||||
constants.
|
||||
.It Fn dwarf_get_VIS_name
|
||||
.Dv DW_VIS_*
|
||||
constants.
|
||||
.Sh RETURN VALUES
|
||||
These functions return
|
||||
.Dv DW_DLV_OK on success.
|
||||
If the DWARF constant denoted by argument
|
||||
.Ar val
|
||||
is not recognized, these function return
|
||||
.Dv DW_DLV_NO_ENTRY .
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3
|
179
contrib/elftoolchain/libdwarf/dwarf_get_abbrev.3
Normal file
179
contrib/elftoolchain/libdwarf/dwarf_get_abbrev.3
Normal file
@ -0,0 +1,179 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_abbrev.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd March 27, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ABBREV 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_abbrev
|
||||
.Nd retrieve abbreviation information
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_abbrev
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Unsigned offset"
|
||||
.Fa "Dwarf_Abbrev *ret_abbrev"
|
||||
.Fa "Dwarf_Unsigned *length"
|
||||
.Fa "Dwarf_Unsigned *attr_count"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_abbrev
|
||||
retrieves information about an abbreviation from the DWARF abbreviations
|
||||
section,
|
||||
.Dq ".debug_abbrev" .
|
||||
Abbreviation information is returned using an opaque descriptor
|
||||
of type
|
||||
.Vt Dwarf_Abbrev .
|
||||
The returned
|
||||
.Vt Dwarf_Abbrev
|
||||
descriptor may then be passed to the other abbreviation related APIs
|
||||
in the DWARF(3) API to retrieve specific information about the
|
||||
abbreviation.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF debug context allocated using
|
||||
.Xr dwarf_init 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar offset
|
||||
should be an offset, relative to the
|
||||
.Dq ".debug_abbrev"
|
||||
section, to the start of an abbreviation entry.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret_abbrev
|
||||
should point to a location that will hold a pointer to the
|
||||
returned
|
||||
.Vt Dwarf_Abbrev
|
||||
descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar length
|
||||
should point to a location that will hold the number of bytes used
|
||||
by the abbrevation in the DWARF
|
||||
.Dq ".debug_abbrev"
|
||||
section.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar attr_count
|
||||
should point to a location that will hold the number of
|
||||
attributes in the abbrevation.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Ss Memory Management
|
||||
The memory area used for the
|
||||
.Vt Dwarf_Abbrev
|
||||
descriptor returned in argument
|
||||
.Ar ret_abbrev
|
||||
is allocated by the
|
||||
.Lb libdwarf .
|
||||
Application code should use function
|
||||
.Fn dwarf_dealloc
|
||||
with the allocation type
|
||||
.Dv DW_DLA_ABBREV
|
||||
to free the memory area when the
|
||||
.Vt Dwarf_Abbrev
|
||||
descriptor is no longer needed.
|
||||
.Ss Application Programming Notes
|
||||
The last abbreviation entry in a standard DWARF abbreviation section
|
||||
will have a special length value of 1.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_abbrev
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
It returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
if there is no abbreviation information at offset
|
||||
.Ar offset .
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_abbrev
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar ret_abbrev ,
|
||||
.Ar length
|
||||
or
|
||||
.Ar attr_count
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
There is no abbreviation information at offset
|
||||
.Ar offset .
|
||||
.El
|
||||
.Sh EXAMPLE
|
||||
To loop through all the abbreviation information associated with
|
||||
a DWARF debug context, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Abbrev ab;
|
||||
Dwarf_Off aboff;
|
||||
Dwarf_Unsigned length, attr_count;
|
||||
Dwarf_Half tag;
|
||||
Dwarf_Error de;
|
||||
int ret;
|
||||
|
||||
while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff,
|
||||
NULL, NULL, &de)) == DW_DLV_OK) {
|
||||
while ((ret = dwarf_get_abbrev(re->dbg, aboff, &ab, &length,
|
||||
&attr_count, &de)) == DW_DLV_OK) {
|
||||
if (length == 1) /* Last entry. */
|
||||
break;
|
||||
aboff += length;
|
||||
if (dwarf_get_abbrev_tag(ab, &tag, &de) != DW_DLV_OK) {
|
||||
warnx("dwarf_get_abbrev_tag failed: %s",
|
||||
dwarf_errmsg(de));
|
||||
continue;
|
||||
}
|
||||
if (ret != DW_DLV_OK)
|
||||
warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de));
|
||||
}
|
||||
if (ret == DW_DLV_ERROR)
|
||||
warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de));
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_dealloc 3 ,
|
||||
.Xr dwarf_get_abbrev_tag 3 ,
|
||||
.Xr dwarf_get_abbrev_code 3 ,
|
||||
.Xr dwarf_get_abbrev_children_flag 3 ,
|
||||
.Xr dwarf_get_abbrev_entry 3
|
100
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
Normal file
100
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
Normal file
@ -0,0 +1,100 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_abbrev_children_flag.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd March 14, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ABBREV_CHILDREN_FLAG 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_abbrev_children_flag
|
||||
.Nd return a flag indicating the presence of children
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_abbrev_children_flag
|
||||
.Fa "Dwarf_Abbrev abbrev"
|
||||
.Fa "Dwarf_Signed *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_children_flag
|
||||
retrieves a flag indicating whether the DWARF debug information entry
|
||||
associated with a DWARF abbreviation descriptor has child entries.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar abbrev
|
||||
should be a valid DWARF abbreviation descriptor, as returned by
|
||||
.Xr dwarf_get_abbrev 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret
|
||||
should point to a location which will hold the returned
|
||||
flag.
|
||||
The value returned will be one of the following:
|
||||
.Bl -tag -width ".Dv DW_CHILDREN_yes" -compact
|
||||
.It Dv DW_CHILDREN_yes
|
||||
The debugging information entry associated with the
|
||||
specified abbreviation descriptor has children.
|
||||
.It Dv DW_CHILDREN_no
|
||||
The debugging information entry associated with the
|
||||
specified abbreviation descriptor has no children.
|
||||
.El
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Pp
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_children_flag
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_children_flag
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar abbrev
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_abbrev 3 ,
|
||||
.Xr dwarf_get_abbrev_code 3 ,
|
||||
.Xr dwarf_get_abbrev_tag 3 ,
|
||||
.Xr dwarf_get_abbrev_entry 3
|
86
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
Normal file
86
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
Normal file
@ -0,0 +1,86 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_abbrev_code.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd March 13, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ABBREV_CODE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_abbrev_code
|
||||
.Nd retrieve the abbreviation code for an abbreviation
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_abbrev_code
|
||||
.Fa "Dwarf_Abbrev abbrev"
|
||||
.Fa "Dwarf_Unsigned *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_code
|
||||
retrieves the abbreviation code for the abbreviation entry descriptor
|
||||
referenced by argument
|
||||
.Ar abbrev .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret
|
||||
should point to a location which will hold the returned
|
||||
abbreviation code.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_code
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_code
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar abbrev
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_abbrev 3 ,
|
||||
.Xr dwarf_get_abbrev_tag 3 ,
|
||||
.Xr dwarf_get_abbrev_children_flag 3 ,
|
||||
.Xr dwarf_get_abbrev_entry 3
|
159
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
Normal file
159
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
Normal file
@ -0,0 +1,159 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_abbrev_entry.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd April 02, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ABBREV_ENTRY 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_abbrev_entry
|
||||
.Nd retrieve attribute information from an abbreviation descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_abbrev_entry
|
||||
.Fa "Dwarf_Abbrev abbrev"
|
||||
.Fa "Dwarf_Signed ndx"
|
||||
.Fa "Dwarf_Half *code"
|
||||
.Fa "Dwarf_Signed *form"
|
||||
.Fa "Dwarf_Off *offset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_entry
|
||||
retrieves attribute information from a DWARF abbreviation descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar abbrev
|
||||
should be a valid abbreviation descriptor, as returned by function
|
||||
.Xr dwarf_get_abbrev 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ndx
|
||||
specifies the 0-based index of the attribute.
|
||||
The total count of the attributes contained in the abbreviation
|
||||
entry can be retrieved using the function
|
||||
.Xr dwarf_get_abbrev 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar code
|
||||
should point to a location which will hold a returned
|
||||
attribute code.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar form
|
||||
should point to a location which will hold the returned
|
||||
form of the attribute.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar offset
|
||||
should point to a location which will hold a returned offset, relative
|
||||
to the
|
||||
.Dq ".debug_abbrev"
|
||||
section, for the specified attribute.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_entry
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
It returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
if the attribute index specified by argument
|
||||
.Ar ndx
|
||||
is out of range.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_entry
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar abbrev ,
|
||||
.Ar code ,
|
||||
.Ar form
|
||||
or
|
||||
.Ar offset
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
The attribute index specified by argument
|
||||
.Ar ndx
|
||||
was out of range.
|
||||
.El
|
||||
.Sh EXAMPLE
|
||||
To loop through all the attribute entries contained in the
|
||||
abbreviation section, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Abbrev ab;
|
||||
Dwarf_Off aboff, atoff;
|
||||
Dwarf_Signed form;
|
||||
Dwarf_Half attr;
|
||||
Dwarf_Unsigned length, attr_count;
|
||||
Dwarf_Error de;
|
||||
int i, ret;
|
||||
|
||||
/* ...allocate 'dbg' using dwarf_init(3) ... */
|
||||
|
||||
while ((ret = dwarf_next_cu_header(dbg, NULL, NULL, &aboff,
|
||||
NULL, NULL, &de)) == DW_DLV_OK) {
|
||||
while ((ret = dwarf_get_abbrev(dbg, aboff, &ab, &length,
|
||||
&attr_count, &de)) == DW_DLV_OK) {
|
||||
if (length == 1) /* Last entry. */
|
||||
break;
|
||||
aboff += length;
|
||||
for (i = 0; (Dwarf_Unsigned) i < attr_count; i++) {
|
||||
if (dwarf_get_abbrev_entry(ab, i,
|
||||
&attr, &form, &atoff, &de) != DW_DLV_OK) {
|
||||
warnx("dwarf_get_abbrev_entry failed:"
|
||||
" %s", dwarf_errmsg(de));
|
||||
continue;
|
||||
}
|
||||
/* .. use the retrieved information ... */
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != DW_DLV_OK)
|
||||
warnx("dwarf_get_abbrev: %s", dwarf_errmsg(de));
|
||||
}
|
||||
|
||||
if (ret == DW_DLV_ERROR)
|
||||
warnx("dwarf_next_cu_header: %s", dwarf_errmsg(de));
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_abbrev 3
|
86
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
Normal file
86
contrib/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
Normal file
@ -0,0 +1,86 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_abbrev_tag.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd March 13, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ABBREV_TAG 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_abbrev_tag
|
||||
.Nd retrieve the tag for an abbreviation
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_abbrev_tag
|
||||
.Fa "Dwarf_Abbrev abbrev"
|
||||
.Fa "Dwarf_Half *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_tag
|
||||
retrieves the tag for the abbreviation entry descriptor referenced by
|
||||
argument
|
||||
.Ar abbrev .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret
|
||||
should point to a location which will hold the returned
|
||||
abbreviation tag.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_tag
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_abbrev_tag
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar abbrev
|
||||
or
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_abbrev 3 ,
|
||||
.Xr dwarf_get_abbrev_code 3 ,
|
||||
.Xr dwarf_get_abbrev_children_flag 3 ,
|
||||
.Xr dwarf_get_abbrev_entry 3
|
82
contrib/elftoolchain/libdwarf/dwarf_get_address_size.3
Normal file
82
contrib/elftoolchain/libdwarf/dwarf_get_address_size.3
Normal file
@ -0,0 +1,82 @@
|
||||
.\" Copyright (c) 2010 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_address_size.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd April 14, 2010
|
||||
.Os
|
||||
.Dt DWARF_GET_ADDRESS_SIZE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_address_size
|
||||
.Nd return the number of bytes needed to represent an address
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_address_size
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Half *addr_size"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_address_size
|
||||
returns the size in bytes of a native address for a program object.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should denote a DWARF debug context created from a program object using
|
||||
.Xr dwarf_init 3 .
|
||||
Argument
|
||||
.Ar addr_size
|
||||
should point to a location that will hold the returned size.
|
||||
Argument
|
||||
.Ar err ,
|
||||
if non-NULL, it will be used to return error information.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_tag
|
||||
returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_address_size
|
||||
can fail with the following error:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arguments
|
||||
.Ar dbg
|
||||
or
|
||||
.Ar addr_size
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_init 3 ,
|
||||
.Xr dwarf_finish 3
|
121
contrib/elftoolchain/libdwarf/dwarf_get_arange.3
Normal file
121
contrib/elftoolchain/libdwarf/dwarf_get_arange.3
Normal file
@ -0,0 +1,121 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_arange.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd April 16, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ARANGE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_arange
|
||||
.Nd retrieve the address range descriptor for an address
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_arange
|
||||
.Fa "Dwarf_Arange *ar_list"
|
||||
.Fa "Dwarf_Unsigned ar_cnt"
|
||||
.Fa "Dwarf_Addr addr"
|
||||
.Fa "Dwarf_Arange *ret_ar"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_arange
|
||||
searches an array of
|
||||
.Vt Dwarf_Arange
|
||||
descriptors for one that covers a given address.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ar_list
|
||||
should point to an array of
|
||||
.Vt Dwarf_Arange
|
||||
descriptors.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ar_cnt
|
||||
specifies the number of
|
||||
.Vt Dwarf_Arange
|
||||
descriptors in the array pointed to by argument
|
||||
.Ar ar_list .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar addr
|
||||
specifies the address being looked up.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret_ar
|
||||
will be used to store the
|
||||
.Vt Dwarf_Arange
|
||||
descriptor that covers the given address.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_arange
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
It returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
if there is no
|
||||
.Vt Dwarf_Arange
|
||||
descriptor that covers the provided address.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_arange
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar ar_list
|
||||
or
|
||||
.Ar ret_ar
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Value of argument
|
||||
.Ar ar_cnt
|
||||
equals to 0.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
A
|
||||
.Vt Dwarf_Arange
|
||||
descriptor that covers the given address
|
||||
was not found.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_aranges 3 ,
|
||||
.Xr dwarf_get_arange_cu_header_offset 3 ,
|
||||
.Xr dwarf_get_arange_info 3 ,
|
||||
.Xr dwarf_get_cu_die_offset 3
|
134
contrib/elftoolchain/libdwarf/dwarf_get_arange_info.3
Normal file
134
contrib/elftoolchain/libdwarf/dwarf_get_arange_info.3
Normal file
@ -0,0 +1,134 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_arange_info.3 2134 2011-11-10 08:40:14Z jkoshy $
|
||||
.\"
|
||||
.Dd April 16, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ARANGE_INFO 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_arange_info
|
||||
.Nd extract address range information from a descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_arange_info
|
||||
.Fa "Dwarf_Arange ar"
|
||||
.Fa "Dwarf_Addr *start"
|
||||
.Fa "Dwarf_Unsigned *length"
|
||||
.Fa "Dwarf_Off *cu_die_offset"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_arange_info
|
||||
extracts address range information from a
|
||||
.Vt Dwarf_Arange
|
||||
descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ar
|
||||
should reference a valid
|
||||
.Vt Dwarf_Arange
|
||||
descriptor returned by function
|
||||
.Xr dwarf_get_aranges 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar start
|
||||
should point to a location which will hold the start value of the
|
||||
address range associated with the descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar length
|
||||
should point to a location which will hold the length in bytes of the
|
||||
address range associated with the descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar cu_die_offset
|
||||
should point to a location which will be set to an offset, relative to
|
||||
the
|
||||
.Dq ".debug_info"
|
||||
section, of the first debugging information entry in the compilation
|
||||
unit associated with argument
|
||||
.Ar ar .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_arange_info
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_arange_info
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar ar ,
|
||||
.Ar start ,
|
||||
.Ar length
|
||||
or
|
||||
.Ar cu_die_offset
|
||||
was NULL.
|
||||
.Sh EXAMPLE
|
||||
To loop through all the address lookup table entries, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Addr start;
|
||||
Dwarf_Arange *aranges;
|
||||
Dwarf_Off die_off;
|
||||
Dwarf_Signed i, cnt;
|
||||
Dwarf_Unsigned length;
|
||||
Dwarf_Error de;
|
||||
|
||||
if (dwarf_get_aranges(dbg, &aranges, &cnt, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_get_aranges: %s",
|
||||
dwarf_errmsg(de));
|
||||
for (i = 0; i < cnt; i++) {
|
||||
if (dwarf_get_arange_info(aranges[i], &start, &length,
|
||||
&die_off, &de) != DW_DLV_OK) {
|
||||
warnx("dwarf_get_arange_info: %s",
|
||||
dwarf_errmsg(de));
|
||||
continue;
|
||||
}
|
||||
/* Do something with the returned information. */
|
||||
}
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_arange 3 ,
|
||||
.Xr dwarf_get_aranges 3 ,
|
||||
.Xr dwarf_get_arange_cu_header_offset 3 ,
|
||||
.Xr dwarf_get_cu_die_offset 3
|
148
contrib/elftoolchain/libdwarf/dwarf_get_aranges.3
Normal file
148
contrib/elftoolchain/libdwarf/dwarf_get_aranges.3
Normal file
@ -0,0 +1,148 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_aranges.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ARANGES 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_aranges
|
||||
.Nd retrieve program address space mappings
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_aranges
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Dwarf_Arange **ar_list"
|
||||
.Fa "Dwarf_Signed *ar_cnt"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
The function
|
||||
.Fn dwarf_get_aranges
|
||||
retrieves address range information from the
|
||||
.Dq ".debug_aranges"
|
||||
DWARF section.
|
||||
Information about address ranges is returned using opaque descriptors
|
||||
of type
|
||||
.Vt Dwarf_Arange ,
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should reference a DWARF debug context allocated using
|
||||
.Xr dwarf_init 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ar_list
|
||||
should point to a location which will be set to a pointer to an array
|
||||
of
|
||||
.Vt Dwarf_Arange
|
||||
descriptors.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ar_cnt
|
||||
should point to a location which will be set to the number of
|
||||
descriptors returned.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Ss Memory Management
|
||||
The memory area used for the array returned in argument
|
||||
.Ar ar_list
|
||||
is owned by
|
||||
.Lb libdwarf .
|
||||
Application code should not attempt to directly free this area.
|
||||
Portable applications should instead use
|
||||
.Xr dwarf_dealloc 3
|
||||
to indicate that the memory area may be freed.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_aranges
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
It returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
if there is no
|
||||
.Dq ".debug_aranges"
|
||||
section associated with the specified debugging context.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_aranges
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar dbg ,
|
||||
.Ar ar_list
|
||||
or
|
||||
.Ar ar_cnt
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
The debugging context
|
||||
.Ar dbg
|
||||
did not contain a
|
||||
.Dq ".debug_aranges"
|
||||
string section.
|
||||
.El
|
||||
.Sh EXAMPLE
|
||||
To loop through all the address lookup table entries, use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Addr start;
|
||||
Dwarf_Arange *aranges;
|
||||
Dwarf_Off die_off;
|
||||
Dwarf_Signed i, cnt;
|
||||
Dwarf_Unsigned length;
|
||||
Dwarf_Error de;
|
||||
|
||||
if (dwarf_get_aranges(dbg, &aranges, &cnt, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_get_aranges: %s",
|
||||
dwarf_errmsg(de));
|
||||
|
||||
for (i = 0; i < cnt; i++) {
|
||||
if (dwarf_get_arange_info(aranges[i], &start, &length,
|
||||
&die_off, &de) != DW_DLV_OK) {
|
||||
warnx("dwarf_get_arange_info: %s",
|
||||
dwarf_errmsg(de));
|
||||
continue;
|
||||
}
|
||||
/* Do something with the returned information. */
|
||||
}
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_arange 3 ,
|
||||
.Xr dwarf_get_arange_cu_header_offset 3 ,
|
||||
.Xr dwarf_get_arange_info 3 ,
|
||||
.Xr dwarf_get_cu_die_offset 3
|
86
contrib/elftoolchain/libdwarf/dwarf_get_cie_index.3
Normal file
86
contrib/elftoolchain/libdwarf/dwarf_get_cie_index.3
Normal file
@ -0,0 +1,86 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_cie_index.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd May 22, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_CIE_INDEX 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_cie_index
|
||||
.Nd retrieve the index of a CIE descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_cie_index
|
||||
.Fa "Dwarf_Cie cie"
|
||||
.Fa "Dwarf_Signed *cie_index"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_cie_index
|
||||
retrieves the zero-based index of a given CIE descriptor in the array
|
||||
of CIE descriptors returned by the functions
|
||||
.Xr dwarf_get_fde_list 3
|
||||
and
|
||||
.Xr dwarf_get_fde_list_eh 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar cie
|
||||
should reference a valid DWARF CIE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar cie_index
|
||||
should point to a location that will hold the returned index.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_cie_index
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_cie_index
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arugments
|
||||
.Ar cie
|
||||
or
|
||||
.Ar cie_index
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_cie_info 3 ,
|
||||
.Xr dwarf_get_cie_of_fde 3 ,
|
||||
.Xr dwarf_get_fde_list 3 ,
|
||||
.Xr dwarf_get_fde_list_eh 3
|
150
contrib/elftoolchain/libdwarf/dwarf_get_cie_info.3
Normal file
150
contrib/elftoolchain/libdwarf/dwarf_get_cie_info.3
Normal file
@ -0,0 +1,150 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_cie_info.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd May 29, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_CIE_INFO 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_cie_info
|
||||
.Nd retrieve information associated with a CIE descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_cie_info
|
||||
.Fa "Dwarf_Cie cie"
|
||||
.Fa "Dwarf_Unsigned *cie_byte_len"
|
||||
.Fa "Dwarf_Small *version"
|
||||
.Fa "char **augmentation"
|
||||
.Fa "Dwarf_Unsigned *caf"
|
||||
.Fa "Dwarf_Unsigned *daf"
|
||||
.Fa "Dwarf_Half *ra"
|
||||
.Fa "Dwarf_Ptr *init_inst"
|
||||
.Fa "Dwarf_Unsigned *inst_len"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_cie_info
|
||||
retrieves the information associated with a given CIE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar cie
|
||||
should reference a valid DWARF CIE descriptor, such as would be
|
||||
returned by function
|
||||
.Xr dwarf_get_cie_of_fde 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar cie_byte_len
|
||||
should point to a location that will hold the length in bytes of
|
||||
the CIE descriptor itself.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar version
|
||||
should point to a location that will hold the version number of
|
||||
the CIE descriptor.
|
||||
.Pp
|
||||
Arugment
|
||||
.Ar augmentation
|
||||
should point to a location that will be set to a pointer to a
|
||||
NUL-terminated string containing augmentation data encoded as UTF-8.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar caf
|
||||
should point to a location that will hold the code alignment
|
||||
factor recorded in the CIE descriptor.
|
||||
.Pp
|
||||
Arugment
|
||||
.Ar daf
|
||||
should point to a location that will hold the data alignment
|
||||
factor recorded in the CIE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ra
|
||||
should point to a location that will hold the return address
|
||||
recorded in the CIE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar init_inst
|
||||
should point to a location that will be set to a pointer to an array
|
||||
of bytes containing the initial instructions associated with the CIE
|
||||
descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar inst_len
|
||||
should point to a location that will hold the length in bytes
|
||||
of the initial instructions returned in argument
|
||||
.Ar init_inst .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_cie_info
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_cie_info
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar cie ,
|
||||
.Ar cie_byte_len ,
|
||||
.Ar version ,
|
||||
.Ar augmentation ,
|
||||
.Ar caf ,
|
||||
.Ar daf ,
|
||||
.Ar ra ,
|
||||
.Ar init_inst
|
||||
or
|
||||
.Ar inst_len
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_cie_index 3 ,
|
||||
.Xr dwarf_get_cie_of_fde 3 ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg3 3 ,
|
||||
.Xr dwarf_get_fde_instr_bytes 3 ,
|
||||
.Xr dwarf_get_fde_list 3 ,
|
||||
.Xr dwarf_get_fde_list_eh 3 ,
|
||||
.Xr dwarf_get_fde_n 3 ,
|
||||
.Xr dwarf_get_fde_range 3
|
88
contrib/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
Normal file
88
contrib/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
Normal file
@ -0,0 +1,88 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_cie_of_fde.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd May 22, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_CIE_OF_FDE 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_cie_of_fde
|
||||
.Nd retrieve CIE descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_cie_of_fde
|
||||
.Fa "Dwarf_Fde fde"
|
||||
.Fa "Dwarf_Cie *ret_cie"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_cie_of_fde
|
||||
retrieves the CIE descriptor associated with a given FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a valid FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret_cie
|
||||
should point to a location that will hold the returned CIE
|
||||
descriptor.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_cie_of_fde
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_cie_of_fde
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Either of arugments
|
||||
.Ar fde
|
||||
or
|
||||
.Ar ret_cie
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_cie_info 3 ,
|
||||
.Xr dwarf_get_cie_index 3 ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_n 3
|
103
contrib/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
Normal file
103
contrib/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
Normal file
@ -0,0 +1,103 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_cu_die_offset.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd April 10, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_CU_DIE_OFFSET 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_arange_cu_header_offset ,
|
||||
.Nm dwarf_get_cu_die_offset
|
||||
.Nd retrieve compilation unit offsets
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_arange_cu_header_offset
|
||||
.Fa "Dwarf_Arange ar"
|
||||
.Fa "Dwarf_Off *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo dwarf_get_cu_die_offset
|
||||
.Fa "Dwarf_Arange ar"
|
||||
.Fa "Dwarf_Off *ret"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
These functions retrieve the offsets, relative to the
|
||||
.Dq ".debug_info"
|
||||
DWARF section, of the debugging information entries describing the
|
||||
compilation unit associated with a
|
||||
.Vt Dwarf_Arange
|
||||
descriptor.
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_get_arange_cu_header_offset
|
||||
retrieves the offset of the compilation unit header associated with
|
||||
argument
|
||||
.Ar ar ,
|
||||
and stores it in the location pointed to by argument
|
||||
.Ar ret .
|
||||
.Pp
|
||||
Function
|
||||
.Fn dwarf_get_cu_die_offset
|
||||
retrieves the offset of the debugging information entry for the
|
||||
compilation unit associated with argument
|
||||
.Ar ar ,
|
||||
and stores it in the location pointed to by argument
|
||||
.Ar ret .
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, these functions will use it to store error information,
|
||||
in case of an error.
|
||||
.Sh RETURN VALUES
|
||||
On success, these functions returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, they return
|
||||
.Dv DW_DLV_ERROR
|
||||
and set the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
These functions may fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar ar
|
||||
was not a valid
|
||||
.Vt Dwarf_Arange
|
||||
descriptor.
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
Argument
|
||||
.Ar ret
|
||||
was NULL.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_arange 3 ,
|
||||
.Xr dwarf_get_arange_info 3 ,
|
||||
.Xr dwarf_get_aranges 3
|
103
contrib/elftoolchain/libdwarf/dwarf_get_elf.3
Normal file
103
contrib/elftoolchain/libdwarf/dwarf_get_elf.3
Normal file
@ -0,0 +1,103 @@
|
||||
.\" Copyright (c) 2009 Joseph Koshy. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" This software is provided by Joseph Koshy ``as is'' and
|
||||
.\" any express or implied warranties, including, but not limited to, the
|
||||
.\" implied warranties of merchantability and fitness for a particular purpose
|
||||
.\" are disclaimed. in no event shall Joseph Koshy be liable
|
||||
.\" for any direct, indirect, incidental, special, exemplary, or consequential
|
||||
.\" damages (including, but not limited to, procurement of substitute goods
|
||||
.\" or services; loss of use, data, or profits; or business interruption)
|
||||
.\" however caused and on any theory of liability, whether in contract, strict
|
||||
.\" liability, or tort (including negligence or otherwise) arising in any way
|
||||
.\" out of the use of this software, even if advised of the possibility of
|
||||
.\" such damage.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_elf.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_ELF 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_elf
|
||||
.Nd retrieve the
|
||||
.Vt Elf
|
||||
descriptor associated with a
|
||||
.Vt Dwarf_Debug
|
||||
instance
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_elf
|
||||
.Fa "Dwarf_Debug dbg"
|
||||
.Fa "Elf **elf"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_elf
|
||||
returns the
|
||||
.Vt Elf
|
||||
descriptor associated with a
|
||||
.Vt Dwarf_Debug
|
||||
instance.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar dbg
|
||||
should be a handle to a valid
|
||||
.Vt Dwarf_Debug
|
||||
instance returned by a prior call to
|
||||
.Xr dwarf_init 3
|
||||
or
|
||||
.Xr dwarf_elf_init 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar elf
|
||||
points a location into which a handle to an
|
||||
.Vt Elf
|
||||
descriptor will be written.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar err
|
||||
is used to record error information in case of failure.
|
||||
.Sh RETURN VALUES
|
||||
On success, function
|
||||
.Fn dwarf_get_elf
|
||||
returns
|
||||
.Dv DW_DLV_OK .
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets argument
|
||||
.Ar err .
|
||||
.Sh EXAMPLES
|
||||
To retrieve the
|
||||
.Vt Elf
|
||||
instance associated with a
|
||||
.Vt Dwarf_Debug
|
||||
instance use:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Debug dbg;
|
||||
Dwarf_Error de;
|
||||
Elf *elf;
|
||||
|
||||
\&... allocate dbg using dwarf_init() etc ...
|
||||
|
||||
if (dwarf_get_elf(dbg, &elf, &de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_get_elf: %s", dwarf_errmsg(de));
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_errmsg 3 ,
|
||||
.Xr dwarf_init 3 ,
|
||||
.Xr dwarf_finish 3 ,
|
||||
.Xr elf 3
|
125
contrib/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
Normal file
125
contrib/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
Normal file
@ -0,0 +1,125 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_at_pc.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd May 22, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_FDE_AT_PC 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_fde_at_pc
|
||||
.Nd retrieve the FDE descriptor for an address
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_fde_at_pc
|
||||
.Fa "Dwarf_Fde *fdelist"
|
||||
.Fa "Dwarf_Addr pc"
|
||||
.Fa "Dwarf_Fde *ret_fde"
|
||||
.Fa "Dwarf_Addr *lopc"
|
||||
.Fa "Dwarf_Addr *hipc"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_fde_at_pc
|
||||
searches the provided array of DWARF FDE descriptors for a descriptor
|
||||
covering a given program counter address.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fdelist
|
||||
should point to an array of FDE descriptors, as returned by the functions
|
||||
.Xr dwarf_get_fde_list 3
|
||||
or
|
||||
.Xr dwarf_get_fde_list_eh 3 .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc
|
||||
should contain the program counter address being looked up.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar ret_fde
|
||||
should point to a location that will hold the returned FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar lopc
|
||||
should point to a location that will be set to the lowest address
|
||||
covered by the returned FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar hipc
|
||||
should point to a location that will be set to the highest address
|
||||
covered by the returned FDE descriptor.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_fde_at_pc
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
It returns
|
||||
.Dv DW_DLV_NO_ENTRY
|
||||
if a FDE descriptor that covers the address specified by argument
|
||||
.Ar pc
|
||||
is not found.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_fde_at_pc
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Va fdelist ,
|
||||
.Va ret_fde ,
|
||||
.Va lopc ,
|
||||
or
|
||||
.Va hipc
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_NO_ENTRY
|
||||
These was no FDE descriptor covering the address specified by argument
|
||||
.Ar pc .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_cie_of_fde 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg3 3 ,
|
||||
.Xr dwarf_get_fde_instr_bytes 3 ,
|
||||
.Xr dwarf_get_fde_list 3 ,
|
||||
.Xr dwarf_get_fde_list_eh 3 ,
|
||||
.Xr dwarf_get_fde_n 3 ,
|
||||
.Xr dwarf_get_fde_range 3
|
155
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
Normal file
155
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
Normal file
@ -0,0 +1,155 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_info_for_all_regs.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd June 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_FDE_INFO_FOR_ALL_REGS 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_fde_info_for_all_regs
|
||||
.Nd retrieve register rule row
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_fde_info_for_all_regs
|
||||
.Fa "Dwarf_Fde fde"
|
||||
.Fa "Dwarf_Addr pc"
|
||||
.Fa "Dwarf_Regtable *reg_table"
|
||||
.Fa "Dwarf_Addr *row_pc"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_all_regs
|
||||
retrieves a row from the register rule table associated with the given
|
||||
FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a valid DWARF FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc
|
||||
should hold the program counter address to be used to locate the
|
||||
desired table row.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar reg_table
|
||||
should point to a
|
||||
.Vt Dwarf_Regtable
|
||||
descriptor which will hold the returned table row of register rules.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar row_pc
|
||||
should point to a location which will be set to the lowest program
|
||||
counter address associated with the table row.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Pp
|
||||
The
|
||||
.Vt Dwarf_Regtable
|
||||
descriptor is defined in the header file
|
||||
.In libdwarf.h :
|
||||
.Bd -literal -offset indent
|
||||
typedef struct {
|
||||
struct {
|
||||
Dwarf_Small dw_offset_relevant;
|
||||
Dwarf_Half dw_regnum;
|
||||
Dwarf_Addr dw_offset;
|
||||
} rules[DW_REG_TABLE_SIZE];
|
||||
} Dwarf_Regtable;
|
||||
.Ed
|
||||
.Pp
|
||||
For each of the register rules returned,
|
||||
the
|
||||
.Va dw_offset_relevant
|
||||
field is set to 1 if the register rule has a offset value. The
|
||||
.Va dw_regnum
|
||||
field is set to the register number associated with the regsiter rule.
|
||||
The
|
||||
.Va dw_offset
|
||||
field is set to the offset value associated with the register rule.
|
||||
.Pp
|
||||
The number of register columns returned is either the constant
|
||||
value
|
||||
.Dv DW_REG_TABLE_SIZE as defined
|
||||
in the header file
|
||||
.In libdwarf.h ,
|
||||
or the value set by function
|
||||
.Xr dwarf_set_frame_rule_table_size 3 ,
|
||||
whichever is smaller.
|
||||
.Ss COMPATIBILITY
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_all_regs
|
||||
is deprecated since it only supports DWARF2 frame sections.
|
||||
Applications should instead use function
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3
|
||||
which supports both DWARF2 and DWARF3 frame sections.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_all_regs
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_all_regs
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar fde ,
|
||||
.Ar reg_table
|
||||
or
|
||||
.Ar row_pc
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
|
||||
The program counter value provided in argument
|
||||
.Ar pc
|
||||
did not fall in the range covered by argument
|
||||
.Ar fde .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg3 3 ,
|
||||
.Xr dwarf_get_fde_n 3 ,
|
||||
.Xr dwarf_set_frame_cfa_value 3 ,
|
||||
.Xr dwarf_set_frame_rule_table_size 3 ,
|
||||
.Xr dwarf_set_frame_rule_initial_value 3 ,
|
||||
.Xr dwarf_set_frame_same_value 3 ,
|
||||
.Xr dwarf_set_frame_undefined_value 3
|
183
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
Normal file
183
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
Normal file
@ -0,0 +1,183 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_info_for_all_regs3.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd June 26, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_FDE_INFO_FOR_ALL_REGS3 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_fde_info_for_all_regs3
|
||||
.Nd retrieve register rule row
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_fde_info_for_all_regs3
|
||||
.Fa "Dwarf_Fde fde"
|
||||
.Fa "Dwarf_Addr pc"
|
||||
.Fa "Dwarf_Regtable3 *reg_table"
|
||||
.Fa "Dwarf_Addr *row_pc"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_all_regs3
|
||||
retrieves a row from the register rule table associated with the given
|
||||
FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a valid DWARF FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc
|
||||
should hold the program counter address to be used to locate the
|
||||
desired table row.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar reg_table
|
||||
should point to a
|
||||
.Vt Dwarf_Regtable3
|
||||
descriptor which will hold the returned table row of register rules.
|
||||
The
|
||||
.Vt Dwarf_Regtable3
|
||||
descriptor is defined in the header file
|
||||
.In libdwarf.h :
|
||||
.Bd -literal -offset indent
|
||||
typedef struct {
|
||||
Dwarf_Small dw_offset_relevant;
|
||||
Dwarf_Small dw_value_type;
|
||||
Dwarf_Half dw_regnum;
|
||||
Dwarf_Unsigned dw_offset_or_block_len;
|
||||
Dwarf_Ptr dw_block_ptr;
|
||||
} Dwarf_Regtable_Entry3;
|
||||
|
||||
typedef struct {
|
||||
Dwarf_Regtable_Entry3 rt3_cfa_rule;
|
||||
Dwarf_Half rt3_reg_table_size;
|
||||
Dwarf_Regtable_Entry3 *rt3_rules;
|
||||
} Dwarf_Regtable3;
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Va rt3_reg_table_size
|
||||
field specifies the maximum number of register rule columns to be
|
||||
returned, and should be set by the application before calling the
|
||||
function.
|
||||
The
|
||||
.Va rt3_rules
|
||||
field should point to a memory arena allocated by the application with
|
||||
space for at least
|
||||
.Vt rt3_reg_table_size
|
||||
descriptors of type
|
||||
.Vt Dwarf_Regtable_Entry3 .
|
||||
.Pp
|
||||
On a successful execution of this function, the
|
||||
.Va rt3_cfa_rule
|
||||
field will be set to the CFA register rule associated with the table
|
||||
row, and the
|
||||
.Va rt3_rules
|
||||
array will hold the returned register rules contained in the table row.
|
||||
.Pp
|
||||
For each register rule descriptor returned,
|
||||
the
|
||||
.Va dw_offset_relevant
|
||||
field will be set to 1 if the register rule has a offset value,
|
||||
the
|
||||
.Va dw_value_type
|
||||
field will be set to the type code of the register rule and the
|
||||
.Va dw_regnum
|
||||
field will be set to the register number associated with the register rule.
|
||||
If the register rule is of type
|
||||
.Dv DW_EXPR_OFFSET
|
||||
or
|
||||
.Dv DW_EXPR_VAL_OFFSET ,
|
||||
the
|
||||
.Va dw_offset_or_block_len
|
||||
field will be set to the offset value associated with the register rule.
|
||||
If the type is
|
||||
.Dv DW_EXPR_EXPRESSION
|
||||
or
|
||||
.Dv DW_EXPR_VAL_EXPRESSION ,
|
||||
the
|
||||
.Va dw_offset_or_block_len
|
||||
field will be set to the length in bytes of the DWARF expression block
|
||||
associated with the register rule.
|
||||
The
|
||||
.Va dw_block_ptr
|
||||
field will be set to a pointer to the content of the DWARF expression block
|
||||
associated with the register rule.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar row_pc
|
||||
should point to a location which will be set to the lowest program
|
||||
counter address associated with the table row.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to store error information in case of an
|
||||
error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_all_regs3
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_all_regs3
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar fde ,
|
||||
.Ar reg_table
|
||||
or
|
||||
.Ar row_pc
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
|
||||
The program counter value provided in argument
|
||||
.Ar pc
|
||||
did not fall in the range covered by argument
|
||||
.Ar fde .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs 3 ,
|
||||
.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg3 3 ,
|
||||
.Xr dwarf_get_fde_n 3 ,
|
||||
.Xr dwarf_set_frame_cfa_value 3 ,
|
||||
.Xr dwarf_set_frame_rule_table_size 3 ,
|
||||
.Xr dwarf_set_frame_rule_initial_value 3 ,
|
||||
.Xr dwarf_set_frame_same_value 3 ,
|
||||
.Xr dwarf_set_frame_undefined_value 3
|
171
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
Normal file
171
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
Normal file
@ -0,0 +1,171 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_info_for_cfa_reg3.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd June 12, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_FDE_INFO_FOR_CFA_REGS3 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_fde_info_for_cfa_regs3
|
||||
.Nd retrieve a CFA register rule
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_fde_info_for_cfa_regs3
|
||||
.Fa "Dwarf_Fde fde"
|
||||
.Fa "Dwarf_Addr pc"
|
||||
.Fa "Dwarf_Small *type"
|
||||
.Fa "Dwarf_Signed *offset_relevant"
|
||||
.Fa "Dwarf_Signed *register_num"
|
||||
.Fa "Dwarf_Signed *offset_or_block_len"
|
||||
.Fa "Dwarf_Ptr *block_ptr"
|
||||
.Fa "Dwarf_Addr *row_pc"
|
||||
.Fa "Dwarf_Error *err"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_cfa_reg3
|
||||
retrieves the CFA register rule for a given program counter address
|
||||
from the register rule table associated with an FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a valid DWARF FDE descriptor.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc
|
||||
should hold the program counter address to be used to locate the
|
||||
desired register rule row.
|
||||
.Pp
|
||||
On successful execution,
|
||||
.Fn dwarf_get_fde_info_for_cfa_reg3
|
||||
stores information about the CFA register rule found into the locations
|
||||
pointed to by the arguments
|
||||
.Ar type ,
|
||||
.Ar offset_relevant ,
|
||||
.Ar register_num ,
|
||||
.Ar offset_or_block_len ,
|
||||
.Ar block_ptr
|
||||
and
|
||||
.Ar row_pc .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar type
|
||||
should point to a location which will hold the type code of the
|
||||
register rule found.
|
||||
The returned value is one of the
|
||||
.Dv DW_EXPR_*
|
||||
contants defined in the header file
|
||||
.In libdwarf.h .
|
||||
.Pp
|
||||
If there is an offset value associated with the CFA register rule,
|
||||
the location pointed to by argument
|
||||
.Ar offset_relevant
|
||||
will be set to 1.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar register_num
|
||||
should point to a location which will hold the register number associated
|
||||
with the CFA register rule.
|
||||
.Pp
|
||||
If the CFA register rule is of type
|
||||
.Dv DW_EXPR_OFFSET
|
||||
or
|
||||
.Dv DW_EXPR_VAL_OFFSET ,
|
||||
the location pointed to by argument
|
||||
.Ar offset_or_block_len
|
||||
will be set to the offset value associated with the register rule,
|
||||
or to 0 if the register rule does not have an offset value.
|
||||
If the type code is
|
||||
.Dv DW_EXPR_EXPRESSION
|
||||
or
|
||||
.Dv DW_EXPR_VAL_EXPRESSION ,
|
||||
the location pointed to by argument
|
||||
.Ar offset_or_block_len
|
||||
will be set to the length in bytes of the DWARF expression block
|
||||
associated with the register rule.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar block_ptr
|
||||
should point to a location which will be set to a pointer to the
|
||||
content of the DWARF expression block associated with the CFA register
|
||||
rule.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar row_pc
|
||||
should point to a location which will be set to the lowest program
|
||||
counter address associated with the register rule found.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_cfa_reg3
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_cfa_reg3
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar block_ptr ,
|
||||
.Ar fde ,
|
||||
.Ar offset_or_block_len ,
|
||||
.Ar offset_relevant ,
|
||||
.Ar register_num ,
|
||||
.Ar row_pc ,
|
||||
or
|
||||
.Ar type
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
|
||||
The program counter value provided in argument
|
||||
.Ar pc
|
||||
did not fall in the range covered by argument
|
||||
.Ar fde .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg3 3 ,
|
||||
.Xr dwarf_get_fde_n 3 ,
|
||||
.Xr dwarf_set_frame_cfa_value 3 ,
|
||||
.Xr dwarf_set_frame_rule_table_size 3 ,
|
||||
.Xr dwarf_set_frame_rule_initial_value 3 ,
|
||||
.Xr dwarf_set_frame_same_value 3 ,
|
||||
.Xr dwarf_set_frame_undefined_value 3
|
156
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
Normal file
156
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
Normal file
@ -0,0 +1,156 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_info_for_reg.3 2071 2011-10-27 03:20:00Z jkoshy $
|
||||
.\"
|
||||
.Dd June 4, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_FDE_INFO_FOR_REG 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_fde_info_for_reg
|
||||
.Nd retrieve register rule
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_fde_info_for_reg
|
||||
.Fa "Dwarf_Fde fde"
|
||||
.Fa "Dwarf_Half table_column"
|
||||
.Fa "Dwarf_Addr pc"
|
||||
.Fa "Dwarf_Signed *offset_relevant"
|
||||
.Fa "Dwarf_Signed *register_num"
|
||||
.Fa "Dwarf_Signed *offset"
|
||||
.Fa "Dwarf_Addr *row_pc"
|
||||
.Fa "Dwarf_Error *error"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg
|
||||
retrieves a register rule from the register rule table associated with
|
||||
a given FDE descriptor, given a program counter address and rule
|
||||
column number.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a valid DWARF FDE descriptor.
|
||||
.Pp
|
||||
Arugment
|
||||
.Ar table_column
|
||||
should hold the column number of the register rule desired.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc
|
||||
should hold the program counter address to be used to locate the
|
||||
desired register rule row.
|
||||
.Pp
|
||||
On successful execution,
|
||||
.Fn dwarf_get_fde_info_for_reg
|
||||
stores information about the register rule found into the locations
|
||||
pointed to by the arguments
|
||||
.Ar offset_relevant ,
|
||||
.Ar register_num ,
|
||||
.Ar offset
|
||||
and
|
||||
.Ar row_pc .
|
||||
.Pp
|
||||
If there is an offset value associated with the register rule,
|
||||
the location pointed to by argument
|
||||
.Ar offset_relevant
|
||||
will be set to 1.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar register_num
|
||||
should point to a location which will hold the register number associated
|
||||
with the register rule.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar offset
|
||||
should point to a location which will be set to the offset value
|
||||
associated with the register rule, or to 0 if the register rule
|
||||
does not have an offset value.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar row_pc
|
||||
should point to a location which will be set to the lowest program
|
||||
counter address associated with the register rule found.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Ss COMPATIBILITY
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg
|
||||
is deprecated since it only supports DWARF2 frame sections.
|
||||
Applications should instead use function
|
||||
.Xr dwarf_get_fde_info_for_reg3 3
|
||||
which supports both DWARF2 and DWARF3 frame sections.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_FRAME_TABLE_COL_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar fde ,
|
||||
.Ar offset_relevant ,
|
||||
.Ar register_num ,
|
||||
.Ar offset
|
||||
or
|
||||
.Ar row_pc
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_FRAME_TABLE_COL_BAD
|
||||
The column number provided in argument
|
||||
.Ar table_column
|
||||
was too large.
|
||||
.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
|
||||
The program counter value provided in argument
|
||||
.Ar pc
|
||||
did not fall in the range covered by argument
|
||||
.Ar fde .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg3 3 ,
|
||||
.Xr dwarf_get_fde_n 3 ,
|
||||
.Xr dwarf_set_frame_cfa_value 3 ,
|
||||
.Xr dwarf_set_frame_rule_table_size 3 ,
|
||||
.Xr dwarf_set_frame_rule_initial_value 3 ,
|
||||
.Xr dwarf_set_frame_same_value 3 ,
|
||||
.Xr dwarf_set_frame_undefined_value 3
|
214
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
Normal file
214
contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
Normal file
@ -0,0 +1,214 @@
|
||||
.\" Copyright (c) 2011 Kai Wang
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: dwarf_get_fde_info_for_reg3.3 2122 2011-11-09 15:35:14Z jkoshy $
|
||||
.\"
|
||||
.Dd November 9, 2011
|
||||
.Os
|
||||
.Dt DWARF_GET_FDE_INFO_FOR_REG3 3
|
||||
.Sh NAME
|
||||
.Nm dwarf_get_fde_info_for_reg3
|
||||
.Nd retrieve register rule
|
||||
.Sh LIBRARY
|
||||
.Lb libdwarf
|
||||
.Sh SYNOPSIS
|
||||
.In libdwarf.h
|
||||
.Ft int
|
||||
.Fo dwarf_get_fde_info_for_reg3
|
||||
.Fa "Dwarf_Fde fde"
|
||||
.Fa "Dwarf_Half table_column"
|
||||
.Fa "Dwarf_Addr pc"
|
||||
.Fa "Dwarf_Small *type"
|
||||
.Fa "Dwarf_Signed *offset_relevant"
|
||||
.Fa "Dwarf_Signed *register_num"
|
||||
.Fa "Dwarf_Signed *offset_or_block_len"
|
||||
.Fa "Dwarf_Ptr *block_ptr"
|
||||
.Fa "Dwarf_Addr *row_pc"
|
||||
.Fa "Dwarf_Error *error"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg3
|
||||
retrieves a register rule from the register rule table associated with
|
||||
a given FDE descriptor, given a program counter address and rule
|
||||
column number.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar fde
|
||||
should reference a valid DWARF FDE descriptor.
|
||||
.Pp
|
||||
Arugment
|
||||
.Ar table_column
|
||||
should hold the column number of the register rule desired.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar pc
|
||||
should hold the program counter address to be used to locate the
|
||||
desired register rule row.
|
||||
.Pp
|
||||
On successful execution,
|
||||
.Fn dwarf_get_fde_info_for_reg3
|
||||
stores information about the register rule found into the locations
|
||||
pointed to by the arguments
|
||||
.Ar type ,
|
||||
.Ar offset_relevant ,
|
||||
.Ar register_num ,
|
||||
.Ar offset_or_block_len ,
|
||||
.Ar block_ptr
|
||||
and
|
||||
.Ar row_pc .
|
||||
.Pp
|
||||
Argument
|
||||
.Ar type
|
||||
should point to a location which will hold the type code of the
|
||||
register rule found.
|
||||
The returned value is one of the
|
||||
.Dv DW_EXPR_*
|
||||
contants defined in the header file
|
||||
.In libdwarf.h .
|
||||
.Pp
|
||||
If there is an offset value associated with the register rule,
|
||||
the location pointed to by argument
|
||||
.Ar offset_relevant
|
||||
will be set to 1.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar register_num
|
||||
should point to a location which will hold the register number associated
|
||||
with the register rule.
|
||||
.Pp
|
||||
If the register rule is of type
|
||||
.Dv DW_EXPR_OFFSET
|
||||
or
|
||||
.Dv DW_EXPR_VAL_OFFSET ,
|
||||
the location pointed to by argument
|
||||
.Ar offset_or_block_len
|
||||
will be set to the offset value associated with the register rule,
|
||||
or to 0 if the register rule does not have an offset value.
|
||||
If the type code is
|
||||
.Dv DW_EXPR_EXPRESSION
|
||||
or
|
||||
.Dv DW_EXPR_VAL_EXPRESSION ,
|
||||
the location pointed to by argument
|
||||
.Ar offset_or_block_len
|
||||
will be set to the length in bytes of the DWARF expression block
|
||||
associated with the register rule.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar block_ptr
|
||||
should point to a location which will be set to a pointer to the
|
||||
content of the DWARF expression block associated with the register
|
||||
rule.
|
||||
.Pp
|
||||
Argument
|
||||
.Ar row_pc
|
||||
should point to a location which will be set to the lowest program
|
||||
counter address associated with the register rule found.
|
||||
.Pp
|
||||
If argument
|
||||
.Ar err
|
||||
is not NULL, it will be used to return an error descriptor in case
|
||||
of an error.
|
||||
.Sh RETURN VALUES
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg3
|
||||
returns
|
||||
.Dv DW_DLV_OK
|
||||
when it succeeds.
|
||||
In case of an error, it returns
|
||||
.Dv DW_DLV_ERROR
|
||||
and sets the argument
|
||||
.Ar err .
|
||||
.Sh ERRORS
|
||||
Function
|
||||
.Fn dwarf_get_fde_info_for_reg3
|
||||
can fail with:
|
||||
.Bl -tag -width ".Bq Er DW_DLE_FRAME_TABLE_COL_BAD"
|
||||
.It Bq Er DW_DLE_ARGUMENT
|
||||
One of the arguments
|
||||
.Ar block_ptr ,
|
||||
.Ar fde ,
|
||||
.Ar offset_or_block_len ,
|
||||
.Ar offset_relevant ,
|
||||
.Ar register_num ,
|
||||
.Ar row_pc ,
|
||||
or
|
||||
.Ar type
|
||||
was NULL.
|
||||
.It Bq Er DW_DLE_FRAME_TABLE_COL_BAD
|
||||
The column number provided in argument
|
||||
.Ar table_column
|
||||
was too large.
|
||||
.It Bq Er DW_DLE_PC_NOT_IN_FDE_RANGE
|
||||
The program counter value provided in argument
|
||||
.Ar pc
|
||||
did not fall in the range covered by argument
|
||||
.Ar fde .
|
||||
.El
|
||||
.Sh EXAMPLE
|
||||
To retrieve the register rules at column 3 from a rule table
|
||||
associated with a FDE descriptor:
|
||||
.Bd -literal -offset indent
|
||||
Dwarf_Fde fde;
|
||||
Dwarf_Off fde_offset, cie_offset;
|
||||
Dwarf_Unsigned func_len, fde_length;
|
||||
Dwarf_Signed cie_index, offset_relevant, register_num;
|
||||
Dwarf_Signed offset_or_block_len;
|
||||
Dwarf_Addr low_pc, row_pc;
|
||||
Dwarf_Ptr fde_addr, block_ptr;
|
||||
Dwarf_Small type;
|
||||
Dwarf_Error de;
|
||||
|
||||
/* ... assuming `fde` references a valid FDE descriptor... */
|
||||
if (dwarf_get_fde_range(fde, &low_pc, &func_len, &fde_addr,
|
||||
&fde_length, &cie_offset, &cie_index, &fde_offset,
|
||||
&de) != DW_DLV_OK)
|
||||
errx(EXIT_FAILURE, "dwarf_get_fde_range failed: %s",
|
||||
dwarf_errmsg(de));
|
||||
|
||||
/* Iterate all the table rows. */
|
||||
for (pc = low_pc; pc < low_pc + func_len; pc++) {
|
||||
if (dwarf_get_fde_info_for_reg3(fde, 3, pc, &type,
|
||||
&offset_relevant, ®ister_num, &offset_or_block_len,
|
||||
&block_ptr, &row_pc, &de) != DW_DLV_OK) {
|
||||
warnx("dwarf_get_fde_info_for_reg3 failed: %s",
|
||||
dwarf_errmsg(de));
|
||||
continue;
|
||||
}
|
||||
/* ... use the retrieved register rule ... */
|
||||
}
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dwarf 3 ,
|
||||
.Xr dwarf_get_fde_at_pc 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs 3 ,
|
||||
.Xr dwarf_get_fde_info_for_all_regs3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_cfa_reg3 3 ,
|
||||
.Xr dwarf_get_fde_info_for_reg 3 ,
|
||||
.Xr dwarf_get_fde_n 3 ,
|
||||
.Xr dwarf_set_frame_cfa_value 3 ,
|
||||
.Xr dwarf_set_frame_rule_table_size 3 ,
|
||||
.Xr dwarf_set_frame_rule_initial_value 3 ,
|
||||
.Xr dwarf_set_frame_same_value 3 ,
|
||||
.Xr dwarf_set_frame_undefined_value 3
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user