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
dwdebug_priv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 2012, 2013, 2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __DWDEBUG_PRIV_H__
20 #define __DWDEBUG_PRIV_H__
21 
22 #include "arch.h"
23 #include "dwdebug.h"
24 
25 #define LOGDUMPSYMBOL(dl,lt,lf,s) \
26  vdebugc((dl),(lt),(lf), \
27  "symbol(%s,%s,0x%"PRIxSMOFFSET",refcnt=%"PRIiREFCNT")", \
28  symbol_get_name((s)),SYMBOL_TYPE((s)->type),(s)->ref,(s)->refcnt);
29 
30 #define LOGDUMPSYMBOL_NL(dl,lt,lf,s) \
31  LOGDUMPSYMBOL((dl),(lt),(lf),(s)); \
32  vdebugc((dl),(lt),(lf),"\n");
33 
34 #define WARNDUMPSYMBOL(s) \
35  vwarnc("symbol(%s,%s,0x%"PRIxSMOFFSET",refcnt=%"PRIiREFCNT")", \
36  symbol_get_name((s)),SYMBOL_TYPE((s)->type),(s)->ref,(s)->refcnt);
37 
38 #define WARNDUMPSYMBOL_NL(s) \
39  WARNDUMPSYMBOL((s)); \
40  vwarnc("\n");
41 
42 #define WARNOPTDUMPSYMBOL(wl,lt,lf,s) \
43  vwarnoptc(wl,lt,lf,"symbol(%s,%s,0x%"PRIxSMOFFSET",refcnt=%"PRIiREFCNT")", \
44  symbol_get_name((s)),SYMBOL_TYPE((s)->type),(s)->ref,(s)->refcnt);
45 
46 #define WARNOPTDUMPSYMBOL_NL(wl,lt,lf,s) \
47  WARNOPTDUMPSYMBOL(wl,lt,lf,(s)); \
48  vwarnoptc(wl,lt,lf,"\n");
49 
50 #define ERRORDUMPSYMBOL(s) \
51  verrorc("symbol(%s,%s,0x%"PRIxSMOFFSET",refcnt=%"PRIiREFCNT")", \
52  symbol_get_name((s)),SYMBOL_TYPE((s)->type),(s)->ref,(s)->refcnt);
53 
54 #define ERRORDUMPSYMBOL_NL(s) \
55  ERRORDUMPSYMBOL((s)); \
56  verrorc("\n");
57 
58 
59 #define LOGDUMPSCOPE(dl,lt,lf,s) \
60  vdebugc((dl),(lt),(lf), \
61  "scope(%s:0x%"PRIxSMOFFSET",[0x%"PRIxADDR",0x%"PRIxADDR"%s]," \
62  " refcnt=%"PRIiREFCNT")", \
63  ((s)->symbol) ? symbol_get_name((s)->symbol) : "NULL", \
64  (s)->ref,((s)->range) ? (s)->range->start : 0, \
65  ((s)->range) ? (s)->range->end : 0, \
66  ((s)->range && (s)->range->next) ? ",..." : "",(s)->refcnt);
67 
68 #define LOGDUMPSCOPE_NL(dl,lt,lf,s) \
69  LOGDUMPSCOPE((dl),(lt),(lf),(s)); \
70  vdebugc((dl),(lt),(lf),"\n");
71 
72 #define ERRORDUMPSCOPE(s) \
73  verrorc("scope(%s:0x%"PRIxSMOFFSET",[0x%"PRIxADDR",0x%"PRIxADDR"%s]," \
74  " refcnt=%"PRIiREFCNT")", \
75  ((s)->symbol) ? symbol_get_name((s)->symbol) : "NULL", \
76  (s)->ref,((s)->range) ? (s)->range->start : 0, \
77  ((s)->range) ? (s)->range->end : 0, \
78  ((s)->range && (s)->range->next) ? ",..." : "",(s)->refcnt);
79 
80 #define ERRORDUMPSCOPE_NL(s) \
81  ERRORDUMPSCOPE((s)); \
82  verrorc("\n");
83 
84 #define WARNDUMPSCOPE(s) \
85  vwarnc( "scope(%s:0x%"PRIxSMOFFSET",[0x%"PRIxADDR",0x%"PRIxADDR"%s]," \
86  " refcnt=%"PRIiREFCNT")", \
87  ((s)->symbol) ? symbol_get_name((s)->symbol) : "NULL", \
88  (s)->ref,((s)->range) ? (s)->range->start : 0, \
89  ((s)->range) ? (s)->range->end : 0, \
90  ((s)->range && (s)->range->next) ? ",..." : "",(s)->refcnt);
91 
92 #define WARNDUMPSCOPE_NL(s) \
93  WARNDUMPSCOPE((s)); \
94  verrorc("\n");
95 
96 
97 #define LOGDUMPLSYMBOL(dl,lt,lf,s) \
98  vdebugc((dl),(lt),(lf), \
99  "lsymbol(%s,%s,0x%"PRIxSMOFFSET";chainlen=%d)", \
100  symbol_get_name((s)->symbol),SYMBOL_TYPE((s)->symbol->type), \
101  (s)->symbol->ref,array_list_len((s)->chain));
102 
103 #define LOGDUMPLSYMBOL_NL(dl,lt,lf,s) \
104  LOGDUMPLSYMBOL((dl),(lt),(lf),(s)); \
105  vdebugc((dl),(lt),(lf),"\n");
106 
107 #define ERRORDUMPLSYMBOL(s) \
108  verrorc("lsymbol(%s,%s,0x%"PRIxSMOFFSET";chainlen=%d)", \
109  symbol_get_name((s)->symbol),SYMBOL_TYPE((s)->symbol->type), \
110  (s)->symbol->ref,array_list_len((s)->chain));
111 
112 #define ERRORDUMPLSYMBOL_NL(s) \
113  ERRORDUMPLSYMBOL((s)); \
114  verrorc("\n");
115 
119 struct symbol_root_dwarf;
120 struct location_ctxt;
121 
125 /*
126  * Each kind of debugfile (i.e., DWARF, ELF) should supply one of these.
127  */
129  int (*init)(struct debugfile *debugfile);
130  int (*load)(struct debugfile *debugfile);
132  struct symbol *old,struct symbol *new);
133  int (*symbol_root_expand)(struct debugfile *debugfile,struct symbol *root);
134  int (*symbol_expand)(struct debugfile *debugfile,
135  struct symbol *root,struct symbol *symbol);
136 
137  /*
138  * Unwinders should basically call location_ctxt_read_retaddr() and
139  * location_ctxt_read_cfa() in the current frame; then create the
140  * previous frame using the first value as the IP and the second as
141  * the stack pointer. Then it can either call frame_read_all_saved,
142  * which will read all saved registers in the current frame -- then
143  * it can fill in current_frame + 1. Alternatively, it can just
144  * create the previous frame with IP and SP, and let it be loaded on
145  * demand via location_resolve (which calls location_ctxt_read_reg).
146  */
147 
148  /*
149  * Tries to find the saved value of @reg in @lctxt->current_frame by
150  * using the current frame's CFA data to get the callee-saved value.
151  * If the register was saved in @lctxt->current_frame - N, this
152  * function must retrieve that value recursively.
153  */
154  int (*frame_read_saved_reg)(struct debugfile *debugfile,
155  struct location_ctxt *lctxt,
156  REG reg,REGVAL *o_regval);
157  /*
158  * Tries to load all saved values of registers in
159  * @lctxt->current_frame by using the current frame's CFA data to
160  * get the callee-saved values. If the register was saved in
161  * @lctxt->current_frame - N, this function must retrieve that value
162  * recursively. It places the values directly into @regcache.
163  */
164  int (*frame_read_all_saved_reg)(struct debugfile *debugfile,
165  struct location_ctxt *lctxt,
166  GHashTable *regcache);
167  /*
168  * This gets the IP the current_frame will jump to when it returns
169  * (the return address).
170  */
171  int (*frame_read_retaddr)(struct debugfile *debugfile,
172  struct location_ctxt *lctxt,ADDR *o_retaddr);
173  /*
174  * This gets the frame pointer address of the current_frame (which
175  * is also the value of the stack pointer at the call site in the
176  * previous frame -- the CFA (call frame address)).
177  */
178  int (*frame_read_cfa)(struct debugfile *debugfile,
179  struct location_ctxt *lctxt,ADDR *o_cfaaddr);
180 
181  int (*symbol_root_priv_free)(struct debugfile *debugfile,struct symbol *root);
182  int (*fini)(struct debugfile *debugfile);
183 };
184 
186  debugfile_type_flags_t dtflags,
187  struct binfile *binfile,
188  struct debugfile_load_opts *opts,
189  struct binfile *binfile_pointing);
191  debugfile_type_flags_t dtflags,
192  char *filename,
193  struct debugfile_load_opts *opts);
194 /* Load DWARF debuginfo into a debugfile. */
196 /* Load ELF symtab info into a debugfile. */
197 int debugfile_load_elfsymtab(struct debugfile *debugfile,Elf *elf,
198  char *elf_filename);
199 loctype_t dwarf_location_resolve(const unsigned char *data,unsigned int len,
200  struct location_ctxt *lctxt,
201  struct symbol *symbol,struct location *o_loc);
203  const unsigned char *data,Dwarf_Word len,
204  unsigned int attr);
206  SMOFFSET offset);
208  char *name);
214  char *typename);
215 int debugfile_add_type(struct debugfile *debugfile,struct symbol *symbol);
217 
219  struct symbol *symbol);
221  struct symbol *symbol);
225  struct symbol *declaration,
226  struct symbol *definition);
228  struct symbol *specification,
229  struct symbol *definition);
232  struct lsymbol **primary,struct lsymbol **alt);
234  char *name,const char *delim,
235  struct rfilter *srcfile_filter,
236  symbol_type_flag_t flags);
238  char *filename,int line,
239  SMOFFSET *offset,ADDR *addr);
240 REFCNT debugfile_free(struct debugfile *debugfile,int force);
241 
245 extern struct debugfile_ops dwarf_debugfile_ops;
246 
248  /*
249  * If this debugfile's DWARF CFA was plain old DWARF CFA, then
250  * is_eh_frame is not set; if it was the special eh_frame encoding,
251  * then it is set.
252  */
253  uint8_t is_eh_frame:1;
254 
255  /*
256  * Easier to stash this here.
257  */
259  uint64_t frame_sec_addr;
260 
261  /*
262  * Our CFA strategy is designed to support caching a scan of the
263  * frame information; storing pointers to per-segment CFA info
264  * (cached in @frametab above) starting at certain addresses;
265  * and later decoding those bytes and placing them in another hash.
266  *
267  * The DWARF functions pre-scan all the CIEs and FDEs in the
268  * .(debug|eh)_frame section; fully decoding each CIE and placing
269  * its offset/decoding in @cfa_cie; and placing the FDE's start addr
270  * and a pointer to the FDE data within @frametab in
271  * @frame_pointers; when we need to decode, the DWARF functions
272  * place decodings of the pointed-to FDEs in @frame_fde.
273  *
274  * NB: Well, it turns out we cannot just read the start addr out of
275  * each FDE; gcc liberally uses augmentations and thus we must
276  * sometimes use CIE info to compute the FDE. So -- we just go
277  * ahead and parse the whole FDE for now, EXCEPT for the CFA
278  * program.
279  */
280  GHashTable *cfa_cie;
282 };
283 
287 /*
288  * Creates an lsymbol data structure and takes references to all its
289  * symbols. Users should never call this function.
290  *
291  * This function takes a ref to each symbol in @chain, BUT NOT to
292  * @return.
293  */
294 struct lsymbol *lsymbol_create(struct symbol *symbol,struct array_list *chain);
295 /*
296  * Add another symbol to the end of our lookup chain and make it the
297  * primary symbol (i.e, @lsymbol->symbol = symbol), and hold a ref on
298  * @symbol. Users should not need to call this.
299  */
300 void lsymbol_append(struct lsymbol *lsymbol,struct symbol *symbol);
301 /*
302  * Add a symbol to the start of our lookup chain and hold a ref on
303  * @symbol. Users should not need to call this.
304  */
305 void lsymbol_prepend(struct lsymbol *lsymbol,struct symbol *symbol);
306 /*
307  * Takes references to the symbols on the lsymbol chain!. Users should
308  * never call this function unless they call lsymbol_create*(); the
309  * lookup functions return lsymbols that have been held. The user
310  * should only call lsymbol_release on them.
311  */
312 void lsymbol_hold_int(struct lsymbol *lsymbol);
313 /*
314  * These functions take refs to each symbol in the lsymbol they create,
315  * BUT NOT to @return (call lsymbol_hold() to get that ref).
316  */
317 
319  const char *name,const char *delim);
320 struct lsymbol *lsymbol_create_from_member__int(struct lsymbol *parent,
321  struct symbol *member);
324 
325 static inline int lsymbol_len(struct lsymbol *lsymbol) {
326  return array_list_len(lsymbol->chain);
327 }
328 static inline struct symbol *lsymbol_last_symbol(struct lsymbol *lsymbol) {
329  if (array_list_len(lsymbol->chain) > 0)
330  return (struct symbol *) \
331  array_list_item(lsymbol->chain,array_list_len(lsymbol->chain) - 1);
332  else
333  return NULL;
334 }
335 static inline struct symbol *lsymbol_symbol(struct lsymbol *lsymbol,int i) {
336  return (struct symbol *)array_list_item(lsymbol->chain,i);
337 }
338 
339 /*
340  * Releases references to the symbols on the chain and tries to free the
341  * lsymbol (not the underlying symbols!).
342  */
343 REFCNT lsymbol_free(struct lsymbol *lsymbol,int force);
344 
345 
349 /*
350  * Symdicts are unfortunate. Some languages allow for different kinds
351  * of symbols with the same name in the same scope/block/whatever. Some
352  * languages allow for unnamed symbols too! So, symdicts have to
353  * account for all these possibilities because they are designed to be
354  * symbol containers for scopes, or for symbols containing nested
355  * symbols (but not necessarily in a scope). Maybe we could improve
356  * this later...
357  */
358 struct symdict {
359  /*
360  * This hashtable stores only *named* symbols that existed in this
361  * scope. If the symbol exists multiple times in this symdict, then
362  * it is not in this table, but rather in duptab below. If we have
363  * to insert a symbol already present in this table, we create a
364  * list and move it to the duptab.
365  *
366  * h(sym) -> struct symbol *
367  */
368  GHashTable *tab;
369 
370  /*
371  * This hashtable stores lists of duplicate symbols in this symdict.
372  *
373  * h(sym) -> struct array_list * (struct symbol *)
374  */
375  GHashTable *duptab;
376 
377  /*
378  * This hashtable stores only *unnamed* symbols that existed in this
379  * scope. These are probably mostly types.
380  *
381  * h(addr) -> struct symbol *
382  */
383  GHashTable *anontab;
384 };
385 
399 struct symdict *symdict_create(void);
401 int symdict_get_size(struct symdict *symdict);
403 int symdict_get_sizes(struct symdict *symdict,int *named,int *duplicated,int *anon);
404 int symdict_insert_symbol(struct symdict *symdict,struct symbol *symbol);
406 struct symbol *symdict_get_sym(struct symdict *symdict,const char *name,
407  symbol_type_flag_t flags);
408 GSList *symdict_match_syms(struct symdict *symdict,struct rfilter *symbol_filter,
409  symbol_type_flag_t flags);
411  struct rfilter *symbol_filter,
412  symbol_type_flag_t flags,
413  int no_main,int no_dup,int no_anon);
414 /*
415  * Removes @symbol from @symdict. Returns 0 if success; -1 if error.
416  */
417 int symdict_remove_symbol(struct symdict *symdict,struct symbol *symbol);
418 void symdict_dump(struct symdict *symdict,struct dump_info *ud);
419 typedef void (*symdict_symbol_dtor_t)(struct symbol *symbol,void *priv);
421 void symdict_free(struct symdict *symdict,symdict_symbol_dtor_t ssd,void *priv);
422 
423 
428 /*
429  * In general, ranges can be either a single range or a list. After
430  * experience, we elect to encode both in a single struct. We do waste
431  * the @next pointer if the range is a singleton; but it simplifies the
432  * code significantly and save us from keeping an array list, or from
433  * using a heavyweight GSList. Since users never should see these
434  * things, we don't really care how they're implemented inside.
435  */
436 struct range {
439  struct range *next;
440 };
441 
442 /*
443  * A symbol's scope may be only a name scope, or it may be a name scope
444  * PLUS a block (code) scope. Block scopes can have anonymous children;
445  * this is how unnamed blocks are represented. A scope may have been
446  * created for a symbol, or for a block of code. This is the right
447  * abstraction to support lots of languages. It was tricky to get it
448  * right. Sometimes we need a block scope hierarchy to search; and
449  * sometimes we need a symbol name scope hierarchy to search. If we are
450  * searching through a scope hierarchy, we need to know what symbol is
451  * associated with the scope, sometimes.
452  */
453 struct scope {
454  /* Our refcnt. */
456 
457  /* Our weak reference count. */
458  //REFCNT refcntw;
459 
461 
462  /* If this scope is owned by a symbol, @symbol is that owner. */
463  struct symbol *symbol;
464 
465  /* If this scope has members, this is the symdict containing them. */
466  struct symdict *symdict;
467 
468  /*
469  * Any block scope should have at least one range associated with it.
470  */
471  struct range *range;
472 
473  /*
474  * If this scope is a child, this is its parent.
475  */
476  struct scope *parent;
477 
478  /*
479  * If this scope has subscopes, this list is the scopes for each
480  * subscope. Of course, each subscope could have more children. We
481  * use a GSList because deletes are rare; they only happen if we
482  * change which parent a subscope is on).
483  */
484  GSList *subscopes;
485 };
486 
487 struct scope *scope_create(struct symbol *owner,SMOFFSET ref);
488 char *scope_get_name(struct scope *scope);
489 int scope_insert_symbol(struct scope *scope,struct symbol *symbol);
490 int scope_hold_symbol(struct scope *scope,struct symbol *symbol);
491 int scope_remove_symbol(struct scope *scope,struct symbol *symbol);
492 int scope_insert_scope(struct scope *parent,struct scope *child);
493 int scope_remove_scope(struct scope *parent,struct scope *child);
494 /*
495  * Since we can get scope info from multiple places (i.e.,
496  * .debug_aranges, and from .debug_info), we need to be able to update
497  * 1) the scope's ranges, and 2) the debugfile's ranges lookup data
498  * struct. This function handles adding a new range, or updating an old
499  * one whose end address may have changed (i.e., dwarf inconsistencies).
500  *
501  * If you supply @action, we set it to 1 if the range was newly added; 2
502  * if the start matched but the end did not; 0 if nothing was changed.
503  */
504 void scope_update_range(struct scope *scope,ADDR start,ADDR end,int *action);
505 
506 static inline struct symbol *scope_get_symbol(struct scope *scope) {
507  return scope->symbol;
508 }
509 struct symbol *scope_get_sym(struct scope *scope,const char *name,
510  symbol_type_flag_t flags);
512 struct lsymbol *scope_lookup_sym(struct scope *scope,
513  const char *name,const char *delim,
514  symbol_type_flag_t flags);
515 void scope_dump(struct scope *scope,struct dump_info *ud);
516 int scope_get_sizes(struct scope *scope,int *named,int *duplicated,int *anon,
517  int *numscopes);
518 /*
519  * For a scope, returns 0 and sets @low_addr_saveptr and
520  * @high_addr_saveptr appropriately. If @scope has multiple ranges, and
521  * if those ranges are noncontiguous, and @is_noncontiguous is not NULL,
522  * we set it to 1.
523  */
524 int scope_get_overall_range(struct scope *scope,ADDR *low_addr_saveptr,
525  ADDR *high_addr_saveptr,int *is_noncontiguous);
526 REFCNT scope_free(struct scope *scope,int force);
527 GSList *scope_match_syms(struct scope *scope,
528  struct rfilter *symbol_filter,
529  symbol_type_flag_t flags);
530 
531 
536 #define LOCTYPE_BITS 5
537 static inline const char *LOCTYPE(int n) {
538  switch (n) {
539  case LOCTYPE_UNKNOWN: return "unknown";
540  case LOCTYPE_ADDR: return "addr";
541  case LOCTYPE_REG: return "reg";
542  case LOCTYPE_REG_ADDR: return "regaddr";
543  case LOCTYPE_REG_OFFSET: return "regoffset";
544  case LOCTYPE_MEMBER_OFFSET: return "memberoffset";
545  case LOCTYPE_FBREG_OFFSET: return "fbregoffset";
546  case LOCTYPE_LOCLIST: return "loclist";
547  case LOCTYPE_IMPLICIT_WORD: return "implicit_word";
548  case LOCTYPE_IMPLICIT_DATA: return "implicit_data";
549  case LOCTYPE_RUNTIME: return "runtime";
550  default: return NULL;
551  }
552 }
553 /*
554  * Sometimes locations change depending on EIP; this struct can form a
555  * list of such locations for a single symbol's location. DWARF uses
556  * these; other languages/debug info sources might as well.
557  */
558 struct loclistloc {
561  struct location *loc;
562  struct loclistloc *next;
563 };
564 
565 /*
566  * We pack loctype plus any data length/register number fields, and
567  * reserve a single bit that specifies if contents (like runtime data,
568  * implicit data, loclist) should not be freed.
569  */
570 #define LOCATION_REMAINING_BITS (__WORDSIZE - LOCTYPE_BITS - 1)
571 
572 struct location {
573  /*
574  * This is basically a tagged union.
575  *
576  * NB: since the tag wastes a lot of space, we optimize by moving
577  * @regoffset.reg and @runtime.len (and now implicit value data len)
578  * out of the union. Then we just have to limit the
579  * runtime/implicit value data len; and ensure we limit the
580  * sizeof(REG) in the future; right now it's int8_t .
581  *
582  * If users ever had to see this, it would stink for them.
583  */
584 
586 
587  /*
588  * Only controls freeing of @l.data -- not l.loclist -- that is
589  * always freed!
590  */
591  int nofree:1;
592 
593  /* Encodes regoffset reg number, or the length of runtime data. */
594 #if LOCATION_REMAINING_BITS > 32
596 #else
598 #endif
599 
600  union {
603  OFFSET offset; /* fboffset, regoffset, member_offset */
605  char *data; /* runtime data or implicit value data */
607  } l;
608 };
609 
610 #define LOCATION_IS_UNKNOWN(loc) ((loc)->loctype == LOCTYPE_UNKNOWN)
611 #define LOCATION_IS_ADDR(loc) ((loc)->loctype == LOCTYPE_ADDR)
612 #define LOCATION_IS_REG(loc) ((loc)->loctype == LOCTYPE_REG)
613 #define LOCATION_IS_REG_ADDR(loc) ((loc)->loctype == LOCTYPE_REG_ADDR)
614 #define LOCATION_IS_REG_OFFSET(loc) ((loc)->loctype == LOCTYPE_REG_OFFSET)
615 #define LOCATION_IS_M_OFFSET(loc) ((loc)->loctype == LOCTYPE_MEMBER_OFFSET)
616 #define LOCATION_IS_FB_OFFSET(loc) ((loc)->loctype == LOCTYPE_FBREG_OFFSET)
617 #define LOCATION_IS_LOCLIST(loc) ((loc)->loctype == LOCTYPE_LOCLIST)
618 #define LOCATION_IS_IMPLICIT_WORD(loc) ((loc)->loctype == LOCTYPE_IMPLICIT_WORD)
619 #define LOCATION_IS_IMPLICIT_DATA(loc) ((loc)->loctype == LOCTYPE_IMPLICIT_DATA)
620 #define LOCATION_IS_RUNTIME(loc) ((loc)->loctype == LOCTYPE_RUNTIME)
621 
622 #define LOCATION_ADDR(loc) (loc)->l.addr
623 #define LOCATION_REG(loc) (loc)->l.reg
624 #define LOCATION_OFFSET(loc) (loc)->l.offset
625 #define LOCATION_LOCLIST(loc) (loc)->l.loclist
626 #define LOCATION_WORD(loc) (loc)->l.word
627 
628 #define LOCATION_GET_REGOFFSET(loc,reg,offset) \
629  do { \
630  reg = (REG)(loc)->extra; \
631  offset = (loc)->l.offset; \
632  } while (0);
633 #define LOCATION_GET_DATA(loc,buf,buflen) \
634  do { \
635  buflen = (int)(loc)->extra; \
636  buf = (loc)->l.data; \
637  } while (0);
638 
639 int location_set_addr(struct location *l,ADDR addr);
640 int location_set_reg(struct location *l,REG reg);
641 int location_set_reg_addr(struct location *l,REG reg);
642 int location_set_reg_offset(struct location *l,REG reg,OFFSET offset);
643 int location_set_member_offset(struct location *l,OFFSET offset);
644 int location_set_fbreg_offset(struct location *l,OFFSET offset);
645 int location_set_loclist(struct location *l,struct loclistloc *list);
647  ADDR start,ADDR end,struct location *rloc,
648  int *action);
649 int location_set_implicit_word(struct location *loc,ADDR word);
650 int location_set_implicit_data(struct location *loc,char *data,int len,
651  int nocopy);
652 int location_set_runtime(struct location *l,char *data,int len,int nocopy);
653 
654 loctype_t location_resolve(struct location *loc,struct location_ctxt *lctxt,
655  struct symbol *symbol,struct location *o_loc);
656 
657 struct location *location_copy(struct location *location);
658 void location_dump(struct location *location,struct dump_info *ud);
660 
661 /*
662  * Targets must supply this interface.
663  */
664 struct location_ops {
665  /*
666  * Change the current frame to something else. This is useful for
667  * obtaining saved register values in caller-saved frames.
668  *
669  * This library only uses it temporarily -- if it calls
670  * setcurrentframe, it will undo that so that current_frame is the
671  * same as it was when it was called.
672  */
673  int (*setcurrentframe)(struct location_ctxt *lctxt,int frame);
674  /*
675  * Gets the debugfile associated with lctxt->current_frame, by IP.
676  */
677  struct debugfile *(*getdebugfile)(struct location_ctxt *lctxt);
678  /*
679  * Gets the symbol associated with lctxt->current_frame.
680  */
681  struct symbol *(*getsymbol)(struct location_ctxt *lctxt);
682  /*
683  * Reads the value of @regno in @lctxt->current_frame. This
684  * function must NOT call location_ctxt_read_reg; that function will
685  * read CFA data to compute it if it's not available in the cache.
686  */
687  int (*readreg)(struct location_ctxt *lctxt,REG regno,REGVAL *regval);
688  int (*writereg)(struct location_ctxt *lctxt,REG regno,REGVAL regval);
689  /*
690  * If location_ctxt_read_reg reads a value, it will try to cache it
691  * in lctxt->current_frame via this function.
692  */
693  int (*cachereg)(struct location_ctxt *lctxt,REG regno,REGVAL regval);
694  /*
695  * This is just syntactic sugar for getregno(CREG_IP) + readreg().
696  */
697  int (*readipreg)(struct location_ctxt *lctxt,REGVAL *regval);
698 
699  /*
700  * Straightforward memory operations.
701  */
702  int (*readword)(struct location_ctxt *lctxt,ADDR real_addr,ADDR *pval);
703  int (*writeword)(struct location_ctxt *lctxt,ADDR real_addr,ADDR pval);
704  int (*relocate)(struct location_ctxt *lctxt,ADDR obj_addr,ADDR *real_addr);
705  int (*unrelocate)(struct location_ctxt *lctxt,ADDR real_addr,ADDR *obj_addr);
706  /*
707  * Gets the target-specific regno for the common_reg_t reg.
708  */
709  int (*getregno)(struct location_ctxt *lctxt,common_reg_t reg,REG *o_reg);
710  int (*getaddrsize)(struct location_ctxt *lctxt);
711 };
712 
713 /*
714  * location_ctxt couples a location_ops struct for reading machine state
715  * to a notion of a stack of activations (frames) in that machine.
716  * Basically, things that can resolve locations (debuginfo backends)
717  * must provide debugfile_ops to virtually restore saved registers in
718  * frame N-1 to frame N (where 0 is the most recent frame). These
719  * operations use location_ctxt_read_reg|read_addr to read registers
720  * from the machine's state (and frame cache). They can also cache
721  * pseudo register values if desireable. Then every time a dwdebug user
722  * calls location_resolve()
723  *
724  * The @current_frame member indicates which frame the location_ops
725  * should use for their current operation. We expect that the
726  * @lops_priv member is per-frame anyway -- so this is a convenient
727  * multi-arg wrapper.
728  *
729  * So, the sequence:
730  *
731  * * location_resolve(loc,ctxt) is called. It uses
732  * ctxt->current_frame as the argument to calling
733  * location_ops->readreg/cache/readipreg as necessary.
734  * * These ops either read a machine value from frame 0; read a cached
735  * value from frame N; or use location_ctxt_read_reg to read the
736  * saved value for frame N in frame N - 1.
737  * * The unwinder uses location_ctxt_read_retaddr and
738  * location_ctxt_read_cfa to determine the value of IP to be
739  * returned to when done with current_frame; and the stack pointer
740  * of the start of the current_frame (CFA). It then places these
741  * values into current_frame + 1 as it creates that frame.
742  */
744  struct location_ops *ops;
745  void *priv;
747 };
748 
750 int location_ctxt_read_retaddr(struct location_ctxt *lctxt,ADDR *o_retaddr);
751 /*
752  * Attempts to load the value of @reg in @lctxt->current_frame.
753  */
754 int location_ctxt_read_reg(struct location_ctxt *lctxt,REG reg,REGVAL *o_regval);
755 //int location_ctxt_read_all_registers(struct location_ctxt *lctxt,
756 int location_ctxt_write_reg(REG reg,struct location_ctxt *lctxt,REGVAL regval);
757 int location_ctxt_get_lops(struct location_ctxt *lctxt,
758  struct location_ops **ops,void **priv);
759 void location_ctxt_free(struct location_ctxt *lctxt);
760 
765 struct symbol_root;
766 struct symbol_root_dwarf;
767 struct symbol_root_elf;
768 struct symbol_type_members;
769 struct symbol_function;
770 struct symbol_variable;
771 struct symbol_label;
772 struct symbol_block;
773 struct symbol_inline;
774 
775 /*
776  * Symbols are always attached to a containing scope, unless they are a
777  * SYMBOL_TYPE_ROOT symbol. That scope may have arisen due to a
778  * hierarchy of names; or due to a hierarchy of code blocks.
779  */
780 struct symbol {
781  /*
782  * Our name, if any.
783  *
784  * BUT, see comments about 'extname' below!!! Do not free .name if
785  * extname is set! Right now it can only be set for type symbols;
786  * hence, it is in the type section of the primary union below.
787  */
788  char *name;
789 
790  /*
791  * Our containing scope or symbol. Every symbol (except a root
792  * symbol) is in a scope. This is the best way to abstract this for
793  * different languages. When you think about it, some languages
794  * have symbols nested directly in other symbols and scope is de
795  * facto (i.e., a C struct member); but in other languages, a
796  * directly nested symbol might still be part of a new scope (i.e.,
797  * a C++ member var/function).
798  *
799  * One word of warning: although all symbols have parents, except
800  * SYMBOL_TYPE_ROOT symbols, the parent might not be the *scope*
801  * parent. For instance, a local var in an anonymous lexical scope
802  * in a C function would have the function as its parent (found via
803  * symbol->scope->...->scope->symbol); but its scope would *not* be
804  * the function's directly owned scope.
805  */
806  struct scope *scope;
807 
808  /*
809  * If we copy the string table from the ELF binary
810  * brute-force to save on lots of mallocs per symbol name,
811  * we don't malloc each symbol's .name . This means that
812  * for type names that must be prepended to (i.e., the DWARF
813  * name for a struct is just 'X', but we have to put it into
814  * the symtab as 'struct X' to avoid typedef collisions
815  * (i.e., typedef struct X X). This means we have to drum
816  * up a fake name.
817  *
818  * But, the fake name always contains the real name as a substring.
819  * So, this is the offset of that string.
820  */
821  unsigned int orig_name_offset:8;
822 
823  /* Where we exist. */
824  unsigned int srcline:SRCLINE_BITS;
825 
826  /* If this is a type symbol, which type. */
828 
829  /* Are we full or partial? */
831 
832  /* The kind of symbol we are. */
834 
835  /* The symbol source. */
837 
838  unsigned int
840  isshared:1,
842  isexternal:1,
844  isdeclaration:1,
845  decldefined:1,
846  decltypedefined:1,
847  isprototyped:1,
848  isparam:1,
849  ismember:1,
850  isenumval:1,
852  isdeclinline:1,
853  isinlined:1,
854  has_addr:1,
855  size_is_bytes:1,
856  size_is_bits:1,
857  guessed_size:1,
858  name_nofree:1,
860  constval_nofree:1;
861 
862  /* Our refcnt. */
864  /* Our weak reference count. */
865  //REFCNT refcntw;
866 
867  /* Our offset location in the debugfile. */
869 
870  /*
871  * If this is a type symbol, datatype_ref and datatype are used as
872  * part of its type definition when the definition references
873  * another type (i.e., typedefs).
874  *
875  * If this is an instance symbol, datatype_ref and datatype are the
876  * instance's type.
877  *
878  * If we see the use of the type before the type, or we're doing
879  * partial loads, we can only fill in the ref and fill the datatype
880  * in a postpass.
881  */
883 
884  /*
885  * If this is a type or var debug symbol, or an ELF symbol, it may
886  * be nonzero.
887  *
888  * If @size.bytes is set, @size_is_bytes will be set above.
889  * If @size.bits and/or @size.offset is set, @size_is_bits will be
890  * set above (and if both a byte_size and bit_size are present,
891  * ctbytes will inherit the byte_size).
892  *
893  * If a type or variable has both a byte_size and a bit_size (gcc
894  * does this for bitfields -- in its DWARF output, byte_size is the
895  * size of the type containing the bitfield; bit_size is the actual
896  * size of the bitfield), bit_size is given precedence, and
897  * byte_size is "lost" -- which is what we care about. WHOOPS --
898  * actually we do care about it for printing values at least.
899  */
900  union {
901  uint32_t bytes;
902  struct {
903 #define SIZE_BITS_SIZE 10
904 #define SIZE_OFFSET_SIZE 10
905 #define SIZE_CTBYTES_SIZE 12
909  };
910  } size;
911 
912  /*
913  * If this symbol has an address (or multiple addresses, or a range
914  * of addresses, this is the smallest one.
915  */
917 
918  /*
919  * If this symbol has a datatype, this is it. These symbols have datatypes:
920  * DATATYPE_FUNC DATATYPE_PTR DATATYPE_REF DATATYPE_TYPEDEF
921  * DATATYPE_CONST DATATYPE_VOL
922  * SYMBOL_TYPE_FUNC SYMBOL_TYPE_VAR
923  * (DATATYPE_ENUM *could* have a type, but we don't bother).
924  */
925  struct symbol *datatype;
926 
927  /*
928  * The meaning of these fields is conditional based on @type and
929  * @datatype_code.
930  *
931  * Note, however, that just because a field is valid does not mean
932  * it is set! Fields spring into existence as needed; backends and
933  * users should only touch them through accessor macros/functions.
934  *
935  * type == SYMBOL_TYPE_ROOT
936  * @extra.root is valid
937  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_BASE
938  * @extra.encoding is valid.
939  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_ARRAY
940  * @extra.subranges valid
941  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_ENUM
942  * @extra.members valid
943  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_FUNC
944  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_STRUCT
945  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_UNION
946  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_CLASS
947  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_NAMESPACE
948  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_TEMPLATE
949  * @extra.container valid
950  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_VOID
951  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_PTR
952  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_REF
953  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_TYPEDEF
954  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_CONST
955  * type == SYMBOL_TYPE_TYPE && datatype_code == DATATYPE_VOL
956  * @extra invalid
957  * type == SYMBOL_TYPE_FUNC
958  * @extra.function is valid
959  * type == SYMBOL_TYPE_VAR
960  * @extra.variable is valid
961  * type == SYMBOL_TYPE_LABEL
962  * @extra.label is valid
963  * type == SYMBOL_TYPE_BLOCK
964  * @extra.block is valid
965  */
966  union {
967  /*
968  * Do we have content, period? Sometimes useful to check in
969  * type-agnostic manner.
970  */
971  void *exists;
972 
973  struct symbol_root *root;
975  GSList *subranges;
976  GSList *members;
978  struct symbol_function *function;
982  } extra;
983 };
984 
985 struct symbol_root {
986  /*
987  * One of these will be set, depending on if it's a debugfile symbol
988  * or a binfile symbol.
989  */
991  struct binfile *binfile;
992 
993  char *compdirname;
994  char *producer;
995  char *language;
996  short int lang_code;
997 
999  producer_nofree:1,
1000  language_nofree:1,
1001  has_entry_pc:1;
1002 
1003  struct scope *scope;
1005 
1006  void *priv;
1007 };
1008 
1010  struct symbol *root;
1012  Dwfl_Module *dwflmod;
1013  Dwarf *dbg;
1014  size_t cuhl;
1015  Dwarf_Half version;
1016  uint8_t addrsize;
1017  uint8_t offsize;
1018  Dwarf_Off abbroffset;
1019  Dwarf_Off nextcu;
1020 
1021  /* Kept until the whole CU is loaded. */
1022  GHashTable *reftab;
1023  GHashTable *refuselist;
1024  GHashTable *spec_reftab;
1026 
1028 };
1029 
1031  struct binfile *binfile;
1032 };
1033 
1034 /*
1035  * Notes. struct/union/enum/function/class types, and function
1036  * instances all have members. In C, only function instances have
1037  * symtabs associated with them. In C++, struct/union/class types may
1038  * also have type members (such as typedefs, or more struct/union/class
1039  * types). In both languages, function instances have symtabs, of
1040  * course. Any time a construct can both have ordered members, and
1041  * symtab entries, we store both the symtab and the order of the
1042  * members.
1043  *
1044  * So, to support C++, we always eat extra bytes for an unnecessary
1045  * symtab pointer for C (or for C++ struct/union/class types that don't
1046  * really need the symbol table for extra type info!).
1047  */
1049  /*
1050  * An ordering over the members.
1051  */
1052  GSList *members;
1053  /*
1054  * The scope created by this container. Note that type symbols
1055  * don't have block scope associated with them; they are about name
1056  * scope. Again, it is struct scope here instead of struct symdict
1057  * because sometimes a symbol's parent is a scope; sometimes it's a
1058  * symbol -- but we only wanted to spend one pointer on that. So
1059  * scope is kind of a unifying concept.
1060  */
1061  struct scope *scope;
1062 };
1063 
1065  GSList *members;
1066  /*
1067  * The scope created by this function.
1068  */
1069  struct scope *scope;
1070  /* The frame base location. */
1071  struct location *fbloc;
1072  uint8_t has_entry_pc:1,
1073  prologue_guessed:1,
1074  prologue_known:1,
1075  epilogue_known:1;
1080 };
1081 
1082 typedef char * dwarf_cfa_info_t;
1083 
1085  struct location *loc;
1086  /* If this instance already has a value, this is it! */
1087  void *constval;
1089 };
1090 
1093 };
1094 
1096  GSList *members;
1097  struct scope *scope;
1099 };
1100 
1102  /* If this instance is inlined, these point back to the
1103  * source for the inlined instance. If it was a forward ref
1104  * in the DWARF info, origin_ref is set and origin has to be
1105  * filled in a postpass.
1106  */
1108  struct symbol *origin;
1109 
1110  /* If this symbol was declared or is inlined (is an abstract
1111  * origin), this is a list of the inline instance symbols
1112  * corresponding to this abstract origin.
1113  */
1115 };
1116 
1117 #define SYMBOL_IS_DWARF(sym) ((sym) && (sym)->source == SYMBOL_SOURCE_DWARF)
1118 #define SYMBOL_IS_ELF(sym) ((sym) && (sym)->source == SYMBOL_SOURCE_ELF)
1119 
1120 #define SYMBOL_IS_FULL(sym) ((sym)->loadtag == LOADTYPE_FULL)
1121 #define SYMBOL_IS_PARTIAL(sym) ((sym)->loadtag == LOADTYPE_PARTIAL)
1122 
1123 #define SYMBOL_IS_ROOT(sym) ((sym)->type == SYMBOL_TYPE_ROOT)
1124 #define SYMBOL_IS_TYPE(sym) ((sym)->type == SYMBOL_TYPE_TYPE)
1125 #define SYMBOL_IS_VAR(sym) ((sym)->type == SYMBOL_TYPE_VAR)
1126 #define SYMBOL_IS_FUNC(sym) ((sym)->type == SYMBOL_TYPE_FUNC)
1127 #define SYMBOL_IS_LABEL(sym) ((sym)->type == SYMBOL_TYPE_LABEL)
1128 #define SYMBOL_IS_BLOCK(sym) ((sym)->type == SYMBOL_TYPE_BLOCK)
1129 #define SYMBOL_IS_INSTANCE(sym) ((sym)->type != SYMBOL_TYPE_TYPE \
1130  && (sym)->type != SYMBOL_TYPE_ROOT \
1131  && (sym)->type != SYMBOL_TYPE_NONE)
1132 
1133 #define SYMBOL_IS_FULL_ROOT(sym) ((sym)->type == SYMBOL_TYPE_ROOT \
1134  && (sym)->extra.exists)
1135 #define SYMBOL_IS_FULL_VAR(sym) ((sym)->type == SYMBOL_TYPE_VAR \
1136  && (sym)->extra.exists)
1137 #define SYMBOL_IS_FULL_FUNC(sym) ((sym)->type == SYMBOL_TYPE_FUNC \
1138  && (sym)->extra.exists)
1139 #define SYMBOL_IS_FULL_LABEL(sym) ((sym)->type == SYMBOL_TYPE_LABEL \
1140  && (sym)->extra.exists)
1141 #define SYMBOL_IS_FULL_BLOCK(sym) ((sym)->type == SYMBOL_TYPE_BLOCK \
1142  && (sym)->extra.exists)
1143 
1144 #define SYMBOL_IST_VOID(sym) (SYMBOL_IS_TYPE(sym) \
1145  && (sym)->datatype_code == DATATYPE_VOID)
1146 #define SYMBOL_IST_ARRAY(sym) (SYMBOL_IS_TYPE(sym) \
1147  && (sym)->datatype_code == DATATYPE_ARRAY)
1148 #define SYMBOL_IST_STRUCT(sym) (SYMBOL_IS_TYPE(sym) \
1149  && (sym)->datatype_code == DATATYPE_STRUCT)
1150 #define SYMBOL_IST_ENUM(sym) (SYMBOL_IS_TYPE(sym) \
1151  && (sym)->datatype_code == DATATYPE_ENUM)
1152 #define SYMBOL_IST_PTR(sym) (SYMBOL_IS_TYPE(sym) \
1153  && ((sym)->datatype_code == DATATYPE_PTR \
1154  || (sym)->datatype_code == DATATYPE_REF))
1155 #define SYMBOL_IST_FUNC(sym) (SYMBOL_IS_TYPE(sym) \
1156  && (sym)->datatype_code == DATATYPE_FUNC)
1157 #define SYMBOL_IST_TYPEDEF(sym) (SYMBOL_IS_TYPE(sym) \
1158  && (sym)->datatype_code \
1159  == DATATYPE_TYPEDEF)
1160 #define SYMBOL_IST_UNION(sym) (SYMBOL_IS_TYPE(sym) \
1161  && (sym)->datatype_code == DATATYPE_UNION)
1162 #define SYMBOL_IST_BASE(sym) (SYMBOL_IS_TYPE(sym) \
1163  && (sym)->datatype_code == DATATYPE_BASE)
1164 #define SYMBOL_IST_CONST(sym) (SYMBOL_IS_TYPE(sym) \
1165  && (sym)->datatype_code == DATATYPE_CONST)
1166 #define SYMBOL_IST_VOL(sym) (SYMBOL_IS_TYPE(sym) \
1167  && (sym)->datatype_code == DATATYPE_VOL)
1168 #define SYMBOL_IST_NAMESPACE(sym)(SYMBOL_IS_TYPE(sym) \
1169  && (sym)->datatype_code == DATATYPE_NAMESPACE)
1170 #define SYMBOL_IST_CLASS(sym) (SYMBOL_IS_TYPE(sym) \
1171  && (sym)->datatype_code == DATATYPE_CLASS)
1172 #define SYMBOL_IST_TEMPLATE(sym) (SYMBOL_IS_TYPE(sym) \
1173  && (sym)->datatype_code == DATATYPE_TEMPLATE)
1174 /* convenient! */
1175 #define SYMBOL_IST_STUN(sym) (SYMBOL_IS_TYPE(sym) \
1176  && ((sym)->datatype_code == DATATYPE_STRUCT \
1177  || (sym)->datatype_code == DATATYPE_UNION))
1178 #define SYMBOL_IST_STUNC(sym) (SYMBOL_IS_TYPE(sym) \
1179  && ((sym)->datatype_code == DATATYPE_STRUCT \
1180  || (sym)->datatype_code == DATATYPE_UNION \
1181  || (sym)->datatype_code == DATATYPE_CLASS))
1182 
1183 #define SYMBOL_TYPE_FLAG_MATCHES(sym,flags) \
1184  (flags == SYMBOL_TYPE_FLAG_NONE \
1185  || ((flags & SYMBOL_TYPE_FLAG_TYPE && SYMBOL_IS_TYPE(sym)) \
1186  || (flags & SYMBOL_TYPE_FLAG_VAR && SYMBOL_IS_VAR(sym)) \
1187  || (flags & SYMBOL_TYPE_FLAG_VAR_ARG && SYMBOL_IS_VAR(sym) \
1188  && (sym)->isparam) \
1189  || (flags & SYMBOL_TYPE_FLAG_VAR_MEMBER && SYMBOL_IS_VAR(sym) \
1190  && (sym)->ismember) \
1191  || (flags & SYMBOL_TYPE_FLAG_VAR_GLOBAL && SYMBOL_IS_VAR(sym) \
1192  && (sym)->isexternal) \
1193  || (flags & SYMBOL_TYPE_FLAG_VAR_LOCAL && SYMBOL_IS_VAR(sym) \
1194  && !((sym)->isparam || (sym)->isexternal || (sym)->ismember \
1195  || (sym)->isenumval)) \
1196  || (flags & SYMBOL_TYPE_FLAG_FUNC && SYMBOL_IS_FUNC(sym)) \
1197  || (flags & SYMBOL_TYPE_FLAG_LABEL && SYMBOL_IS_LABEL(sym)) \
1198  || (flags & SYMBOL_TYPE_FLAG_ROOT && SYMBOL_IS_ROOT(sym)) \
1199  || (flags & SYMBOL_TYPE_FLAG_BLOCK && SYMBOL_IS_BLOCK(sym))))
1200 
1201 #define SYMBOL_IST_CONTAINER(sym) (SYMBOL_IS_TYPE(sym) \
1202  && ((sym)->datatype_code == DATATYPE_FUNC \
1203  || (sym)->datatype_code == DATATYPE_STRUCT \
1204  || (sym)->datatype_code == DATATYPE_UNION \
1205  || (sym)->datatype_code == DATATYPE_NAMESPACE \
1206  || (sym)->datatype_code == DATATYPE_CLASS \
1207  || (sym)->datatype_code == DATATYPE_TEMPLATE))
1208 #define SYMBOL_HAS_MEMBERS(sym) \
1209  (SYMBOL_IST_CONTAINER(sym) || SYMBOL_IST_ENUM(sym) \
1210  || SYMBOL_IS_ROOT(sym) || SYMBOL_IS_FUNC(sym) || SYMBOL_IS_BLOCK(sym))
1211 #define SYMBOL_CAN_OWN_SCOPE(sym) \
1212  (SYMBOL_IST_CONTAINER(sym) \
1213  || SYMBOL_IS_ROOT(sym) || SYMBOL_IS_FUNC(sym) || SYMBOL_IS_BLOCK(sym))
1214 #define SYMBOL_IS_OWN_DATATYPE(sym) \
1215  (SYMBOL_IST_VOID(sym) || SYMBOL_IST_STUN(sym) || SYMBOL_IST_BASE(sym) \
1216  || SYMBOL_IST_NAMESPACE(sym) || SYMBOL_IST_CLASS(sym) \
1217  || SYMBOL_IST_TEMPLATE(sym))
1218 
1219 #define SYMBOL_IS_INLINEABLE(sym) \
1220  (SYMBOL_IS_FUNC(sym) || SYMBOL_IS_VAR(sym) \
1221  || SYMBOL_IS_LABEL(sym) || SYMBOL_IS_BLOCK(sym))
1222 
1223 #define SYMBOL_IS_CONTAINER(sym) \
1224  (SYMBOL_IST_CONTAINER(sym) \
1225  || SYMBOL_IS_ROOT(sym) || SYMBOL_IS_FUNC(sym) || SYMBOL_IS_BLOCK(sym))
1226 #define SYMBOL_HAS_EXTRA(sym) ((sym)->extra.exists != NULL)
1227 #define SYMBOL_HAS_INLINE(sym) \
1228  (SYMBOL_HAS_EXTRA(sym) \
1229  && ((SYMBOL_IS_VAR(sym) && SYMBOLX_VAR(sym)->ii) \
1230  || (SYMBOL_IS_FUNC(sym) && SYMBOLX_FUNC(sym)->ii) \
1231  || (SYMBOL_IS_LABEL(sym) && SYMBOLX_LABEL(sym)->ii) \
1232  || (SYMBOL_IS_BLOCK(sym) && SYMBOLX_BLOCK(sym)->ii)))
1233 
1234 #define SYMBOLX_ROOT(sym) (sym)->extra.root
1235 #define SYMBOL_RX_ROOT(sym,rvar) struct symbol_root *rvar = SYMBOLX_ROOT(sym)
1236 #define SYMBOL_WX_ROOT(sym,wvar,reterr) \
1237  struct symbol_root *wvar; \
1238  if (!SYMBOL_IS_ROOT(sym)) return reterr; \
1239  if ((sym)->extra.root) \
1240  wvar = (sym)->extra.root; \
1241  else \
1242  wvar = (sym)->extra.root = (struct symbol_root *) \
1243  calloc(1,sizeof(*(sym)->extra.root));
1244 #define SYMBOLX_ENCODING_V(sym) (sym)->extra.encoding
1245 #define SYMBOLX_SUBRANGES(sym) (sym)->extra.subranges
1246 #define SYMBOLX_CONTAINER(sym) (sym)->extra.container
1247 #define SYMBOL_RX_CONTAINER(sym,rvar) \
1248  struct symbol_type_container *rvar = SYMBOLX_CONTAINER(sym)
1249 #define SYMBOL_WX_CONTAINER(sym,wvar,reterr) \
1250  struct symbol_type_container *wvar; \
1251  if (!SYMBOL_IST_CONTAINER(sym)) return reterr; \
1252  if ((sym)->extra.container) \
1253  wvar = (sym)->extra.container; \
1254  else \
1255  wvar = (sym)->extra.container = (struct symbol_type_container *) \
1256  calloc(1,sizeof(*(sym)->extra.container));
1257 #define SYMBOLX_FUNC(sym) (sym)->extra.function
1258 #define SYMBOL_RX_FUNC(sym,rvar) struct symbol_function *rvar = SYMBOLX_FUNC(sym)
1259 #define SYMBOL_WX_FUNC(sym,wvar,reterr) \
1260  struct symbol_function *wvar; \
1261  if (!SYMBOL_IS_FUNC(sym)) return reterr; \
1262  if ((sym)->extra.function) \
1263  wvar = (sym)->extra.function; \
1264  else \
1265  wvar = (sym)->extra.function = (struct symbol_function *) \
1266  calloc(1,sizeof(*(sym)->extra.function));
1267 
1268 #define SYMBOLX_VAR(sym) (sym)->extra.variable
1269 #define SYMBOL_RX_VAR(sym,rvar) struct symbol_variable *rvar = SYMBOLX_VAR(sym)
1270 #define SYMBOL_WX_VAR(sym,wvar,reterr) \
1271  struct symbol_variable *wvar; \
1272  if (!SYMBOL_IS_VAR(sym)) return reterr; \
1273  if ((sym)->extra.variable) \
1274  wvar = (sym)->extra.variable; \
1275  else \
1276  wvar = (sym)->extra.variable = (struct symbol_variable *) \
1277  calloc(1,sizeof(*(sym)->extra.variable));
1278 #define SYMBOLX_LABEL(sym) (sym)->extra.label
1279 #define SYMBOL_RX_LABEL(sym,rvar) struct symbol_label *rvar = SYMBOLX_LABEL(sym)
1280 #define SYMBOL_WX_LABEL(sym,wvar,reterr) \
1281  struct symbol_label *wvar; \
1282  if (!SYMBOL_IS_LABEL(sym)) return reterr; \
1283  if ((sym)->extra.label) \
1284  wvar = (sym)->extra.label; \
1285  else \
1286  wvar = (sym)->extra.label = (struct symbol_label *) \
1287  calloc(1,sizeof(*(sym)->extra.label));
1288 #define SYMBOLX_BLOCK(sym) (sym)->extra.block
1289 #define SYMBOL_RX_BLOCK(sym,rvar) struct symbol_block *rvar = SYMBOLX_BLOCK(sym)
1290 #define SYMBOL_WX_BLOCK(sym,wvar,reterr) \
1291  struct symbol_block *wvar; \
1292  if (!SYMBOL_IS_BLOCK(sym)) return reterr; \
1293  if ((sym)->extra.block) \
1294  wvar = (sym)->extra.block; \
1295  else \
1296  wvar = (sym)->extra.block = (struct symbol_block *) \
1297  calloc(1,sizeof(*(sym)->extra.block));
1298 #define SYMBOLX_INLINE(sym) \
1299  (!SYMBOL_HAS_EXTRA(sym) ? NULL : \
1300  (SYMBOL_IS_VAR(sym) ? SYMBOLX_VAR(sym)->ii : \
1301  (SYMBOL_IS_FUNC(sym) ? SYMBOLX_FUNC(sym)->ii : \
1302  (SYMBOL_IS_LABEL(sym) ? SYMBOLX_LABEL(sym)->ii : \
1303  (SYMBOL_IS_BLOCK(sym) ? SYMBOLX_BLOCK(sym)->ii : NULL)))))
1304 #define SYMBOL_RX_INLINE(sym,rvar) \
1305  struct symbol_inline *rvar = SYMBOLX_INLINE(sym)
1306 #define SYMBOL_WX_INLINE(sym,wvar,reterr) \
1307  struct symbol_inline *wvar; \
1308  if (SYMBOL_IS_FUNC(sym)) { \
1309  SYMBOL_WX_FUNC(sym,sf,reterr); \
1310  if (!sf->ii) sf->ii = calloc(1,sizeof(*(sf->ii))); \
1311  wvar = sf->ii; \
1312  } \
1313  else if (SYMBOL_IS_VAR(sym)) { \
1314  SYMBOL_WX_VAR(sym,sv,reterr); \
1315  if (!sv->ii) sv->ii = calloc(1,sizeof(*(sv->ii))); \
1316  wvar = sv->ii; \
1317  } \
1318  else if (SYMBOL_IS_LABEL(sym)) { \
1319  SYMBOL_WX_LABEL(sym,sl,reterr); \
1320  if (!sl->ii) sl->ii = calloc(1,sizeof(*(sl->ii))); \
1321  wvar = sl->ii; \
1322  } \
1323  else if (SYMBOL_IS_BLOCK(sym)) { \
1324  SYMBOL_WX_BLOCK(sym,sb,reterr); \
1325  if (!sb->ii) sb->ii = calloc(1,sizeof(*(sb->ii))); \
1326  wvar = sb->ii; \
1327  } \
1328  else \
1329  return reterr;
1330 #define SYMBOLX_MEMBERS(sym) \
1331  (!SYMBOL_HAS_EXTRA(sym) ? NULL : \
1332  (SYMBOL_IS_FUNC(sym) ? SYMBOLX_FUNC(sym)->members : \
1333  (SYMBOL_IS_FUNC(sym) ? SYMBOLX_FUNC(sym)->members : \
1334  (SYMBOL_IST_ENUM(sym) ? (sym)->extra.members : \
1335  (SYMBOL_IST_CONTAINER(sym) ? SYMBOLX_CONTAINER(sym)->members : NULL)))))
1336 #define SYMBOLX_SCOPE(sym) \
1337  (!SYMBOL_HAS_EXTRA(sym) ? NULL : \
1338  (SYMBOL_IS_FUNC(sym) ? SYMBOLX_FUNC(sym)->scope : \
1339  (SYMBOL_IST_CONTAINER(sym) ? SYMBOLX_CONTAINER(sym)->scope : \
1340  (SYMBOL_IS_ROOT(sym) ? SYMBOLX_ROOT(sym)->scope : \
1341  (SYMBOL_IS_BLOCK(sym) ? SYMBOLX_BLOCK(sym)->scope : NULL)))))
1342 #define SYMBOLX_VAR_LOC(sym) \
1343  (!SYMBOL_HAS_EXTRA(sym) ? NULL : \
1344  (SYMBOL_IS_VAR(sym) ? SYMBOLX_VAR(sym)->loc : NULL))
1345 #define SYMBOLX_VAR_CONSTVAL(sym) \
1346  (!SYMBOL_HAS_EXTRA(sym) ? NULL : \
1347  (SYMBOL_IS_VAR(sym) ? SYMBOLX_VAR(sym)->constval : NULL))
1348 
1349 #define SYMBOL_EXPAND_WARN(symbol) \
1350  do { \
1351  if (!SYMBOL_IS_FULL(symbol)) { \
1352  if (symbol_expand(symbol)) \
1353  vwarn("could not expand datatype symbol %s; continuing!\n", \
1354  symbol_get_name(symbol)); \
1355  } \
1356  } while(0);
1357 #define SYMBOL_EXPAND_ERROR_RET(symbol,retval) \
1358  do { \
1359  if (!SYMBOL_IS_FULL(symbol)) { \
1360  if (symbol_expand(symbol)) { \
1361  verror("could not expand datatype symbol %s; continuing!\n", \
1362  symbol_get_name(symbol)); \
1363  return retval; \
1364  } \
1365  } \
1366  } while(0);
1367 #define SYMBOL_EXPAND_ERROR_OUT(symbol,label) \
1368  do { \
1369  if (!SYMBOL_IS_FULL(symbol)) { \
1370  if (symbol_expand(symbol)) { \
1371  verror("could not expand datatype symbol %s; continuing!\n", \
1372  symbol_get_name(symbol)); \
1373  goto label; \
1374  } \
1375  } \
1376  } while(0);
1377 
1378 static inline symbol_type_flag_t symbol_to_type_flag_t(struct symbol *symbol) {
1379  symbol_type_flag_t retval = 0;
1380 
1381  if (SYMBOL_IS_TYPE(symbol))
1382  retval = SYMBOL_TYPE_FLAG_TYPE;
1383  else if (SYMBOL_IS_ROOT(symbol))
1384  retval = SYMBOL_TYPE_FLAG_ROOT;
1385  else if (SYMBOL_IS_VAR(symbol)) {
1386  retval = SYMBOL_TYPE_FLAG_VAR;
1387  if (symbol->isparam)
1388  retval |= SYMBOL_TYPE_FLAG_VAR_ARG;
1389  if (symbol->ismember)
1390  retval |= SYMBOL_TYPE_FLAG_VAR_MEMBER;
1391  }
1392  else if (SYMBOL_IS_FUNC(symbol))
1393  retval = SYMBOL_TYPE_FLAG_FUNC;
1394  else if (SYMBOL_IS_LABEL(symbol))
1395  retval = SYMBOL_TYPE_FLAG_LABEL;
1396  else if (SYMBOL_IS_BLOCK(symbol))
1397  retval = SYMBOL_TYPE_FLAG_BLOCK;
1398 
1399  return retval;
1400 }
1401 
1402 /*
1403  * Internal lookup prototypes.
1404  */
1405 struct lsymbol *scope_lookup_sym__int(struct scope *scope,
1406  const char *name,const char *delim,
1407  symbol_type_flag_t flags);
1408 struct lsymbol *symbol_lookup_sym__int(struct symbol *symbol,
1409  const char *name,const char *delim);
1410 
1411 /*
1412  * Returns 0 if the symbol is already LOADTYPE_FULL, or if the full load
1413  * succeeds. Returns nonzero if failure.
1414  *
1415  * Use the macros above, not this function.
1416  */
1417 int symbol_expand(struct symbol *symbol);
1418 
1419 /*
1420  * This function simplifies the process of adding a child symbol to a
1421  * parent.
1422  */
1423 int symbol_insert_symbol(struct symbol *parent,struct symbol *child);
1424 int symbol_remove_symbol(struct symbol *parent,struct symbol *child);
1425 int symbol_change_parent(struct symbol *parent,struct symbol *child,
1426  struct symbol *newparent);
1427 /*
1428  * If this symbol's name was modified by symbol_build_extname (i.e., if
1429  * it is an enum/struct/union type), this returns the base name.
1430  */
1431 char *symbol_get_name_orig(struct symbol *symbol);
1432 void symbol_set_name(struct symbol *symbol,char *name,int name_copy);
1433 void symbol_build_extname(struct symbol *symbol);
1434 int symbol_has_ext_name(struct symbol *symbol);
1435 
1436 /*
1437  * Users should not have to deal directly with scopes. These functions
1438  * do *not* hold on the returned scope.
1439  */
1440 struct scope *symbol_containing_scope(struct symbol *symbol);
1441 struct scope *symbol_read_owned_scope(struct symbol *symbol);
1442 struct scope *symbol_write_owned_scope(struct symbol *symbol);
1443 struct scope *symbol_link_owned_scope(struct symbol *symbol,
1444  struct scope *new_parent);
1445 
1446 #define symbol_set_external(s) (s)->isexternal = 1
1447 #define symbol_set_parameter(s) (s)->isparam = 1
1448 #define symbol_set_enumval(s) (s)->isenumval = 1
1449 #define symbol_set_member(s) (s)->ismember = 1
1450 #define symbol_set_unspec_params(s) (s)->has_unspec_params = 1
1451 void symbol_set_srcline(struct symbol *s,int sl);
1452 void symbol_set_bytesize(struct symbol *s,uint32_t b);
1453 void symbol_set_bitsize(struct symbol *s,uint32_t b);
1454 void symbol_set_bitoffset(struct symbol *s,uint32_t bo);
1455 void symbol_set_bitsize_all(struct symbol *s,uint32_t b,uint32_t bo,uint32_t ctb);
1456 void symbol_set_addr(struct symbol *s,ADDR a);
1457 int symbol_set_root_priv(struct symbol *symbol,void *priv);
1458 int symbol_set_root_compdir(struct symbol *symbol,char *compdirname,int copy);
1459 int symbol_set_root_producer(struct symbol *symbol,char *producer,int copy);
1460 int symbol_set_root_language(struct symbol *symbol,char *language,int copy,
1461  short int lang_code);
1462 int symbol_set_encoding(struct symbol *symbol,encoding_t num);
1463 
1464 int symbol_add_subrange(struct symbol *symbol,int subrange);
1465 int symbol_set_entry_pc(struct symbol *symbol,ADDR entry_pc);
1466 int symbol_set_location(struct symbol *symbol,struct location *loc);
1467 int symbol_set_inline_info(struct symbol *symbol,int isinlined,int isdeclinline);
1468 int symbol_set_inline_origin(struct symbol *symbol,
1469  SMOFFSET ref,struct symbol *origin);
1470 /* int symbol_set_inline_instances(struct symbol *symbol,GSList *instances); */
1471 int symbol_add_inline_instance(struct symbol *symbol,struct symbol *instance);
1472 int symbol_set_constval(struct symbol *symbol,void *value,int len,int copy);
1473 
1474 struct symbol *__symbol_get_one_member__int(struct symbol *symbol,char *member,
1475  struct array_list **chainptr);
1476 struct symbol *symbol_get_one_member__int(struct symbol *symbol,char *member);
1477 
1478 void symbol_free_extra(struct symbol *symbol);
1479 /*
1480  * Frees a symbol. Users should never call this; call symbol_release
1481  * instead.
1482  */
1483 REFCNT symbol_free(struct symbol *symbol,int force);
1484 
1488 void g_hash_foreach_dump_symbol_list(gpointer key __attribute__((unused)),
1489  gpointer value,gpointer userdata);
1490 void g_hash_foreach_dump_symbol(gpointer key __attribute__((unused)),
1491  gpointer value,gpointer userdata);
1492 
1493 #endif
struct scope * symbol_containing_scope(struct symbol *symbol)
Definition: debug.c:2671
unsigned int srcline
Definition: dwdebug_priv.h:824
int(* getaddrsize)(struct location_ctxt *lctxt)
Definition: dwdebug_priv.h:710
int symbol_insert_symbol(struct symbol *parent, struct symbol *child)
Definition: debug.c:2758
char * data
Definition: dwdebug_priv.h:605
struct debugfile * debugfile_create_basic(debugfile_type_t dtype, debugfile_type_flags_t dtflags, char *filename, struct debugfile_load_opts *opts)
Definition: debug.c:1298
void symbol_build_extname(struct symbol *symbol)
Definition: debug.c:2628
struct symdict * symdict_create(void)
Definition: symdict.c:35
void location_ctxt_free(struct location_ctxt *lctxt)
Definition: location.c:812
GSList * subranges
Definition: dwdebug_priv.h:975
struct location * location_copy(struct location *location)
Definition: location.c:313
encoding_t
Definition: dwdebug.h:266
union location::@6 l
uint8_t has_entry_pc
unsigned int has_addr
Definition: dwdebug_priv.h:839
void debugfile_save_declaration(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:2081
uint8_t epilogue_known
ADDR end
Definition: dwdebug_priv.h:438
struct location * fbloc
GHashTable * cfa_cie
Definition: dwdebug_priv.h:280
unsigned int decltypedefined
Definition: dwdebug_priv.h:839
struct debugfile_ops dwarf_debugfile_ops
unsigned int orig_name_offset
Definition: dwdebug_priv.h:821
struct symbol * origin
int location_set_reg_offset(struct location *l, REG reg, OFFSET offset)
Definition: location.c:73
int location_set_implicit_data(struct location *loc, char *data, int len, int nocopy)
Definition: location.c:128
struct symbol_label * label
Definition: dwdebug_priv.h:980
common_reg_t
Definition: arch.h:73
union symbol::@7 size
GHashTable * anontab
Definition: dwdebug_priv.h:383
int debugfile_lookup_addr_alt__int(struct debugfile *debugfile, ADDR addr, struct lsymbol **primary, struct lsymbol **alt)
Definition: debug.c:580
void location_dump(struct location *location, struct dump_info *ud)
Definition: location.c:392
load_type_t
Definition: dwdebug.h:166
Dwarf_Off first_top_level_die_offset
GSList * members
Definition: dwdebug_priv.h:976
Definition: probe.h:392
void symbol_set_srcline(struct symbol *s, int sl)
Definition: debug.c:3194
struct location_ops * ops
Definition: dwdebug_priv.h:744
unsigned int guessed_size
Definition: dwdebug_priv.h:839
Dwarf_Off abbroffset
void symdict_dump(struct symdict *symdict, struct dump_info *ud)
Definition: symdict.c:317
void g_hash_foreach_dump_symbol_list(gpointer key __attribute__((unused)), gpointer value, gpointer userdata)
Definition: debug.c:4847
void symbol_free_extra(struct symbol *symbol)
Definition: debug.c:4402
#define SYMBOL_SOURCE_BITS
Definition: dwdebug.h:183
static uint64_t unsigned int i
load_type_t loadtag
Definition: dwdebug_priv.h:830
struct symbol * debugfile_lookup_root_name(struct debugfile *debugfile, char *name)
Definition: debug.c:1978
int(* writeword)(struct location_ctxt *lctxt, ADDR real_addr, ADDR pval)
Definition: dwdebug_priv.h:703
GHashTable * tab
Definition: dwdebug_priv.h:368
struct location * dwarf_get_static_ops(struct symbol_root_dwarf *srd, const unsigned char *data, Dwarf_Word len, unsigned int attr)
Definition: dwarf_expr.c:987
int scope_insert_symbol(struct scope *scope, struct symbol *symbol)
Definition: scope.c:57
GSList * symdict_match_syms(struct symdict *symdict, struct rfilter *symbol_filter, symbol_type_flag_t flags)
Definition: symdict.c:481
struct array_list __attribute__
SMOFFSET origin_ref
int debugfile_replace_type(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:2334
unsigned int isexternal
Definition: dwdebug_priv.h:839
struct symdict * symdict
Definition: dwdebug_priv.h:466
struct lsymbol * lsymbol_create_from_member__int(struct lsymbol *parent, struct symbol *member)
Definition: debug.c:4632
int(* relocate)(struct location_ctxt *lctxt, ADDR obj_addr, ADDR *real_addr)
Definition: dwdebug_priv.h:704
int(* frame_read_cfa)(struct debugfile *debugfile, struct location_ctxt *lctxt, ADDR *o_cfaaddr)
Definition: dwdebug_priv.h:178
REFCNT debugfile_free(struct debugfile *debugfile, int force)
Definition: debug.c:2384
SMOFFSET ref
Definition: dwdebug_priv.h:868
void location_internal_free(struct location *location)
Definition: location.c:347
int symbol_add_subrange(struct symbol *symbol, int subrange)
Definition: debug.c:3448
struct lsymbol * lsymbol_lookup_sym__int(struct lsymbol *lsymbol, const char *name, const char *delim)
Definition: debug.c:275
int debugfile_type_flags_t
Definition: dwdebug.h:782
unsigned int size_is_bytes
Definition: dwdebug_priv.h:839
REFCNT symbol_free(struct symbol *symbol, int force)
Definition: debug.c:4516
ADDR addr
Definition: dwdebug_priv.h:916
clmatchone_t top_level_die_offsets
void symbol_set_addr(struct symbol *s, ADDR a)
Definition: debug.c:3276
unsigned int isshared
Definition: dwdebug_priv.h:839
struct scope * symbol_link_owned_scope(struct symbol *symbol, struct scope *new_parent)
Definition: debug.c:2726
struct binfile * binfile
struct symbol_block * block
Definition: dwdebug_priv.h:981
int symdict_get_size(struct symdict *symdict)
Definition: symdict.c:68
struct scope * symbol_write_owned_scope(struct symbol *symbol)
Definition: debug.c:2689
#define SIZE_OFFSET_SIZE
Definition: dwdebug_priv.h:904
int32_t SMOFFSET
Definition: common.h:100
symbol_source_t
Definition: dwdebug.h:159
int(* frame_read_all_saved_reg)(struct debugfile *debugfile, struct location_ctxt *lctxt, GHashTable *regcache)
Definition: dwdebug_priv.h:164
char * language
Definition: dwdebug_priv.h:995
GSList * symdict_match_syms_by_tab(struct symdict *symdict, struct rfilter *symbol_filter, symbol_type_flag_t flags, int no_main, int no_dup, int no_anon)
Definition: symdict.c:419
int symdict_get_size_simple(struct symdict *symdict)
Definition: symdict.c:55
void symbol_set_bitoffset(struct symbol *s, uint32_t bo)
Definition: debug.c:3247
ADDR start
Definition: dwdebug_priv.h:437
struct lsymbol * lsymbol_create_noninline__int(struct lsymbol *lsymbol)
Definition: debug.c:4757
int32_t OFFSET
Definition: common.h:65
SMOFFSET datatype_ref
Definition: dwdebug_priv.h:882
struct symbol * debugfile_lookup_root(struct debugfile *debugfile, SMOFFSET offset)
Definition: debug.c:1972
struct symbol_inline * ii
int location_ctxt_write_reg(REG reg, struct location_ctxt *lctxt, REGVAL regval)
int debugfile_load_debuginfo(struct debugfile *debugfile)
int symbol_set_root_compdir(struct symbol *symbol, char *compdirname, int copy)
Definition: debug.c:3294
int location_ctxt_read_retaddr(struct location_ctxt *lctxt, ADDR *o_retaddr)
Definition: location.c:576
int(* frame_read_saved_reg)(struct debugfile *debugfile, struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
Definition: dwdebug_priv.h:154
int symdict_insert_symbol_anon(struct symdict *symdict, struct symbol *symbol)
Definition: symdict.c:201
int(* symbol_root_priv_free)(struct debugfile *debugfile, struct symbol *root)
Definition: dwdebug_priv.h:181
int location_ctxt_read_reg(struct location_ctxt *lctxt, REG reg, REGVAL *o_regval)
Definition: location.c:632
symdict_symbol_dtor_t default_symdict_symbol_dtor
Definition: symdict.c:268
symbol_type_t type
Definition: dwdebug_priv.h:833
uint32_t ctbytes
Definition: dwdebug_priv.h:906
void debugfile_resolve_declarations(struct debugfile *debugfile)
Definition: debug.c:2250
struct symbol_inline * ii
GSList * scope_match_syms(struct scope *scope, struct rfilter *symbol_filter, symbol_type_flag_t flags)
Definition: scope.c:811
OFFSET offset
Definition: dwdebug_priv.h:603
struct scope * scope
REFCNT scope_free(struct scope *scope, int force)
Definition: scope.c:352
symbol_type_t
Definition: dwdebug.h:148
int symbol_remove_symbol(struct symbol *parent, struct symbol *child)
Definition: debug.c:2845
int location_update_loclist(struct location *loc, ADDR start, ADDR end, struct location *rloc, int *action)
Definition: location.c:199
int location_set_implicit_word(struct location *loc, ADDR word)
Definition: location.c:119
int debugfile_remove_root(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:1933
struct symbol_variable * variable
Definition: dwdebug_priv.h:979
#define SYMBOL_TYPE_BITS
Definition: dwdebug.h:182
struct symbol_type_container * container
Definition: dwdebug_priv.h:977
struct range * range
Definition: dwdebug_priv.h:471
struct symbol * scope_get_sym(struct scope *scope, const char *name, symbol_type_flag_t flags)
Definition: scope.c:771
loctype_t dwarf_location_resolve(const unsigned char *data, unsigned int len, struct location_ctxt *lctxt, struct symbol *symbol, struct location *o_loc)
Definition: dwarf_expr.c:213
#define SYMBOL_IS_LABEL(sym)
struct scope * scope
struct symbol * debugfile_find_type(struct debugfile *debugfile, char *typename)
Definition: debug.c:2288
GHashTable * spec_reftab
Dwfl_Module * dwflmod
int symbol_set_location(struct symbol *symbol, struct location *loc)
Definition: debug.c:3365
struct loclistloc * next
Definition: dwdebug_priv.h:562
unsigned int constval_nofree
Definition: dwdebug_priv.h:839
struct lsymbol * lsymbol_create_from_symbol__int(struct symbol *symbol)
Definition: debug.c:4657
int(* load)(struct debugfile *debugfile)
Definition: dwdebug_priv.h:130
struct location * loc
Definition: dwdebug_priv.h:561
#define LOCTYPE_BITS
Definition: dwdebug_priv.h:536
struct symbol * root
int(* symbol_expand)(struct debugfile *debugfile, struct symbol *root, struct symbol *symbol)
Definition: dwdebug_priv.h:134
int(* fini)(struct debugfile *debugfile)
Definition: dwdebug_priv.h:182
struct loclistloc * loclist
Definition: dwdebug_priv.h:606
void symbol_set_name(struct symbol *symbol, char *name, int name_copy)
Definition: debug.c:2615
int location_set_reg(struct location *l, REG reg)
Definition: location.c:55
GSList * inline_instances
int debugfile_add_global(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:2262
unsigned int isparam
Definition: dwdebug_priv.h:839
void lsymbol_append(struct lsymbol *lsymbol, struct symbol *symbol)
Definition: debug.c:4610
int symdict_remove_symbol(struct symdict *symdict, struct symbol *symbol)
Definition: symdict.c:223
datatype_code_t datatype_code
Definition: dwdebug_priv.h:827
debugfile_type_t
Definition: dwdebug.h:770
char * producer
Definition: dwdebug_priv.h:994
struct range * next
Definition: dwdebug_priv.h:439
unsigned int isprototyped
Definition: dwdebug_priv.h:839
REFCNT refcnt
Definition: dwdebug_priv.h:455
int scope_hold_symbol(struct scope *scope, struct symbol *symbol)
Definition: scope.c:73
int(* init)(struct debugfile *debugfile)
Definition: dwdebug_priv.h:129
unsigned int isenumval
Definition: dwdebug_priv.h:839
uint32_t offset
Definition: dwdebug_priv.h:906
struct dt_argp_state opts
Definition: dumptarget.c:111
int(* cachereg)(struct location_ctxt *lctxt, REG regno, REGVAL regval)
Definition: dwdebug_priv.h:693
int location_ctxt_get_lops(struct location_ctxt *lctxt, struct location_ops **ops, void **priv)
struct debugfile * debugfile
Definition: dwdebug_priv.h:990
struct symbol_inline * ii
struct symbol_inline * ii
clrangesimple_t cfa_fde
Definition: dwdebug_priv.h:281
struct lsymbol * lsymbol_create(struct symbol *symbol, struct array_list *chain)
Definition: debug.c:4595
int location_set_member_offset(struct location *l, OFFSET offset)
Definition: location.c:89
REFCNT lsymbol_free(struct lsymbol *lsymbol, int force)
Definition: debug.c:4811
void lsymbol_prepend(struct lsymbol *lsymbol, struct symbol *symbol)
Definition: debug.c:4623
#define SYMBOL_IS_BLOCK(sym)
char * name
Definition: dwdebug_priv.h:788
void symbol_set_bitsize(struct symbol *s, uint32_t b)
Definition: debug.c:3232
int symbol_has_ext_name(struct symbol *symbol)
Definition: debug.c:2667
struct symbol * __symbol_get_one_member__int(struct symbol *symbol, char *member, struct array_list **chainptr)
Definition: debug.c:3815
Pvoid_t clrangesimple_t
Definition: clfit.h:95
struct debugfile * debugfile
SMOFFSET ref
Definition: dwdebug_priv.h:460
struct location_ctxt * location_ctxt_create(struct location_ops *ops, void *priv)
Definition: location.c:802
int(* readipreg)(struct location_ctxt *lctxt, REGVAL *regval)
Definition: dwdebug_priv.h:697
datatype_code_t
Definition: dwdebug.h:208
int(* frame_read_retaddr)(struct debugfile *debugfile, struct location_ctxt *lctxt, ADDR *o_retaddr)
Definition: dwdebug_priv.h:171
unsigned int name_nofree
Definition: dwdebug_priv.h:839
struct binfile * binfile
Definition: dwdebug_priv.h:991
int location_set_runtime(struct location *l, char *data, int len, int nocopy)
Definition: location.c:164
unsigned int has_linkage_name
Definition: dwdebug_priv.h:839
encoding_t encoding
Definition: dwdebug_priv.h:974
struct symbol * symbol_get_one_member__int(struct symbol *symbol, char *member)
Definition: debug.c:4123
int len
Definition: dumptarget.c:52
int scope_remove_symbol(struct scope *scope, struct symbol *symbol)
Definition: scope.c:132
REFCNT refcnt
Definition: dwdebug_priv.h:863
void lsymbol_hold_int(struct lsymbol *lsymbol)
Definition: debug.c:4798
unsigned int has_unspec_params
Definition: dwdebug_priv.h:839
int symbol_change_parent(struct symbol *parent, struct symbol *child, struct symbol *newparent)
Definition: debug.c:2884
void(* symdict_symbol_dtor_t)(struct symbol *symbol, void *priv)
Definition: dwdebug_priv.h:419
int(* symbol_root_expand)(struct debugfile *debugfile, struct symbol *root)
Definition: dwdebug_priv.h:133
GHashTable * refuselist
unsigned int issynthetic
Definition: dwdebug_priv.h:839
int location_set_addr(struct location *l, ADDR addr)
Definition: location.c:46
struct lsymbol * scope_lookup_sym__int(struct scope *scope, const char *name, const char *delim, symbol_type_flag_t flags)
Definition: scope.c:573
Dwarf_Half version
uint32_t bits
Definition: dwdebug_priv.h:906
uint8_t has_entry_pc
Definition: dwdebug_priv.h:998
int(* readreg)(struct location_ctxt *lctxt, REG regno, REGVAL *regval)
Definition: dwdebug_priv.h:687
int location_set_reg_addr(struct location *l, REG reg)
Definition: location.c:64
char * symbol_get_name_orig(struct symbol *symbol)
Definition: debug.c:2612
struct scope * parent
Definition: dwdebug_priv.h:476
struct scope * scope
unsigned int isdeclaration
Definition: dwdebug_priv.h:839
int symbol_set_root_priv(struct symbol *symbol, void *priv)
Definition: debug.c:3288
unsigned int isdeclinline
Definition: dwdebug_priv.h:839
char * dwarf_cfa_info_t
int symbol_set_inline_origin(struct symbol *symbol, SMOFFSET ref, struct symbol *origin)
Definition: debug.c:3395
int(* setcurrentframe)(struct location_ctxt *lctxt, int frame)
Definition: dwdebug_priv.h:673
union symbol::@8 extra
int debugfile_insert_root(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:1891
#define SYMBOL_IS_TYPE(sym)
struct lsymbol * debugfile_lookup_sym_line__int(struct debugfile *debugfile, char *filename, int line, SMOFFSET *offset, ADDR *addr)
Definition: debug.c:463
int symdict_get_sizes(struct symdict *symdict, int *named, int *duplicated, int *anon)
Definition: symdict.c:108
int debugfile_load_elfsymtab(struct debugfile *debugfile, Elf *elf, char *elf_filename)
Definition: debug_elf.c:331
struct location * loc
#define SRCLINE_BITS
Definition: dwdebug.h:185
struct lsymbol * symbol_lookup_sym__int(struct symbol *symbol, const char *name, const char *delim)
Definition: debug.c:195
void symdict_free(struct symdict *symdict, symdict_symbol_dtor_t ssd, void *priv)
Definition: symdict.c:271
void debugfile_resolve_one_declaration(struct debugfile *debugfile, char *name)
Definition: debug.c:2241
struct lsymbol * debugfile_lookup_addr__int(struct debugfile *debugfile, ADDR addr)
Definition: debug.c:503
void g_hash_foreach_dump_symbol(gpointer key __attribute__((unused)), gpointer value, gpointer userdata)
Definition: debug.c:4860
int(* unrelocate)(struct location_ctxt *lctxt, ADDR real_addr, ADDR *obj_addr)
Definition: dwdebug_priv.h:705
uint32_t REGVAL
Definition: common.h:66
int location_set_fbreg_offset(struct location *l, OFFSET offset)
Definition: location.c:98
#define LOCATION_REMAINING_BITS
Definition: dwdebug_priv.h:570
void symbol_set_bytesize(struct symbol *s, uint32_t b)
Definition: debug.c:3219
void scope_update_range(struct scope *scope, ADDR start, ADDR end, int *action)
Definition: scope.c:166
uint8_t prologue_guessed
int scope_remove_scope(struct scope *parent, struct scope *child)
Definition: scope.c:110
struct binfile * binfile_pointing
Definition: dwdebug.h:830
int scope_get_sizes(struct scope *scope, int *named, int *duplicated, int *anon, int *numscopes)
Definition: scope.c:263
int8_t REG
Definition: common.h:93
int symbol_set_encoding(struct symbol *symbol, encoding_t num)
Definition: debug.c:3332
int debugfile_declaration_copy_definition(struct debugfile *debugfile, struct symbol *declaration, struct symbol *definition)
Definition: debug.c:1994
struct scope * scope
Definition: dwdebug_priv.h:806
void * exists
Definition: dwdebug_priv.h:971
uint32_t ADDR
Definition: common.h:64
int symdict_get_size_named(struct symdict *symdict)
Definition: symdict.c:89
GHashTable * duptab
Definition: dwdebug_priv.h:375
short int lang_code
Definition: dwdebug_priv.h:996
struct lsymbol * debugfile_lookup_sym__int(struct debugfile *debugfile, char *name, const char *delim, struct rfilter *srcfile_filter, symbol_type_flag_t flags)
Definition: debug.c:677
int symbol_add_inline_instance(struct symbol *symbol, struct symbol *instance)
Definition: debug.c:3420
void symbol_set_bitsize_all(struct symbol *s, uint32_t b, uint32_t bo, uint32_t ctb)
Definition: debug.c:3262
#define SIZE_BITS_SIZE
Definition: dwdebug_priv.h:903
int scope_insert_scope(struct scope *parent, struct scope *child)
Definition: scope.c:88
GSList * subscopes
Definition: dwdebug_priv.h:484
int location_set_loclist(struct location *l, struct loclistloc *list)
Definition: location.c:107
loctype_t loctype
Definition: dwdebug_priv.h:585
char * filename
Definition: dwdebug.h:817
int symbol_set_inline_info(struct symbol *symbol, int isinlined, int isdeclinline)
Definition: debug.c:3389
symbol_source_t source
Definition: dwdebug_priv.h:836
struct scope * scope
uint32_t REFCNT
Definition: common.h:124
uint8_t language_nofree
Definition: dwdebug_priv.h:998
uint32_t bytes
Definition: dwdebug_priv.h:901
struct debugfile * debugfile_create(debugfile_type_t dtype, debugfile_type_flags_t dtflags, struct binfile *binfile, struct debugfile_load_opts *opts, struct binfile *binfile_pointing)
Definition: debug.c:1336
#define SYMBOL_IS_ROOT(sym)
int(* getregno)(struct location_ctxt *lctxt, common_reg_t reg, REG *o_reg)
Definition: dwdebug_priv.h:709
void scope_dump(struct scope *scope, struct dump_info *ud)
Definition: scope.c:409
#define LOAD_TYPE_BITS
Definition: dwdebug.h:181
unsigned int isinlined
Definition: dwdebug_priv.h:839
int symbol_set_root_language(struct symbol *symbol, char *language, int copy, short int lang_code)
Definition: debug.c:3318
GSList * members
struct symbol_root * root
Definition: dwdebug_priv.h:973
int debugfile_add_type(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:2300
int symbol_expand(struct symbol *symbol)
Definition: debug.c:3161
struct lsymbol * scope_lookup_sym(struct scope *scope, const char *name, const char *delim, symbol_type_flag_t flags)
Definition: scope.c:758
struct array_list * chain
Definition: dwdebug.h:1016
int symbol_set_root_producer(struct symbol *symbol, char *producer, int copy)
Definition: debug.c:3306
int(* writereg)(struct location_ctxt *lctxt, REG regno, REGVAL regval)
Definition: dwdebug_priv.h:688
symbol_type_flag_t
Definition: dwdebug.h:190
unsigned int isinlineinstance
Definition: dwdebug_priv.h:839
int scope_contains_addr(struct scope *scope, ADDR addr)
Definition: scope.c:504
loctype_t location_resolve(struct location *loc, struct location_ctxt *lctxt, struct symbol *symbol, struct location *o_loc)
Definition: location.c:825
char * scope_get_name(struct scope *scope)
Definition: scope.c:50
int(* symbol_replace)(struct debugfile *debugfile, struct symbol *old, struct symbol *new)
Definition: dwdebug_priv.h:131
#define SIZE_CTBYTES_SIZE
Definition: dwdebug_priv.h:905
unsigned int decldefined
Definition: dwdebug_priv.h:839
Pvoid_t clmatchone_t
Definition: clfit.h:136
uint8_t prologue_known
int symbol_set_constval(struct symbol *symbol, void *value, int len, int copy)
Definition: debug.c:3429
int scope_get_overall_range(struct scope *scope, ADDR *low_addr_saveptr, ADDR *high_addr_saveptr, int *is_noncontiguous)
Definition: scope.c:290
uint8_t compdirname_nofree
Definition: dwdebug_priv.h:998
#define SYMBOL_IS_FUNC(sym)
struct symbol * symdict_get_sym(struct symdict *symdict, const char *name, symbol_type_flag_t flags)
Definition: symdict.c:348
int(* readword)(struct location_ctxt *lctxt, ADDR real_addr, ADDR *pval)
Definition: dwdebug_priv.h:702
unsigned int usesshareddatatype
Definition: dwdebug_priv.h:839
unsigned int size_is_bits
Definition: dwdebug_priv.h:839
uint8_t producer_nofree
Definition: dwdebug_priv.h:998
loctype_t
Definition: dwdebug.h:234
struct symbol * datatype
Definition: dwdebug_priv.h:925
unsigned int ismember
Definition: dwdebug_priv.h:839
int debugfile_update_root(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:1826
#define SYMBOL_IS_VAR(sym)
int symdict_insert_symbol(struct symdict *symdict, struct symbol *symbol)
Definition: symdict.c:141
#define DATATYPE_CODE_BITS
Definition: dwdebug.h:184
int symbol_set_entry_pc(struct symbol *symbol, ADDR entry_pc)
Definition: debug.c:3340
char * compdirname
Definition: dwdebug_priv.h:993
int debugfile_define_by_specification(struct debugfile *debugfile, struct symbol *specification, struct symbol *definition)
struct scope * scope_create(struct symbol *owner, SMOFFSET ref)
Definition: scope.c:37
struct scope * symbol_read_owned_scope(struct symbol *symbol)
Definition: debug.c:2674
void debugfile_handle_declaration(struct debugfile *debugfile, struct symbol *symbol)
Definition: debug.c:2100
struct symbol * symbol
Definition: dwdebug_priv.h:463
GHashTable * reftab