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
target.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 2012, 2013, 2014, 2015 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 __TARGET_H__
20 #define __TARGET_H__
21 
22 #include "config.h"
23 
24 #include <stdint.h>
25 #include <inttypes.h>
26 #include <glib.h>
27 
28 #include "common.h"
29 #include "object.h"
30 #include "debugpred.h"
31 #include "alist.h"
32 #include "log.h"
33 #include "memcache.h"
34 #include "target_api.h"
35 #include "dwdebug.h"
36 #ifdef ENABLE_DISTORM
37 #include "disasm.h"
38 #endif
39 #include "probe.h"
40 
41 #define LOGDUMPBSYMBOL(dl,lt,s) \
42  vdebugc((dl),(lt), \
43  "bsymbol(lsymbol(%s,%s,%"PRIxSMOFFSET";chainlen=%d)," \
44  "region=(%s(space=%s:0x%"PRIxADDR")))", \
45  symbol_get_name((s)->lsymbol->symbol), \
46  SYMBOL_TYPE((s)->lsymbol->symbol->type), \
47  (s)->lsymbol->symbol->ref, \
48  array_list_len((s)->lsymbol->chain), \
49  (s)->region ? (s)->region->name : NULL, \
50  (s)->region ? (s)->region->space->name : NULL, \
51  (s)->region ? (s)->region->space->tag : 0);
52 
53 #define LOGDUMPBSYMBOL_NL(dl,lt,s) \
54  LOGDUMPBSYMBOL((dl),(lt),(s)); \
55  vdebugc((dl),(lt),"\n");
56 
57 #define ERRORDUMPBSYMBOL(s) \
58  verrorc("bsymbol(lsymbol(%s,%s,%"PRIxSMOFFSET";chainlen=%d)," \
59  "region=(%s(space=%s:0x%"PRIxADDR")))", \
60  symbol_get_name((s)->lsymbol->symbol), \
61  SYMBOL_TYPE((s)->lsymbol->symbol->type), \
62  (s)->lsymbol->symbol->ref, \
63  array_list_len((s)->lsymbol->chain), \
64  (s)->region ? (s)->region->name : NULL, \
65  (s)->region ? (s)->region->space->name : NULL, \
66  (s)->region ? (s)->region->space->tag : 0);
67 
68 #define ERRORDUMPBSYMBOL_NL(s) \
69  ERRORDUMPBSYMBOL((s)); \
70  verrorc("\n");
71 
75 struct addrspace;
76 struct memregion;
77 struct memrange;
78 struct value;
79 
84 struct target *target_create(char *type,struct target_spec *spec);
85 struct mmap_entry *target_lookup_mmap_entry(struct target *target,
86  ADDR base_addr);
88  struct mmap_entry *mme);
90  struct mmap_entry *mme);
91 
92 unsigned char *target_generic_fd_read(int fd,
93  ADDR addr,
94  unsigned long length,
95  unsigned char *buf);
96 unsigned long target_generic_fd_write(int fd,
97  ADDR addr,
98  unsigned long length,
99  unsigned char *buf);
100 
102  struct memregion *region,
103  struct debugfile *debugfile);
104 struct debugfile *target_lookup_debugfile(struct target *target,ADDR addr);
105 
106 int target_attach_space(struct target *target,struct addrspace *space);
107 int target_detach_space(struct target *target,struct addrspace *space);
108 
109 /*
110  * Utility function for targets and personalities to set a register
111  * value during thread loading. It's like target_write_reg, but it
112  * doesn't mark the thread valid nor load it. It just sets the value.
113  * This is currently necessary for personalities to initialize thread
114  * values independent of the target itself.
115  */
116 int target_load_reg(struct target *target,struct target_thread *tthread,
117  REG reg,REGVAL regval);
118 
119 /*
120  * Given a range and some flags, does the actual target_addr_read after
121  * checking bounds (if the flags wanted it).
122  */
123 unsigned char *__target_load_addr_real(struct target *target,
124  struct memrange *range,
125  ADDR addr,load_flags_t flags,
126  unsigned char *buf,int bufsiz);
127 
128 /*
129  * The default underlying function for inserting sw breakpoints.
130  * Basically, it exposes @is_phys to backends that want to implement
131  * breakpoints as phys addrs instead of or in addition to virt addrs.
132  */
134  tid_t tid,ADDR addr,
135  int is_phys,int nowrite);
137  struct target_memmod *mmod);
139  struct target_memmod *mmod);
141  struct target_memmod *mmod);
143  struct target_memmod *mmod,
144  unsigned char *code,unsigned long code_len);
146  struct target_memmod *mmod);
147 
152  struct target_thread *tthread,
153  thread_ctxt_t tctxt,
154  REG reg,REGVAL regval);
156  tid_t tid,thread_ctxt_t tctxt);
158  struct target_thread *tthread,
159  thread_ctxt_t tctxt,
160  REG reg,REGVAL regval,
161  void *priv);
162 typedef int (*target_regcache_rawval_handler_t)(struct target *target,
163  struct target_thread *tthread,
164  thread_ctxt_t tctxt,
165  REG reg,void *rawval,int rawlen,
166  void *priv);
167 int target_regcache_foreach_dirty(struct target *target,
168  struct target_thread *tthread,
169  thread_ctxt_t tctxt,
172  void *priv);
173 int target_regcache_readreg_ifdirty(struct target *target,
174  struct target_thread *tthread,
175  thread_ctxt_t tctxt,REG reg,REGVAL *regval);
176 int target_regcache_isdirty(struct target *target,
177  struct target_thread *tthread,
178  thread_ctxt_t tctxt);
179 int target_regcache_isdirty_reg(struct target *target,
180  struct target_thread *tthread,
181  thread_ctxt_t tctxt,REG reg);
182 int target_regcache_isdirty_reg_range(struct target *target,
183  struct target_thread *tthread,
184  thread_ctxt_t tctxt,REG start,REG end);
185 struct regcache *target_regcache_get(struct target *target,
186  struct target_thread *tthread,
187  thread_ctxt_t tctxt);
188 int target_regcache_snprintf(struct target *target,struct target_thread *tthread,
189  thread_ctxt_t tctxt,char *buf,int bufsiz,
190  int detail,char *sep,char *kvsep,int flags);
191 int target_regcache_zero(struct target *target,struct target_thread *tthread,
192  thread_ctxt_t tctxt);
193 int target_regcache_mark_flushed(struct target *target,
194  struct target_thread *tthread,
195  thread_ctxt_t tctxt);
196 int target_regcache_invalidate(struct target *target,
197  struct target_thread *tthread,
198  thread_ctxt_t tctxt);
199 int target_regcache_copy_all(struct target_thread *sthread,
200  thread_ctxt_t stidctxt,
201  struct target_thread *dthread,
202  thread_ctxt_t dtidctxt);
203 int target_regcache_copy_all_zero(struct target_thread *sthread,
204  thread_ctxt_t stidctxt,
205  struct target_thread *dthread,
206  thread_ctxt_t dtidctxt);
207 int target_regcache_copy_from(struct target_thread *dthread,
208  thread_ctxt_t dtidctxt,
209  struct regcache *sregcache);
210 int target_regcache_copy_dirty_to(struct target_thread *sthread,
211  thread_ctxt_t stidctxt,
212  struct regcache *dregcache);
213 /*
214  * These are the drop-ins for the backend register functions.
215  */
216 REGVAL target_regcache_readreg(struct target *target,tid_t tid,REG reg);
217 int target_regcache_writereg(struct target *target,tid_t tid,
218  REG reg,REGVAL value);
219 GHashTable *target_regcache_copy_registers(struct target *target,tid_t tid);
220 REGVAL target_regcache_readreg_tidctxt(struct target *target,
221  tid_t tid,thread_ctxt_t tidctxt,
222  REG reg);
223 int target_regcache_writereg_tidctxt(struct target *target,
224  tid_t tid,thread_ctxt_t tidctxt,
225  REG reg,REGVAL value);
226 GHashTable *target_regcache_copy_registers_tidctxt(struct target *target,
227  tid_t tid,
228  thread_ctxt_t tidctxt);
234  char *personality;
237  void *pops;
238 };
239 
240 int target_personality_attach(struct target *target,
241  char *personality,char *personality_lib);
242 int target_personality_register(char *personality,target_personality_t pt,
243  struct target_personality_ops *ptops,void *pops);
244 
248 int target_decoder_lib_load(char *filename);
250 int target_decoder_lib_bind(struct target *target,char *decoder_lib,
251  char *decoder_lib_lib);
253  (struct target_decoder_lib *lib,struct target *target);
255 
259 struct target *target_lookup_overlay(struct target *target,tid_t tid);
260 void target_detach_overlay(struct target *base,tid_t overlay);
261 int target_attach_overlay_thread(struct target *base,struct target *overlay,
262  tid_t newtid);
263 int target_detach_overlay_thread(struct target *base,struct target *overlay,
264  tid_t tid);
265 
269 /*
270  * We need to "wrap" SW breakpoint information, because not all targets
271  * implement breakpoints as direct memory modifications (esp interpreted
272  * languages).
273  */
274 typedef enum {
275  BP_NONE = 0,
276  BP_SW = 1,
277  BP_HW = 2,
278  BP_PROBE = 3,
280 
282  struct target *target;
285  union {
288  struct {
289  struct probe *pre;
290  struct probe *post;
291  } probe;
292  };
293 };
294 
299 /*
300  * Oftentimes, we want to edit memory with a replacement that is live as
301  * long as the target is open (i.e., a software breakpoint), with
302  * temporary changes (i.e., the original instruction during single step;
303  * OR a substitute for the original instruction). The long-term
304  * replacement can be set in place via target_memmod_create and
305  * target_memmod_set; the original can be returned to by
306  * target_memmod_unset (or target_memmod_release); a short-term
307  * temporary can be set via target_memmod_set_tmp.
308  *
309  * In a flat target with all pages accessible to all threads within the
310  * same address space (a linux kernel in a VM, or a ptraced process in
311  * userspace), we don't need to worry about collisions between threads
312  * requiring memmod writes (i.e., writes to the same location) IF the
313  * target supports thread control (i.e., ptrace).
314  *
315  * If the target does not support thread control, the target can either
316  * operate in LOOSE mode, where it intentionally acknowledges that one
317  * thread might miss a breakpoint (if the original code was substituted
318  * in for another thread for a single step there); OR (really risky) if
319  * some tmp code was injected at that breakpoint (i.e., a return
320  * action) for another thread... the first thread would execute the
321  * return action *unintended*. Both are "dangerous" depending on the
322  * debugging user's model.
323  *
324  * Our only alternative, then, to support a STRICT mode on targets where
325  * you cannot simply pause all threads to allow a single thread to do
326  * all the single stepping or custom injected code runs at a breakpoint
327  * that the user might want -- is to track thread scheduling within the
328  * target and ensure that the memmod is *consistent* for the thread that
329  * is about to run.
330  *
331  * XXX: this is not implemented yet.
332  *
333  * This abstraction also helps support the case where threads in an
334  * overlay target set breakpoints in pages that are shared with other
335  * threads that are not members of an overlay target. In this case, the
336  * underlying target would see different virtual addresses that map to
337  * the same physical page. If the physical address of a memmod is
338  * known, that is used in preference to its virtual address.
339  */
340 typedef enum {
341  MMT_NONE = 0,
342  MMT_BP = 1,
343  MMT_DATA = 2,
344  MMT_CODE = 3,
346 #define MEMMOD_TYPE_BITS 2
347 
348 struct target_memmod *target_memmod_create(struct target *target,tid_t tid,
349  ADDR addr,int is_phys,
351  unsigned char *code,
352  unsigned int code_len,int nowrite);
353 int target_memmod_set_writeable(struct target *target,
354  struct target_memmod *mmod,int writeable);
355 struct target_memmod *target_memmod_lookup(struct target *target,tid_t tid,
356  ADDR addr,int is_phys);
357 unsigned long target_memmod_length(struct target *target,
358  struct target_memmod *mmod);
359 int target_memmod_set(struct target *target,tid_t tid,
360  struct target_memmod *mmod);
361 int target_memmod_unset(struct target *target,tid_t tid,
362  struct target_memmod *mmod);
363 int target_memmod_set_tmp(struct target *target,tid_t tid,
364  struct target_memmod *mmod,
365  unsigned char *code,unsigned long code_len);
366 int target_memmod_release(struct target *target,tid_t tid,
367  struct target_memmod *mmod);
368 int target_memmod_free(struct target *target,tid_t tid,
369  struct target_memmod *mmod,int force);
370 
371 typedef enum {
372  MMS_ORIG = 1,
374  MMS_TMP = 3,
376 #define MEMMOD_STATE_BITS 2
377 
379  struct target *target;
380  /*
381  * Eventually, this will just be one thread; for now, it is global
382  * to the target.
383  */
384  //struct target_thread *thread;
386 
389  unsigned int is_phys:1,
390  no_write:1;
391 
393 
394  /*
395  * The original contents of memory -- not free until memmod is
396  * freed. This is always a copy.
397  */
398  unsigned char *orig;
399  unsigned long orig_len;
400  /*
401  * The long-term substitution -- not free until memmod is freed. If
402  * this is not target->breakpoint_instrs, it will be freed when the
403  * memmod is removed.
404  */
405  unsigned char *mod;
406  unsigned long mod_len;
407  /*
408  * A short-term substitution -- copied and freed at need.
409  */
410  unsigned char *tmp;
411  unsigned long tmp_len;
412 
413  /*
414  * If state is MMS_ORIG or MMS_TMP, this is the owner. For now, we
415  * cannot handle collisions when changing the memmod at all -- we
416  * just detect them and warn.
417  *
418  * Eventually, to handle collisions, whenever there is a
419  * modification to a shared page, we have to track thread schedule
420  * and ensure that the shared write state is consistent with what
421  * the incoming thread expects to see. This will be expensive, but
422  * it is the only way to stay sane without modifying the underlying
423  * platform.
424  */
426 };
427 
431 struct probepoint *target_lookup_probepoint(struct target *target,
432  struct target_thread *tthread,
433  ADDR addr);
434 int target_insert_probepoint(struct target *target,
435  struct target_thread *tthread,
436  struct probepoint *probepoint);
437 int target_remove_probepoint(struct target *target,
438  struct target_thread *tthread,
439  struct probepoint *probepoint);
440 int target_attach_space(struct target *target,struct addrspace *space);
441 int target_detach_space(struct target *target,struct addrspace *space);
442 
446 target_status_t target_get_status(struct target *target);
447 void target_set_status(struct target *target,target_status_t status);
448 
453 int target_obj_flags_propagate(struct target *target,
454  obj_flags_t orf,obj_flags_t nandf);
459 REFCNT target_free(struct target *target,int force);
460 
464 struct target_thread *target_lookup_thread(struct target *target,tid_t tid);
465 struct target_thread *target_create_thread(struct target *target,tid_t tid,
466  void *tstate,void *tpstate);
467 void target_reuse_thread_as_global(struct target *target,
468  struct target_thread *thread);
469 void target_detach_thread(struct target *target,struct target_thread *tthread);
471  obj_flags_t orf,obj_flags_t nandf);
472 REFCNT target_thread_free(struct target_thread *tthread,int force);
473 
474 int target_invalidate_thread(struct target *target,
475  struct target_thread *tthread);
476 int target_invalidate_all_threads(struct target *target);
477 
478 void target_thread_set_status(struct target_thread *tthread,
480 void target_tid_set_status(struct target *target,tid_t tid,
482 
486 struct addrspace *addrspace_create(struct target *target,char *name,ADDR tag);
487 struct memregion *addrspace_find_region(struct addrspace *space,char *name);
489  region_type_t rtype,char *name);
491  region_type_t rtype,ADDR start);
493  struct memregion **region_saveptr,
494  struct memrange **range_saveptr);
495 int addrspace_detach_region(struct addrspace *space,struct memregion *region);
497  obj_flags_t orf,obj_flags_t nandf);
498 REFCNT addrspace_free(struct addrspace *space,int force);
499 void addrspace_dump(struct addrspace *space,struct dump_info *ud);
500 
504 struct memregion *memregion_create(struct addrspace *space,
505  region_type_t type,char *name);
506 int memregion_contains_real(struct memregion *region,ADDR addr);
508  ADDR real_addr);
510  ADDR obj_addr);
511 ADDR memregion_relocate(struct memregion *region,ADDR obj_addr,
512  struct memrange **range_saveptr);
513 ADDR memregion_unrelocate(struct memregion *region,ADDR real_addr,
514  struct memrange **range_saveptr);
516 void memregion_dump(struct memregion *region,struct dump_info *ud);
519  obj_flags_t orf,obj_flags_t nandf);
520 REFCNT memregion_free(struct memregion *region,int force);
521 
522 struct memrange *memrange_create(struct memregion *region,
524  unsigned int prot_flags);
525 int memrange_contains_real(struct memrange *range,ADDR real_addr);
526 int memrange_contains_obj(struct memrange *range,ADDR obj_addr);
529 struct target *memrange_target(struct memrange *range);
530 struct addrspace *memrange_space(struct memrange *range);
531 void memrange_dump(struct memrange *range,struct dump_info *ud);
533  obj_flags_t orf,obj_flags_t nandf);
534 REFCNT memrange_free(struct memrange *range,int force);
535 
536 struct mmap_entry *target_lookup_mmap_entry(struct target *target,
537  ADDR base_addr);
538 void target_attach_mmap_entry(struct target *target,
539  struct mmap_entry *mme);
540 void target_release_mmap_entry(struct target *target,
541  struct mmap_entry *mme);
542 
549 typedef void (*target_gkv_dtor_t)(struct target *target,char *key,void *value);
550 typedef void (*target_thread_gkv_dtor_t)(struct target *target,tid_t tid,
551  char *key,void *value);
552 
553 static inline void target_gkv_dtor_free(struct target *target,
554  char *key,void *value) {
555  if (value)
556  free(value);
557 }
558 static inline void target_gkv_dtor_bsymbol(struct target *target,
559  char *key,void *value) {
560  if (value)
561  bsymbol_release((struct bsymbol *)value);
562 }
563 static inline void target_gkv_dtor_probe(struct target *target,
564  char *key,void *value) {
565  if (value)
566  probe_free((struct probe *)value,0);
567 }
568 static inline void target_gkv_dtor_alist_deep_free(struct target *target,
569  char *key,void *value) {
570  if (value)
571  array_list_deep_free((struct array_list *)value);
572 }
573 static inline void target_thread_gkv_dtor_free(struct target *target,
574  char *key,void *value) {
575  if (value)
576  free(value);
577 }
578 
579 int target_gkv_insert(struct target *target,char *key,void *value,
580  target_gkv_dtor_t dtor);
581 void *target_gkv_lookup(struct target *target,char *key);
582 void *target_gkv_steal(struct target *target,char *key);
583 void target_gkv_remove(struct target *target,char *key);
584 /* NB: internal. */
585 void target_gkv_destroy(struct target *target);
586 
587 int target_thread_gkv_insert(struct target *target,tid_t tid,
588  char *key,void *value,
590 void *target_thread_gkv_lookup(struct target *target,tid_t tid,char *key);
591 void *target_thread_gkv_steal(struct target *target,tid_t tid,char *key);
592 void target_thread_gkv_remove(struct target *target,tid_t tid,char *key);
593 /* NB: internal. */
594 void target_thread_gkv_destroy(struct target *target,
595  struct target_thread *tthread);
596 
600 /*
601  * Attaches a probe to a target. For now, simply returns a target-wide
602  * probe ID, and places the probe in the target's hashtable with that ID.
603  */
604 int target_attach_probe(struct target *target,struct target_thread *thread,
605  struct probe *probe);
606 
607 /*
608  * Detaches a probe from a target.
609  */
610 int target_detach_probe(struct target *target,struct probe *probe);
611 
612 /*
613  * Attaches an action to a target. For now, simply returns a target-wide
614  * action ID, and places the action in the target's hashtable with that ID.
615  */
616 int target_attach_action(struct target *target,struct action *action);
617 
618 /*
619  * Detaches a action from a target.
620  */
621 int target_detach_action(struct target *target,struct action *action);
622 
626 /*
627  * Binds an lsymbol to a memregion. Does NOT hold a ref to the returned
628  * bsymbol; the user must do that if they want to use the bsymbol in
629  * their code.
630  */
631 struct bsymbol *bsymbol_create(struct lsymbol *lsymbol,
632  struct memregion *region);
633 /*
634  * Frees a bsymbol. Users should never call this; call bsymbol_release
635  * instead.
636  */
637 REFCNT bsymbol_free(struct bsymbol *bsymbol,int force);
638 
642 extern struct location_ops target_location_ops;
643 
648 int target_symbol_resolve_bounds(struct target *target,
649  struct target_location_ctxt *tlctxt,
650  struct symbol *symbol,
651  ADDR *start,ADDR *end,int *is_noncontiguous,
652  ADDR *alt_start,ADDR *alt_end);
653 loctype_t target_lsymbol_resolve_location(struct target *target,
654  struct target_location_ctxt *tlctxt,
655  struct lsymbol *lsymbol,
656  ADDR base_addr,
657  load_flags_t flags,
658  struct location *o_loc,
659  struct symbol **o_datatype,
660  struct memrange **o_range);
661 int target_lsymbol_resolve_bounds(struct target *target,
662  struct target_location_ctxt *tlctxt,
663  struct lsymbol *lsymbol,ADDR base_addr,
664  ADDR *start,ADDR *end,int *is_noncontiguous,
665  ADDR *alt_start,ADDR *alt_end);
666 int target_bsymbol_resolve_bounds(struct target *target,
667  struct target_location_ctxt *tlctxt,
668  struct bsymbol *bsymbol,ADDR base_addr,
669  ADDR *start,ADDR *end,int *is_noncontiguous,
670  ADDR *alt_start,ADDR *alt_end);
671 
679  char *value_name;
680  regex_t regex;
681 };
682 
684  /* A list of struct target_nv_filter_regex. */
686 };
687 
688 struct target_nv_filter *target_nv_filter_parse(char *expr);
689 void target_nv_filter_free(struct target_nv_filter *pf);
690 
691 int target_thread_filter_check(struct target *target,tid_t tid,
692  struct target_nv_filter *tf);
693 
697 /*
698  * Values.
699  */
700 struct value *value_create_raw(struct target *target,
701  struct target_thread *thread,
702  struct memrange *range,int len);
703 struct value *value_create_type(struct target_thread *thread,
704  struct memrange *range,struct symbol *type);
705 struct value *value_create(struct target_thread *thread,struct memrange *range,
706  struct lsymbol *lsymbol,struct symbol *type);
707 struct value *value_create_noalloc(struct target_thread *thread,
708  struct memrange *range,
709  struct lsymbol *lsymbol,struct symbol *type);
710 
711 void value_set_strlen(struct value *value,int len);
712 
713 int value_set_addr(struct value *value,ADDR addr);
714 int value_set_mmap(struct value *value,ADDR addr,struct memcache_mmap_entry *mme,
715  char *offset_ptr);
716 int value_set_reg(struct value *value,REG reg);
717 int value_set_child(struct value *value,struct value *parent_value,ADDR addr);
718 void value_set_const(struct value *value);
719 
720 void symbol_rvalue_print(FILE *stream,struct symbol *symbol,
721  void *buf,int bufsiz,
722  load_flags_t flags,struct target *target);
723 
727 #ifdef ENABLE_DISTORM
729 /*
730  * XXX: if either of the array_list outvars get set, the caller must
731  * free them with array_list_deep_free . Yes, this is bad.
732  */
733 int disasm_generic(struct target *target,
734  unsigned char *inst_buf,unsigned int buf_len,
735  struct array_list **idata_list_saveptr,int noabort);
736 int disasm_get_control_flow_offsets(struct target *target,inst_cf_flags_t flags,
737  unsigned char *inst_buf,unsigned int buf_len,
738  struct array_list **offset_list,ADDR base,
739  int noabort);
740 int disasm_get_prologue_stack_size(struct target *target,
741  unsigned char *inst_buf,unsigned int buf_len,
742  int *sp);
743 #endif
744 
748 #define SAFE_PERSONALITY_OP_WARN(op,outvar,expoutval,target,...) \
749  do { \
750  if (target->personality_ops && target->personality_ops->op) { \
751  vdebug(5,LA_TARGET,LF_TARGET, \
752  "target(%s): personality_ops->" #op "\n", \
753  target->name); \
754  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
755  if (outvar != expoutval) { \
756  vwarnopt(5,LA_TARGET,LF_TARGET, \
757  "target(%s): personality_ops->" #op " failed!\n", \
758  target->name); \
759  return outvar; \
760  } \
761  } \
762  else \
763  outvar = expoutval; \
764  } while (0);
765 
766 #define SAFE_PERSONALITY_OP_WARN_NORET(op,outvar,expoutval,target,...) \
767  do { \
768  if (target->personality_ops && target->personality_ops->op) { \
769  vdebug(5,LA_TARGET,LF_TARGET, \
770  "target(%s): personality_ops->" #op "\n", \
771  target->name); \
772  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
773  if (outvar != expoutval) { \
774  vwarnopt(5,LA_TARGET,LF_TARGET, \
775  "target(%s): personality_ops->" #op " failed!\n", \
776  target->name); \
777  } \
778  } \
779  else \
780  outvar = expoutval; \
781  } while (0);
782 
783 #define SAFE_PERSONALITY_OP(op,outvar,defoutval,target,...) \
784  do { \
785  if (target->personality_ops && target->personality_ops->op) { \
786  vdebug(5,LA_TARGET,LF_TARGET, \
787  "target(%s): personality_ops->" #op "\n", \
788  target->name); \
789  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
790  } \
791  else \
792  outvar = defoutval; \
793  } while (0);
794 
795 #define SAFE_TARGET_OP(op,outvar,expoutval,target,...) \
796  do { \
797  if (target->ops && target->ops->op) { \
798  vdebug(5,LA_TARGET,LF_TARGET, \
799  "target(%s): ops->" #op "\n", \
800  target->name); \
801  outvar = target->ops->op(target, ## __VA_ARGS__); \
802  if (outvar != expoutval) { \
803  vwarnopt(5,LA_TARGET,LF_TARGET, \
804  "target(%s): ops->" #op " failed!\n", \
805  target->name); \
806  return outvar; \
807  } \
808  } \
809  else if (target->personality_ops && target->personality_ops->op) { \
810  vdebug(5,LA_TARGET,LF_TARGET, \
811  "target(%s): personality_ops->" #op "\n", \
812  target->name); \
813  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
814  if (outvar != expoutval) { \
815  vwarnopt(5,LA_TARGET,LF_TARGET, \
816  "target(%s): personality_ops->" #op " failed!\n", \
817  target->name); \
818  return outvar; \
819  } \
820  } \
821  else \
822  outvar = expoutval; \
823  } while (0);
824 
825 #define SAFE_TARGET_OP_WARN_NORET(op,outvar,expoutval,target,...) \
826  do { \
827  if (target->ops && target->ops->op) { \
828  vdebug(5,LA_TARGET,LF_TARGET, \
829  "target(%s): ops->" #op "\n", \
830  target->name); \
831  outvar = target->ops->op(target, ## __VA_ARGS__); \
832  if (outvar != expoutval) { \
833  vwarnopt(5,LA_TARGET,LF_TARGET, \
834  "target(%s): ops->" #op " failed!\n", \
835  target->name); \
836  } \
837  } \
838  else if (target->personality_ops && target->personality_ops->op) { \
839  vdebug(5,LA_TARGET,LF_TARGET, \
840  "target(%s): personality_ops->" #op "\n", \
841  target->name); \
842  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
843  if (outvar != expoutval) { \
844  vwarnopt(5,LA_TARGET,LF_TARGET, \
845  "target(%s): personality_ops->" #op " failed!\n", \
846  target->name); \
847  } \
848  } \
849  else \
850  outvar = expoutval; \
851  } while (0);
852 
853 #define SAFE_TARGET_ONLY_OP(op,outvar,expoutval,target,...) \
854  do { \
855  if (target->ops && target->ops->op) { \
856  vdebug(5,LA_TARGET,LF_TARGET, \
857  "target(%s): ops->" #op "\n", \
858  target->name); \
859  outvar = target->ops->op(target, ## __VA_ARGS__); \
860  if (outvar != expoutval) { \
861  vwarnopt(5,LA_TARGET,LF_TARGET, \
862  "target(%s): ops->" #op " failed!\n", \
863  target->name); \
864  return outvar; \
865  } \
866  } \
867  else \
868  outvar = expoutval; \
869  } while (0);
870 
874 /*
875  * An address space is the primary abstraction for associating debuginfo
876  * with memory ranges. But, note that debuginfo files are associated
877  * specifically with regions -- each address space is associated with
878  * subentities I call regions, which include one or more ranges. A
879  * range closely corresponds to Linux's notion of describing a process's
880  * address space as a collection of mmaps of the program text/data, its
881  * libs, anonymous maps, and heap, stack, syscall trampolines, etc --
882  * and the protections associated with those ranges. Ranges can be
883  * grouped; the analogue is when an ELF object file is loaded into
884  * memory, it is split into several distinct memory ranges, each with
885  * different memory protections. HOWEVER, each of these ranges
886  * corresponds to the same debugfile(s) that have debuginfo for the ELF
887  * object file.
888  *
889  * Regions, then, hold references to debugfiles, and potentially include
890  * multiple ranges.
891  */
892 
893 struct addrspace {
894  /* A backref to the target containing this address space. */
895  struct target *target;
896 
898  char *name;
899 
900  /*
901  * The regions contained in this address space.
902  *
903  * Regions may overlap; thus, lookup functions should query
904  * binfiles/debugfiles based on tightest region match, then fall
905  * back to next tightest, and so on. This was added to account for
906  * a single giant kernel region, but then to have "sub" regions for
907  * modules. Process address spaces do not need this.
908  */
909  GList *regions;
910 
914 };
915 
916 /*
917  * Regions contain one or more ranges. The initial reason to have a
918  * two-level hierarchy here is that when we load symbols, we know the
919  * symbol is in some debugfile, but if we maintained the mapping between
920  * debugfiles and ranges within the range data structure itself, we
921  * would not know which range the resolved symbol is associated with!
922  *
923  * More generally, when we lookup a symbol in a target's debugfiles, we
924  * don't know which range the symbol is in until we resolve its address
925  * (and address resolution can be a runtime process involving reading
926  * target execution state like registers). So, we can only bind a
927  * symbol to one or more of the ranges that are connected to the
928  * debugfiles.
929  *
930  * This requires us to have a region structure that binds debugfile(s)
931  * to one or more ranges. Regions are named and typed; we expect that
932  * the range itself is just an address range, potentially with an
933  * offset, and a set of protection flags.
934  */
935 struct memregion {
936  /* backref to containing space */
937  struct addrspace *space;
938 
939  char *name;
941 
945 
946  /* The ranges contained in this region. */
947  GList *ranges;
948 
949  /*
950  * Debugfiles associated with this region.
951  *
952  * Really, there should be only one, but I guess this does allow the
953  * debuginfo to be split into multiple files. I doubt this ever
954  * happens.
955  */
956  GHashTable *debugfiles;
957 
958  /*
959  * A ref to the primary binfile
960  */
961  struct binfile *binfile;
962 
963  /*
964  * This is the base physical address the region's code got loaded
965  * at. We have to use this to translate addresses for the relocated
966  * object in its debuginfo.
967  */
969 
970  /*
971  * These are the minimum phys/virt address pairs that we learn from
972  * looking at the program headers in the binfile (in fact, these
973  * should be propagated from the binfile backing the code loaded
974  * into this region -- target backend should set it when it loads
975  * the debugfile(s) for the region).
976  */
979 
980  /* Once we have base_virt_addr and base_phys_addr after looking at
981  * the ELF program headers (the ones of type load -- maybe we should
982  * check other ones later), we can determine the virt_to_phys
983  * offset.
984  *
985  * We later use this in virt<->phys address translation.
986  */
988 };
989 
990 struct memrange {
991  /* backref to containing region */
992  struct memregion *region;
993 
997  unsigned int prot_flags;
998 
1001 };
1002 
1003 /*
1004  * This is a symbol that is bound to a memory region. At binding time,
1005  * we record the stamp of the region, so we can tell later if the region
1006  * "changed" in some way after this symbol was bound (we might need to
1007  * rebind). Finally, we include the address so that a bound symbol can
1008  * be resolved (i.e., its address filled in). Address resolution may
1009  * need to be recomputed every time the PC changes, although the region
1010  * binding may still be valid.
1011  */
1012 struct bsymbol {
1013  /*
1014  * The lookup information -- the deepest-nested symbol, and a
1015  * top-to-bottom list of parents.
1016  */
1017  struct lsymbol *lsymbol;
1018 
1019  /* Binding to a target region/range pair. */
1021  //struct memrange *range;
1022 
1024 };
1025 
1026 #endif
int target_regcache_isdirty_reg_range(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG start, REG end)
Definition: target.c:6658
int memrange_contains_real(struct memrange *range, ADDR real_addr)
Definition: memory.c:583
unsigned long target_generic_fd_write(int fd, ADDR addr, unsigned long length, unsigned char *buf)
ADDR memrange_relocate(struct memrange *range, ADDR obj)
Definition: memory.c:602
Definition: target.h:276
struct array_list * threads
Definition: target.h:385
struct value * value_create_noalloc(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
Definition: value.c:153
unsigned int no_write
Definition: target.h:389
int target_memmod_release(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target.c:4933
int disasm_generic(struct target *target, unsigned char *inst_buf, unsigned int buf_len, struct array_list **idata_list_saveptr, int noabort)
Definition: disasm.c:47
obj_flags_t obj_flags
Definition: target.h:942
struct target * base
Definition: target_api.h:2654
struct target_thread * target_create_thread(struct target *target, tid_t tid, void *tstate, void *tpstate)
Definition: target.c:4063
void target_gkv_destroy(struct target *target)
Definition: target.c:1472
void value_set_strlen(struct value *value, int len)
Definition: value.c:68
int target_associate_debugfile(struct target *target, struct memregion *region, struct debugfile *debugfile)
Definition: target.c:1993
void memrange_obj_flags_propagate(struct memrange *range, obj_flags_t orf, obj_flags_t nandf)
Definition: memory.c:606
int target_memmod_free(struct target *target, tid_t tid, struct target_memmod *mmod, int force)
Definition: target.c:4970
int target_regcache_copy_dirty_to(struct target_thread *sthread, thread_ctxt_t stidctxt, struct regcache *dregcache)
Definition: target.c:6840
int(* target_regcache_regval_handler_t)(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL regval, void *priv)
Definition: target.h:157
#define MEMMOD_TYPE_BITS
Definition: target.h:346
struct lsymbol * lsymbol
Definition: target.h:1017
int memrange_contains_obj(struct memrange *range, ADDR obj_addr)
Definition: memory.c:587
int32_t tid_t
Definition: common.h:36
struct target_thread * target_lookup_thread(struct target *target, tid_t tid)
Definition: target.c:4023
unsigned long target_memmod_length(struct target *target, struct target_memmod *mmod)
Definition: target.c:4752
struct memrange * memrange_create(struct memregion *region, ADDR start, ADDR end, OFFSET offset, unsigned int prot_flags)
Definition: memory.c:538
int target_decoder_lib_bind(struct target *target, char *decoder_lib, char *decoder_lib_lib)
Definition: target.c:6206
void target_release_mmap_entry(struct target *target, struct mmap_entry *mme)
target_status_t
Definition: target_api.h:197
int target_regcache_writereg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
Definition: target.c:6907
int target_personality_register(char *personality, target_personality_t pt, struct target_personality_ops *ptops, void *pops)
Definition: target.c:6040
loctype_t target_lsymbol_resolve_location(struct target *target, struct target_location_ctxt *tlctxt, struct lsymbol *lsymbol, ADDR base_addr, load_flags_t flags, struct location *o_loc, struct symbol **o_datatype, struct memrange **o_range)
Definition: target.c:2452
int target_regcache_init_reg_tidctxt(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL regval)
Definition: target.c:6449
struct probe * pre
Definition: target.h:289
Definition: probe.h:392
int target_regcache_isdirty_reg(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg)
Definition: target.c:6642
int target_memmod_set(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target.c:5021
struct target_thread * owner
Definition: target.h:425
target_status_t target_get_status(struct target *target)
Definition: target.c:4029
ADDR addr
Definition: probe.h:218
GHashTable * target_regcache_copy_registers(struct target *target, tid_t tid)
Definition: target.c:6862
int target_detach_action(struct target *target, struct action *action)
Definition: target.c:4743
ADDR end
Definition: target.h:995
int target_lsymbol_resolve_bounds(struct target *target, struct target_location_ctxt *tlctxt, struct lsymbol *lsymbol, ADDR base_addr, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
Definition: target.c:2418
int target_attach_space(struct target *target, struct addrspace *space)
Definition: target.c:4588
int _target_unchange_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1809
struct location_ops target_location_ops
Definition: location.c:310
struct target * target_lookup_overlay(struct target *target, tid_t tid)
Definition: target.c:4497
target_memmod_state_t state
Definition: target.h:388
ADDR addr
Definition: target_api.h:3309
char * name
Definition: target.h:939
unsigned long mod_len
Definition: target.h:406
struct target * target
Definition: target.h:895
OFFSET phys_offset
Definition: target.h:987
int target_remove_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
Definition: target.c:4687
int32_t OFFSET
Definition: common.h:65
void target_thread_gkv_destroy(struct target *target, struct target_thread *tthread)
Definition: target.c:1606
ADDR start
Definition: target.h:994
struct probe * post
Definition: target.h:290
int addrspace_find_range_real(struct addrspace *space, ADDR addr, struct memregion **region_saveptr, struct memrange **range_saveptr)
Definition: memory.c:141
struct target_thread * thread
Definition: target_api.h:3277
target_personality_t ptype
Definition: target.h:235
int memregion_detach_range(struct memregion *region, struct memrange *range)
Definition: memory.c:293
int bufsiz
Definition: target_api.h:3297
void * target_gkv_steal(struct target *target, char *key)
Definition: target.c:1436
GHashTable * debugfiles
Definition: target.h:956
int target_attach_probe(struct target *target, struct target_thread *thread, struct probe *probe)
Definition: target.c:4711
struct target_decoder_binding * target_decoder_binding_create(struct target_decoder_lib *lib, struct target *target)
Definition: target.c:6313
void target_reuse_thread_as_global(struct target *target, struct target_thread *thread)
Definition: target.c:4105
void memregion_obj_flags_propagate(struct memregion *region, obj_flags_t orf, obj_flags_t nandf)
Definition: memory.c:433
#define MEMMOD_STATE_BITS
Definition: target.h:376
int(* target_regcache_rawval_handler_t)(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, void *rawval, int rawlen, void *priv)
Definition: target.h:162
struct debugfile * target_lookup_debugfile(struct target *target, ADDR addr)
Definition: target.c:2020
int target_memmod_set_writeable(struct target *target, struct target_memmod *mmod, int writeable)
Definition: target.c:4884
void memrange_dump(struct memrange *range, struct dump_info *ud)
Definition: memory.c:591
REFCNT bsymbol_free(struct bsymbol *bsymbol, int force)
Definition: symbol.c:96
ADDR base_phys_addr
Definition: target.h:977
int target_regcache_readreg_ifdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL *regval)
Definition: target.c:6610
int memregion_contains_real(struct memregion *region, ADDR addr)
Definition: memory.c:327
REFCNT refcnt
Definition: target.h:911
thread_status_t status
Definition: target_api.h:2084
int target_thread_obj_flags_propagate(struct target_thread *tthread, obj_flags_t orf, obj_flags_t nandf)
Definition: target.c:4159
int value_set_mmap(struct value *value, ADDR addr, struct memcache_mmap_entry *mme, char *offset_ptr)
Definition: value.c:35
void free(void *ptr)
Definition: debugserver.c:207
int disasm_get_control_flow_offsets(struct target *target, inst_cf_flags_t flags, unsigned char *inst_buf, unsigned int buf_len, struct array_list **offset_list, ADDR base, int noabort)
Definition: disasm.c:131
struct regcache * target_regcache_get(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6674
int target_personality_attach(struct target *target, char *personality, char *personality_lib)
Definition: target.c:6062
void target_gkv_remove(struct target *target, char *key)
Definition: target.c:1454
REFCNT refcnt
Definition: target.h:1023
struct target * memrange_target(struct memrange *range)
Definition: memory.c:578
int target_attach_overlay_thread(struct target *base, struct target *overlay, tid_t newtid)
Definition: target.c:4530
struct target_memmod * mmod
Definition: target.h:286
void(* target_gkv_dtor_t)(struct target *target, char *key, void *value)
Definition: target.h:549
void target_thread_gkv_remove(struct target *target, tid_t tid, char *key)
Definition: target.c:1580
target_breakpoint_type_t
Definition: target.h:274
unsigned long tmp_len
Definition: target.h:411
int target_invalidate_all_threads(struct target *target)
Definition: target.c:4468
REFCNT bsymbol_release(struct bsymbol *bsymbol)
Definition: symbol.c:90
struct target_decoder_lib * lib
Definition: target_api.h:1974
int target_insert_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
Definition: target.c:4661
void * target_thread_gkv_lookup(struct target *target, tid_t tid, char *key)
Definition: target.c:1535
struct value * value_create_raw(struct target *target, struct target_thread *thread, struct memrange *range, int len)
Definition: value.c:77
struct target * target
Definition: target.h:282
region_type_t
void(* target_thread_gkv_dtor_t)(struct target *target, tid_t tid, char *key, void *value)
Definition: target.h:550
struct memregion * addrspace_match_region_start(struct addrspace *space, region_type_t rtype, ADDR start)
Definition: memory.c:126
int probe_free(struct probe *probe, int force)
Definition: probe.c:777
void target_detach_thread(struct target *target, struct target_thread *tthread)
Definition: target.c:4115
struct addrspace * space
Definition: target.h:937
char * buf
Definition: target_api.h:3298
target_memmod_type_t type
Definition: target.h:387
void * target_gkv_lookup(struct target *target, char *key)
Definition: target.c:1425
Definition: target.h:342
int value_set_child(struct value *value, struct value *parent_value, ADDR addr)
Definition: value.c:53
REFCNT refcntw
Definition: target.h:912
REFCNT refcntw
Definition: target.h:944
int target_regcache_init_done(struct target *target, tid_t tid, thread_ctxt_t tctxt)
Definition: target.c:6470
Definition: target.h:277
obj_flags_t obj_flags
Definition: target.h:999
struct value * parent_value
Definition: target_api.h:3318
target_breakpoint_type_t bptype
Definition: target.h:284
int target_thread_gkv_insert(struct target *target, tid_t tid, char *key, void *value, target_thread_gkv_dtor_t dtor)
Definition: target.c:1507
REFCNT memrange_free(struct memrange *range, int force)
Definition: memory.c:612
int target_regcache_isdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6626
unsigned char * tmp
Definition: target.h:410
int target_symbol_resolve_bounds(struct target *target, struct target_location_ctxt *tlctxt, struct symbol *symbol, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
Definition: target.c:2403
int target_memmod_unset(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target.c:5102
uint8_t * flags
Definition: regcache.h:70
unsigned char * __target_load_addr_real(struct target *target, struct memrange *range, ADDR addr, load_flags_t flags, unsigned char *buf, int bufsiz)
Definition: target.c:3801
struct value * value_create_type(struct target_thread *thread, struct memrange *range, struct symbol *type)
Definition: value.c:102
int target_regcache_foreach_dirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, target_regcache_regval_handler_t regh, target_regcache_rawval_handler_t rawh, void *priv)
Definition: target.c:6488
target_memmod_state_t
Definition: target.h:371
struct memrange * memregion_match_range(struct memregion *region, ADDR start)
Definition: memory.c:315
REFCNT target_thread_free(struct target_thread *tthread, int force)
Definition: target.c:4168
int addrspace_detach_region(struct addrspace *space, struct memregion *region)
Definition: memory.c:89
void addrspace_obj_flags_propagate(struct addrspace *addrspace, obj_flags_t orf, obj_flags_t nandf)
Definition: memory.c:162
unsigned char * orig
Definition: target.h:398
ADDR tag
Definition: target.h:897
int target_detach_space(struct target *target, struct addrspace *space)
Definition: target.c:4610
struct addrspace * addrspace_create(struct target *target, char *name, ADDR tag)
Definition: memory.c:41
int len
Definition: dumptarget.c:52
ADDR addr
Definition: target.h:392
Definition: probe.h:308
REFCNT addrspace_free(struct addrspace *space, int force)
Definition: memory.c:175
int target_memmod_set_tmp(struct target *target, tid_t tid, struct target_memmod *mmod, unsigned char *code, unsigned long code_len)
Definition: target.c:5179
unsigned char * target_generic_fd_read(int fd, ADDR addr, unsigned long length, unsigned char *buf)
obj_flags_t obj_flags
Definition: target.h:913
void memregion_dump(struct memregion *region, struct dump_info *ud)
Definition: memory.c:428
struct target_ops * target_get_ops(target_type_t target_type)
Definition: target.c:1858
inst_cf_flags_t
Definition: disasm.h:67
struct memregion * memregion_create(struct addrspace *space, region_type_t type, char *name)
Definition: memory.c:242
int value_set_addr(struct value *value, ADDR addr)
Definition: value.c:28
int target_gkv_insert(struct target *target, char *key, void *value, target_gkv_dtor_t dtor)
Definition: target.c:1407
int target_regcache_zero(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6717
obj_flags_t
Definition: object.h:43
int target_attach_action(struct target *target, struct action *action)
Definition: target.c:4734
struct memrange * memregion_find_range_obj(struct memregion *region, ADDR obj_addr)
Definition: memory.c:357
REFCNT memregion_free(struct memregion *region, int force)
Definition: memory.c:445
struct memregion * addrspace_find_region(struct addrspace *space, char *name)
Definition: memory.c:69
int _target_enable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1768
const char * disasm_get_inst_name(inst_type_t type)
Definition: disasm.c:43
struct bsymbol * bsymbol_create(struct lsymbol *lsymbol, struct memregion *region)
Definition: symbol.c:48
struct probepoint * target_lookup_probepoint(struct target *target, struct target_thread *tthread, ADDR addr)
Definition: target.c:4636
ADDR memregion_relocate(struct memregion *region, ADDR obj_addr, struct memrange **range_saveptr)
Definition: memory.c:375
unsigned long orig_len
Definition: target.h:399
GSList * value_regex_list
Definition: target.h:685
struct memregion * region
Definition: target.h:992
ADDR offset
Definition: target.h:996
unsigned int prot_flags
Definition: target.h:997
void target_thread_set_status(struct target_thread *tthread, thread_status_t status)
Definition: target.c:4041
struct value * value_create(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
Definition: value.c:138
struct target_nv_filter * target_nv_filter_parse(char *expr)
struct target_personality_ops * ptops
Definition: target.h:236
unsigned int is_phys
Definition: target.h:389
int value_set_reg(struct value *value, REG reg)
Definition: value.c:45
unsigned int thread_ctxt_t
Definition: target_api.h:300
struct addrspace * memrange_space(struct memrange *range)
Definition: memory.c:574
int target_regcache_copy_from(struct target_thread *dthread, thread_ctxt_t dtidctxt, struct regcache *sregcache)
Definition: target.c:6818
GList * ranges
Definition: target.h:947
void addrspace_dump(struct addrspace *space, struct dump_info *ud)
int target_bsymbol_resolve_bounds(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, ADDR base_addr, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
Definition: target.c:2433
REGVAL target_regcache_readreg(struct target *target, tid_t tid, REG reg)
Definition: target.c:6528
int target_decoder_lib_register(struct target_decoder_lib *lib)
Definition: target.c:6195
uint32_t REGVAL
Definition: common.h:66
int target_regcache_writereg(struct target *target, tid_t tid, REG reg, REGVAL value)
Definition: target.c:6569
void * target_thread_gkv_steal(struct target *target, tid_t tid, char *key)
Definition: target.c:1554
struct target * target_create(char *type, struct target_spec *spec)
Definition: target.c:1875
struct memregion * addrspace_match_region_name(struct addrspace *space, region_type_t rtype, char *name)
Definition: memory.c:111
struct target_memmod * target_memmod_create(struct target *target, tid_t tid, ADDR addr, int is_phys, target_memmod_type_t mmt, unsigned char *code, unsigned int code_len, int nowrite)
Definition: target.c:4768
int target_thread_filter_check(struct target *target, tid_t tid, struct target_nv_filter *tf)
Definition: target.c:4295
int8_t REG
Definition: common.h:93
target_type_t
Definition: target_api.h:163
struct target_memmod * target_memmod_lookup(struct target *target, tid_t tid, ADDR addr, int is_phys)
Definition: target.c:4897
void target_nv_filter_free(struct target_nv_filter *pf)
target_personality_t
Definition: target_api.h:180
int target_load_reg(struct target *target, struct target_thread *tthread, REG reg, REGVAL regval)
uint32_t ADDR
Definition: common.h:64
REGVAL target_regcache_readreg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
Definition: target.c:6885
int target_regcache_invalidate(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6752
struct symbol * type
Definition: target_api.h:3287
int _target_remove_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1738
char * name
Definition: target.h:898
REFCNT target_free(struct target *target, int force)
Definition: target.c:1636
target_memmod_type_t
Definition: target.h:340
int _target_disable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1781
thread_status_t
Definition: target_api.h:254
int target_obj_flags_propagate(struct target *target, obj_flags_t orf, obj_flags_t nandf)
Definition: target_api.c:1620
Definition: memcache.h:110
struct mmap_entry * target_lookup_mmap_entry(struct target *target, ADDR base_addr)
void symbol_rvalue_print(FILE *stream, struct symbol *symbol, void *buf, int bufsiz, load_flags_t flags, struct target *target)
Definition: symbol.c:352
int target_regcache_copy_all_zero(struct target_thread *sthread, thread_ctxt_t stidctxt, struct target_thread *dthread, thread_ctxt_t dtidctxt)
Definition: target.c:6798
void target_tid_set_status(struct target *target, tid_t tid, thread_status_t status)
Definition: target.c:4049
struct target * target
Definition: target.h:379
uint32_t REFCNT
Definition: common.h:124
int target_decoder_lib_load(char *filename)
Definition: target.c:6169
int target_invalidate_thread(struct target *target, struct target_thread *tthread)
Definition: target.c:4408
struct target_spec * spec
Definition: target_api.h:2605
void target_attach_mmap_entry(struct target *target, struct mmap_entry *mme)
load_flags_t
Definition: target_api.h:406
debugfile_type_flags_t flags
Definition: dwdebug.h:789
GHashTable * target_regcache_copy_registers_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt)
Definition: target.c:6867
inst_type_t
Definition: disasm.h:46
int disasm_get_prologue_stack_size(struct target *target, unsigned char *inst_buf, unsigned int buf_len, int *sp)
Definition: disasm.c:409
ADDR base_virt_addr
Definition: target.h:978
int target_regcache_mark_flushed(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6734
void target_decoder_binding_free(struct target_decoder_binding *tdb)
Definition: target.c:6331
unsigned char * mod
Definition: target.h:405
int target_detach_overlay_thread(struct target *base, struct target *overlay, tid_t tid)
Definition: target.c:4558
ADDR memregion_unrelocate(struct memregion *region, ADDR real_addr, struct memrange **range_saveptr)
Definition: memory.c:402
region_type_t type
Definition: target.h:940
ADDR base_load_addr
Definition: target.h:968
target_type_t target_type(struct target *target)
Definition: target_api.c:501
struct target_memmod * _target_insert_sw_breakpoint(struct target *target, tid_t tid, ADDR addr, int is_phys, int nowrite)
Definition: target_api.c:1676
ADDR memrange_unrelocate(struct memrange *range, ADDR real)
Definition: memory.c:598
void value_set_const(struct value *value)
Definition: value.c:73
REG reg
Definition: target_api.h:3310
int target_regcache_copy_all(struct target_thread *sthread, thread_ctxt_t stidctxt, struct target_thread *dthread, thread_ctxt_t dtidctxt)
Definition: target.c:6770
int target_detach_probe(struct target *target, struct probe *probe)
Definition: target.c:4723
struct binfile * binfile
Definition: target.h:961
int _target_change_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod, unsigned char *code, unsigned long code_len)
Definition: target_api.c:1794
void target_detach_overlay(struct target *base, tid_t overlay)
Definition: target.c:4509
struct target_breakpoint::@22::@24 probe
loctype_t
Definition: dwdebug.h:234
struct memrange * memregion_find_range_real(struct memregion *region, ADDR real_addr)
Definition: memory.c:339
REFCNT refcnt
Definition: target.h:1000
REFCNT refcnt
Definition: target.h:943
struct memregion * region
Definition: target.h:1020
int target_regcache_snprintf(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, char *buf, int bufsiz, int detail, char *sep, char *kvsep, int flags)
Definition: target.c:6687
void target_set_status(struct target *target, target_status_t status)
Definition: target.c:4035
GList * regions
Definition: target.h:909