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 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 struct target *target_lookup_overlay(struct target *target,tid_t tid);
249 void target_detach_overlay(struct target *base,tid_t overlay);
250 int target_attach_overlay_thread(struct target *base,struct target *overlay,
251  tid_t newtid);
252 int target_detach_overlay_thread(struct target *base,struct target *overlay,
253  tid_t tid);
254 
258 /*
259  * We need to "wrap" SW breakpoint information, because not all targets
260  * implement breakpoints as direct memory modifications (esp interpreted
261  * languages).
262  */
263 typedef enum {
264  BP_NONE = 0,
265  BP_SW = 1,
266  BP_HW = 2,
267  BP_PROBE = 3,
269 
271  struct target *target;
274  union {
277  struct {
278  struct probe *pre;
279  struct probe *post;
280  } probe;
281  };
282 };
283 
288 /*
289  * Oftentimes, we want to edit memory with a replacement that is live as
290  * long as the target is open (i.e., a software breakpoint), with
291  * temporary changes (i.e., the original instruction during single step;
292  * OR a substitute for the original instruction). The long-term
293  * replacement can be set in place via target_memmod_create and
294  * target_memmod_set; the original can be returned to by
295  * target_memmod_unset (or target_memmod_release); a short-term
296  * temporary can be set via target_memmod_set_tmp.
297  *
298  * In a flat target with all pages accessible to all threads within the
299  * same address space (a linux kernel in a VM, or a ptraced process in
300  * userspace), we don't need to worry about collisions between threads
301  * requiring memmod writes (i.e., writes to the same location) IF the
302  * target supports thread control (i.e., ptrace).
303  *
304  * If the target does not support thread control, the target can either
305  * operate in LOOSE mode, where it intentionally acknowledges that one
306  * thread might miss a breakpoint (if the original code was substituted
307  * in for another thread for a single step there); OR (really risky) if
308  * some tmp code was injected at that breakpoint (i.e., a return
309  * action) for another thread... the first thread would execute the
310  * return action *unintended*. Both are "dangerous" depending on the
311  * debugging user's model.
312  *
313  * Our only alternative, then, to support a STRICT mode on targets where
314  * you cannot simply pause all threads to allow a single thread to do
315  * all the single stepping or custom injected code runs at a breakpoint
316  * that the user might want -- is to track thread scheduling within the
317  * target and ensure that the memmod is *consistent* for the thread that
318  * is about to run.
319  *
320  * XXX: this is not implemented yet.
321  *
322  * This abstraction also helps support the case where threads in an
323  * overlay target set breakpoints in pages that are shared with other
324  * threads that are not members of an overlay target. In this case, the
325  * underlying target would see different virtual addresses that map to
326  * the same physical page. If the physical address of a memmod is
327  * known, that is used in preference to its virtual address.
328  */
329 typedef enum {
330  MMT_NONE = 0,
331  MMT_BP = 1,
332  MMT_DATA = 2,
333  MMT_CODE = 3,
335 #define MEMMOD_TYPE_BITS 2
336 
337 struct target_memmod *target_memmod_create(struct target *target,tid_t tid,
338  ADDR addr,int is_phys,
340  unsigned char *code,
341  unsigned int code_len,int nowrite);
342 void target_memmod_set_writeable(struct target *target,
343  struct target_memmod *mmod,int writeable);
344 struct target_memmod *target_memmod_lookup(struct target *target,tid_t tid,
345  ADDR addr,int is_phys);
346 unsigned long target_memmod_length(struct target *target,
347  struct target_memmod *mmod);
348 int target_memmod_set(struct target *target,tid_t tid,
349  struct target_memmod *mmod);
350 int target_memmod_unset(struct target *target,tid_t tid,
351  struct target_memmod *mmod);
352 int target_memmod_set_tmp(struct target *target,tid_t tid,
353  struct target_memmod *mmod,
354  unsigned char *code,unsigned long code_len);
355 int target_memmod_release(struct target *target,tid_t tid,
356  struct target_memmod *mmod);
357 int target_memmod_free(struct target *target,tid_t tid,
358  struct target_memmod *mmod,int force);
359 
360 typedef enum {
361  MMS_ORIG = 1,
363  MMS_TMP = 3,
365 #define MEMMOD_STATE_BITS 2
366 
368  struct target *target;
369  /*
370  * Eventually, this will just be one thread; for now, it is global
371  * to the target.
372  */
373  //struct target_thread *thread;
375 
378  unsigned int is_phys:1,
379  no_write:1;
380 
382 
383  /*
384  * The original contents of memory -- not free until memmod is
385  * freed. This is always a copy.
386  */
387  unsigned char *orig;
388  unsigned long orig_len;
389  /*
390  * The long-term substitution -- not free until memmod is freed. If
391  * this is not target->breakpoint_instrs, it will be freed when the
392  * memmod is removed.
393  */
394  unsigned char *mod;
395  unsigned long mod_len;
396  /*
397  * A short-term substitution -- copied and freed at need.
398  */
399  unsigned char *tmp;
400  unsigned long tmp_len;
401 
402  /*
403  * If state is MMS_ORIG or MMS_TMP, this is the owner. For now, we
404  * cannot handle collisions when changing the memmod at all -- we
405  * just detect them and warn.
406  *
407  * Eventually, to handle collisions, whenever there is a
408  * modification to a shared page, we have to track thread schedule
409  * and ensure that the shared write state is consistent with what
410  * the incoming thread expects to see. This will be expensive, but
411  * it is the only way to stay sane without modifying the underlying
412  * platform.
413  */
415 };
416 
420 struct probepoint *target_lookup_probepoint(struct target *target,
421  struct target_thread *tthread,
422  ADDR addr);
423 int target_insert_probepoint(struct target *target,
424  struct target_thread *tthread,
425  struct probepoint *probepoint);
426 int target_remove_probepoint(struct target *target,
427  struct target_thread *tthread,
428  struct probepoint *probepoint);
429 int target_attach_space(struct target *target,struct addrspace *space);
430 int target_detach_space(struct target *target,struct addrspace *space);
431 
435 target_status_t target_get_status(struct target *target);
436 void target_set_status(struct target *target,target_status_t status);
437 
442 int target_obj_flags_propagate(struct target *target,
443  obj_flags_t orf,obj_flags_t nandf);
448 REFCNT target_free(struct target *target,int force);
449 
453 struct target_thread *target_lookup_thread(struct target *target,tid_t tid);
454 struct target_thread *target_create_thread(struct target *target,tid_t tid,
455  void *tstate,void *tpstate);
456 void target_reuse_thread_as_global(struct target *target,
457  struct target_thread *thread);
458 void target_detach_thread(struct target *target,struct target_thread *tthread);
460  obj_flags_t orf,obj_flags_t nandf);
461 REFCNT target_thread_free(struct target_thread *tthread,int force);
462 
463 int target_invalidate_thread(struct target *target,
464  struct target_thread *tthread);
465 int target_invalidate_all_threads(struct target *target);
466 
467 void target_thread_set_status(struct target_thread *tthread,
469 void target_tid_set_status(struct target *target,tid_t tid,
471 
475 struct addrspace *addrspace_create(struct target *target,char *name,ADDR tag);
476 struct memregion *addrspace_find_region(struct addrspace *space,char *name);
478  region_type_t rtype,char *name);
480  region_type_t rtype,ADDR start);
482  struct memregion **region_saveptr,
483  struct memrange **range_saveptr);
484 int addrspace_detach_region(struct addrspace *space,struct memregion *region);
486  obj_flags_t orf,obj_flags_t nandf);
487 REFCNT addrspace_free(struct addrspace *space,int force);
488 void addrspace_dump(struct addrspace *space,struct dump_info *ud);
489 
493 struct memregion *memregion_create(struct addrspace *space,
494  region_type_t type,char *name);
495 int memregion_contains_real(struct memregion *region,ADDR addr);
497  ADDR real_addr);
499  ADDR obj_addr);
500 ADDR memregion_relocate(struct memregion *region,ADDR obj_addr,
501  struct memrange **range_saveptr);
502 ADDR memregion_unrelocate(struct memregion *region,ADDR real_addr,
503  struct memrange **range_saveptr);
505 void memregion_dump(struct memregion *region,struct dump_info *ud);
508  obj_flags_t orf,obj_flags_t nandf);
509 REFCNT memregion_free(struct memregion *region,int force);
510 
511 struct memrange *memrange_create(struct memregion *region,
513  unsigned int prot_flags);
514 int memrange_contains_real(struct memrange *range,ADDR real_addr);
515 int memrange_contains_obj(struct memrange *range,ADDR obj_addr);
518 struct target *memrange_target(struct memrange *range);
519 struct addrspace *memrange_space(struct memrange *range);
520 void memrange_dump(struct memrange *range,struct dump_info *ud);
522  obj_flags_t orf,obj_flags_t nandf);
523 REFCNT memrange_free(struct memrange *range,int force);
524 
525 struct mmap_entry *target_lookup_mmap_entry(struct target *target,
526  ADDR base_addr);
527 void target_attach_mmap_entry(struct target *target,
528  struct mmap_entry *mme);
529 void target_release_mmap_entry(struct target *target,
530  struct mmap_entry *mme);
531 
538 typedef void (*target_gkv_dtor_t)(struct target *target,char *key,void *value);
539 typedef void (*target_thread_gkv_dtor_t)(struct target *target,tid_t tid,
540  char *key,void *value);
541 
542 static inline void target_gkv_dtor_free(struct target *target,
543  char *key,void *value) {
544  if (value)
545  free(value);
546 }
547 static inline void target_gkv_dtor_bsymbol(struct target *target,
548  char *key,void *value) {
549  if (value)
550  bsymbol_release((struct bsymbol *)value);
551 }
552 static inline void target_gkv_dtor_probe(struct target *target,
553  char *key,void *value) {
554  if (value)
555  probe_free((struct probe *)value,0);
556 }
557 static inline void target_gkv_dtor_alist_deep_free(struct target *target,
558  char *key,void *value) {
559  if (value)
560  array_list_deep_free((struct array_list *)value);
561 }
562 static inline void target_thread_gkv_dtor_free(struct target *target,
563  char *key,void *value) {
564  if (value)
565  free(value);
566 }
567 
568 int target_gkv_insert(struct target *target,char *key,void *value,
569  target_gkv_dtor_t dtor);
570 void *target_gkv_lookup(struct target *target,char *key);
571 void *target_gkv_steal(struct target *target,char *key);
572 void target_gkv_remove(struct target *target,char *key);
573 /* NB: internal. */
574 void target_gkv_destroy(struct target *target);
575 
576 int target_thread_gkv_insert(struct target *target,tid_t tid,
577  char *key,void *value,
579 void *target_thread_gkv_lookup(struct target *target,tid_t tid,char *key);
580 void *target_thread_gkv_steal(struct target *target,tid_t tid,char *key);
581 void target_thread_gkv_remove(struct target *target,tid_t tid,char *key);
582 /* NB: internal. */
583 void target_thread_gkv_destroy(struct target *target,
584  struct target_thread *tthread);
585 
589 /*
590  * Attaches a probe to a target. For now, simply returns a target-wide
591  * probe ID, and places the probe in the target's hashtable with that ID.
592  */
593 int target_attach_probe(struct target *target,struct target_thread *thread,
594  struct probe *probe);
595 
596 /*
597  * Detaches a probe from a target.
598  */
599 int target_detach_probe(struct target *target,struct probe *probe);
600 
601 /*
602  * Attaches an action to a target. For now, simply returns a target-wide
603  * action ID, and places the action in the target's hashtable with that ID.
604  */
605 int target_attach_action(struct target *target,struct action *action);
606 
607 /*
608  * Detaches a action from a target.
609  */
610 int target_detach_action(struct target *target,struct action *action);
611 
615 /*
616  * Binds an lsymbol to a memregion. Does NOT hold a ref to the returned
617  * bsymbol; the user must do that if they want to use the bsymbol in
618  * their code.
619  */
620 struct bsymbol *bsymbol_create(struct lsymbol *lsymbol,
621  struct memregion *region);
622 /*
623  * Frees a bsymbol. Users should never call this; call bsymbol_release
624  * instead.
625  */
626 REFCNT bsymbol_free(struct bsymbol *bsymbol,int force);
627 
631 extern struct location_ops target_location_ops;
632 
637 int target_symbol_resolve_bounds(struct target *target,
638  struct target_location_ctxt *tlctxt,
639  struct symbol *symbol,
640  ADDR *start,ADDR *end,int *is_noncontiguous,
641  ADDR *alt_start,ADDR *alt_end);
642 loctype_t target_lsymbol_resolve_location(struct target *target,
643  struct target_location_ctxt *tlctxt,
644  struct lsymbol *lsymbol,
645  ADDR base_addr,
646  load_flags_t flags,
647  struct location *o_loc,
648  struct symbol **o_datatype,
649  struct memrange **o_range);
650 int target_lsymbol_resolve_bounds(struct target *target,
651  struct target_location_ctxt *tlctxt,
652  struct lsymbol *lsymbol,ADDR base_addr,
653  ADDR *start,ADDR *end,int *is_noncontiguous,
654  ADDR *alt_start,ADDR *alt_end);
655 int target_bsymbol_resolve_bounds(struct target *target,
656  struct target_location_ctxt *tlctxt,
657  struct bsymbol *bsymbol,ADDR base_addr,
658  ADDR *start,ADDR *end,int *is_noncontiguous,
659  ADDR *alt_start,ADDR *alt_end);
660 
668  char *value_name;
669  regex_t regex;
670 };
671 
673  /* A list of struct target_nv_filter_regex. */
675 };
676 
677 struct target_nv_filter *target_nv_filter_parse(char *expr);
678 void target_nv_filter_free(struct target_nv_filter *pf);
679 
680 int target_thread_filter_check(struct target *target,tid_t tid,
681  struct target_nv_filter *tf);
682 
686 /*
687  * Values.
688  */
689 struct value *value_create_raw(struct target *target,
690  struct target_thread *thread,
691  struct memrange *range,int len);
692 struct value *value_create_type(struct target_thread *thread,
693  struct memrange *range,struct symbol *type);
694 struct value *value_create(struct target_thread *thread,struct memrange *range,
695  struct lsymbol *lsymbol,struct symbol *type);
696 struct value *value_create_noalloc(struct target_thread *thread,
697  struct memrange *range,
698  struct lsymbol *lsymbol,struct symbol *type);
699 
700 void value_set_strlen(struct value *value,int len);
701 
702 int value_set_addr(struct value *value,ADDR addr);
703 int value_set_mmap(struct value *value,ADDR addr,struct memcache_mmap_entry *mme,
704  char *offset_ptr);
705 int value_set_reg(struct value *value,REG reg);
706 int value_set_child(struct value *value,struct value *parent_value,ADDR addr);
707 void value_set_const(struct value *value);
708 
709 void symbol_rvalue_print(FILE *stream,struct symbol *symbol,
710  void *buf,int bufsiz,
711  load_flags_t flags,struct target *target);
712 
716 #ifdef ENABLE_DISTORM
718 /*
719  * XXX: if either of the array_list outvars get set, the caller must
720  * free them with array_list_deep_free . Yes, this is bad.
721  */
722 int disasm_generic(struct target *target,
723  unsigned char *inst_buf,unsigned int buf_len,
724  struct array_list **idata_list_saveptr,int noabort);
725 int disasm_get_control_flow_offsets(struct target *target,inst_cf_flags_t flags,
726  unsigned char *inst_buf,unsigned int buf_len,
727  struct array_list **offset_list,ADDR base,
728  int noabort);
729 int disasm_get_prologue_stack_size(struct target *target,
730  unsigned char *inst_buf,unsigned int buf_len,
731  int *sp);
732 #endif
733 
737 #define SAFE_PERSONALITY_OP_WARN(op,outvar,expoutval,target,...) \
738  do { \
739  if (target->personality_ops && target->personality_ops->op) { \
740  vdebug(5,LA_TARGET,LF_TARGET, \
741  "target(%s): personality_ops->" #op "\n", \
742  target->name); \
743  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
744  if (outvar != expoutval) { \
745  vwarnopt(5,LA_TARGET,LF_TARGET, \
746  "target(%s): personality_ops->" #op " failed!\n", \
747  target->name); \
748  return outvar; \
749  } \
750  } \
751  else \
752  outvar = expoutval; \
753  } while (0);
754 
755 #define SAFE_PERSONALITY_OP_WARN_NORET(op,outvar,expoutval,target,...) \
756  do { \
757  if (target->personality_ops && target->personality_ops->op) { \
758  vdebug(5,LA_TARGET,LF_TARGET, \
759  "target(%s): personality_ops->" #op "\n", \
760  target->name); \
761  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
762  if (outvar != expoutval) { \
763  vwarnopt(5,LA_TARGET,LF_TARGET, \
764  "target(%s): personality_ops->" #op " failed!\n", \
765  target->name); \
766  } \
767  } \
768  else \
769  outvar = expoutval; \
770  } while (0);
771 
772 #define SAFE_PERSONALITY_OP(op,outvar,defoutval,target,...) \
773  do { \
774  if (target->personality_ops && target->personality_ops->op) { \
775  vdebug(5,LA_TARGET,LF_TARGET, \
776  "target(%s): personality_ops->" #op "\n", \
777  target->name); \
778  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
779  } \
780  else \
781  outvar = defoutval; \
782  } while (0);
783 
784 #define SAFE_TARGET_OP(op,outvar,expoutval,target,...) \
785  do { \
786  if (target->ops && target->ops->op) { \
787  vdebug(5,LA_TARGET,LF_TARGET, \
788  "target(%s): ops->" #op "\n", \
789  target->name); \
790  outvar = target->ops->op(target, ## __VA_ARGS__); \
791  if (outvar != expoutval) { \
792  vwarnopt(5,LA_TARGET,LF_TARGET, \
793  "target(%s): ops->" #op " failed!\n", \
794  target->name); \
795  return outvar; \
796  } \
797  } \
798  else if (target->personality_ops && target->personality_ops->op) { \
799  vdebug(5,LA_TARGET,LF_TARGET, \
800  "target(%s): personality_ops->" #op "\n", \
801  target->name); \
802  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
803  if (outvar != expoutval) { \
804  vwarnopt(5,LA_TARGET,LF_TARGET, \
805  "target(%s): personality_ops->" #op " failed!\n", \
806  target->name); \
807  return outvar; \
808  } \
809  } \
810  else \
811  outvar = expoutval; \
812  } while (0);
813 
814 #define SAFE_TARGET_OP_WARN_NORET(op,outvar,expoutval,target,...) \
815  do { \
816  if (target->ops && target->ops->op) { \
817  vdebug(5,LA_TARGET,LF_TARGET, \
818  "target(%s): ops->" #op "\n", \
819  target->name); \
820  outvar = target->ops->op(target, ## __VA_ARGS__); \
821  if (outvar != expoutval) { \
822  vwarnopt(5,LA_TARGET,LF_TARGET, \
823  "target(%s): ops->" #op " failed!\n", \
824  target->name); \
825  } \
826  } \
827  else if (target->personality_ops && target->personality_ops->op) { \
828  vdebug(5,LA_TARGET,LF_TARGET, \
829  "target(%s): personality_ops->" #op "\n", \
830  target->name); \
831  outvar = target->personality_ops->op(target, ## __VA_ARGS__); \
832  if (outvar != expoutval) { \
833  vwarnopt(5,LA_TARGET,LF_TARGET, \
834  "target(%s): personality_ops->" #op " failed!\n", \
835  target->name); \
836  } \
837  } \
838  else \
839  outvar = expoutval; \
840  } while (0);
841 
842 #define SAFE_TARGET_ONLY_OP(op,outvar,expoutval,target,...) \
843  do { \
844  if (target->ops && target->ops->op) { \
845  vdebug(5,LA_TARGET,LF_TARGET, \
846  "target(%s): ops->" #op "\n", \
847  target->name); \
848  outvar = target->ops->op(target, ## __VA_ARGS__); \
849  if (outvar != expoutval) { \
850  vwarnopt(5,LA_TARGET,LF_TARGET, \
851  "target(%s): ops->" #op " failed!\n", \
852  target->name); \
853  return outvar; \
854  } \
855  } \
856  else \
857  outvar = expoutval; \
858  } while (0);
859 
863 /*
864  * An address space is the primary abstraction for associating debuginfo
865  * with memory ranges. But, note that debuginfo files are associated
866  * specifically with regions -- each address space is associated with
867  * subentities I call regions, which include one or more ranges. A
868  * range closely corresponds to Linux's notion of describing a process's
869  * address space as a collection of mmaps of the program text/data, its
870  * libs, anonymous maps, and heap, stack, syscall trampolines, etc --
871  * and the protections associated with those ranges. Ranges can be
872  * grouped; the analogue is when an ELF object file is loaded into
873  * memory, it is split into several distinct memory ranges, each with
874  * different memory protections. HOWEVER, each of these ranges
875  * corresponds to the same debugfile(s) that have debuginfo for the ELF
876  * object file.
877  *
878  * Regions, then, hold references to debugfiles, and potentially include
879  * multiple ranges.
880  */
881 
882 struct addrspace {
883  /* A backref to the target containing this address space. */
884  struct target *target;
885 
887  char *name;
888 
889  /*
890  * The regions contained in this address space.
891  *
892  * Regions may overlap; thus, lookup functions should query
893  * binfiles/debugfiles based on tightest region match, then fall
894  * back to next tightest, and so on. This was added to account for
895  * a single giant kernel region, but then to have "sub" regions for
896  * modules. Process address spaces do not need this.
897  */
898  GList *regions;
899 
903 };
904 
905 /*
906  * Regions contain one or more ranges. The initial reason to have a
907  * two-level hierarchy here is that when we load symbols, we know the
908  * symbol is in some debugfile, but if we maintained the mapping between
909  * debugfiles and ranges within the range data structure itself, we
910  * would not know which range the resolved symbol is associated with!
911  *
912  * More generally, when we lookup a symbol in a target's debugfiles, we
913  * don't know which range the symbol is in until we resolve its address
914  * (and address resolution can be a runtime process involving reading
915  * target execution state like registers). So, we can only bind a
916  * symbol to one or more of the ranges that are connected to the
917  * debugfiles.
918  *
919  * This requires us to have a region structure that binds debugfile(s)
920  * to one or more ranges. Regions are named and typed; we expect that
921  * the range itself is just an address range, potentially with an
922  * offset, and a set of protection flags.
923  */
924 struct memregion {
925  /* backref to containing space */
926  struct addrspace *space;
927 
928  char *name;
930 
934 
935  /* The ranges contained in this region. */
936  GList *ranges;
937 
938  /*
939  * Debugfiles associated with this region.
940  *
941  * Really, there should be only one, but I guess this does allow the
942  * debuginfo to be split into multiple files. I doubt this ever
943  * happens.
944  */
945  GHashTable *debugfiles;
946 
947  /*
948  * A ref to the primary binfile
949  */
950  struct binfile *binfile;
951 
952  /*
953  * This is the base physical address the region's code got loaded
954  * at. We have to use this to translate addresses for the relocated
955  * object in its debuginfo.
956  */
958 
959  /*
960  * These are the minimum phys/virt address pairs that we learn from
961  * looking at the program headers in the binfile (in fact, these
962  * should be propagated from the binfile backing the code loaded
963  * into this region -- target backend should set it when it loads
964  * the debugfile(s) for the region).
965  */
968 
969  /* Once we have base_virt_addr and base_phys_addr after looking at
970  * the ELF program headers (the ones of type load -- maybe we should
971  * check other ones later), we can determine the virt_to_phys
972  * offset.
973  *
974  * We later use this in virt<->phys address translation.
975  */
977 };
978 
979 struct memrange {
980  /* backref to containing region */
981  struct memregion *region;
982 
986  unsigned int prot_flags;
987 
990 };
991 
992 /*
993  * This is a symbol that is bound to a memory region. At binding time,
994  * we record the stamp of the region, so we can tell later if the region
995  * "changed" in some way after this symbol was bound (we might need to
996  * rebind). Finally, we include the address so that a bound symbol can
997  * be resolved (i.e., its address filled in). Address resolution may
998  * need to be recomputed every time the PC changes, although the region
999  * binding may still be valid.
1000  */
1001 struct bsymbol {
1002  /*
1003  * The lookup information -- the deepest-nested symbol, and a
1004  * top-to-bottom list of parents.
1005  */
1006  struct lsymbol *lsymbol;
1007 
1008  /* Binding to a target region/range pair. */
1010  //struct memrange *range;
1011 
1013 };
1014 
1015 #endif
struct bsymbol * bsymbol_create(struct lsymbol *lsymbol, struct memregion *region)
Definition: symbol.c:48
REFCNT target_thread_free(struct target_thread *tthread, int force)
Definition: target.c:4126
unsigned long target_generic_fd_write(int fd, ADDR addr, unsigned long length, unsigned char *buf)
int addrspace_detach_region(struct addrspace *space, struct memregion *region)
Definition: memory.c:89
int memregion_contains_real(struct memregion *region, ADDR addr)
Definition: memory.c:327
REGVAL target_regcache_readreg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
Definition: target.c:6566
Definition: target.h:265
struct array_list * threads
Definition: target.h:374
struct value * value_create_noalloc(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
Definition: value.c:153
REFCNT memrange_free(struct memrange *range, int force)
Definition: memory.c:612
unsigned int no_write
Definition: target.h:378
unsigned long target_memmod_length(struct target *target, struct target_memmod *mmod)
Definition: target.c:4710
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:931
struct target * base
Definition: target_api.h:2614
void value_set_strlen(struct value *value, int len)
Definition: value.c:68
target_status_t target_get_status(struct target *target)
Definition: target.c:3987
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:335
int target_regcache_zero(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6398
struct lsymbol * lsymbol
Definition: target.h:1006
int32_t tid_t
Definition: common.h:36
ADDR memregion_unrelocate(struct memregion *region, ADDR real_addr, struct memrange **range_saveptr)
Definition: memory.c:402
void target_release_mmap_entry(struct target *target, struct mmap_entry *mme)
target_status_t
Definition: target_api.h:197
void memrange_dump(struct memrange *range, struct dump_info *ud)
Definition: memory.c:591
int target_insert_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
Definition: target.c:4619
void addrspace_obj_flags_propagate(struct addrspace *space, obj_flags_t orf, obj_flags_t nandf)
Definition: memory.c:162
int target_personality_register(char *personality, target_personality_t pt, struct target_personality_ops *ptops, void *pops)
Definition: target.c:5943
void target_thread_gkv_remove(struct target *target, tid_t tid, char *key)
Definition: target.c:1564
struct probe * pre
Definition: target.h:278
int addrspace_find_range_real(struct addrspace *space, ADDR addr, struct memregion **region_saveptr, struct memrange **range_saveptr)
Definition: memory.c:141
int target_detach_probe(struct target *target, struct probe *probe)
Definition: target.c:4681
Definition: probe.h:392
int target_regcache_copy_all(struct target_thread *sthread, thread_ctxt_t stidctxt, struct target_thread *dthread, thread_ctxt_t dtidctxt)
Definition: target.c:6451
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:2387
int target_regcache_copy_dirty_to(struct target_thread *sthread, thread_ctxt_t stidctxt, struct regcache *dregcache)
Definition: target.c:6521
struct target_thread * owner
Definition: target.h:414
GHashTable * target_regcache_copy_registers(struct target *target, tid_t tid)
Definition: target.c:6543
int memregion_detach_range(struct memregion *region, struct memrange *range)
Definition: memory.c:293
ADDR addr
Definition: probe.h:218
struct probepoint * target_lookup_probepoint(struct target *target, struct target_thread *tthread, ADDR addr)
Definition: target.c:4594
ADDR end
Definition: target.h:984
int memrange_contains_obj(struct memrange *range, ADDR obj_addr)
Definition: memory.c:587
int target_regcache_copy_from(struct target_thread *dthread, thread_ctxt_t dtidctxt, struct regcache *sregcache)
Definition: target.c:6499
int target_regcache_init_done(struct target *target, tid_t tid, thread_ctxt_t tctxt)
Definition: target.c:6151
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:4726
int _target_unchange_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1744
int target_detach_space(struct target *target, struct addrspace *space)
Definition: target.c:4568
struct regcache * target_regcache_get(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6355
struct target * target_create(char *type, struct target_spec *spec)
Definition: target.c:1849
void * target_gkv_steal(struct target *target, char *key)
Definition: target.c:1420
target_memmod_state_t state
Definition: target.h:377
ADDR addr
Definition: target_api.h:3269
char * name
Definition: target.h:928
unsigned long mod_len
Definition: target.h:395
struct debugfile * target_lookup_debugfile(struct target *target, ADDR addr)
Definition: target.c:1990
struct target * target
Definition: target.h:884
int target_regcache_writereg_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
Definition: target.c:6588
int target_remove_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
Definition: target.c:4645
OFFSET phys_offset
Definition: target.h:976
int target_associate_debugfile(struct target *target, struct memregion *region, struct debugfile *debugfile)
Definition: target.c:1963
int32_t OFFSET
Definition: common.h:65
ADDR start
Definition: target.h:983
struct probe * post
Definition: target.h:279
int target_detach_action(struct target *target, struct action *action)
Definition: target.c:4701
struct target_thread * thread
Definition: target_api.h:3237
target_personality_t ptype
Definition: target.h:235
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:3759
int bufsiz
Definition: target_api.h:3257
int target_attach_space(struct target *target, struct addrspace *space)
Definition: target.c:4546
GHashTable * debugfiles
Definition: target.h:945
void target_detach_thread(struct target *target, struct target_thread *tthread)
Definition: target.c:4073
#define MEMMOD_STATE_BITS
Definition: target.h:365
int target_regcache_isdirty_reg(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg)
Definition: target.c:6323
struct memrange * memregion_find_range_obj(struct memregion *region, ADDR obj_addr)
Definition: memory.c:357
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 memregion * memregion_create(struct addrspace *space, region_type_t type, char *name)
Definition: memory.c:242
int target_invalidate_thread(struct target *target, struct target_thread *tthread)
Definition: target.c:4366
ADDR base_phys_addr
Definition: target.h:966
int target_personality_attach(struct target *target, char *personality, char *personality_lib)
Definition: target.c:5965
REFCNT refcnt
Definition: target.h:900
thread_status_t status
Definition: target_api.h:2047
int value_set_mmap(struct value *value, ADDR addr, struct memcache_mmap_entry *mme, char *offset_ptr)
Definition: value.c:35
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
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:6169
REFCNT refcnt
Definition: target.h:1012
struct target_memmod * mmod
Definition: target.h:275
void(* target_gkv_dtor_t)(struct target *target, char *key, void *value)
Definition: target.h:538
int target_thread_gkv_insert(struct target *target, tid_t tid, char *key, void *value, target_thread_gkv_dtor_t dtor)
Definition: target.c:1491
target_breakpoint_type_t
Definition: target.h:263
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:2402
unsigned long tmp_len
Definition: target.h:400
struct memrange * memrange_create(struct memregion *region, ADDR start, ADDR end, OFFSET offset, unsigned int prot_flags)
Definition: memory.c:538
REFCNT memregion_free(struct memregion *region, int force)
Definition: memory.c:445
void memregion_dump(struct memregion *region, struct dump_info *ud)
Definition: memory.c:428
REFCNT bsymbol_release(struct bsymbol *bsymbol)
Definition: symbol.c:90
REFCNT bsymbol_free(struct bsymbol *bsymbol, int force)
Definition: symbol.c:96
struct value * value_create_raw(struct target *target, struct target_thread *thread, struct memrange *range, int len)
Definition: value.c:77
struct memregion * addrspace_match_region_start(struct addrspace *space, region_type_t rtype, ADDR start)
Definition: memory.c:126
struct target_memmod * target_memmod_lookup(struct target *target, tid_t tid, ADDR addr, int is_phys)
Definition: target.c:4841
struct target * target
Definition: target.h:271
region_type_t
void(* target_thread_gkv_dtor_t)(struct target *target, tid_t tid, char *key, void *value)
Definition: target.h:539
void target_memmod_set_writeable(struct target *target, struct target_memmod *mmod, int writeable)
Definition: target.c:4836
int probe_free(struct probe *probe, int force)
Definition: probe.c:777
struct addrspace * space
Definition: target.h:926
int target_attach_overlay_thread(struct target *base, struct target *overlay, tid_t newtid)
Definition: target.c:4488
struct memrange * memregion_find_range_real(struct memregion *region, ADDR real_addr)
Definition: memory.c:339
char * buf
Definition: target_api.h:3258
target_memmod_type_t type
Definition: target.h:376
Definition: target.h:331
int value_set_child(struct value *value, struct value *parent_value, ADDR addr)
Definition: value.c:53
REFCNT refcntw
Definition: target.h:901
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:2372
REFCNT refcntw
Definition: target.h:933
Definition: target.h:266
obj_flags_t obj_flags
Definition: target.h:988
struct value * parent_value
Definition: target_api.h:3278
target_breakpoint_type_t bptype
Definition: target.h:273
struct memregion * addrspace_match_region_name(struct addrspace *space, region_type_t rtype, char *name)
Definition: memory.c:111
unsigned char * tmp
Definition: target.h:399
void memregion_obj_flags_propagate(struct memregion *region, obj_flags_t orf, obj_flags_t nandf)
Definition: memory.c:433
struct memrange * memregion_match_range(struct memregion *region, ADDR start)
Definition: memory.c:315
int target_memmod_unset(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target.c:5046
uint8_t * flags
Definition: regcache.h:70
struct value * value_create_type(struct target_thread *thread, struct memrange *range, struct symbol *type)
Definition: value.c:102
target_memmod_state_t
Definition: target.h:360
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:6479
struct target * memrange_target(struct memrange *range)
Definition: memory.c:578
unsigned char * orig
Definition: target.h:387
ADDR tag
Definition: target.h:886
int target_gkv_insert(struct target *target, char *key, void *value, target_gkv_dtor_t dtor)
Definition: target.c:1391
int len
Definition: dumptarget.c:52
ADDR addr
Definition: target.h:381
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:6368
Definition: probe.h:308
unsigned char * target_generic_fd_read(int fd, ADDR addr, unsigned long length, unsigned char *buf)
obj_flags_t obj_flags
Definition: target.h:902
inst_cf_flags_t
Definition: disasm.h:67
int value_set_addr(struct value *value, ADDR addr)
Definition: value.c:28
int target_attach_probe(struct target *target, struct target_thread *thread, struct probe *probe)
Definition: target.c:4669
ADDR memrange_unrelocate(struct memrange *range, ADDR real)
Definition: memory.c:598
int target_regcache_readreg_ifdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL *regval)
Definition: target.c:6291
REFCNT target_free(struct target *target, int force)
Definition: target.c:1620
obj_flags_t
Definition: object.h:43
int _target_enable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1703
const char * disasm_get_inst_name(inst_type_t type)
Definition: disasm.c:43
int target_regcache_init_reg_tidctxt(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG reg, REGVAL regval)
Definition: target.c:6130
unsigned long orig_len
Definition: target.h:388
GSList * value_regex_list
Definition: target.h:674
struct memregion * region
Definition: target.h:981
struct target_ops * target_get_ops(target_type_t target_type)
Definition: target.c:1832
ADDR offset
Definition: target.h:985
unsigned int prot_flags
Definition: target.h:986
void target_detach_overlay(struct target *base, tid_t overlaytid)
Definition: target.c:4467
struct value * value_create(struct target_thread *thread, struct memrange *range, struct lsymbol *lsymbol, struct symbol *type)
Definition: value.c:138
int target_detach_overlay_thread(struct target *base, struct target *overlay, tid_t tid)
Definition: target.c:4516
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:378
int value_set_reg(struct value *value, REG reg)
Definition: value.c:45
int target_regcache_mark_flushed(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6415
unsigned int thread_ctxt_t
Definition: target_api.h:300
void target_thread_set_status(struct target_thread *tthread, thread_status_t status)
Definition: target.c:3999
GList * ranges
Definition: target.h:936
void addrspace_dump(struct addrspace *space, struct dump_info *ud)
void * target_thread_gkv_lookup(struct target *target, tid_t tid, char *key)
Definition: target.c:1519
uint32_t REGVAL
Definition: common.h:66
int target_memmod_release(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target.c:4877
int target_attach_action(struct target *target, struct action *action)
Definition: target.c:4692
int target_invalidate_all_threads(struct target *target)
Definition: target.c:4426
struct location_ops target_location_ops
Definition: location.c:310
int memrange_contains_real(struct memrange *range, ADDR real_addr)
Definition: memory.c:583
int target_regcache_isdirty(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6307
void target_reuse_thread_as_global(struct target *target, struct target_thread *thread)
Definition: target.c:4063
struct addrspace * memrange_space(struct memrange *range)
Definition: memory.c:574
int8_t REG
Definition: common.h:93
target_type_t
Definition: target_api.h:163
void target_thread_gkv_destroy(struct target *target, struct target_thread *tthread)
Definition: target.c:1590
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
struct target * target_lookup_overlay(struct target *target, tid_t tid)
Definition: target.c:4455
struct symbol * type
Definition: target_api.h:3247
int _target_remove_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1673
int target_memmod_set(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target.c:4965
char * name
Definition: target.h:887
target_memmod_type_t
Definition: target.h:329
int _target_disable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1716
ADDR memregion_relocate(struct memregion *region, ADDR obj_addr, struct memrange **range_saveptr)
Definition: memory.c:375
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:1555
void target_gkv_destroy(struct target *target)
Definition: target.c:1456
Definition: memcache.h:110
struct mmap_entry * target_lookup_mmap_entry(struct target *target, ADDR base_addr)
int target_regcache_isdirty_reg_range(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt, REG start, REG end)
Definition: target.c:6339
struct target * target
Definition: target.h:368
int target_regcache_invalidate(struct target *target, struct target_thread *tthread, thread_ctxt_t tctxt)
Definition: target.c:6433
uint32_t REFCNT
Definition: common.h:124
REGVAL target_regcache_readreg(struct target *target, tid_t tid, REG reg)
Definition: target.c:6209
void target_tid_set_status(struct target *target, tid_t tid, thread_status_t status)
Definition: target.c:4007
struct target_spec * spec
Definition: target_api.h:2565
ADDR memrange_relocate(struct memrange *range, ADDR obj)
Definition: memory.c:602
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:5123
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
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:967
void symbol_rvalue_print(FILE *stream, struct symbol *symbol, void *buf, int bufsiz, load_flags_t flags, struct target *target)
Definition: symbol.c:352
unsigned char * mod
Definition: target.h:394
region_type_t type
Definition: target.h:929
struct target_thread * target_lookup_thread(struct target *target, tid_t tid)
Definition: target.c:3981
void target_set_status(struct target *target, target_status_t status)
Definition: target.c:3993
ADDR base_load_addr
Definition: target.h:957
target_type_t target_type(struct target *target)
Definition: target_api.c:484
struct target_memmod * _target_insert_sw_breakpoint(struct target *target, tid_t tid, ADDR addr, int is_phys, int nowrite)
Definition: target_api.c:1611
void value_set_const(struct value *value)
Definition: value.c:73
void memrange_obj_flags_propagate(struct memrange *range, obj_flags_t orf, obj_flags_t nandf)
Definition: memory.c:606
REG reg
Definition: target_api.h:3270
void target_gkv_remove(struct target *target, char *key)
Definition: target.c:1438
void * target_gkv_lookup(struct target *target, char *key)
Definition: target.c:1409
struct memregion * addrspace_find_region(struct addrspace *space, char *name)
Definition: memory.c:69
GHashTable * target_regcache_copy_registers_tidctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt)
Definition: target.c:6548
int target_thread_filter_check(struct target *target, tid_t tid, struct target_nv_filter *tf)
Definition: target.c:4253
struct binfile * binfile
Definition: target.h:950
struct target_thread * target_create_thread(struct target *target, tid_t tid, void *tstate, void *tpstate)
Definition: target.c:4021
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:1729
int target_regcache_writereg(struct target *target, tid_t tid, REG reg, REGVAL value)
Definition: target.c:6250
void * target_thread_gkv_steal(struct target *target, tid_t tid, char *key)
Definition: target.c:1538
struct target_breakpoint::@22::@24 probe
loctype_t
Definition: dwdebug.h:234
int target_thread_obj_flags_propagate(struct target_thread *tthread, obj_flags_t orf, obj_flags_t nandf)
Definition: target.c:4117
REFCNT refcnt
Definition: target.h:989
REFCNT refcnt
Definition: target.h:932
int target_memmod_free(struct target *target, tid_t tid, struct target_memmod *mmod, int force)
Definition: target.c:4914
struct memregion * region
Definition: target.h:1009
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:2421
GList * regions
Definition: target.h:898
REFCNT addrspace_free(struct addrspace *space, int force)
Definition: memory.c:175
struct addrspace * addrspace_create(struct target *target, char *name, ADDR tag)
Definition: memory.c:41