Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Functions | Variables
dwarf_debuginfo.c File Reference
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <inttypes.h>
#include <assert.h>
#include <regex.h>
#include "config.h"
#include "common.h"
#include "glib_wrapper.h"
#include "log.h"
#include "output.h"
#include "list.h"
#include "alist.h"
#include "binfile.h"
#include "dwdebug.h"
#include "dwdebug_priv.h"
#include <dwarf.h>
#include <gelf.h>
#include <elfutils/libebl.h>
#include <elfutils/libdw.h>
#include <elfutils/libdwfl.h>
#include "memory-access.h"
Include dependency graph for dwarf_debuginfo.c:

Go to the source code of this file.

Data Structures

struct  attrcb_args
 

Macros

#define DFE(msg)
 
#define DAW_STR(msg)
 
#define DAW_ADDR(msg)
 
#define DAW_NUM(msg)
 
#define DAW_BLOCK(msg)
 
#define DAW_REF(msg)
 
#define DAW_FLAG(msg)
 
#define DAW(msg)
 
#define DAWL(msg)
 

Functions

int dwarf_load_cfa (struct debugfile *debugfile, char *buf, unsigned int len, Dwarf *dbg)
 
int dwarf_unload_cfa (struct debugfile *debugfile)
 
int dwarf_get_lines (struct symbol_root_dwarf *srd, Dwarf_Off offset)
 
const char * dwarf_tag_string (unsigned int tag)
 
const char * dwarf_attr_string (unsigned int attrnum)
 
const char * dwarf_form_string (unsigned int form)
 
const char * dwarf_lang_string (unsigned int lang)
 
const char * dwarf_inline_string (unsigned int code)
 
const char * dwarf_encoding_string (unsigned int code)
 
const char * dwarf_access_string (unsigned int code)
 
const char * dwarf_visibility_string (unsigned int code)
 
const char * dwarf_virtuality_string (unsigned int code)
 
const char * dwarf_identifier_case_string (unsigned int code)
 
const char * dwarf_calling_convention_string (unsigned int code)
 
const char * dwarf_ordering_string (unsigned int code)
 
const char * dwarf_discr_list_string (unsigned int code)
 
