25 static void loclistloc_free(
struct loclistloc *loclist) {
31 loclist = loclist->
next;
41 (
struct location *)
calloc(1,
sizeof(*location));
78 verror(
"regoffset reg %d too big!\n",reg);
135 verror(
"implicit data len %d too big!\n",len);
147 memcpy(loc->
l.
data,data,len);
170 verror(
"runtime data len %d too big!\n",len);
182 memcpy(l->
l.
data,data,len);
205 verror(
"location is not a loclist!\n");
237 if (l->
start == start) {
240 " (new end 0x%"PRIxADDR"); updating!\n",
253 " not updating; freeing \"new\" location!\n",
264 else if (l->
start > start) {
314 struct location *retval;
315 struct loclistloc *old, *
new, *lastnew = NULL;
328 new =
calloc(1,
sizeof(*
new));
329 new->start = old->
start;
342 memcpy(&retval->
l,&location->
l,
sizeof(location->
l));
355 loclistloc_free(location->
l.
loclist);
426 fprintf(ud->
stream,
"IMPLICITDATA(%d,",(
int)location->
extra);
427 for (i = 0; i < (int)location->
extra; ++i)
432 fprintf(ud->
stream,
"RUNTIMEDATA(%d,",(
int)location->
extra);
433 for (i = 0; i < (int)location->
extra; ++i)
454 struct symbol **top_symbol_saveptr,
455 int *chain_top_symbol_idx_saveptr) {
460 struct symbol *tdatatype;
463 verror(
"location type %s is not a member offset!",
474 verror(
"cannot resolve MEMBER_OFFSET without containing symbol_chain!\n");
479 chlen = array_list_len(symbol_chain);
480 symbol = array_list_item(symbol_chain,chlen - 1);
483 verror(
"deepest symbol (%s) in chain is not member; cannot resolve"
493 for (i = chlen - 1; i > -1; --
i) {
494 symbol = array_list_item(symbol_chain,i);
505 if (top_symbol_saveptr)
506 *top_symbol_saveptr = symbol;
507 if (chain_top_symbol_idx_saveptr)
508 *chain_top_symbol_idx_saveptr =
i;
520 if (top_symbol_saveptr)
521 *top_symbol_saveptr = symbol;
522 if (chain_top_symbol_idx_saveptr)
523 *chain_top_symbol_idx_saveptr =
i;
535 verror(
"invalid chain member (%s,%s) for nested S/U member (%d)!\n",
548 struct location *o_loc) {
555 if (lctxt && lctxt->
ops)
559 if (lops->
relocate(lctxt,addr,&addr)) {
581 verror(
"no location_ops->getdebugfile!\n");
596 verror(
"debugfile does not support unwinding!\n");
601 verror(
"failed to read return address in frame %d!\n",
613 *o_retaddr = retaddr;
636 struct symbol *symbol;
640 verror(
"no location_ops->readreg for current frame %d!\n",
654 else if (errno != EADDRNOTAVAIL) {
655 verror(
"could not read reg %d in frame %d: %s (%d)!\n",
665 verror(
"no location_ops->setcurrentframe!\n");
670 verror(
"no location_ops->getsymbol!\n");
676 verror(
"could not set current frame from %d to %d (next)!\n",
685 vwarn(
"could not find symbol for current (well, \"next\") frame %d!\n",
688 goto prev_frame_load_err_try_next_next;
692 verror(
"could not find root symbol for symbol '%s'!\n",
695 goto prev_frame_load_err;
698 debugfile = srd->debugfile;
700 verror(
"could not find debugfile for root symbol '%s'!\n",
703 goto prev_frame_load_err;
708 verror(
"debugfile does not support unwinding!\n");
710 goto prev_frame_load_err;
715 "could not read reg %"PRIiREG" in frame %d!\n",
719 goto prev_frame_load_err;
728 verror(
"could not set current frame from %d to %d (next)!\n",
746 prev_frame_load_err_try_next_next:
749 "checking cache in (next next) frame %d because no CFI data\n",
753 verror(
"could not read reg %"PRIiREG" in (next next) frame %d!\n",
755 goto prev_frame_load_err;
766 verror(
"could not set current frame from %d to %d (next)!\n",
805 lctxt =
calloc(1,
sizeof(*lctxt));
826 struct symbol *symbol,
struct location *o_loc) {
828 struct symbol *parent;
838 struct location tloc;
841 if (lctxt && lctxt->
ops)
846 vwarn(
"cannot resolve LOCTYPE_UNKNOWN");
864 if (lops->
relocate(lctxt,addr,&addr)) {
875 verror(
"could not read address from reg %d!\n",
889 verror(
"could not read address from reg %d!\n",reg);
900 verror(
"cannot calc frame_base; no symbol supplied!\n");
930 "cannot calc frame_base; no parent function contains ");
937 if (!pf || !pf->fbloc) {
939 "cannot calc frame_base; no frame base in parent function of ");
946 memset(&tloc,0,
sizeof(tloc));
951 verror(
"cannot read reg %"PRIiREG" to get frame_base value\n",
959 verror(
"cannot get frame base value: %s (%s)\n",
960 strerror(errno),LOCTYPE(rc));
980 verror(
"could not read IP reg!\n");
1001 while (loclistloc) {
1002 if (loclistloc->
start <= obj_ip && obj_ip < loclistloc->end) {
1006 loclistloc = loclistloc->
next;
1010 "could not match obj_ip 0x%"PRIxADDR
" in loclist!\n",
1012 errno = EADDRNOTAVAIL;
1036 lctxt,symbol,o_loc);
1048 ADDR *o_start,
ADDR *o_end,
int *is_noncontiguous,
1049 ADDR *o_alt_start,
ADDR *o_alt_end) {
1050 uint8_t as = 0,ae = 0;
1051 ADDR start = 0,end = 0,alt_start = 0,alt_end = 0;
1054 struct location o_loc;
1062 if (!lctxt || !lctxt->
ops) {
1069 memset(&o_loc,0,
sizeof(o_loc));
1084 if (sr->scope && sr->scope->range && !sr->scope->range->next) {
1085 start = sr->scope->range->start;
1086 end = sr->scope->range->end;
1088 if (sr->has_entry_pc) {
1090 alt_start = sr->entry_pc;
1094 if (!start || (symbol->
has_addr && start != symbol->
addr))
1095 start = symbol->
addr;
1106 if (sf->prologue_guessed || sf->prologue_known) {
1108 alt_start = sf->prologue_end;
1110 else if (sf->has_entry_pc) {
1112 alt_start = sf->entry_pc;
1114 if (sf->epilogue_known) {
1116 alt_end = sf->epilogue_begin;
1122 start = symbol->
addr;
1127 if (trc && !as && !ae) {
1136 if (!start || (symbol->
has_addr && start != symbol->
addr))
1137 start = symbol->
addr;
1144 start = symbol->
addr;
1151 start = symbol->
addr;
1169 lops->
relocate(lctxt,start,o_start);
1180 if (as && o_alt_start) {
1182 lops->
relocate(lctxt,alt_start,o_alt_start);
1186 if (ae && o_alt_end) {
1188 lops->
relocate(lctxt,alt_end,o_alt_end);
1190 *o_alt_end = alt_end;
1198 struct symbol **datatype_saveptr) {
1207 "loading ptr at 0x%"PRIxADDR"\n",paddr);
1217 if (lops->
readword(lctxt,paddr,&paddr)) {
1226 "loaded next ptr value 0x%"PRIxADDR" (#%d)\n",
1234 if (datatype_saveptr)
1235 *datatype_saveptr = datatype;
1268 struct location *o_loc) {
1275 ADDR retval = base_addr;
1276 struct symbol *symbol;
1281 struct symbol *tdatatype;
1283 struct location tloc;
1285 llen = lsymbol_len(lsymbol);
1302 symbol = lsymbol_last_symbol(lsymbol);
1306 verror(
"could not resolve base addr for function %s!\n",
1352 symbol = lsymbol_symbol(lsymbol,i);
1401 datatype = tdatatype;
1408 verror(
"cannot load intermediate type symbol %s!\n",
1417 verror(
"symbol %s of type %s is not a full variable!\n",
1426 memset(&tloc,0,
sizeof(tloc));
1452 "var %s has implicit value 0x%"PRIxADDR"\n",
1457 "could not resolve location for symbol %s: %s (%d)!\n",
1479 verror(
"could not read ptr symbol %s from reg %d: %s!\n",
1505 verror(
"could not load pointer for symbol %s\n",
1511 "autoloaded pointer(s) for var %s = 0x%"PRIxADDR"\n",
1551 "implicit word = 0x%"PRIxADDR"; datatype = ",retval);
1568 ADDR *start,
ADDR *end,
int *is_noncontiguous,
1570 struct symbol *symbol;
1573 struct location tloc;
1576 verror(
"no location_ctxt for current frame!\n");
1581 symbol = lsymbol_last_symbol(lsymbol);
1595 is_noncontiguous,alt_start,alt_end);
1601 memset(&tloc,0,
sizeof(tloc));
1604 verror(
"could not resolve location for %s to addr: %s (%d) (%s)!\n",
1611 "found base of '%s' at 0x%"PRIxADDR"\n",
1617 *end = *start + size;
#define SYMBOL_IST_NAMESPACE(sym)
#define LOCATION_ADDR(loc)
void loclistloc_dump(struct loclistloc *list, struct dump_info *ud)
void location_dump(struct location *location, struct dump_info *ud)
int location_set_fbreg_offset(struct location *l, OFFSET offset)
#define vwarnopt(level, area, flags, format,...)
struct symbol * symbol_find_parent(struct symbol *symbol)
#define LOCATION_IS_ADDR(loc)
int location_ctxt_writereg(struct location_ctxt *lctxt, REG reg, REGVAL regval)
#define LOCATION_IS_FB_OFFSET(loc)
struct location * location_create(void)
#define SYMBOL_RX_ROOT(sym, rvar)
#define SYMBOL_RX_FUNC(sym, rvar)
struct scope * symbol_read_owned_scope(struct symbol *symbol)
struct location_ops * ops
int location_update_loclist(struct location *loc, ADDR start, ADDR end, struct location *rloc, int *action)
static uint64_t unsigned int i
struct symbol * symbol_find_root(struct symbol *symbol)
int(* relocate)(struct location_ctxt *lctxt, ADDR obj_addr, ADDR *real_addr)
void location_internal_free(struct location *location)
#define LOCATION_LOCLIST(loc)
uint32_t symbol_get_bytesize(struct symbol *symbol)
ADDR __autoload_pointers(struct symbol *datatype, ADDR addr, struct location_ctxt *lctxt, struct symbol **datatype_saveptr)
int location_ctxt_read_reg(struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
#define verror(format,...)
struct symbol * symbol_get_datatype(struct symbol *symbol)
int(* frame_read_saved_reg)(struct debugfile *debugfile, struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
#define SYMBOLX_VAR_LOC(sym)
#define LOGDUMPSYMBOL_NL(dl, lt, lf, s)
int location_set_reg(struct location *l, REG reg)
int symbol_is_member(struct symbol *symbol)
#define vwarn(format,...)
#define LOCATION_WORD(loc)
#define LOCATION_GET_DATA(loc, buf, buflen)
#define LOCATION_IS_M_OFFSET(loc)
#define SYMBOL_IS_LABEL(sym)
#define LOCATION_OFFSET(loc)
int location_set_implicit_data(struct location *loc, char *data, int len, int nocopy)
loctype_t location_resolve(struct location *loc, struct location_ctxt *lctxt, struct symbol *symbol, struct location *o_loc)
struct loclistloc * loclist
int location_set_reg_addr(struct location *l, REG reg)
struct symbol *(* getsymbol)(struct location_ctxt *lctxt)
struct debugfile *(* getdebugfile)(struct location_ctxt *lctxt)
struct debugfile_ops * ops
int(* cachereg)(struct location_ctxt *lctxt, REG regno, REGVAL regval)
int lsymbol_resolve_bounds(struct lsymbol *lsymbol, ADDR base_addr, struct location_ctxt *lctxt, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
#define SYMBOL_IST_PTR(sym)
#define WARNDUMPSYMBOL_NL(s)
#define SYMBOL_IS_BLOCK(sym)
int(* readipreg)(struct location_ctxt *lctxt, REGVAL *regval)
int(* frame_read_retaddr)(struct debugfile *debugfile, struct location_ctxt *lctxt, ADDR *o_retaddr)
#define LOCATION_GET_REGOFFSET(loc, reg, offset)
#define SYMBOL_IST_STUNC(sym)
#define SYMBOL_IST_STUN(sym)
#define LOCATION_IS_REG_ADDR(loc)
int location_set_member_offset(struct location *l, OFFSET offset)
int(* readreg)(struct location_ctxt *lctxt, REG regno, REGVAL *regval)
#define vdebug(devel, areas, flags, format,...)
int location_ctxt_read_retaddr(struct location_ctxt *lctxt, ADDR *o_retaddr)
loctype_t dwarf_location_resolve(const unsigned char *data, unsigned int len, struct location_ctxt *lctxt, struct symbol *symbol, struct location *o_loc)
struct symbol * symbol_type_skip_qualifiers(struct symbol *type)
loctype_t symbol_resolve_location(struct symbol *symbol, struct location_ctxt *lctxt, struct location *o_loc)
int location_set_loclist(struct location *l, struct loclistloc *list)
int(* setcurrentframe)(struct location_ctxt *lctxt, int frame)
#define vdebugc(devel, areas, flags, format,...)
#define SYMBOL_IS_TYPE(sym)
#define SYMBOL_IS_FULL_VAR(sym)
void * calloc(size_t nmemb, size_t size)
int symbol_resolve_bounds(struct symbol *symbol, struct location_ctxt *lctxt, ADDR *o_start, ADDR *o_end, int *is_noncontiguous, ADDR *o_alt_start, ADDR *o_alt_end)
#define LOCATION_IS_REG_OFFSET(loc)
int(* unrelocate)(struct location_ctxt *lctxt, ADDR real_addr, ADDR *obj_addr)
int location_set_reg_offset(struct location *l, REG reg, OFFSET offset)
#define LOCATION_REMAINING_BITS
#define LOCATION_IS_LOCLIST(loc)
#define LOCATION_IS_RUNTIME(loc)
#define vwarnc(format,...)
struct location_ctxt * location_ctxt_create(struct location_ops *ops, void *priv)
#define SYMBOL_IS_ROOT(sym)
char * SYMBOL_TYPE(int n)
#define LOCATION_REG(loc)
char * symbol_get_name(struct symbol *symbol)
#define LOCATION_IS_IMPLICIT_WORD(loc)
struct symbol_root * root
void * malloc(size_t size)
int(* writereg)(struct location_ctxt *lctxt, REG regno, REGVAL regval)
unsigned int isinlineinstance
void location_free(struct location *location)
int location_set_implicit_word(struct location *loc, ADDR word)
int location_set_runtime(struct location *l, char *data, int len, int nocopy)
int scope_get_overall_range(struct scope *scope, ADDR *low_addr_saveptr, ADDR *high_addr_saveptr, int *is_noncontiguous)
struct location * location_copy(struct location *location)
#define SYMBOL_IS_FUNC(sym)
void location_ctxt_free(struct location_ctxt *lctxt)
int(* readword)(struct location_ctxt *lctxt, ADDR real_addr, ADDR *pval)
#define LOCATION_IS_REG(loc)
#define WARNOPTDUMPSYMBOL_NL(wl, lt, lf, s)
#define LOGDUMPSYMBOL(dl, lt, lf, s)
#define SYMBOL_IS_VAR(sym)
loctype_t lsymbol_resolve_location(struct lsymbol *lsymbol, ADDR base_addr, struct location_ctxt *lctxt, struct location *o_loc)
int location_set_addr(struct location *l, ADDR addr)
#define LOCATION_IS_UNKNOWN(loc)