int dwarf_refuselist_hold (struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
 
int dwarf_refuselist_release (struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
 
GSList * dwarf_refuselist_get (struct symbol_root_dwarf *srd, SMOFFSET ref)
 
int dwarf_symbol_refuselist_release_all (struct symbol_root_dwarf *srd, struct symbol *symbol)
 
int dwarf_symbol_ref_symbol_changed (struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref, struct symbol *refsym)
 
int dwarf_refuselist_notify_reftab_changed (struct symbol_root_dwarf *srd, SMOFFSET ref, struct symbol *refsym)
 
int dwarf_symbol_set_datatype_ref (struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
 
int dwarf_symbol_set_origin_ref (struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
 
int dwarf_reftab_insert (struct symbol_root_dwarf *srd, struct symbol *symbol, SMOFFSET ref)
 
int dwarf_reftab_replace (struct symbol_root_dwarf *srd, struct symbol *existing, struct symbol *new, SMOFFSET ref, GHashTableIter *iter)
 
int dwarf_specify_definition_attrs (struct symbol_root_dwarf *srd, struct symbol *specification, struct symbol *definition)
 
int dwarf_specify_definition_members (struct symbol_root_dwarf *srd, struct symbol *specification, struct symbol *definition)
 
void finalize_die_symbol_name (struct symbol *symbol)
 
void finalize_die_symbol (struct debugfile *debugfile, int level, struct symbol *symbol, struct symbol *parentsymbol, struct symbol *voidsymbol, GHashTable *reftab, struct array_list *die_offsets, SMOFFSET cu_offset)
 
struct symboldo_void_symbol (struct debugfile *debugfile, struct symbol *root)
 
struct symboldo_word_symbol (struct debugfile *debugfile, struct symbol *root)
 
int dwarf_symbol_replace (struct debugfile *debugfile, struct symbol *old, struct symbol *new)
 
int dwarf_symbol_expand (struct debugfile *debugfile, struct symbol *root, struct symbol *symbol)
 
int dwarf_symbol_root_expand (struct debugfile *debugfile, struct symbol *root)
 
int dwarf_load_pubnames (struct debugfile *debugfile, unsigned char *buf, unsigned int len, Dwarf *dbg)
 
int dwarf_load_aranges (struct debugfile *debugfile, unsigned char *buf, unsigned int len, Dwarf *dbg)
 
int dwarf_load_debuginfo (struct debugfile *debugfile)
 
int dwarf_symbol_root_priv_free (struct debugfile *debugfile, struct symbol *root)
 
int dwarf_init (struct debugfile *debugfile)
 
int dwarf_fini (struct debugfile *debugfile)
 
int dwarf_cfa_read_saved_reg (struct debugfile *debugfile, struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
 
int dwarf_cfa_read_retaddr (struct debugfile *debugfile, struct location_ctxt *lctxt, ADDR *o_retaddr)
 

Variables

struct debugfile_ops dwarf_debugfile_ops
 

Macro Definition Documentation

#define DAW (   msg)
Value:
" <%d><%"PRIx64"> %s: %s\n", \
level,die_offset,dwarf_attr_string(attr),msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define DAW_ADDR (   msg)
Value:
" <%d><%"PRIx64"> %s (0x%"PRIxADDR"): %s\n", \
level,die_offset,dwarf_attr_string(attr),addr,msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define PRIxADDR
Definition: common.h:67
#define DAW_BLOCK (   msg)
Value:
" <%d><%"PRIx64"> %s (0x%"PRIxADDR"): %s\n", \
level,die_offset,dwarf_attr_string(attr),block,msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define PRIxADDR
Definition: common.h:67
#define DAW_FLAG (   msg)
Value:
" <%d><%"PRIx64"> %s (%d): %s\n", \
level,die_offset,dwarf_attr_string(attr),flag,msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define DAW_NUM (   msg)
Value:
" <%d><%"PRIx64"> %s (%d): %s\n", \
level,die_offset,dwarf_attr_string(attr),num,msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define DAW_REF (   msg)
Value:
" <%d><%"PRIx64"> %s (0x%"PRIxSMOFFSET"): %s\n", \
level,die_offset,dwarf_attr_string(attr),ref,msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define PRIxSMOFFSET
Definition: common.h:102
#define DAW_STR (   msg)
Value:
" <%d><%"PRIx64"> %s (%s): %s\n", \
level,die_offset,dwarf_attr_string(attr),str,msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define DAWL (   msg)
Value:
" <%d><%"PRIx64"> %s: %s\n", \
level,die_offset,dwarf_attr_string(attr),msg); }
const char * dwarf_attr_string(unsigned int attrnum)
#define vwarnopt(level, area, flags, format,...)
Definition: log.h:37
Definition: log.h:69
#define DFE (   msg)
Value:
verror(" <%d><%"PRIx64"> %s: %s\n", \
level,die_offset,dwarf_attr_string(attr),msg);
const char * dwarf_attr_string(unsigned int attrnum)
#define verror(format,...)
Definition: log.h:30

Function Documentation

struct symbol* do_void_symbol ( struct debugfile debugfile,
struct symbol root 
)

Definition at line 1761 of file dwarf_debuginfo.c.

struct symbol* do_word_symbol ( struct debugfile debugfile,
struct symbol root 
)

Definition at line 1784 of file dwarf_debuginfo.c.

const char* dwarf_access_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1281 of file dwarf_elfutils.c.

const char* dwarf_attr_string ( unsigned int  attrnum)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 850 of file dwarf_elfutils.c.

const char* dwarf_calling_convention_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1362 of file dwarf_elfutils.c.

int dwarf_cfa_read_retaddr ( struct debugfile debugfile,
struct location_ctxt lctxt,
ADDR o_retaddr 
)

Definition at line 1609 of file dwarf_cfa.c.

int dwarf_cfa_read_saved_reg ( struct debugfile debugfile,
struct location_ctxt lctxt,
REG  reg,
REGVAL o_regval 
)

Definition at line 1392 of file dwarf_cfa.c.

const char* dwarf_discr_list_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1408 of file dwarf_elfutils.c.

const char* dwarf_encoding_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1241 of file dwarf_elfutils.c.

int dwarf_fini ( struct debugfile debugfile)

Definition at line 4820 of file dwarf_debuginfo.c.

const char* dwarf_form_string ( unsigned int  form)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1119 of file dwarf_elfutils.c.

int dwarf_get_lines ( struct symbol_root_dwarf srd,
Dwarf_Off  offset 
)

Most of the src in this file is slightly-tweaked stuff from elfutils, especially readelf.c. May as well just take all their stuff – plus it is more relocation-ready!

Definition at line 62 of file dwarf_elfutils.c.

const char* dwarf_identifier_case_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1341 of file dwarf_elfutils.c.

int dwarf_init ( struct debugfile debugfile)

Definition at line 4808 of file dwarf_debuginfo.c.

const char* dwarf_inline_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1220 of file dwarf_elfutils.c.

const char* dwarf_lang_string ( unsigned int  lang)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1170 of file dwarf_elfutils.c.

int dwarf_load_aranges ( struct debugfile debugfile,
unsigned char *  buf,
unsigned int  len,
Dwarf *  dbg 
)

Definition at line 4169 of file dwarf_debuginfo.c.

int dwarf_load_cfa ( struct debugfile debugfile,
char *  buf,
unsigned int  len,
Dwarf *  dbg 
)
int dwarf_load_debuginfo ( struct debugfile debugfile)

Definition at line 4668 of file dwarf_debuginfo.c.

int dwarf_load_pubnames ( struct debugfile debugfile,
unsigned char *  buf,
unsigned int  len,
Dwarf *  dbg 
)

Definition at line 4087 of file dwarf_debuginfo.c.

const char* dwarf_ordering_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1389 of file dwarf_elfutils.c.

int dwarf_reftab_insert ( struct symbol_root_dwarf srd,
struct symbol symbol,
SMOFFSET  ref 
)

Definition at line 346 of file dwarf_debuginfo.c.

int dwarf_reftab_replace ( struct symbol_root_dwarf srd,
struct symbol existing,
struct symbol new,
SMOFFSET  ref,
GHashTableIter *  iter 
)

Definition at line 369 of file dwarf_debuginfo.c.

GSList* dwarf_refuselist_get ( struct symbol_root_dwarf srd,
SMOFFSET  ref 
)

Definition at line 138 of file dwarf_debuginfo.c.

int dwarf_refuselist_hold ( struct symbol_root_dwarf srd,
struct symbol symbol,
SMOFFSET  ref 
)

Definition at line 109 of file dwarf_debuginfo.c.

int dwarf_refuselist_notify_reftab_changed ( struct symbol_root_dwarf srd,
SMOFFSET  ref,
struct symbol refsym 
)

Definition at line 268 of file dwarf_debuginfo.c.

int dwarf_refuselist_release ( struct symbol_root_dwarf srd,
struct symbol symbol,
SMOFFSET  ref 
)

Definition at line 122 of file dwarf_debuginfo.c.

int dwarf_specify_definition_attrs ( struct symbol_root_dwarf srd,
struct symbol specification,
struct symbol definition 
)

Definition at line 660 of file dwarf_debuginfo.c.

int dwarf_specify_definition_members ( struct symbol_root_dwarf srd,
struct symbol specification,
struct symbol definition 
)

Definition at line 677 of file dwarf_debuginfo.c.

int dwarf_symbol_expand ( struct debugfile debugfile,
struct symbol root,
struct symbol symbol 
)

Definition at line 3560 of file dwarf_debuginfo.c.

int dwarf_symbol_ref_symbol_changed ( struct symbol_root_dwarf srd,
struct symbol symbol,
SMOFFSET  ref,
struct symbol refsym 
)

Definition at line 166 of file dwarf_debuginfo.c.

int dwarf_symbol_refuselist_release_all ( struct symbol_root_dwarf srd,
struct symbol symbol 
)

Definition at line 144 of file dwarf_debuginfo.c.

int dwarf_symbol_replace ( struct debugfile debugfile,
struct symbol old,
struct symbol new 
)

Definition at line 3523 of file dwarf_debuginfo.c.

int dwarf_symbol_root_expand ( struct debugfile debugfile,
struct symbol root 
)

Definition at line 3602 of file dwarf_debuginfo.c.

int dwarf_symbol_root_priv_free ( struct debugfile debugfile,
struct symbol root 
)

Definition at line 4778 of file dwarf_debuginfo.c.

int dwarf_symbol_set_datatype_ref ( struct symbol_root_dwarf srd,
struct symbol symbol,
SMOFFSET  ref 
)

Definition at line 290 of file dwarf_debuginfo.c.

int dwarf_symbol_set_origin_ref ( struct symbol_root_dwarf srd,
struct symbol symbol,
SMOFFSET  ref 
)

Definition at line 309 of file dwarf_debuginfo.c.

const char* dwarf_tag_string ( unsigned int  tag)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 708 of file dwarf_elfutils.c.

int dwarf_unload_cfa ( struct debugfile debugfile)

Definition at line 1802 of file dwarf_cfa.c.

const char* dwarf_virtuality_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1321 of file dwarf_elfutils.c.

const char* dwarf_visibility_string ( unsigned int  code)

Convenience string function, straight out of elfutils/readelf.c !

Definition at line 1301 of file dwarf_elfutils.c.

void finalize_die_symbol ( struct debugfile debugfile,
int  level,
struct symbol symbol,
struct symbol parentsymbol,
struct symbol voidsymbol,
GHashTable *  reftab,
struct array_list die_offsets,
SMOFFSET  cu_offset 
)

Definition at line 3902 of file dwarf_debuginfo.c.

void finalize_die_symbol_name ( struct symbol symbol)

Definition at line 3879 of file dwarf_debuginfo.c.

Variable Documentation

struct debugfile_ops dwarf_debugfile_ops
Initial value:
= {
.init = dwarf_init,
.symbol_replace = dwarf_symbol_replace,
.symbol_expand = dwarf_symbol_expand,
.symbol_root_expand = dwarf_symbol_root_expand,
.frame_read_saved_reg = dwarf_cfa_read_saved_reg,
.frame_read_retaddr = dwarf_cfa_read_retaddr,
.symbol_root_priv_free = dwarf_symbol_root_priv_free,
.fini = dwarf_fini,
}
int dwarf_init(struct debugfile *debugfile)
int dwarf_fini(struct debugfile *debugfile)
int dwarf_cfa_read_saved_reg(struct debugfile *debugfile, struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
Definition: dwarf_cfa.c:1392
int dwarf_symbol_expand(struct debugfile *debugfile, struct symbol *root, struct symbol *symbol)
int dwarf_cfa_read_retaddr(struct debugfile *debugfile, struct location_ctxt *lctxt, ADDR *o_retaddr)
Definition: dwarf_cfa.c:1609
int dwarf_symbol_root_priv_free(struct debugfile *debugfile, struct symbol *root)
int dwarf_load_debuginfo(struct debugfile *debugfile)
int dwarf_symbol_root_expand(struct debugfile *debugfile, struct symbol *root)
int dwarf_symbol_replace(struct debugfile *debugfile, struct symbol *old, struct symbol *new)

DWARF debugfile backend API stuff.

Definition at line 4846 of file dwarf_debuginfo.c.