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_api.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_API_H__
20 #define __TARGET_API_H__
21 
22 #include "config.h"
23 #include "common.h"
24 #include "object.h"
25 #include "arch.h"
26 #include "list.h"
27 #include "evloop.h"
28 #include "dwdebug.h"
29 #include "target_event.h"
30 #include "probe_api.h"
31 #include <glib.h>
32 
98 void target_init(void);
99 
113 void target_fini(void);
114 
115 /*
116  * The thread identifier type (tid_t) is declared in include/common.h .
117  */
118 
119 /*
120  * Each target must support operations on the "global" thread. The
121  * intent is that library users can use TID_GLOBAL to probe and access
122  * per-thread state, without having to deal with each thread
123  * individually. How this is actually implemented *is* target
124  * backend-specific.
125  *
126  * In the Xen target, TID_GLOBAL will allow you to access the hardware
127  * state for the current executing thread (or interrupt context, if not
128  * in process context). This means that if you ask for a hardware
129  * probepoint, you'll set a debug register in the current thread. In
130  * the Linux kernel guest, this means that as long as no other thread in
131  * the guest is using debug registers, that setting will be truly global
132  * -- any running thread could be stopped with a debug exception at that
133  * probepoint. If you mix TID_GLOBAL and per-tid hardware probepoints,
134  * however, your global probepoints will likely be stomped. So, don't
135  * do that. (Actually, right now, the Xen target does not support
136  * per-thread hardware breakpoints anyway -- but the behavior will be as
137  * described in the previous sentence once it does.)
138  *
139  * In the Linux ptrace target, TID_GLOBAL gets you access only to the
140  * primary thread of a process. We probaby should, in the future, make
141  * global truly global, in that if you ask for a hardware probepoint
142  * with TID_GLOBAL, that all threads add a per-thread hardware
143  * probepoint. But not yet.
144  */
145 #define TID_GLOBAL INT32_MAX
146 
147 struct target;
148 struct target_thread;
149 struct target_ops;
150 struct target_os_ops;
151 struct target_process_ops;
152 struct target_spec;
153 struct target_location_ctxt;
154 struct target_memmod;
155 struct regfile;
156 struct addrspace;
157 struct memregion;
158 struct memrange;
159 
160 /*
161  * These are flags; we need to create masks of them sometimes.
162  */
163 typedef enum {
166  TARGET_TYPE_XEN = 1 << 1,
168  TARGET_TYPE_PHP = 1 << 3,
169  TARGET_TYPE_GDB = 1 << 4,
170 } target_type_t;
171 #define TARGET_TYPE_BITS 5
172 #define TARGET_TYPE_MASK_BASE \
173  (TARGET_TYPE_PTRACE | TARGET_TYPE_XEN | TARGET_TYPE_GDB)
174 #define TARGET_TYPE_MASK_OVERLAY \
175  (TARGET_TYPE_PHP | TARGET_TYPE_OS_PROCESS)
176 
177 /*
178  * Order of these is important!
179  */
180 typedef enum {
186 
187 typedef enum {
192 } target_mode_t;
193 
194 /*
195  * NB: make sure these align with THREAD_STATUS_* and ASTATUS_* !
196  */
197 typedef enum {
199  /*
200  * The normal state of affairs; it can be returned regardless of if
201  * target_is_open() or not.
202  */
204  /*
205  * A target can only be paused if target_is_open() is true.
206  */
208  /*
209  * A severe error has occured; user should cleanup. There are
210  * exactly zero guarantees about the target's status at this point.
211  * The only guarantee is that the target libraries should not crash,
212  * no matter what the user tries to do to cleanup -- removing
213  * probes, freeing probes, closing the target, freeing the target.
214  */
216  /*
217  * The target has either exited, or we have detached from it.
218  */
220  /*
221  * This is a temporary state to be returned when the target library
222  * knows the target will exit, but is still live enough to examine
223  * its runtime state, remove probes, etc. Not all backends may
224  * provide this state.
225  *
226  * It implies TSTATUS_PAUSED.
227  *
228  * If it is uncaught, that is ok; the user can just catch
229  * TSTATUS_DONE.
230  */
232 
233  /*
234  * These states can only be returned when target_is_open() is
235  * false. DEAD corresponds to a zombie target; STOPPED corresponds
236  * to a target that is SIGSTOP'd, or the backend equivalent to
237  * that.
238  */
241 
242  /*
243  * Currently used to return from target_monitor if the user called
244  * target_monitor_interrupt()
245  */
248 
249 #define TSTATUS_MAX TSTATUS_STOPPED
250 
251 extern char *TSTATUS_STRINGS[];
252 #define TSTATUS(n) (((n) <= TSTATUS_MAX) ? TSTATUS_STRINGS[(n)] : NULL)
253 
254 typedef enum {
255  /*
256  * The first few status bits are deliberately the same as the target
257  * status bits.
258  */
265 
268 
269  /*
270  * These are thread-specific.
271  */
279 
280 #define THREAD_STATUS_MAX THREAD_STATUS_RETURNING_KERNEL
281 
282 #define THREAD_STATUS_BITS 5
283 
284 #define THREAD_SPECIFIC_STATUS(status) \
285  ((thread_status_t)(status) >= THREAD_STATUS_SLEEPING)
286 
287 extern char *THREAD_STATUS_STRINGS[];
288 #define THREAD_STATUS(n) (((n) <= THREAD_STATUS_RETURNING_KERNEL) \
289  ? THREAD_STATUS_STRINGS[(n)] : NULL)
290 
291 /*
292  * Thread contexts are a bit funny. They exist so that threads can have
293  * different contexts; right now only registers are per-context.
294  * Targets need not provide multiple contexts; but they can make use of
295  * them if desired. We don't make thread_ctxt_t an enum because we want
296  * to leave context numbering/naming to personalities as possible (i.e.,
297  * THREAD_CTXT_KERNEL and THREAD_CTXT_USER for the OS personality), and
298  * to backends where necessary (but personalities are more abstract...).
299  */
300 typedef unsigned int thread_ctxt_t;
301 #define THREAD_CTXT_DEFAULT 0
302 
303 /*
304  * When we handle a breakpoint, we *have* to single step some
305  * instruction(s) to get us past the breakpoint (unless it's a hardware
306  * BP and there are no actions nor post handlers). If there are no
307  * complex actions that replace the original instruction's effect
308  * (obviate), it's the original instruction; otherwise it might have
309  * been (part of) a non-boosted complex action running at the
310  * probepoint. BUT, since hardware probepoints are per-thread, we only
311  * have to worry about shared software probepoints. These are embedded
312  * in memory shared amidst multiple threads, so before changing memory
313  * (i.e., to single step the original instruction, or a complex action),
314  * we technically must stop all other threads that share the memory.
315  * However, this is expensive, may be undesireable, or may be impossible
316  * (i.e., if the target does not support thread control, but only
317  * supports thread observation/detection).
318  *
319  * So we support different modes for handling shared probepoints. In
320  * THREAD_BPMODE_STRICT, we *require* that the target pause all other
321  * threads before handling a probepoint at all. The handling thread
322  * blocks all other threads until handling is done.
323  *
324  * In THREAD_BPMODE_SEMI_STRICT, we allow a probepoint to change memory
325  * and single step one instruction, and immediately change memory back.
326  * This means we assume/trust that there won't be a thread collision at
327  * the probepoint where thread A hits the probepoint, changes mem, and
328  * invokes a single step -- but is interrupted before it executes that,
329  * and thread B hits the probepoint (but it won't actually hit it; it
330  * would hit wahtever we put in place of the breakpoint -- either the
331  * orig instruction, or a complex action (the former would be a missed
332  * breakpoint hit; the latter could completely screw up thread B)).
333  * There are other cases. But we assume in this mode that the memory
334  * change/single step of a single instruction is "atomic". This is the
335  * only way the Xen VM target can work right now (we could disable
336  * interrupts, kind of, but we can't disable NMIs... so we would have to
337  * override at least the NMI handler... and we have to deal with things
338  * like page faults sanely -- it's perfectly legit for a breakpointed
339  * instruction to page fault).
340  *
341  * Finally, in THREAD_BPMODE_LOOSE, we allow anything to happen at the
342  * probepoint without requiring that threads be paused; the handling
343  * process is free to allow as many memory changes and single steps as
344  * it likes. This mode is dangerous!!!
345  *
346  * We permit multiple instructions to be inserted here, but this is
347  * dangerous. For a multithreaded target, we're already at risk as
348  * soon as we hit the breakpoint and change it into another real
349  * instruction, because another thread could hit the changed real
350  * instruction if the first thread is interrupted before it can
351  * single step. So technically, in BPMODE_STRICT, we have to pause
352  * all other threads before changing the breakpoint at all. But,
353  * some targets can't really do this (or can't do it well, or it's
354  * hard -- for instnace, for a Xen VM with a Linux guest, we can
355  * disable interrupts while we handle, but even that doesn't disable
356  * NMIs, so we would have to override the guest's NMI handler... and
357  * what exactly we would do in the override code is questionable
358  * anyway!). So we invent another mode, BPMODE_SEMI_STRICT that
359  * says if we have only a single real instruction to single step, we
360  * "trust" that it won't be interrupted; in this mode, if there are
361  * multiple instructions to step, we try to pause all other threads
362  * before handling the breakpoint. Finally, in BPMODE_LOOSE, we
363  * allow endless single steps at the breakpoint without attempting
364  * to pause threads.
365  */
366 typedef enum {
371 
372 typedef enum {
382 } region_type_t;
383 extern char *REGION_TYPE_STRINGS[];
384 #define REGION_TYPE(n) (((n) < __REGION_TYPE_MAX) ? REGION_TYPE_STRINGS[(n)] : NULL)
385 
386 typedef enum {
387  EXCEPTION_NONE = 1 << 0,
393 
394 typedef enum {
401 
402 extern char *POLL_STRINGS[];
403 #define POLL(n) (((n) < sizeof(POLL_STRINGS)/sizeof(char *)) \
404  ? POLL_STRINGS[(n)] : NULL)
405 
406 typedef enum {
415 } load_flags_t;
416 
417 /*
418  * We have flags for each level -- because some backends/personalities
419  * might actively probe at a level they are not natively providing --
420  * for instance, an OS personality might as well actively probe process
421  * mmap regions; why bother splitting that out into a process-level
422  * personality's job? The knowledge is about the OS's process
423  * structures.
424  *
425  * Anyway, that's why we have the "default" flags -- a user can specify
426  * those no matter what personality level their backend is providing,
427  * and the backend will enable those flags *at its level*. Or, for
428  * instance, if you have an OS personality that can provide active
429  * probing of process-level entities, you can enable those too with the
430  * APF_PROCESS_* flags.
431  */
432 typedef enum {
433  AFP_NONE = 0,
434 
436  APF_THREAD_EXIT = 1 << 1,
437  APF_MEMORY = 1 << 2,
438  APF_OTHER = 1 << 3,
439 
442  APF_OS_MEMORY = 1 << 10,
443  APF_OS_OTHER = 1 << 11,
444 
448  APF_PROCESS_OTHER = 1 << 19,
449 
452  APF_APP_MEMORY = 1 << 26,
453  APF_APP_OTHER = 1 << 27,
455 
456 #define APF_WILD (APF_THREAD_ENTRY | APF_THREAD_EXIT | APF_MEMORY | APF_OTHER)
457 #define APF_OS (APF_OS_THREAD_ENTRY | APF_OS_THREAD_EXIT | APF_OS_MEMORY \
458  | APF_OS_OTHER)
459 #define APF_PROCESS (APF_PROCESS_THREAD_ENTRY | APF_PROCESS_THREAD_EXIT \
460  | APF_PROCESS_MEMORY | APF_PROCESS_OTHER)
461 #define APF_APP (APF_APP_THREAD_ENTRY | APF_APP_THREAD_EXIT \
462  | APF_APP_MEMORY | APF_APP_OTHER)
463 #define APF_ALL (APF_WILD | APF_OS | APF_PROCESS | APF_APP)
464 
465 /*
466  * The following functions form the target API.
467  */
468 
504 struct target_spec *target_argp_driver_parse_one(struct argp *driver_parser,
505  void *driver_state,
506  int argc,char **argv,
507  target_type_t target_types,
508  int filter_quoted);
557 int target_argp_driver_parse(struct argp *driver_parser,void *driver_state,
558  int argc,char **argv,
559  target_type_t target_types,int filter_quoted,
560  struct target_spec **primary_target_spec,
561  GList **base_target_specs,
562  GList **overlay_target_specs);
563 struct target_spec *target_argp_target_spec(struct argp_state *state);
564 void *target_argp_driver_state(struct argp_state *state);
565 void target_driver_argp_init_children(struct argp_state *state);
566 int target_spec_to_argv(struct target_spec *spec,char *arg0,
567  int *argc,char ***argv);
569 void target_free_spec(struct target_spec *spec);
570 
604 struct target *target_instantiate(struct target_spec *spec,
605  struct evloop *evloop);
648 GList *target_instantiate_and_open(struct target_spec *primary_target_spec,
649  GList *base_target_specs,
650  GList *overlay_target_specs,
651  struct evloop *evloop,
652  GList **error_specs);
691 GList *target_instantiate_and_open_list(GList *target_specs,
692  struct evloop *evloop,
693  GList **error_specs);
694 
695 /*
696  * Look up an existing target by its id.
697  */
698 struct target *target_lookup_target_id(int id);
699 
701 
702 /*
703  * Get the name of a target. The name will be initially filled in after
704  * target_ops->init is called (by target_open).
705  */
706 char *target_name(struct target *target);
707 
708 /*
709  * Simple accessor to get the target's ID.
710  */
711 int target_id(struct target *target);
712 
713 /*
714  * Opens a target. If returns 0, the target is paused and ready for API
715  * calls. If it returns nonzero, it failed.
716  *
717  * (Internally, it calls the following target_ops: init(), loadspaces(),
718  * loadregions(space), loaddebugfiles(space,region), postloadinit(),
719  * attach().)
720  */
721 int target_open(struct target *target);
722 
723 int target_open_all(struct target *target);
724 
725 /*
726  * Prints a string representation of the given target to @buf. Behaves
727  * according to and assumes a C99 implementation of snprintf (man sprintf).
728  */
729 int target_snprintf(struct target *target,char *buf,int bufsiz);
730 
731 /*
732  * Populates an evloop with any select()able file descriptors that this
733  * target needs monitored, and with their evloop callback functions.
734  * This way, the user can use a single evloop to handle multiple
735  * different kinds of blocking waiting, as well as multiple targets,
736  * instead of directly poll()ing or monitor()ing a single target.
737  *
738  * If a file descriptor closes or exhibits error conditions, the
739  * target's evloop callback function *must* remove the descriptor from
740  * the @evloop -- there is no mechanism for the evloop to clean up
741  * garbage.
742  */
743 int target_attach_evloop(struct target *target,struct evloop *evloop);
744 
745 /*
746  * Removes the selectable file descriptors for @target from @target->evloop.
747  */
748 int target_detach_evloop(struct target *target);
749 
750 /*
751  * Returns 1 if @evloop is already attached to @target; 0 if not.
752  */
754 
755 /*
756  * Returns > 0 if @base is a base ancestor of @overlay. The exact
757  * number is how many levels separate the two: 1 if overlay->base ==
758  * base; 2 if overlay->base->base == base; and so on.
759  */
760 int target_has_base(struct target *overlay,struct target *base);
761 
762 /*
763  * Enables/disables active probing techniques based on bits set in
764  * @flags.
765  *
766  * NB: sometimes it may not be possible to enable certain bits (backend
767  * may not support it); or disable certain bits (backend may require
768  * them, or an overlay target requires them). No good way to help the
769  * user navigate this for now; it's basically best-effort; and if you
770  * use an overlay target, the overlay target's requirements for active
771  * probing *will* override yours.
772  */
774 
775 /*
776  *
777  * If @evloop is specified, the target *must* add a select()able fd,
778  * handler, and state to @evloop. @evloop must be specified if the user
779  * is going to use evloop_* instead of target_monitor or target_poll to
780  * wait on one or more targets from a single
781  */
782 
828 int target_monitor_evloop(struct evloop *evloop,struct timeval *timeout,
829  struct target **target,target_status_t *status);
830 
831 /*
832  * These two functions are only useful when using target_monitor(). If
833  * your program needs to handle a signal, what you should do in the
834  * handler is
835  *
836  * if (target_monitor_handling_exception(t)) {
837  * needtodosomething = 1;
838  * target_monitor_schedule_interrupt(t);
839  * }
840  * else {
841  * target_pause(t);
842  * cleanup();
843  * }
844  *
845  * Then, if you set needtodosomething, when target_monitor() returns,
846  * you can dosomething as safely as possible.
847  *
848  * These functions are not thread-safe; they should only be called from
849  * within a signal handler!
850  */
851 
882 
891 
897 int target_monitor_was_interrupted(siginfo_t *last_siginfo);
898 
926  (void (*sighandler)(int signo,siginfo_t *siginfo,void *x));
956  (sigset_t *ignored,sigset_t *interrupt,sigset_t *exit,
957  void (*sighandler)(int signo,siginfo_t *siginfo,void *x));
967 void target_default_cleanup(void);
978 void target_default_sighandler(int signo,siginfo_t *siginfo,void *x);
979 
980 /*
981  * Polls a target for debug/exception events, and *will* try to handle
982  * any probes if it gets an event. It saves the outcome in @outcome if
983  * you provide a non-NULL value. @pstatus is mostly a legacy of the
984  * linux userspace target; in any case, its value is target-specific,
985  * and the target backend may populate it however it wishes. Finally,
986  * like target_monitor, target_poll will return control to the user for
987  * any exceptions it encounters that it can't handle.
988  *
989  * You must always call target_resume() following a poll, if you choose
990  * to continue.
991  *
992  * NOTE: @tv may be modified during the poll, as described in the
993  * select(2) manual page. This gives you a hint of how long the poll
994  * had to wait.
995  *
996  * ALSO NOTE: the behavior of @tv is different that described in
997  * select(2). If you pass NULL, we auto-fill a struct timeval with 0s,
998  * meaning that select and thus target_poll() will return immediately if
999  * nothing is pending; select blocks if you pass NULL. We don't need
1000  * that behavior, since target_monitor() sort of provides it.
1001  */
1002 target_status_t target_poll(struct target *target,struct timeval *tv,
1003  target_poll_outcome_t *outcome,int *pstatus);
1004 
1005 /*
1006  * Resumes a target from a user-visible pause. This will resume all of
1007  * the resumable threads, and guarantees that the user can call
1008  * target_poll or target_monitor again. If the user does not call
1009  * target_resume before invoking those functions, the target may not be
1010  * running.
1011  */
1012 int target_resume(struct target *target);
1013 
1014 /*
1015  * Pauses a target. This completely pauses a target, and all its
1016  * threads.
1017  */
1018 int target_pause(struct target *target);
1019 
1020 /*
1021  * Returns 1 if the target is open; 0 otherwise. Most target
1022  * operations only make sense if the target is open (i.e., reading
1023  * mem, reading CPU state, pausing/resuming/monitoring/probing, etc).
1024  */
1025 int target_is_open(struct target *target);
1026 
1027 /*
1028  * Returns the target's status.
1029  */
1031 
1038 int target_close(struct target *target);
1039 
1056 int target_finalize(struct target *target);
1057 
1058 /*
1059  * Destroys a target.
1060  */
1061 int target_kill(struct target *target,int sig);
1062 
1063 /*
1064  * Holds a ref to, or releases, a target object. Most users can just
1065  * get away with the normal target_open/target_close pattern; but if you
1066  * need to keep the target struct around after calling target_close,
1067  * you'll need to keep a ref to it!
1068  */
1069 void target_hold(struct target *target);
1070 void target_release(struct target *target);
1071 
1072 /*
1073  * Overlay support.
1074  */
1076  target_type_t type);
1077 struct array_list *target_list_overlays(struct target *target);
1081  tid_t tid);
1083  struct target_spec *spec);
1086  tid_t tid,ADDR ipval,int *again);
1087 
1088 /*
1089  * Returns the probe attached to this target with ID @probe_id, if any.
1090  */
1091 struct probe *target_lookup_probe(struct target *target,int probe_id);
1092 
1093 /*
1094  * Returns the action attached to this target with ID @probe_id, if any.
1095  */
1096 struct action *target_lookup_action(struct target *target,int action_id);
1097 
1098 /*
1099  * Reads a block of memory from the target. If @buf is non-NULL, we
1100  * assume it is at least @length bytes long; the result is placed into
1101  * @buf and @buf is returned. If @buf is NULL, we allocate a buffer
1102  * large enough to hold the result (@length if @length >0; if @length is
1103  * 0 we attempt to read a string at that address; we stop when we hit a
1104  * NULL byte).
1105  *
1106  * On error, returns NULL, and sets errno.
1107  */
1108 unsigned char *target_read_addr(struct target *target,ADDR addr,
1109  unsigned long length,unsigned char *buf);
1110 
1111 /*
1112  * Writes @length bytes from @buf to @addr. Returns the number of bytes
1113  * written (and sets errno nonzero if there is an error). Successful if
1114  * @return == @length.
1115  */
1116 unsigned long target_write_addr(struct target *target,ADDR addr,
1117  unsigned long length,unsigned char *buf);
1118 
1119 int target_addr_v2p(struct target *target,tid_t tid,ADDR vaddr,ADDR *paddr);
1120 unsigned char *target_read_physaddr(struct target *target,ADDR paddr,
1121  unsigned long length,unsigned char *buf);
1122 unsigned long target_write_physaddr(struct target *target,ADDR paddr,
1123  unsigned long length,unsigned char *buf);
1124 
1125 /*
1126  * Returns a string representation for the DWARF register number on this
1127  * particular target type. Will (likely) differ between targets/archs.
1128  */
1129 const char *target_regname(struct target *target,REG reg);
1130 
1131 /*
1132  * Returns the target-specific DWARF register number for the
1133  * target-specific register name @name.
1134  */
1135 int target_regno(struct target *target,char *name,REG *reg);
1136 
1137 /*
1138  * Returns the target-specific DWARF register number for the common
1139  * register @reg.
1140  */
1141 int target_cregno(struct target *target,common_reg_t creg,REG *reg);
1142 
1143 /*
1144  * Reads the DWARF register @reg from thread @tid in @target. Returns 0
1145  * and sets errno nonzero on error.
1146  */
1147 REGVAL target_read_reg(struct target *target,tid_t tid,REG reg);
1148 
1149 /*
1150  * Writes @value to the DWARF register @reg. Returns 0 on success;
1151  * nonzero on failure.
1152  */
1153 int target_write_reg(struct target *target,tid_t tid,REG reg,REGVAL value);
1154 
1155 /*
1156  * Reads the DWARF register @reg from thread @tid in @target. Returns 0
1157  * and sets errno nonzero on error.
1158  */
1160  REG reg);
1161 
1162 /*
1163  * Writes @value to the DWARF register @reg. Returns 0 on success;
1164  * nonzero on failure.
1165  */
1166 int target_write_reg_ctxt(struct target *target,tid_t tid,thread_ctxt_t tidctxt,
1167  REG reg,REGVAL value);
1168 
1169 /*
1170  * Reads the common register @reg in thread @tid in target @target.
1171  * Returns 0 and sets errno on failure.
1172  */
1174 
1175 /*
1176  * Writes @value to the common register @reg. Returns 0 on success;
1177  * nonzero on failure.
1178  */
1179 int target_write_creg(struct target *target,tid_t tid,common_reg_t reg,
1180  REGVAL value);
1181 
1182 /*
1183  * @return a copy of current values of @target/@tid's registers.
1184  *
1185  * Keys are strings corresponding to the target's register names; values
1186  * are REGVAL *'s.
1187  */
1188 GHashTable *target_copy_registers(struct target *target,tid_t tid);
1189 
1190 /*
1191  * Returns the currently executing thread's TID. Only valid when the
1192  * target's current thread is paused; returns 0 and sets errno EBUSY if
1193  * that is not true.
1194  */
1195 tid_t target_gettid(struct target *target);
1196 
1197 /*
1198  * @return: an array_list of TIDs that are in our cache. In this case,
1199  * use (tid_t)array_list_item(list,i) to get the value.
1200  */
1201 struct array_list *target_list_tids(struct target *target);
1202 
1203 /*
1204  * @return: an array_list of target_thread structs that are in our
1205  * cache.
1206  */
1207 struct array_list *target_list_threads(struct target *target);
1208 
1209 /*
1210  * @return: a GHashTable of TIDs->threads that are in our cache. The
1211  * hashtable keys are tid_t types, not ptr_t types!
1212  *
1213  * You might wonder why you need to call this; after all,
1214  * target->threads is a perfectly good hashtable. But, if you ever need
1215  * to loop over the keys in the hash and maybe delete a thread, you need
1216  * to be really careful. This eliminates the need for such caution by
1217  * basically duplicating the hashtable.
1218  */
1219 GHashTable *target_hash_threads(struct target *target);
1220 
1221 /*
1222  * @return: an array_list of TIDs that are part of the target, whether
1223  * they are loaded or not.
1224  */
1226 
1227 /*
1228  * @return: a GHashTable of TIDs that are part of the target, whether
1229  * they are loaded or not. Just a map of tid_t to tid_t .
1230  */
1231 GHashTable *target_hash_available_tids(struct target *target);
1232 
1233 /*
1234  * Load the currently executing thread (may also load the "global"
1235  * thread, depending on the target backend).
1236  */
1238  int force);
1239 
1240 /*
1241  * Load a specific thread's context from the target. If the thread does
1242  * not exist in the target, we return NULL. If it exists in our cache
1243  * and is valid, we do not re-read its state unless @force is nonzero.
1244  */
1246  int force);
1247 /*
1248  * (Re)load all our cached threads' contexts. Only invalid threads are
1249  * loaded unless @force is set nonzero. This function does not attempt
1250  * to discover other threads in the target that are unknown; it only
1251  * tries to reload those it has been told about.
1252  */
1253 int target_load_all_threads(struct target *target,int force);
1254 
1255 /*
1256  * Loads all threads that are part of the target. May evict cached
1257  * threads that no longer exist or whose tids have been reused for other
1258  * threads. Only reloads invalid threads if @force is nonzero.
1259  */
1260 int target_load_available_threads(struct target *target,int force);
1261 
1262 /*
1263  * Pauses a thread (if the target supports thread control). If @nowait
1264  * is set, it will not wait for the pause signal to hit the thread.
1265  *
1266  * XXX: at this point, @nowait is not supported!
1267  */
1268 int target_pause_thread(struct target *target,tid_t tid,int nowait);
1269 
1270 /*
1271  * Flush the currently executing thread's context. Context is only
1272  * written if it is dirty.
1273  */
1275 
1276 /*
1277  * Flush a specific thread's context back to the target. Context is
1278  * only written if it is dirty.
1279  */
1281 /*
1282  * Flush all our cached threads' contexts back to target.
1283  */
1285 
1286 /*
1287  * Garbage collects cached threads. If !target->ops->gc_threads, it
1288  * grabs the list of available thread ids, and compares those to the
1289  * current cache, evicting any stale members of the cache and destroying
1290  * those threads.
1291  *
1292  * @return the number of threads evicted/destroyed, or < 0 on error.
1293  */
1294 int target_gc_threads(struct target *target);
1295 
1296 /*
1297  * Prints a representation of @tid to @buf. Behaves according to and
1298  * assumes a C99 implementation of snprintf (man sprintf).
1299  */
1301  char *buf,int bufsiz,
1302  int detail,char *sep,char *key_val_sep);
1303 void target_dump_thread(struct target *target,tid_t tid,FILE *stream,int detail);
1304 void target_dump_all_threads(struct target *target,FILE *stream,int detail);
1305 
1307  ADDR addr);
1309  struct target_memmod *mmod);
1311  struct target_memmod *mmod);
1313  struct target_memmod *mmod);
1315  struct target_memmod *mmod,
1316  unsigned char *code,unsigned long code_len);
1318  struct target_memmod *mmod);
1319 
1321 int target_set_hw_breakpoint(struct target *target,tid_t tid,REG reg,ADDR addr);
1323  probepoint_whence_t whence,int watchsize);
1324 int target_unset_hw_breakpoint(struct target *target,tid_t tid,REG reg);
1325 int target_unset_hw_watchpoint(struct target *target,tid_t tid,REG reg);
1326 
1329 
1330 int target_disable_hw_breakpoint(struct target *target,tid_t tid,REG dreg);
1331 int target_enable_hw_breakpoint(struct target *target,tid_t tid,REG dreg);
1332 
1334  int notification);
1335 int target_singlestep(struct target *target,tid_t tid,int isbp);
1336 int target_singlestep_end(struct target *target,tid_t tid);
1337 
1338 uint64_t target_get_tsc(struct target *target);
1339 uint64_t target_get_time(struct target *target);
1340 uint64_t target_get_counter(struct target *target);
1341 
1342 /*
1343  * Feature functions. Enable/disable a specific feature on a target.
1344  * Feature flags are target-specific.
1345  */
1346 int target_enable_feature(struct target *target,int feature,void *arg);
1347 int target_disable_feature(struct target *target,int feature);
1348 
1349 /*
1350  * @return: the thread's status if it exists in our cache, or
1351  * THREAD_STATUS_UNKNOWN if the thread does not exist or if the status
1352  * is actually unknown.
1353  */
1355 
1356 
1366  ADDR *start,ADDR *end,void **data);
1368  ADDR *start,ADDR *end,void **data);
1369 unsigned char *target_load_code(struct target *target,
1370  ADDR start,unsigned int len,
1371  int nocache,int force_copy,int *caller_free);
1372 
1376 /*
1377  * Find the symbol table corresponding to the supplied PC.
1378  */
1379 struct scope *target_lookup_addr(struct target *target,uint64_t addr);
1380 
1381 /*
1382  * Looks up a symbol, or hierarchy of nested symbols. Users shouldn't
1383  * need to know the details of the bsymbol struct; it largely functions
1384  * as a placeholder that saves the result of a nested lookup so that it
1385  * is available for a later load. The single symbol, or deepest-nested
1386  * symbol, is in .symbol. The chain of nested symbols (possibly
1387  * including anonymous symbols), which includes the deepest-nested
1388  * symbol itself, is in .chain.
1389  *
1390  * The bsymbol struct should be passed to _load functions, where it may
1391  * be further annotated with load information.
1392  *
1393  * Each symbol chain member is either a SYMBOL_TYPE_VAR or a
1394  * SYMBOL_TYPE_FUNCTION -- unless the first member in your @name string
1395  * resolves to a SYMBOL_TYPE_TYPE. In this case, the first member will
1396  * be a SYMBOL_TYPE_TYPE!
1397  *
1398  * This function takes a ref to its return value on the user's behalf;
1399  * call bsymbol_release() to release (and maybe free) it.
1400  */
1401 
1402 struct bsymbol *target_lookup_sym(struct target *target,
1403  const char *name,const char *delim,
1404  char *srcfile,symbol_type_flag_t ftype);
1406  struct bsymbol *bsymbol,
1407  const char *name,const char *delim);
1408 
1409 struct bsymbol *target_lookup_sym_addr(struct target *target,ADDR addr);
1410 
1412  char *filename,int line,
1413  SMOFFSET *offset,ADDR *addr);
1415  char *filename,ADDR addr);
1416 
1420 int target_contains_real(struct target *target,ADDR addr);
1421 int target_find_memory_real(struct target *target,ADDR addr,
1422  struct addrspace **space_saveptr,
1423  struct memregion **region_saveptr,
1424  struct memrange **range_saveptr);
1426  struct target_location_ctxt *tlctxt,
1427  struct bsymbol *bsymbol,ADDR *o_addr,
1428  struct memrange **o_range);
1452  struct target_location_ctxt *tlctxt,
1453  struct bsymbol *bsymbol,load_flags_t flags,
1454  struct memrange **range_saveptr);
1456  char *member,const char *delim);
1457 struct value *target_load_symbol(struct target *target,
1458  struct target_location_ctxt *tlctxt,
1459  struct bsymbol *bsymbol,load_flags_t flags);
1460 /*
1461  * You can ask for *any* nesting of variables, given some bound symbol.
1462  * If @bsymbol is a function, you can ask for its args or locals. If
1463  * the locals or args are structs, you can directly ask for members --
1464  * but make sure that if you want pointers followed, you set the
1465  * LOAD_FLAG_AUTO_DEREF flag; otherwise a nested load across a pointer
1466  * (i.e., if the current member we're working on is a pointer, and you
1467  * have specified another nested member within that thing, we won't be
1468  * able to follow the pointer, and hence will fail to find the next
1469  * member) will fail. If @bsymbol is a struct/union var, you can of
1470  * course ask for any of its (nested) members.
1471  *
1472  * Your top-level @bsymbol must be either a function or a struct/union
1473  * var; nothing else makes sense as far as loading memory.
1474  */
1476  struct target_location_ctxt *tlctxt,
1477  struct bsymbol *bsymbol,
1478  const char *member,const char *delim,
1479  load_flags_t flags);
1481  struct target_location_ctxt *tlctxt,
1482  struct value *old_value,
1483  const char *member,const char *delim,
1484  load_flags_t flags);
1485 /*
1486  * This function creates a value by loading the number of bytes
1487  * specified by @type from a real @addr.
1488  */
1489 struct value *target_load_type(struct target *target,struct symbol *type,
1490  ADDR addr,load_flags_t flags);
1491 /*
1492  * This function creates a value by loading the number of bytes
1493  * specified by @type from @tid's register @reg.
1494  */
1495 struct value *target_load_type_reg(struct target *target,struct symbol *type,
1496  tid_t tid,REG reg,load_flags_t flags);
1497 /* Or if you've already read the register, this one. */
1498 struct value *target_load_type_regval(struct target *target,struct symbol *type,
1499  tid_t tid,REG reg,REGVAL regval,
1500  load_flags_t flags);
1501 /*
1502  * Load a raw value (i.e., no symbol or type info) using an object
1503  * file-based location (i.e., a fixed object-relative address) and a
1504  * specific region.
1505  *
1506  * Note: you cannot mmap raw values; they must be copied from target memory.
1507  */
1508 struct value *target_load_addr_obj(struct target *target,struct memregion *region,
1509  ADDR obj_addr,load_flags_t flags,int len);
1510 /*
1511  * Load a raw value (i.e., no symbol or type info) using a real address.
1512  *
1513  * Note: you cannot mmap raw values; they must be copied from target memory.
1514  */
1516  load_flags_t flags,int len);
1517 
1518 /*
1519  * Starting at @addr, which is of type @datatype, load as many pointers
1520  * as specified by our @flags (if @flags does not have
1521  * LOAD_FLAG_AUTO_DEREF or LOAD_FLAG_AUTO_STRING set, or @datatype is
1522  * not a pointer type symbol, this function will immediately return, and
1523  * will return @addr without setting @datatype_saveptr and
1524  * @range_saveptr).
1525  *
1526  * This function will keep loading pointers as long as @datatype and its
1527  * pointed-to type (recursively) are pointers. Once @datatype is no
1528  * longer a pointer, we stop, return the last pointer value, save the
1529  * non-pointer type in @datatype_saveptr, and save the memrange
1530  * containing the last pointer in @range_saveptr.
1531  *
1532  * You can set @datatype_saveptr and/or @range_saveptr to NULL safely.
1533  *
1534  * If an error occurs (i.e., attempt to deref a NULL pointer), we return
1535  * 0 and set errno appropriately.
1536  */
1537 ADDR target_autoload_pointers(struct target *target,struct symbol *datatype,
1538  ADDR addr,load_flags_t flags,
1539  struct symbol **datatype_saveptr,
1540  struct memrange **range_saveptr);
1541 /*
1542  * Load @count void pointers. Save off the range containing the final
1543  * pointer (not the final pointed-to value!) in @range_saveptr if
1544  * supplied. If an intermediate pointer is NULL, we set errno to EFAULT
1545  * and return 0.
1546  */
1547 ADDR target_load_pointers(struct target *target,ADDR addr,int count,
1548  struct memrange **range_saveptr);
1549 
1553 /*
1554  * If you have the type of symbol you're interested in, but you need to
1555  * load a pointer to a chunk of memory of that type, you can create a
1556  * synthetic type symbol that points to your "base" type.
1557  *
1558  * Synthetic symbols are the only kind of symbols that hold refs to other
1559  * symbols (in this case, the return value holds a ref to @type). This
1560  * function also holds a ref to the symbol it returns, since it is
1561  * anticipated that only users will call this function.
1562  */
1564  struct symbol *type);
1565 
1570 char *bsymbol_get_name(struct bsymbol *bsymbol);
1571 struct symbol *bsymbol_get_symbol(struct bsymbol *bsymbol);
1572 struct lsymbol *bsymbol_get_lsymbol(struct bsymbol *bsymbol);
1573 int bsymbol_is_inline(struct bsymbol *bsymbol);
1574 /*
1575  * Creates a bsymbol that basically is the deepest non-inline instance
1576  * part of @bsymbol.
1577  *
1578  * This function does not take a reference to the returned bsymbol;
1579  * (call bsymbol_hold() to get that ref if you need it; otherwise free
1580  * it as soon as you are done with it and don't pass it to anyone).
1581  */
1583 void bsymbol_dump(struct bsymbol *bsymbol,struct dump_info *ud);
1584 /*
1585  * Takes a reference to the bsymbol. Users should not call this; target
1586  * lookup functions will do this for you.
1587  */
1588 void bsymbol_hold(struct bsymbol *bsymbol);
1589 /*
1590  * Releases a reference to the bsymbol and tries to free it.
1591  */
1593 
1597 /*
1598  * Creates a fully independent value with a copy of whatever was in
1599  * @in's value buffer; also holds refs to in->type and in->lsymbol if
1600  * they exist -- so you must free it with value_free like normal.
1601  *
1602  * Note that if you clone a value that is sharing a parent value's
1603  * buffer space, the clone does not maintain this relationship; clones
1604  * always have their own private buffer.
1605  */
1606 struct value *value_clone(struct value *in);
1607 /*
1608  * Returns the resolved address of the value; if the value is a register
1609  * value, it returns 0 and sets errno to EINVAL.
1610  */
1611 ADDR value_addr(struct value *value);
1612 void value_free(struct value *value);
1613 int value_snprintf(struct value *value,char *buf,int buflen);
1614 void value_dump(struct value *value,struct dump_info *ud);
1615 void value_dump_simple(struct value *value,struct dump_info *ud);
1616 /*
1617  * Using @value's address, and the given @type, load a new value from
1618  * target memory that is the size of @type. If @force is nonzero, you
1619  * can force the load to happen even if the new type is larger in size
1620  * than the old one; generally, loading a larger value from memory could
1621  * be unsafe.
1622  */
1623 struct value *value_reload_as_type(struct value *value,struct symbol *type,
1624  int force);
1625 /*
1626  * Refreshes @value if necessary. If @value is a child of another
1627  * value, we will try to force a refresh of its parent (and upwards
1628  * recursively). Be careful of @recursive -- this might make values
1629  * change unexpectedly for you! You must only use value_refresh if you
1630  * are fine with "live" values.
1631  */
1632 int value_refresh(struct value *value,int recursive);
1633 
1634 typedef enum {
1639 } value_diff_t;
1640 
1641 typedef uintptr_t value_hash_t;
1642 
1643 /*
1644  * Reloads the content of @value and recomputes its new hash, setting
1645  * @vdiff accordingly if supplied. If @vdiff is VALUE_DIFF_DIFF, and if
1646  * @old_* are supplied, they are set to the old values, if any.
1647  * @old_buf and @old_bufsiz can only be set if the value was not mmap'd
1648  * (if it was, the value has already changed in the buffer and we don't
1649  * know what it was; so if this is important, then make sure to load the
1650  * value with LOAD_FLAG_NO_MMAP). @old_vhash will always be set if
1651  * VALUE_DIFF_DIFF.
1652  *
1653  * If there was an error loading the value, -1 is returned. This is the
1654  * only case an error can (realistically) occur.
1655  */
1656 int value_refresh_diff(struct value *value,int recurse,value_diff_t *vdiff,
1657  char **old_buf,int *old_bufsiz,value_hash_t *old_vhash);
1658 
1662 /*
1663  * Load a value. If @invalue is specified, load @varstr as a member.
1664  * If @invalue is not specified, lookup @varstr on @target as a symbol,
1665  * and load it! Load with @loadflags. If @outvarptr is specified, copy
1666  * the raw value's bytes into it -- if sizeof(*@outvarptr) < value->buflen
1667  * (poor man's C type "equivalence" check). If @outvalueptr is not
1668  * NULL, save the loaded struct value into *@outvalueptr and don't free
1669  * it (otherwise it is freed).
1670 
1671  * (NB: initially we had supported this (If *@outvalueptr == @invalue,
1672  * value_free(*@outvalueptr) first!), but not now -- it is not good.)
1673  *
1674  * This encapsulates the common ways we use VMI to load values, and
1675  * saves the user a lot of code.
1676  */
1677 #define VLS(target,tlctxt,varstr,loadflags,outvarptr,outvalueptr,errlabel) \
1678  do { \
1679  struct value *_outvalue; \
1680  void *__outvar = (outvarptr); \
1681  struct bsymbol *_varsym; \
1682  _varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
1683  SYMBOL_TYPE_NONE); \
1684  if (!_varsym) { \
1685  goto errlabel; \
1686  } \
1687  _outvalue = target_load_symbol((target),(tlctxt),_varsym, \
1688  (loadflags)); \
1689  bsymbol_release(_varsym); \
1690  if (!_outvalue) \
1691  goto errlabel; \
1692  if (__outvar) { \
1693  if ((int)sizeof(*(outvarptr)) < _outvalue->bufsiz) { \
1694  verror("outvar size %u smaller than outvalue len %d\n", \
1695  (unsigned)sizeof(*(outvarptr)),_outvalue->bufsiz); \
1696  value_free(_outvalue); \
1697  goto errlabel; \
1698  } \
1699  memcpy(outvarptr,_outvalue->buf, \
1700  ((int)sizeof(*(outvarptr))) > _outvalue->bufsiz \
1701  ? _outvalue->bufsiz : (int)sizeof(*(outvarptr)));\
1702  } \
1703  if (outvalueptr) \
1704  *(struct value **)(outvalueptr) = _outvalue; \
1705  else \
1706  value_free(_outvalue); \
1707  } while (0);
1708 #define VL(target,tlctxt,invalue,varstr,loadflags,outvalueptr,errlabel) \
1709  do { \
1710  struct value *_outvalue; \
1711  \
1712  if ((invalue) != NULL) { \
1713  _outvalue = target_load_value_member((target),(tlctxt),(invalue),(varstr), \
1714  NULL,(loadflags)); \
1715  } \
1716  else { \
1717  struct bsymbol *_varsym; \
1718  _varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
1719  SYMBOL_TYPE_NONE); \
1720  if (!_varsym) { \
1721  goto errlabel; \
1722  } \
1723  _outvalue = target_load_symbol((target),(tlctxt),_varsym, \
1724  (loadflags)); \
1725  bsymbol_release(_varsym); \
1726  } \
1727  if (!_outvalue) \
1728  goto errlabel; \
1729  if (outvalueptr) { \
1730  if (0 && *(struct value **)(outvalueptr) == invalue) { \
1731  value_free(*(struct value **)(outvalueptr)); \
1732  } \
1733  *(struct value **)(outvalueptr) = _outvalue; \
1734  } \
1735  else { \
1736  value_free(_outvalue); \
1737  } \
1738  } while (0);
1739 #define VLV(target,tlctxt,invalue,varstr,loadflags,outvarptr,outvalueptr,errlabel) \
1740  do { \
1741  struct value *_outvalue; \
1742  void *__outvar = (outvarptr); \
1743  \
1744  if ((invalue) != NULL) { \
1745  _outvalue = target_load_value_member((target),(tlctxt),(invalue),(varstr), \
1746  NULL,(loadflags)); \
1747  } \
1748  else { \
1749  struct bsymbol *_varsym; \
1750  _varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
1751  SYMBOL_TYPE_NONE); \
1752  if (!_varsym) { \
1753  goto errlabel; \
1754  } \
1755  _outvalue = target_load_symbol((target),(tlctxt),_varsym, \
1756  (loadflags)); \
1757  bsymbol_release(_varsym); \
1758  } \
1759  if (!_outvalue) \
1760  goto errlabel; \
1761  if (__outvar) { \
1762  if ((int)sizeof(*(outvarptr)) < _outvalue->bufsiz) { \
1763  verror("outvar size %u smaller than outvalue len %d\n", \
1764  (unsigned)sizeof(*(outvarptr)),_outvalue->bufsiz); \
1765  value_free(_outvalue); \
1766  goto errlabel; \
1767  } \
1768  memcpy(outvarptr,_outvalue->buf, \
1769  ((int)sizeof(*(outvarptr))) > _outvalue->bufsiz \
1770  ? _outvalue->bufsiz : (int)sizeof(*(outvarptr)));\
1771  } \
1772  if (outvalueptr) { \
1773  if (0 && *(struct value **)(outvalueptr) == invalue) { \
1774  value_free(*(struct value **)(outvalueptr)); \
1775  } \
1776  *(struct value **)(outvalueptr) = _outvalue; \
1777  } \
1778  else { \
1779  value_free(_outvalue); \
1780  } \
1781  } while (0);
1782 #define VLVAR(target,tlctxt,invalue,varstr,loadflags,outvarptr,errlabel) \
1783  do { \
1784  struct value *_outvalue; \
1785  \
1786  if ((invalue) != NULL) { \
1787  _outvalue = target_load_value_member((target),(tlctxt),(invalue),(varstr), \
1788  NULL,(loadflags)); \
1789  } \
1790  else { \
1791  struct bsymbol *_varsym; \
1792  _varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
1793  SYMBOL_TYPE_NONE); \
1794  if (!_varsym) { \
1795  goto errlabel; \
1796  } \
1797  _outvalue = target_load_symbol((target),(tlctxt),_varsym, \
1798  (loadflags)); \
1799  bsymbol_release(_varsym); \
1800  } \
1801  if (!_outvalue) \
1802  goto errlabel; \
1803  if ((int)sizeof(*(outvarptr)) < _outvalue->bufsiz) { \
1804  verror("outvar size %u smaller than outvalue len %d\n", \
1805  (unsigned)sizeof(*(outvarptr)),_outvalue->bufsiz); \
1806  value_free(_outvalue); \
1807  goto errlabel; \
1808  } \
1809  memcpy(outvarptr,_outvalue->buf, \
1810  ((int)sizeof(*(outvarptr))) > _outvalue->bufsiz \
1811  ? _outvalue->bufsiz : (int)sizeof(*(outvarptr))); \
1812  value_free(_outvalue); \
1813  } while (0);
1814 #define VLVAL(target,tlctxt,invalue,varstr,loadflags,outvalueptr,errlabel) \
1815  do { \
1816  struct value *_outvalue; \
1817  \
1818  if ((invalue) != NULL) { \
1819  _outvalue = target_load_value_member((target),(tlctxt),(invalue),(varstr), \
1820  NULL,(loadflags)); \
1821  } \
1822  else { \
1823  struct bsymbol *_varsym; \
1824  _varsym = target_lookup_sym((target),(varstr),NULL,NULL, \
1825  SYMBOL_TYPE_NONE); \
1826  if (!_varsym) { \
1827  goto errlabel; \
1828  } \
1829  _outvalue = target_load_symbol((target),(tlctxt),_varsym, \
1830  (loadflags)); \
1831  bsymbol_release(_varsym); \
1832  } \
1833  if (!_outvalue) \
1834  goto errlabel; \
1835  if (0 && *(struct value **)(outvalueptr) == invalue) { \
1836  value_free(*(struct value **)(outvalueptr)); \
1837  } \
1838  *(struct value **)(outvalueptr) = _outvalue; \
1839  } while (0);
1840 #define VLA(target,addr,loadflags,outbufptr,outbuflen,outvalueptr,errlabel) \
1841  do { \
1842  struct value *_outvalue; \
1843  \
1844  _outvalue = target_load_addr_real((target),(addr),(loadflags), \
1845  outbuflen); \
1846  if (!_outvalue) \
1847  goto errlabel; \
1848  if (!*outbufptr) { \
1849  *outbufptr = malloc(outbuflen); \
1850  } \
1851  memcpy(*outbufptr,_outvalue->buf,outbuflen); \
1852  if (outvalueptr) { \
1853  *(struct value **)(outvalueptr) = _outvalue; \
1854  } \
1855  else { \
1856  value_free(_outvalue); \
1857  } \
1858  } while (0);
1859 
1863 signed char v_c(struct value *v);
1864 unsigned char v_uc(struct value *v);
1865 wchar_t v_wc(struct value *v);
1866 uint8_t v_u8(struct value *v);
1867 uint16_t v_u16(struct value *v);
1868 uint32_t v_u32(struct value *v);
1869 uint64_t v_u64(struct value *v);
1870 int8_t v_i8(struct value *v);
1871 int16_t v_i16(struct value *v);
1872 int32_t v_i32(struct value *v);
1873 int64_t v_i64(struct value *v);
1874 num_t v_num(struct value *v);
1875 unum_t v_unum(struct value *v);
1876 float v_f(struct value *v);
1877 double v_d(struct value *v);
1878 long double v_dd(struct value *v);
1879 ADDR v_addr(struct value *v);
1880 char * v_string(struct value *v);
1881 
1885 int value_update(struct value *value,const char *buf,int bufsiz);
1886 int value_update_zero(struct value *value,const char *buf,int bufsiz);
1887 int value_update_c(struct value *value,signed char v);
1888 int value_update_uc(struct value *value,unsigned char v);
1889 int value_update_wc(struct value *value,wchar_t v);
1890 int value_update_u8(struct value *value,uint8_t v);
1891 int value_update_u16(struct value *value,uint16_t v);
1892 int value_update_u32(struct value *value,uint32_t v);
1893 int value_update_u64(struct value *value,uint64_t v);
1894 int value_update_i8(struct value *value,int8_t v);
1895 int value_update_i16(struct value *value,int16_t v);
1896 int value_update_i32(struct value *value,int32_t v);
1897 int value_update_i64(struct value *value,int64_t v);
1898 int value_update_f(struct value *value,float v);
1899 int value_update_d(struct value *value,double v);
1900 int value_update_dd(struct value *value,long double v);
1901 int value_update_addr(struct value *value,ADDR v);
1902 int value_update_num(struct value *value,num_t v);
1903 int value_update_unum(struct value *value,unum_t v);
1904 
1908 int target_store_value(struct target *target,struct value *value);
1909 
1910 #define value_to_u64(v) (*((uint64_t *)(v)->buf))
1911 #define value_to_u32(v) (*((uint32_t *)(v)->buf))
1912 #define value_to_u16(v) (*((uint16_t *)(v)->buf))
1913 #define value_to_u8(v) (*((uint8_t *)(v)->buf))
1914 
1915 #define value_to_i64(v) (*((int64_t *)(v)->buf))
1916 #define value_to_i32(v) (*((int32_t *)(v)->buf))
1917 #define value_to_i16(v) (*((int16_t *)(v)->buf))
1918 #define value_to_i8(v) (*((int8_t *)(v)->buf))
1919 
1920 #if __WORDSIZE == 64
1921 #define value_to_unsigned_long value_to_u64
1922 #define value_to_long value_to_i64
1923 #else
1924 #define value_to_unsigned_long value_to_u32
1925 #define value_to_long value_to_i32
1926 #endif
1927 
1928 #define value_to_int value_to_i32
1929 #define value_to_unsigned_int value_to_u32
1930 
1931 #define value_to_char(v) ((char)value_to_i8((v)))
1932 #define value_to_unsigned_char(v) ((unsigned char)value_to_i8((v)))
1933 #define value_to_string(v) ((v)->buf)
1934 #if __WORDSIZE == 64
1935 #define value_to_num(v) value_to_i64((v))
1936 #else
1937 #define value_to_num(v) value_to_i32((v))
1938 #endif
1939 
1943 signed char rv_c(void *buf);
1944 unsigned char rv_uc(void *buf);
1945 wchar_t rv_wc(void *buf);
1946 uint8_t rv_u8(void *buf);
1947 uint16_t rv_u16(void *buf);
1948 uint32_t rv_u32(void *buf);
1949 uint64_t rv_u64(void *buf);
1950 int8_t rv_i8(void *buf);
1951 int16_t rv_i16(void *buf);
1952 int32_t rv_i32(void *buf);
1953 int64_t rv_i64(void *buf);
1954 float rv_f(void *buf);
1955 double rv_d(void *buf);
1956 long double rv_dd(void *buf);
1957 ADDR rv_addr(void *buf);
1958 
1962 struct target_decoder_binding;
1963 
1965  char *name;
1966  void *(*bind)(struct target_decoder_binding *tdb);
1967  int (*unbind)(struct target_decoder_binding *tdb,void *decoder_data);
1968 };
1969 
1971  struct target *target;
1975 };
1976 
1977 typedef int (*target_decoder_t)(struct target *target,void *data,
1978  struct value *value,char *buf,int buflen);
1979 
1981 int target_decoder_lib_bind(struct target *target,char *decoder_lib,
1982  char *decoder_lib_lib);
1984  struct bsymbol *bsymbol,target_decoder_t dfn);
1985 int target_decoder_lookup(struct target *target,struct value *value,
1986  target_decoder_t *decoder,void **decoder_data);
1987 
1992 /*
1993  * For now, targets can support multiple threads. However, these
1994  * threads should share their address spaces; if they do not, use a
1995  * separate target to track them.
1996  *
1997  * XXX: we really need to have each thread "own" its own addrspace --
1998  * even if that addrspace is shared throughout a group of threads. This
1999  * isn't too hard to fix; BUT all access to memory would then need to go
2000  * through a thread id. That's a fundamental API change, throughout the
2001  * library.
2002  *
2003  * Targets can support either single-thread mode or multi-thread mode
2004  * (or may only support one or the other). To support single-thread
2005  * mode, each target should supply a "default thread" that either really
2006  * is the single thread of the target, or somehow abstracts around the
2007  * fact that there are multiple threads running.
2008  *
2009  * In single thread mode, only the default thread is used; hardware
2010  * state of the machine is always in this thread's context. So, if the
2011  * user/library calls target_load_current_thread, the default thread is
2012  * always populated with current hardware state and returned.
2013  * target_load_thread(tid) will always fail in single-thread mode.
2014  * Summary: single-thread mode exists so that the user doesn't have to
2015  * worry about which thread context they are executing in, if they don't
2016  * care.
2017  *
2018  * In thread-aware mode, the user is unaware that there are multiple
2019  * threads, but the VMI library knows there are; it detects these
2020  * threads as separate execution contexts so that it can maintain
2021  * probepoint state amongst multiple threads. However, they are not
2022  * exposed to the user (i.e., the user sees only the def
2023  *
2024  * In multi-thread mode, target_load_current_thread should load the
2025  * current thread's hardware context into a thread that is truly
2026  * associated with the thread's real TID (unlike loading the current
2027  * thread in single-thread mode). Hence, in multi-thread mode, the
2028  * default thread is never used.
2029  *
2030  * When setting probes, if your target is single threaded, probes are
2031  * always "global" -- that is, if they manifest as hardware debug
2032  * register probes, the debug registers are set globally; if they
2033  * manifest as software probes, the software probes will cause
2034  * interrupts no matter what thread hits them, and the probes will
2035  * always be notified no matter which thread is executing.
2036  *
2037  * When setting probes on a multi threaded target, you have two options:
2038  * set the probes per-thread, or to be TID_GLOBAL. The idea is that if
2039  * a probe is per-thread, the probe will only be notified if the thread
2040  * named hits the probe. If you have set TID_GLOBAL for your probe, the
2041  * probe will be notified for any thread that triggers the probe. Why
2042  * is the distinction important? If you set software probes, they will
2043  * cause interrupts in any thread in the target (since they are embedded
2044  * in the shared text pages). BUT, if you set the probes per-thread,
2045  * the probes will only be notified in the thread they were associated
2046  * with.
2047  *
2048  * When setting a hardware probe per-thread or with TID_GLOBAL, the
2049  * behavior is target-dependent, because it depends on the model for
2050  * using/sharing the hardware debug registers. On x86 architectures,
2051  * there is no hardware support for sharing the debug registers, so
2052  * things are tricky.
2053  *
2054  * For our two existing targets, these are the rules:
2055  *
2056  * xen_vm -- you should either set all your hardware probes with
2057  * TID_GLOBAL, or per-thread. Do not mix them. Why? Because once you
2058  * set a per-thread probe, the Linux kernel running in the guest VM will
2059  * modify the contents of the debug registers when a process is context
2060  * switched. This will wipe out any registers set with TID_GLOBAL, and
2061  * your TID_GLOBAL probes may not work anymore. We recommend that you
2062  * only probe with TID_GLOBAL for this target.
2063  *
2064  * linux_userspace_process -- TID_GLOBAL is meaningless on this target.
2065  * You can only set per-thread hardware debug registers.
2066  *
2067  */
2068 
2069 typedef enum {
2076 
2078  struct target *target;
2081  int8_t resumeat:4,
2082  attached:1,
2083  exiting:1;
2086 
2090 
2091  /*
2092  * Target backends may or may not set these fields when they load
2093  * threads. If @name is set, it will be freed when the thread is
2094  * freed. @ptid is the parent thread, or -1. @tgid is the thread
2095  * group id (on Linux, it's the process id). @uid and @gid are the
2096  * user id and group id of this thread; or -1 if not
2097  * available/meaningless.
2098  */
2099  char *name;
2102  int uid;
2103  int gid;
2104 
2105  void *state;
2107 
2108  /*
2109  * Built-in support for regcache. We do expect most target backends
2110  * to use it!
2111  */
2113 
2114  /*
2115  * A hashtable of addresses to probe points.
2116  */
2117  GHashTable *hard_probepoints;
2118 
2119  /*
2120  * Info about the probepoint we are handling. A single thread can
2121  * only be directly handling one probepoint at once. The only case
2122  * where we could stack up two breakpoints is when we single step
2123  * after hitting a breakpoint, and we trigger a watchpoint. This
2124  * is a special case, and for x86 targets, the x86 guarantees that
2125  * the watchpoint exception will happen first, then the single step
2126  * exception. But in any case, we know what is happening, so we can
2127  * handle it.
2128  *
2129  * The other case where it could happen is if an interrupt fires
2130  * before the single step following a breakpoint can run, or if an
2131  * exception occurs during the single step, which triggers control
2132  * flow to divert to another path involving another probepoint. In
2133  * the interrupt case, the thread could be preempted by another
2134  * thread. This is bad, because when we handled the breakpoint, we
2135  * replaced the breakpoint instruction with either an action
2136  * instruction or the original instruction and were about to single
2137  * step it. The only way we could handle this is to snoop on
2138  * higher-prio interrupts; see if the interrupt preempted our
2139  * handling of a breakpoint, and put the breakpoint instruction back
2140  * in (or reenable the hw breakpoint in question) before the
2141  * interrupt is handled. Then, when the other thread resumes, we're
2142  * going to single step the breakpoint instruction, and we need to
2143  * recognize this and basically try the single step again.
2144  *
2145  * For the case where an exception fires during the single
2146  * step... actually I think the x86 will not fire the single step
2147  * trap until the exception has been handled, because the single
2148  * step trap cannot happen until the instruction pointer can be
2149  * moved past the instruction... ?
2150  *
2151  * The other case where this can happen is when one of the actions
2152  * is one or more custom code actions, and we have to execute more
2153  * instructions that just the one single step following a
2154  * breakpoint. In this case, our thread might get interrupted while
2155  * handling actions, and we must therefore remember which action for
2156  * which probepoint we are handling later when the thread resumes.
2157  *
2158  * So, anyway, for these reasons at least, we have to keep
2159  * per-probepoint, per-action state for each thread. We push a new
2160  * context each time we hit a breakpoint. When a debug event
2161  * happens for a thread, we continue operating with the context atop
2162  * the stack. This doesn't solve the problems of interrupts and
2163  * exceptions during or before the single step of the breakpoint,
2164  * but it solves the problem of running multiple actions within the
2165  * thread. If we didn't have the stack, we would no longer know
2166  * which probepoint we were handling...
2167  */
2170 
2171  /*
2172  * If this target supports an underlying physical address space, and
2173  * that address space can be shared amongst the target's threads, we
2174  * might place breakpoints in shared pages. So -- if we hit a
2175  * breakpoint at such a page in a thread that is not registered on
2176  * the breakpoint, we have to emulate the breakpoint's behavior. See
2177  * target_memmod_emulate_bp_handler() and target_memmod_ss_handler().
2178  */
2180 
2181  /* See target->interrupted_ss_handler. */
2183 
2184  /*
2185  * Any single step actions that are executing in this thread. We
2186  * might have more than one at a single probepoint, or we might have
2187  * accumulated one or more from previous probepoints that are still
2188  * being handled. They each have per-thread state, since an action
2189  * for a probe attached to TID_GLOBAL could be fired in any thread.
2190  * If it wasn't for that case, action state would be per-thread
2191  * only, but able to be kept entirely within the action struct.
2192  */
2194 
2195  /*
2196  * A simple key/value store for generic target thread state that is
2197  * specific to this target thread instance.
2198  */
2199  GHashTable *gkv_store;
2200 };
2201 
2202 struct target_spec {
2204 
2209 
2213  uint8_t spec_was_base:1,
2214  spec_was_overlay:1,
2215  start_paused:1,
2216  kill_on_close:1,
2217  stay_paused:1,
2218  read_only:1;
2219 
2221 
2222  /*
2223  * All personalities have unique string IDs. The user can force a
2224  * specific one to be used here if they like, although that is
2225  * likely to be a bad idea, unless they've implemented a custom
2226  * personality that is outside the VMI install tree.
2227  */
2229  /*
2230  * If the personality is to be loaded from a specific shared
2231  * library, this is the filename.
2232  */
2234 
2236  /* struct array_list of struct debugfile_load_opts * */
2238 
2239  /*
2240  * If kill_on_close, call kill() during close() with this signal.
2241  */
2243 
2244  /*
2245  * I/O behavior is a bit complicated. We want a couple things -- to
2246  * support the target library by itself (i.e., user code calling
2247  * directly into the library); and to support the XML SOAP server
2248  * calling into the library on behalf of the user. In both cases,
2249  * we might want I/O logged to a file; we might want I/O callbacks
2250  * to the user (we might want it buffered too, but forget that for
2251  * now).
2252  *
2253  * So, if the caller wants stdio interaction, the backend must open
2254  * the I/O devices and expose them to the caller as an FD -- the
2255  * caller specifies this by providing evloop_handler_ts for the
2256  * stdio descriptor types it cares about. If the user does not
2257  * specify one of these, but instead specifies a filename, the
2258  * backend must auto-write/-read the output/input to/from the named
2259  * file.
2260  *
2261  * (If handlers are provided, the caller *must* call
2262  * target_attach_evloop() sometime -- otherwise if the target does
2263  * i/o on those descriptors, they will probably fill up and block it!)
2264  *
2265  *
2266  * Only the backend knows how to deal with I/O, for each backend.
2267  * So, we have to rely on the backend to give us file descriptors
2268  * for the target I/Os we care about. We assume stdin, stdout, and
2269  * an optional stderr. The problem is, some backends might provide
2270  * stdio access only if we launch a new target (Ptrace); others
2271  * might provide access anytime (Xen); but we can't know until the
2272  * backend parses the spec and figures out what to do.
2273  *
2274  * (Even if the backend opens one of these files, it must not remove
2275  * it! That is the user or caller's job.)
2276  *
2277  * This kind of sucks... but we'll just warn the client if it tries
2278  * to do something the backend doesn't support. Later we can do
2279  * something better, like warning a priori.
2280  *
2281  */
2285 
2286  char *infile;
2287  char *outfile;
2288  char *errfile;
2289 
2291 };
2292 
2299  char **quoted_argv;
2302 };
2303 
2304 typedef target_status_t (*target_exception_handler_t)(struct target *target,
2306  int *again,void *priv);
2307 
2308 typedef result_t (*target_debug_bp_handler_t)(struct target *target,
2309  struct target_thread *tthread,
2310  struct probepoint *probepoint,
2311  int was_stepping);
2312 typedef result_t (*target_debug_handler_t)(struct target *target,
2313  struct target_thread *tthread,
2314  struct probepoint *probepoint);
2315 
2332 struct target_location_ctxt *target_global_tlctxt(struct target *target);
2333 
2334 struct target_location_ctxt *
2335 target_location_ctxt_create(struct target *target,tid_t tid,
2336  struct memregion *region);
2337 struct target_location_ctxt *
2338 target_location_ctxt_create_from_bsymbol(struct target *target,tid_t tid,
2339  struct bsymbol *bsymbol);
2340 void
2342  struct bsymbol *bsymbol);
2343 void target_location_ctxt_free(struct target_location_ctxt *tlctxt);
2344 
2345 /*
2346  * Thread stack unwind support. Not all targets need to support this.
2347  *
2348  * A user calls target_unwind to set up an unwinding context. Then they
2349  * can call target_unw_getframe repeatedly until they get no more
2350  * frames. If it returns NULL and errno is set, there was an error; if
2351  * errno is not set, there are no more frames on the call stack. Then
2352  * the user must call target_unw_free to clean up the unwinding
2353  * context. This will free all values, register caches, etc. It is not
2354  * safe to reuse any of those pointers.
2355  */
2356 typedef enum {
2363 
2364 /*
2365  * We pass one of these to the dwdebug location functions as the
2366  * location_ops priv data; thus it gets back to us. We need to be able
2367  * to pass this when we have
2368  */
2370  /*
2371  * We pass a pointer to this to the location_* functions; they pass
2372  * us a pointer to the containing struct (target_location_ctxt). In
2373  * other words, lctxt->priv points to the containing struct. This
2374  * means we don't always have to malloc a location_ctxt struct; and
2375  * then lctxt is the only keeper of current_frame.
2376  */
2378 
2379  /*
2380  * A location context is always pinned to a specific target thread.
2381  * This makes sure we access the correct registers.
2382  */
2384  /*
2385  * On the other hand, the region it is bound to changes as the
2386  * *frame* context changes (i.e., if @unw is set below, @region will
2387  * correspond to the region associated with the symbol
2388  *
2389  * These are dynamically set according @unw, if it is in use!
2390  */
2392 
2393  /*
2394  * If we've attached unwinding state to this context, this is it.
2395  */
2397 };
2398 
2399 /*
2400  * A stack frame (activation).
2401  */
2404  int frame;
2406 
2407  /*
2408  * The function symbol associated with this frame. Ok, now we have
2409  * an "alternate" symbol -- the primary is the one associated with
2410  * the debuginfo; the alternate is the binfile symbol. Sometimes
2411  * the best debuginfo symbol we can get is the file symbol; but
2412  * usually the binfile has more fine-grained symbols we can use
2413  * instead; they just might not be in debuginfo.
2414  */
2415  struct bsymbol *bsymbol;
2416  struct bsymbol *alt_bsymbol;
2417 
2418  /*
2419  * This contains the restored registers.
2420  *
2421  * NB: this is NULL if @frame == 0, because we want to support live
2422  * edits to the base registers, and don't want to cache them.
2423  */
2424  GHashTable *registers;
2425 
2426  /*
2427  * Backend-specific extra state.
2428  */
2429  void *priv;
2430 };
2431 
2432 typedef enum {
2437 
2438 /*
2439  * This is a very simple unwinding API.
2440  */
2441 struct target_location_ctxt *target_unwind(struct target *target,tid_t tid);
2442 int target_unwind_snprintf(char *buf,int buflen,struct target *target,tid_t tid,
2443  target_unwind_style_t fstyle,
2444  char *frame_sep,char *ksep);
2449  REG reg,REGVAL *o_regval);
2454 
2455 /*
2456  * A target is the top-level entity a user creates or associates with to
2457  * start a debugging session. Targets bind state and type metadata to
2458  * an execution context and at least one address space.
2459  */
2460 struct target {
2464 
2465  uint32_t live:1,
2466  writeable:1,
2468  threadctl:1,
2469  mmapable:1,
2470  opened:1,
2471  kill_on_close:1,
2472  monitorhandling:1,
2475  no_adjust_bp_ip:1;
2476 
2478 
2479  /*
2480  * How we track status is a little funny. Basically, we want the
2481  * target's event handlers (monitor, poll, an evloop handler) to set
2482  * status before leaving the handling code (to return into the rest
2483  * of the library, or to the user code). This avoids lots of
2484  * (potentially, depending on backend) expensive calls to
2485  * @ops->status.
2486  *
2487  * The backend must only set target and thread status via
2488  * target(_thread)_set_status or similar, so that we can track and
2489  * debug the changes. The backend must set status corresponding to
2490  * whatever state it leaves the target in. That means, for
2491  * instance, for the ptrace target, if it resumes tracing on behalf
2492  * of the user, it sets status to RUNNING. The backend should only
2493  * set status to _ERROR if the error is a fatal, final error, and
2494  * the target API cannot continue. monitor/poll can return _ERROR,
2495  * *but* only if they are temporary errors that the backend feels
2496  * safe continuing with. In reality, the backend author must
2497  * minimize these; the user cannot deal with them very well, other
2498  * than cleaning up as best they can.
2499  *
2500  * When the target is not opened, we always call into the backend to
2501  * set the status field each time target_status is called.
2502  */
2504 
2505  unsigned int max_thread_ctxt;
2509 
2510  /*
2511  * Each target has a unique integer ID; this is the key into the
2512  * target hashtable, for instance.
2513  */
2514  int id;
2516 
2517  /*
2518  * Each target has a unique name; this is generated by
2519  * target_ops->snprintf during target_init.
2520  */
2521  char *name;
2522 
2523  /*
2524  * state is for, and owned, by the backend providing this target.
2525  */
2526  void *state;
2527  /*
2528  * Right now, personality_state is owned by the personality -- and
2529  * the personality_ops and
2530  * (os_ops|process_ops|application_ops|runtime_ops) own that state
2531  * together. No need to separate those things for now.
2532  */
2534 
2535  /*
2536  * These are the primary target operations, provided by the backend
2537  * as necessary/applicable. The backend need not provide all
2538  * operations, especially if it is counting on a personality to fill
2539  * them in, as described below. Target backends may be designed to
2540  * require a personality; utilize a personality; or to block any
2541  * personality ops from ever being called (i.e., if the personality
2542  * is effectively integrated fully into the target ops -- sometimes
2543  * a target backend cannot be separated into a generic control
2544  * interface, or there might not be an available personality, or
2545  * whatever -- the abstraction is deliberately designed to be
2546  * flexible). Read more below...
2547  */
2548  struct target_ops *ops;
2550  /*
2551  * Ok, these ops structures are for personalities. A personality
2552  * can "overload" the target with more information. For instance,
2553  * some targets may provide low-level machine control/read/write;
2554  * but a *personality* might be able to fill in more info by
2555  * reading/writing symbols in the target to obtain a richer
2556  * representation of the target, or to enable more functionality.
2557  *
2558  * By abstracting it this way, we allow a target backend to be
2559  * written in a minimal style, and to be enriched by a personality.
2560  * This supports writing, for instance, a bare-bones xen vm backend
2561  * that supports minimal x86 machine control/read/write via the Xen
2562  * control interface; but allows that same backend to be enriched by
2563  * the os_linux_generic personality; a customized version for
2564  * specific linux kernel versions; or a windows personality.
2565  *
2566  * The reason we reuse a full struct target_ops for personality ops,
2567  * instead of creating a struct target_personality_ops, is because
2568  * many of the operations could legitimately be provided by either
2569  * the target backend, or by the personality, depending on the
2570  * target in question. A PHP target backend might not support a
2571  * separate personality; it might just be all integrated into the
2572  * backend. It may be impossible to disentangle the primary backend
2573  * from the personality.
2574  *
2575  * So here's how the Target API/library work this all out.
2576  * Everything goes through the target API or library wrapper
2577  * functions; they are the only things that call through the ops
2578  * structs. Basically, if the target backend implements one of the
2579  * target ops, the implementation should call the
2580  * target_personality_[op] wrapper function for the op in question.
2581  * If the target backend does *not* implement an op, but the
2582  * personality does; the target library will call that op instead of
2583  * the target op.
2584  */
2586  /*
2587  * OS/Process/Application ops will probably also be provided by the
2588  * same library providing the personality, but this need not be the
2589  * case.
2590  */
2591  union {
2595  };
2596 
2597  GHashTable *decoders;
2598 
2599  /*
2600  * Each target *must* have an architecture. This pointer must be
2601  * set by the target backend factory functions.
2602  */
2603  struct arch *arch;
2604 
2606 
2608 
2609  /*
2610  * If the spec specified stdio interactions via handlers, these are
2611  * the file descriptors.
2612  */
2613  int infd;
2614  int outfd;
2615  int errfd;
2616 
2617  /*
2618  * A simple key/value store for generic target configuration
2619  * options. Anything keys/values placed in it will be free()d when
2620  * the hashtable is freed, so be careful!
2621  */
2622  GHashTable *config;
2623 
2624  /*
2625  * A simple key/value store for generic target state that is
2626  * specific to this target instance. This is useful for probe
2627  * libraries that store per-target info -- but don't want to manage
2628  * a per-target cache themselves.
2629  *
2630  * It's also useful for any state that is per-target that must be
2631  * automatically destroyed on target close or free.
2632  */
2633  GHashTable *gkv_store;
2634 
2635  /*
2636  * If the target is attached to an evloop, this is that evloop.
2637  */
2638  struct evloop *evloop;
2639 
2640  /* Targets can have multiple address spaces, but not sure how we're
2641  * going to use this yet.
2642  */
2643  GList *spaces;
2644 
2645  /*
2646  * Each target has a primary binfile associated with it; think
2647  * "main" for userspace, the kernel for kernels.
2648  */
2649  struct binfile *binfile;
2650 
2651  /*
2652  * If this is an overlay, this is the underlying "base" target info.
2653  */
2654  struct target *base;
2656  int base_id;
2658 
2659  /*
2660  * Any live overlay targets are placed here. There can only be a
2661  * single overlay per thread, at the moment.
2662  */
2663  GHashTable *overlays;
2664  /*
2665  * Once an overlay has attached to one of this target's threads, it
2666  * can can "alias" other threads in the underlying target to point
2667  * to the overlay. For instance, this can help to map all threads
2668  * in a thread group into a single overlay process target.
2669  */
2670  GHashTable *overlay_aliases;
2671 
2672  GHashTable *threads;
2673  /*
2674  * For single-threaded targets, this will always be the global
2675  * thread. For multi-threaded targets, it will be the
2676  * currently-executing thread (and if there is no thread context,
2677  * i.e., the machine is in interrupt context, it will be the global
2678  * thread).
2679  */
2681  /*
2682  * This is the thread that should be used for any TID_GLOBAL
2683  * operations. Its state should always be loaded
2684  */
2686 
2687  /*
2688  * If we have to pause all threads in the target while we handle a
2689  * breakpoint for one thread, we always make sure to waitpid() for
2690  * this blocking thread first, and handle it first, before handling
2691  * any others.
2692  */
2694 
2695  /*
2696  * This should be a load context corresponding to TID_GLOBAL.
2697  * Target backends should create it in their init() functions. If
2698  * they set the global_tlctxt_is_dynamic bit above, as well,
2699  * target_global_tlctxt() will attempt to replace the value of the
2700  * ->region member with the region associated with the current IP.
2701  * This supports backends that create a single static region
2702  * spanning the entire target.
2703  *
2704  * target_global_tlctxt() will return this structure; it should never
2705  * be freed.
2706  */
2708 
2709  /*
2710  * This is for target backends to use if they wish.
2711  *
2712  * The idea is, each time we single step a thread, we make a note of
2713  * it here; each time we run the monitor loop looking for debug
2714  * exceptions, after we find one, clear this variable after checking
2715  * any state related to it, so that we know how to handle the debug
2716  * exception -- but then CLEAR it before handling the exception via
2717  * the probe library. The Xen target does this; the linux ptrace
2718  * target does not.
2719  *
2720  * This is not completely trustworthy on targets that do not provide
2721  * good thread control. It is here for the case in which we single
2722  * step an instruction that might switch contexts. If we have just
2723  * done that, and this var is set, a target's monitor loop should
2724  * notice and try to "handle" the singlestep in the previous thread,
2725  * even though the thread is no longer running.
2726  */
2728  /*
2729  * Also, if the overlay target uses the underlay's single step
2730  * mechanism, provide a place to mark that it did, so that the
2731  * overlay can handle the resulting single steps if it needs to.
2732  */
2733  struct target *sstep_thread_overlay;
2734 
2735  GHashTable *soft_probepoints;
2736 
2737  /*
2738  * A table of memory modifications, and their states. We use this
2739  * to support software probepoints.
2740  */
2741  GHashTable *mmods;
2742 
2743  /*
2744  * A table of physical memory modifications, and their states. We
2745  * use this to support software probepoints.
2746  *
2747  * Phys mmods are global to a target because it supports MMU-based
2748  * multiple address spaces -- i.e., addrs are fundamentally virt
2749  * addrs in a target. This allows a target to be aware of physical
2750  * addrs below virt addrs. So, it can support the case where a
2751  * memmod might have been made in the VMM of a userspace process,
2752  * but that this memmod might also manifest in the VMM of another
2753  * userspace process at a different virt addr; but at the same phys
2754  * addr.
2755  */
2756  GHashTable *phys_mmods;
2757 
2758  /*
2759  * A hashtable of probe IDs to probes that were created on this
2760  * target.
2761  *
2762  * Probes may be attached to specific threads, but we track them
2763  * globally here, mostly for the XML RPC server.
2764  */
2765  GHashTable *probes;
2766 
2767  /*
2768  * A hashtable of (scheduled) action IDs to actions.
2769  *
2770  * Although (scheduled) actions are attached to probepoints, we
2771  * track them by ID on a per-target basis. Right now, this is only
2772  * used for XML RPCs; internally, the IDs are unused.
2773  *
2774  * Also note that we do not explicitly "free" actions; users
2775  */
2776  GHashTable *actions;
2777 
2778  /*
2779  * Counters for the IDs for probes/actions.
2780  */
2783 
2784  /*
2785  * If we cache any of the target's v2p mappings or mmap its memory,
2786  * this is the struct the backends should initialize, populate, and
2787  * use. See memcache.h... For now, backends interact with the
2788  * memcache, and the target API does not. Backends should control
2789  * it for now.
2790  */
2792 
2793  /* Cache of loaded code, by address range. */
2795 };
2796 
2797 struct target_ops {
2798  int (*snprintf)(struct target *target,char *buf,int bufsiz);
2799 
2800  /*
2801  * init any target state, like a private per-target state struct.
2802  *
2803  * If the backend needs to attach to the target and pause it now so
2804  * that it can initialize, that is allowed -- but we don't expect
2805  * it.
2806  *
2807  * XXX: what about personalities that might try to read the target's
2808  * reg/mem to initialize???
2809  */
2810  int (*init)(struct target *target);
2811  /*
2812  * Destroy any target state and perform any final cleanup specific
2813  * to the backend.
2814  */
2815  int (*fini)(struct target *target);
2816  /*
2817  * Actually connect to the target to enable read/write.
2818  */
2819  int (*attach)(struct target *target);
2820  /* detach from target, but don't unload */
2821  int (*detach)(struct target *target,int stay_paused);
2822  /* destroy the target */
2823  int (*kill)(struct target *target,int sig);
2824 
2825  /* Divide the target into address spaces with different IDs, that
2826  * might contain multiple subregions.
2827  */
2828  int (*loadspaces)(struct target *target);
2829  /* divide the address space into regions, each containing one
2830  * or more ranges, with different protection flags, that might come
2831  * from different source binary files.
2832  */
2833  int (*loadregions)(struct target *target,
2834  struct addrspace *space);
2835  /* for each loaded region, load one or more debugfiles and associate
2836  * them with the region.
2837  */
2838  int (*loaddebugfiles)(struct target *target,
2839  struct addrspace *space,
2840  struct memregion *region);
2841  /* Once regions and debugfiles are loaded, we call this -- it's a
2842  * second-pass init, basically.
2843  */
2844  int (*postloadinit)(struct target *target);
2845  /* Once @attach has been called and has succeeded, we call this --
2846  * primarily it's a chance for the target to register probes on
2847  * itself.
2848  *
2849  * We initially call it with @target->spec->active_probe_flags; but
2850  * users may later call target_set_active_probing() to fine-tune
2851  * settings.
2852  */
2853  int (*set_active_probing)(struct target *target,active_probe_flags_t flags);
2854  /* Once @attach has been called and has succeeded, the target is
2855  * opened. This is the final function we call in target_open.
2856  */
2857  int (*postopened)(struct target *target);
2858 
2859  /* Single step and breakpoint handlers. Since we control
2860  * single-step mode, we report *any* single step stop events to the
2861  * handler, and do nothing with them ourselves.
2862  *
2863  * For breakpoints, if we don't have a probepoint matching the
2864  * breaking EIP, target_monitor will return to the library user, and
2865  * they'll have to handle the exception themselves (i.e., this would
2866  * happen if their code had a software breakpoint in it).
2867  */
2871  /*
2872  * If a thread was supposed to be stepping, but it steps into a new
2873  * context, this handler should be called to abort the single step;
2874  * save the probepoint in thread->interrupted_ss_probepoint; restore
2875  * the breakpoint. We save off the breakpoint so we can know that
2876  * when the breakpoint is hit again, we shouldn't run pre-handlers
2877  * again. This is definitely a dicey strategy -- how can we know
2878  * that we'll be at the interrupted context when we hit the
2879  * breakpoint next in this thread? For instance, the only place
2880  * this is used right now is the Xen target. Consider: a
2881  * xen-process target breakpoint is hit; we single step using HVM
2882  * MTF; instead of stepping in userspace, we find ourselves stepping
2883  * in that thread, but in the kernel. That means the singlestep of
2884  * the breakpoint didn't happen; thus we need to reset the
2885  * breakpoint. BUT, then, what happens on return from the kernel?
2886  * Normally, the breakpoint would be immediately hit again, and the
2887  * single step would work. Unfortunately, kernels don't guarantee
2888  * this behavior... the userspace EIP could be adjusted to deliver a
2889  * signal, or whatever. But all we can do is assume it, unless we
2890  * want to get into the heavyweight business of tracking context
2891  * switches.
2892  */
2894 
2895  /*
2896  * A single function that allows a target backend to be notified of
2897  * key target events. This allows a backend to be notified of
2898  * changes that its personality makes; or for an overlay target
2899  * backend to be notified when the underlying target senses an event
2900  * that is relevant to the overlay.
2901  */
2902  void (*handle_event)(struct target *target,struct target_event *event);
2903 
2904  int (*obj_flags_propagate)(struct target *target,
2905  obj_flags_t orf,obj_flags_t nandf);
2906 
2907  /*
2908  * "Underlay" targets (that support overlays) must define these
2909  * functions.
2910  */
2911  struct target_spec *(*build_default_overlay_spec)(struct target *target,
2912  tid_t tid);
2913  struct target *(*instantiate_overlay)(struct target *target,
2914  struct target_thread *tthread,
2915  struct target_spec *spec,
2916  struct target_thread **ntthread);
2917  struct target_thread *(*lookup_overlay_thread_by_id)(struct target *target,
2918  int id);
2919  struct target_thread *(*lookup_overlay_thread_by_name)(struct target *target,
2920  char *name);
2921  int (*attach_overlay_thread)(struct target *base,struct target *overlay,
2922  tid_t newtid);
2923  int (*detach_overlay_thread)(struct target *base,struct target *overlay,
2924  tid_t tid);
2925  /*
2926  * Overlay targets must support this if their exceptions come from
2927  * the underlying target.
2928  */
2929  target_status_t (*handle_overlay_exception)(struct target *overlay,
2931  tid_t tid,ADDR ipval,int *again);
2932 
2933  /* get target status. */
2934  target_status_t (*status)(struct target *target);
2935  /* pause a target */
2936  int (*pause)(struct target *target,int nowait);
2937  /* resume from a paused state */
2938  int (*resume)(struct target *target);
2939  /* wait for something to happen to the target */
2940  target_status_t (*monitor)(struct target *target);
2941  target_status_t (*poll)(struct target *target,struct timeval *tv,
2942  target_poll_outcome_t *outcome,int *pstatus);
2943 
2944  /*
2945  * NB, driver developers: target_monitor_evloop() assumes that you
2946  * will set the void *state param to evloop_set_fd to the target
2947  * argument!!! Make sure to follow that convention.
2948  */
2949  int (*attach_evloop)(struct target *target,struct evloop *evloop);
2950  int (*detach_evloop)(struct target *target);
2951 
2952  /* read some memory, potentially into a supplied buffer. */
2953  unsigned char *(*read) (struct target *target,ADDR addr,
2954  unsigned long length,unsigned char *buf);
2955  /* write some memory */
2956  unsigned long (*write)(struct target *target,ADDR addr,
2957  unsigned long length,unsigned char *buf);
2958 
2959  /* Some targets only support symbol reads/writes; support them! */
2960  struct value *(*read_symbol)(struct target *target,
2961  struct target_location_ctxt *tlctxt,
2962  struct bsymbol *bsymbol,load_flags_t flags);
2963  int (*write_symbol)(struct target *target,struct value *value);
2964 
2965  /*
2966  * Some targets might support threads that have their own virtual
2967  * address spaces, but an underlying system (like the kernel) might
2968  * share phys memory amongst separate thread virtual address
2969  * spaces.
2970  *
2971  * (The Xen target uses this to provide shared-page breakpoint
2972  * support to Xen Process overlay targets.)
2973  */
2974 
2975  int (*addr_v2p)(struct target *target,tid_t tid,ADDR vaddr,ADDR *paddr);
2976 
2977  /* read some phys memory, potentially into a supplied buffer. */
2978  unsigned char *(*read_phys)(struct target *target,ADDR paddr,
2979  unsigned long length,unsigned char *buf);
2980  /* write some phys memory */
2981  unsigned long (*write_phys)(struct target *target,ADDR paddr,
2982  unsigned long length,unsigned char *buf);
2983 
2988  /* Context stuff so that we can handle multithreaded targets, and
2989  * infinite single stepping in their presence.
2990  */
2991  tid_t (*gettid)(struct target *target);
2992  void (*free_thread_state)(struct target *target,void *state);
2993  struct array_list *(*list_available_tids)(struct target *target);
2994  struct target_thread *(*load_thread)(struct target *target,tid_t tid,
2995  int force);
2996  struct target_thread *(*load_current_thread)(struct target *target,
2997  int force);
2998  int (*load_all_threads)(struct target *target,int force);
2999  int (*load_available_threads)(struct target *target,int force);
3000  int (*pause_thread)(struct target *target,tid_t tid,int nowait);
3001  /* flush target(:tid) machine state */
3002  int (*flush_thread)(struct target *target,tid_t tid);
3003  int (*flush_current_thread)(struct target *target);
3004  int (*flush_all_threads)(struct target *target);
3005  int (*invalidate_thread)(struct target *target,struct target_thread *tthread);
3006  int (*gc_threads)(struct target *target);
3007  int (*thread_snprintf)(struct target *target,struct target_thread *tthread,
3008  char *buf,int bufsiz,
3009  int detail,char *sep,char *key_val_sep);
3010 
3011  /*
3012  * Register stuff.
3013  *
3014  * A backend can use several strategies to implement register handling.
3015  *
3016  * 1) Implement the methods below, and handle caching itself. This
3017  * would be more suitable to on-demand register loading (i.e., if
3018  * you're not going to load all registers in the thread load
3019  * methods).
3020  *
3021  * 2) Use the regcache, and set all these methods to the
3022  * target_regcache_* versions. Then you must load all registers in
3023  * the thread loader methods, and flush all dirty registers in the
3024  * thread flush methods. In some ways, this is currently the
3025  * preferred style, because then there is some linkage that a user
3026  * could/should expect between the backend and the arch's registers
3027  * (in that the backend should load all the arch registers!). But
3028  * the downside is the double buffering and copying
3029  * overhead... because backends that can load multiple registers
3030  * from a single copy in memory might well just copy that whole
3031  * section and write it out once. However, the regcache also helps
3032  * you track dirty registers on a more fine-grained level.
3033  *
3034  * If the target backend is going to use our
3035  * generic regcache support, these should all be set to the
3036  * target_regcache_* functions, or to NULL! If it does not use
3037  * regcache, all of these must be set to custom functions.
3038  *
3039  * If it does use regcache, its thread-loading functions *must* call
3040  * the target_regcache_init_reg functions to load registers.
3041  *
3042  * This may seem a bit weird, and it does force the thread loaders
3043  * to pre-populate the cache. BUT, that is why we have the
3044  * initreg_tidctxt method below. The target_init_reg_tidctxt
3045  * function calls that backend function if it is defined; else, it
3046  * sticks the reg into the regcache. So, as a backend developer, if
3047  * you want to make sure you control your own register caching, and
3048  * want to support the target_init_reg_tidctxt backend/personality
3049  * helper function, you must define initreg_tidctxt.
3050  *
3051  * That is the guts of the compromise of supporting an optional
3052  * regcache, or allowing the backend to support its own caching --
3053  * while still allowing a personality to *not* manage its own
3054  * caching.
3055  *
3056  * (Realistically, these functions need to be implemented; it's just
3057  * a matter of how the backend wants to flush a cache of pending
3058  * register writes at target_resume as it flushes its threads. Many
3059  * backends may implement readreg/writereg as calls to
3060  * readreg/writereg_tidctxt, where the tidctxt is the thread's
3061  * current context).
3062  */
3063  REGVAL (*readreg)(struct target *target,tid_t tid,REG reg);
3064  int (*writereg)(struct target *target,tid_t tid,REG reg,REGVAL value);
3065  GHashTable *(*copy_registers)(struct target *target,tid_t tid);
3066 
3067  REGVAL (*readreg_tidctxt)(struct target *target,
3068  tid_t tid,thread_ctxt_t tidctxt,REG reg);
3069  int (*writereg_tidctxt)(struct target *target,
3070  tid_t tid,thread_ctxt_t tidctxt,REG reg,REGVAL value);
3071 
3072  /* unwind support */
3073  struct target_location_ctxt *(*unwind)(struct target *target,tid_t tid);
3074  int (*unwind_read_reg)(struct target_location_ctxt *tlctxt,
3075  REG reg,REGVAL *o_regval);
3077  (*unwind_prev)(struct target_location_ctxt *tlctxt);
3078 
3079  /* breakpoint/watchpoint stuff */
3080  int (*probe_register_symbol)(struct target *target,tid_t tid,
3081  struct probe *probe,struct bsymbol *bsymbol,
3082  probepoint_style_t style,
3083  probepoint_whence_t whence,
3084  probepoint_watchsize_t watchsize);
3085  struct target_memmod *(*insert_sw_breakpoint)(struct target *target,tid_t tid,
3086  ADDR addr);
3087  int (*remove_sw_breakpoint)(struct target *target,tid_t tid,
3088  struct target_memmod *mmod);
3089  int (*enable_sw_breakpoint)(struct target *target,tid_t tid,
3090  struct target_memmod *mmod);
3091  int (*disable_sw_breakpoint)(struct target *target,tid_t tid,
3092  struct target_memmod *mmod);
3093  int (*change_sw_breakpoint)(struct target *target,tid_t tid,
3094  struct target_memmod *mmod,
3095  unsigned char *code,unsigned long code_len);
3096  int (*unchange_sw_breakpoint)(struct target *target,tid_t tid,
3097  struct target_memmod *mmod);
3098  REG (*get_unused_debug_reg)(struct target *target,tid_t tid);
3099  int (*set_hw_breakpoint)(struct target *target,tid_t tid,REG reg,ADDR addr);
3100  int (*set_hw_watchpoint)(struct target *target,tid_t tid,REG reg,ADDR addr,
3101  probepoint_whence_t whence,
3102  probepoint_watchsize_t watchsize);
3103  int (*unset_hw_breakpoint)(struct target *target,tid_t tid,REG reg);
3104  int (*unset_hw_watchpoint)(struct target *target,tid_t tid,REG reg);
3105  int (*disable_hw_breakpoints)(struct target *target,tid_t tid);
3106  int (*enable_hw_breakpoints)(struct target *target,tid_t tid);
3107  int (*disable_hw_breakpoint)(struct target *target,tid_t tid,REG dreg);
3108  int (*enable_hw_breakpoint)(struct target *target,tid_t tid,REG dreg);
3109  int (*notify_sw_breakpoint)(struct target *target,ADDR addr,
3110  int notification);
3111  int (*singlestep)(struct target *target,tid_t tid,int isbp,
3112  struct target *overlay);
3113  int (*singlestep_end)(struct target *target,tid_t tid,
3114  struct target *overlay);
3115 
3116  /* Instruction-specific stuff for stepping. */
3117  /*
3118  * Returns > 0 if the instruction might switch contexts; 0
3119  * if not; -1 on error.
3120  */
3121  int (*instr_can_switch_context)(struct target *target,ADDR addr);
3122 
3123  /*
3124  * Stuff for counters. Each target should provide its TSC
3125  * timestamp, an internal notion of time since boot in nanoseconds,
3126  * and if they support indexed execution, a "cycle counter" or
3127  * something.
3128  */
3129  uint64_t (*get_tsc)(struct target *target);
3130  uint64_t (*get_time)(struct target *target);
3131  uint64_t (*get_counter)(struct target *target);
3132 
3133  int (*enable_feature)(struct target *target,int feature,void *arg);
3134  int (*disable_feature)(struct target *target,int feature);
3135 };
3136 
3138  int (*snprintf)(struct target *target,char *buf,int bufsiz);
3139 
3140  int (*attach)(struct target *target);
3141  int (*init)(struct target *target);
3142  int (*fini)(struct target *target);
3143 
3144  int (*loadspaces)(struct target *target);
3145  int (*loadregions)(struct target *target,
3146  struct addrspace *space);
3147  int (*loaddebugfiles)(struct target *target,
3148  struct addrspace *space,
3149  struct memregion *region);
3150 
3151  int (*postloadinit)(struct target *target);
3152 
3153  int (*set_active_probing)(struct target *target,active_probe_flags_t flags);
3154 
3155  int (*postopened)(struct target *target);
3156 
3157  void (*handle_event)(struct target *target,struct target_event *event);
3158  int (*obj_flags_propagate)(struct target *target,
3159  obj_flags_t orf,obj_flags_t nandf);
3160 
3161  int (*handle_exception)(struct target *target,
3162  target_exception_flags_t flags);
3163 
3164  unsigned char *(*read)(struct target *target,ADDR addr,
3165  unsigned long length,unsigned char *buf);
3166  unsigned long (*write)(struct target *target,ADDR addr,
3167  unsigned long length,unsigned char *buf);
3168  int (*addr_v2p)(struct target *target,tid_t tid,ADDR vaddr,ADDR *paddr);
3169  unsigned char *(*read_phys)(struct target *target,ADDR paddr,
3170  unsigned long length,unsigned char *buf);
3171  unsigned long (*write_phys)(struct target *target,ADDR paddr,
3172  unsigned long length,unsigned char *buf);
3173 
3174  void (*free_thread_state)(struct target *target,void *state);
3175  struct array_list *(*list_available_tids)(struct target *target);
3176  struct target_thread *(*load_thread)(struct target *target,tid_t tid,
3177  int force);
3178  struct target_thread *(*load_current_thread)(struct target *target,
3179  int force);
3180  int (*load_available_threads)(struct target *target,int force);
3181  int (*pause_thread)(struct target *target,tid_t tid,int nowait);
3182  /* flush target(:tid) machine state */
3183  int (*flush_thread)(struct target *target,tid_t tid);
3184  int (*flush_current_thread)(struct target *target);
3185  int (*invalidate_thread)(struct target *target,struct target_thread *tthread);
3186  int (*gc_threads)(struct target *target);
3187  int (*thread_snprintf)(struct target *target,struct target_thread *tthread,
3188  char *buf,int bufsiz,
3189  int detail,char *sep,char *key_val_sep);
3190 
3191  /* get/set contents of a register */
3192  REGVAL (*readreg)(struct target *target,tid_t tid,REG reg);
3193  int (*writereg)(struct target *target,tid_t tid,REG reg,REGVAL value);
3194  GHashTable *(*copy_registers)(struct target *target,tid_t tid);
3195 
3196  REGVAL (*readreg_tidctxt)(struct target *target,
3197  tid_t tid,thread_ctxt_t tidctxt,REG reg);
3198  int (*writereg_tidctxt)(struct target *target,
3199  tid_t tid,thread_ctxt_t tidctxt,REG reg,REGVAL value);
3200 
3201  /* unwind support */
3202  struct target_location_ctxt *(*unwind)(struct target *target,tid_t tid);
3203  int (*unwind_read_reg)(struct target_location_ctxt *tlctxt,
3204  REG reg,REGVAL *o_regval);
3206  (*unwind_prev)(struct target_location_ctxt *tlctxt);
3207 
3208  /* breakpoint/watchpoint stuff */
3209  int (*probe_register_symbol)(struct target *target,tid_t tid,
3210  struct probe *probe,struct bsymbol *bsymbol,
3211  probepoint_style_t style,
3212  probepoint_whence_t whence,
3213  probepoint_watchsize_t watchsize);
3214  struct target_memmod *(*insert_sw_breakpoint)(struct target *target,tid_t tid,
3215  ADDR addr);
3216  int (*remove_sw_breakpoint)(struct target *target,tid_t tid,
3217  struct target_memmod *mmod);
3218  int (*enable_sw_breakpoint)(struct target *target,tid_t tid,
3219  struct target_memmod *mmod);
3220  int (*disable_sw_breakpoint)(struct target *target,tid_t tid,
3221  struct target_memmod *mmod);
3222  int (*change_sw_breakpoint)(struct target *target,tid_t tid,
3223  struct target_memmod *mmod,
3224  unsigned char *code,unsigned long code_len);
3225  int (*unchange_sw_breakpoint)(struct target *target,tid_t tid,
3226  struct target_memmod *mmod);
3227  REG (*get_unused_debug_reg)(struct target *target,tid_t tid);
3228  int (*set_hw_breakpoint)(struct target *target,tid_t tid,REG reg,ADDR addr);
3229  int (*set_hw_watchpoint)(struct target *target,tid_t tid,REG reg,ADDR addr,
3230  probepoint_whence_t whence,
3231  probepoint_watchsize_t watchsize);
3232  int (*unset_hw_breakpoint)(struct target *target,tid_t tid,REG reg);
3233  int (*unset_hw_watchpoint)(struct target *target,tid_t tid,REG reg);
3234  int (*disable_hw_breakpoints)(struct target *target,tid_t tid);
3235  int (*enable_hw_breakpoints)(struct target *target,tid_t tid);
3236  int (*disable_hw_breakpoint)(struct target *target,tid_t tid,REG dreg);
3237  int (*enable_hw_breakpoint)(struct target *target,tid_t tid,REG dreg);
3238  int (*notify_sw_breakpoint)(struct target *target,ADDR addr,
3239  int notification);
3240  int (*singlestep)(struct target *target,tid_t tid,int isbp,
3241  struct target *overlay);
3242  int (*singlestep_end)(struct target *target,tid_t tid,
3243  struct target *overlay);
3244 
3245  /* Instruction-specific stuff for stepping. */
3246  /*
3247  * Returns > 0 if the instruction might switch contexts; 0
3248  * if not; -1 on error.
3249  */
3250  int (*instr_can_switch_context)(struct target *target,ADDR addr);
3251 
3252  /*
3253  * Stuff for counters. Each target should provide its TSC
3254  * timestamp, an internal notion of time since boot in nanoseconds,
3255  * and if they support indexed execution, a "cycle counter" or
3256  * something.
3257  */
3258  uint64_t (*get_tsc)(struct target *target);
3259  uint64_t (*get_time)(struct target *target);
3260  uint64_t (*get_counter)(struct target *target);
3261 
3262  int (*enable_feature)(struct target *target,int feature,void *arg);
3263  int (*disable_feature)(struct target *target,int feature);
3264 };
3265 
3266 struct value {
3267  /*
3268  * We keep a reference to the target thread that resolved this
3269  * value. Why? Because although memory is thread-independent, the
3270  * location of variables is thread-dependent; it may depend on CPU
3271  * register state (i.e., a DWARF location expression that involves
3272  * reading the contents of registers).
3273  *
3274  * When a thread doesn't matter, @thread will be
3275  * target->global_thread (i.e., for loading values by type).
3276  */
3278 
3279  /*
3280  * The type of value -- it may NOT be the primary type of the
3281  * bsymbol! i.e., it may be the pointed-to type, or we may have
3282  * stripped off the const/vol qualifiers.
3283  *
3284  * We could also save the load flags so we always know what type of
3285  * memory this object is pointing to, but we'll skip that for now.
3286  */
3287  struct symbol *type;
3288 
3289  /*
3290  * A backreference to the symbol this value is associated with.
3291  */
3292  struct lsymbol *lsymbol;
3293 
3294  /* The memrange this value exists in. */
3295  struct memrange *range;
3296 
3297  int bufsiz;
3298  char *buf;
3299 
3300  uint8_t ismmap:1,
3301  isreg:1,
3302  isstring:1,
3303  isconst:1;
3304 
3305  /*
3306  * The location of the value.
3307  */
3308  union {
3311  } res;
3312 
3313  /*
3314  * The value of the PC when we last loaded this symbol.
3315  */
3317 
3318  struct value *parent_value;
3319 };
3320 
3321 #endif
int target_enable_feature(struct target *target, int feature, void *arg)
Definition: target_api.c:1950
struct bsymbol * target_lookup_sym_line(struct target *target, char *filename, int line, SMOFFSET *offset, ADDR *addr)
Definition: target.c:2267
int target_decoder_lib_bind(struct target *target, char *decoder_lib, char *decoder_lib_lib)
Definition: target.c:6206
uint64_t(* get_time)(struct target *target)
Definition: target_api.h:3259
target_status_t target_poll(struct target *target, struct timeval *tv, target_poll_outcome_t *outcome, int *pstatus)
Definition: target_api.c:1001
int bsymbol_is_inline(struct bsymbol *bsymbol)
Definition: symbol.c:74
int target_find_memory_real(struct target *target, ADDR addr, struct addrspace **space_saveptr, struct memregion **region_saveptr, struct memrange **range_saveptr)
Definition: target.c:3578
int infd
Definition: target_api.h:2613
target_type_t target_type(struct target *target)
Definition: target_api.c:501
uint64_t target_get_time(struct target *target)
Definition: target_api.c:1936
uint16_t rv_u16(void *buf)
Definition: value.c:1340
int target_monitor_evloop(struct evloop *evloop, struct timeval *timeout, struct target **target, target_status_t *status)
Definition: target_api.c:880
GHashTable * config
Definition: target_api.h:2622
int(* singlestep)(struct target *target, tid_t tid, int isbp, struct target *overlay)
Definition: target_api.h:3111
int(* fini)(struct target *target)
Definition: target_api.h:3142
int16_t v_i16(struct value *v)
Definition: value.c:393
int(* fini)(struct target *target)
Definition: target_api.h:2815
int(* flush_current_thread)(struct target *target)
Definition: target_api.h:3003
void target_location_ctxt_free(struct target_location_ctxt *tlctxt)
Definition: target.c:5348
#define THREAD_STATUS_BITS
Definition: target_api.h:282
int target_install_custom_sighandlers(sigset_t *ignored, sigset_t *interrupt, sigset_t *exit, void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
Definition: target.c:270
target_mode_t target_mode
Definition: target_api.h:2210
int value_update_i16(struct value *value, int16_t v)
Definition: value.c:529
struct target * base
Definition: target_api.h:2654
struct target_location_ctxt * target_unwind(struct target *target, tid_t tid)
Definition: target.c:5354
GHashTable * target_copy_registers(struct target *target, tid_t tid)
Definition: target_api.c:1203
void * state
Definition: target_api.h:2526
int target_enable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1773
char * TSTATUS_STRINGS[]
Definition: target.c:6933
int value_snprintf(struct value *value, char *buf, int buflen)
Definition: value.c:639
int target_is_evloop_attached(struct target *target, struct evloop *evloop)
Definition: target_api.c:863
int value_update_i32(struct value *value, int32_t v)
Definition: value.c:537
int target_disable_feature(struct target *target, int feature)
Definition: target_api.c:1957
int action_id_counter
Definition: target_api.h:2782
int(* enable_hw_breakpoint)(struct target *target, tid_t tid, REG dreg)
Definition: target_api.h:3237
unsigned char * target_read_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
Definition: target_api.c:1053
int target_singlestep(struct target *target, tid_t tid, int isbp)
Definition: target_api.c:1903
void * backend_spec
Definition: target_api.h:2290
void target_dump_thread(struct target *target, tid_t tid, FILE *stream, int detail)
Definition: target_api.c:1484
int(* attach)(struct target *target)
Definition: target_api.h:2819
int(* handle_exception)(struct target *target, target_exception_flags_t flags)
Definition: target_api.h:3161
int target_write_reg(struct target *target, tid_t tid, REG reg, REGVAL value)
Definition: target_api.c:1141
int target_lookup_line_addr(struct target *target, char *filename, ADDR addr)
Definition: target.c:2320
thread_bpmode_t bpmode
Definition: target_api.h:2211
int value_update_f(struct value *value, float v)
Definition: value.c:553
int32_t tid_t
Definition: common.h:36
target_personality_t personality
Definition: target_api.h:2515
struct array_list * frames
Definition: target_api.h:2396
int(* addr_v2p)(struct target *target, tid_t tid, ADDR vaddr, ADDR *paddr)
Definition: target_api.h:2975
char * target_name(struct target *target)
Definition: target_api.c:505
struct target * target_lookup_target_id(int id)
Definition: target.c:332
int(* attach)(struct target *target)
Definition: target_api.h:3140
target_status_t
Definition: target_api.h:197
void value_dump_simple(struct value *value, struct dump_info *ud)
Definition: value.c:1289
int(* disable_hw_breakpoints)(struct target *target, tid_t tid)
Definition: target_api.h:3105
common_reg_t
Definition: arch.h:73
char * bsymbol_get_name(struct bsymbol *bsymbol)
Definition: symbol.c:62
int target_remove_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1760
int target_store_value(struct target *target, struct value *value)
Definition: target.c:3548
int target_bsymbol_resolve_base(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, ADDR *o_addr, struct memrange **o_range)
Definition: target.c:2618
int(* flush_all_threads)(struct target *target)
Definition: target_api.h:3004
uint32_t no_adjust_bp_ip
Definition: target_api.h:2465
uint8_t isreg
Definition: target_api.h:3300
struct memregion * region
Definition: target_api.h:2391
GHashTable * overlays
Definition: target_api.h:2663
struct target_spec * target_build_spec(target_type_t type, target_mode_t mode)
Definition: target_api.c:410
Definition: probe.h:392
struct target * target
Definition: target_api.h:1971
int8_t v_i8(struct value *v)
Definition: value.c:392
GHashTable * decoders
Definition: target_api.h:2597
struct value * target_load_addr_obj(struct target *target, struct memregion *region, ADDR obj_addr, load_flags_t flags, int len)
Definition: target.c:3742
int target_unset_hw_watchpoint(struct target *target, tid_t tid, REG reg)
Definition: target_api.c:1858
int(* unchange_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3096
GHashTable * soft_probepoints
Definition: target_api.h:2735
sigset_t interrupt
Definition: spf.c:211
int target_load_available_threads(struct target *target, int force)
Definition: target_api.c:1300
tid_t(* gettid)(struct target *target)
Definition: target_api.h:2991
struct target_personality_ops * personality_ops
Definition: target_api.h:2585
int target_location_ctxt_read_reg(struct target_location_ctxt *tlctxt, REG reg, REGVAL *o_regval)
Definition: target.c:5756
struct target * sstep_thread_overlay
Definition: target_api.h:2733
struct target_thread * sstep_thread
Definition: target_api.h:2727
int(* unset_hw_breakpoint)(struct target *target, tid_t tid, REG reg)
Definition: target_api.h:3232
thread_resumeat_t
Definition: target_api.h:2069
GHashTable * symbol_name_decoders
Definition: target_api.h:1973
int(* set_active_probing)(struct target *target, active_probe_flags_t flags)
Definition: target_api.h:3153
struct scope * target_lookup_addr(struct target *target, uint64_t addr)
Definition: target.c:2053
evloop_handler_t in_evh
Definition: target_api.h:2282
struct target_process_ops * process_ops
Definition: target_api.h:2594
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
Definition: target.c:2199
GHashTable * actions
Definition: target_api.h:2776
struct target_spec * target_argp_driver_parse_one(struct argp *driver_parser, void *driver_state, int argc, char **argv, target_type_t target_types, int filter_quoted)
Definition: target.c:802
int target_location_ctxt_unwind(struct target_location_ctxt *tlctxt)
Definition: target.c:5417
uint8_t rv_u8(void *buf)
Definition: value.c:1339
int target_has_base(struct target *overlay, struct target *base)
long double v_dd(struct value *v)
Definition: value.c:428
uint8_t spec_was_base
Definition: target_api.h:2213
int target_lookup_next_safe_disasm_range(struct target *target, ADDR addr, ADDR *start, ADDR *end, void **data)
Definition: target.c:3860
int(* pause_thread)(struct target *target, tid_t tid, int nowait)
Definition: target_api.h:3181
GList * target_instantiate_and_open(struct target_spec *primary_target_spec, GList *base_target_specs, GList *overlay_target_specs, struct evloop *evloop, GList **error_specs)
Definition: target_api.c:92
thread_status_t target_thread_status(struct target *target, tid_t tid)
Definition: target_api.c:1964
probepoint_whence_t
Definition: probe_api.h:234
obj_flags_t obj_flags
Definition: target_api.h:2463
uint8_t kill_on_close
Definition: target_api.h:2213
target_debug_bp_handler_t handle_break
Definition: target_api.h:2869
struct target_thread * base_thread
Definition: target_api.h:2655
region_type_t
Definition: target_api.h:372
void target_driver_argp_init_children(struct argp_state *state)
Definition: target.c:1057
wchar_t rv_wc(void *buf)
Definition: value.c:1338
struct target_location_ctxt * tlctxt
Definition: target_api.h:2403
active_probe_flags_t ap_flags
Definition: target_api.h:2477
probepoint_style_t style
Definition: target_api.h:2212
int(* unset_hw_breakpoint)(struct target *target, tid_t tid, REG reg)
Definition: target_api.h:3103
int(* flush_thread)(struct target *target, tid_t tid)
Definition: target_api.h:3183
REFCNT refcntw
Definition: target_api.h:2462
union value::@27 res
int64_t num_t
Definition: common.h:87
int target_close(struct target *target)
Definition: target_api.c:1511
int32_t SMOFFSET
Definition: common.h:100
struct action * target_lookup_action(struct target *target, int action_id)
Definition: target_api.c:1671
struct array_list * target_list_tids(struct target *target)
Definition: target_api.c:1210
int(* init)(struct target *target)
Definition: target_api.h:3141
int kill_on_close_sig
Definition: target_api.h:2607
void value_dump(struct value *value, struct dump_info *ud)
Definition: value.c:1294
int64_t v_i64(struct value *v)
Definition: value.c:395
int(* unset_hw_watchpoint)(struct target *target, tid_t tid, REG reg)
Definition: target_api.h:3233
struct target_location_ctxt * target_location_ctxt_create(struct target *target, tid_t tid, struct memregion *region)
Definition: target.c:5304
int(* unwind_read_reg)(struct target_location_ctxt *tlctxt, REG reg, REGVAL *o_regval)
Definition: target_api.h:3074
evloop_handler_t out_evh
Definition: target_api.h:2283
struct target_thread * global_thread
Definition: target_api.h:2685
target_status_t(* target_exception_handler_t)(struct target *target, target_exception_flags_t flags, int *again, void *priv)
Definition: target_api.h:2304
uint32_t monitorhandling
Definition: target_api.h:2465
int target_open_all(struct target *target)
int(* disable_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3091
int(* obj_flags_propagate)(struct target *target, obj_flags_t orf, obj_flags_t nandf)
Definition: target_api.h:3158
ADDR addr
Definition: target_api.h:3309
int(* load_available_threads)(struct target *target, int force)
Definition: target_api.h:2999
int(* set_hw_breakpoint)(struct target *target, tid_t tid, REG reg, ADDR addr)
Definition: target_api.h:3099
int target_singlestep_end(struct target *target, tid_t tid)
Definition: target_api.c:1909
int(* set_hw_breakpoint)(struct target *target, tid_t tid, REG reg, ADDR addr)
Definition: target_api.h:3228
int target_decoder_lookup(struct target *target, struct value *value, target_decoder_t *decoder, void **decoder_data)
Definition: target.c:6350
struct target_os_ops * os_ops
Definition: target_api.h:2593
Pvoid_t clrange_t
Definition: clfit.h:34
int value_update_addr(struct value *value, ADDR v)
Definition: value.c:577
int value_update_num(struct value *value, num_t v)
Definition: value.c:586
evloop_handler_t err_evh
Definition: target_api.h:2284
int32_t OFFSET
Definition: common.h:65
unsigned long target_write_physaddr(struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
Definition: target_api.c:1096
uint8_t stay_paused
Definition: target_api.h:2213
target_status_t(* status)(struct target *target)
Definition: target_api.h:2934
struct bsymbol * alt_bsymbol
Definition: target_api.h:2416
int(* writereg)(struct target *target, tid_t tid, REG reg, REGVAL value)
Definition: target_api.h:3064
int(* postopened)(struct target *target)
Definition: target_api.h:2857
int value_update(struct value *value, const char *buf, int bufsiz)
Definition: value.c:432
struct list_head probe
Definition: probe.h:379
struct target_thread * thread
Definition: target_api.h:3277
signed char rv_c(void *buf)
Definition: value.c:1336
tid_t target_gettid(struct target *target)
Definition: target_api.c:1918
uint8_t spec_was_overlay
Definition: target_api.h:2213
int base_target_id
Definition: target_api.h:2206
int bufsiz
Definition: target_api.h:3297
Definition: list.h:51
uint64_t(* get_tsc)(struct target *target)
Definition: target_api.h:3258
GHashTable * phys_mmods
Definition: target_api.h:2756
GList * target_instantiate_and_open_list(GList *target_specs, struct evloop *evloop, GList **error_specs)
Definition: target_api.c:287
void target_hold(struct target *target)
Definition: target_api.c:1657
int target_resume(struct target *target)
Definition: target_api.c:1012
int target_enable_hw_breakpoint(struct target *target, tid_t tid, REG dreg)
Definition: target_api.c:1884
int(* obj_flags_propagate)(struct target *target, obj_flags_t orf, obj_flags_t nandf)
Definition: target_api.h:2904
int(* notify_sw_breakpoint)(struct target *target, ADDR addr, int notification)
Definition: target_api.h:3238
GHashTable * gkv_store
Definition: target_api.h:2633
wchar_t v_wc(struct value *v)
Definition: value.c:387
int(* writereg_tidctxt)(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
Definition: target_api.h:3069
symbol_type_t type
Definition: dwdebug_priv.h:833
Definition: evloop.h:66
uint32_t mmapable
Definition: target_api.h:2465
struct array_list * target_list_threads(struct target *target)
Definition: target_api.c:1233
GHashTable * mmods
Definition: target_api.h:2741
int target_write_reg_ctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
Definition: target_api.c:1165
char * base_thread_name
Definition: target_api.h:2208
int(* pause)(struct target *target, int nowait)
Definition: target_api.h:2936
OFFSET target_offsetof_symbol(struct target *target, struct bsymbol *bsymbol, char *member, const char *delim)
Definition: target.c:3485
ADDR target_autoload_pointers(struct target *target, struct symbol *datatype, ADDR addr, load_flags_t flags, struct symbol **datatype_saveptr, struct memrange **range_saveptr)
Definition: target.c:3668
int(* remove_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3216
int(* snprintf)(struct target *target, char *buf, int bufsiz)
Definition: target_api.h:3138
thread_status_t status
Definition: target_api.h:2084
uint32_t threadctl
Definition: target_api.h:2465
struct evloop * evloop
Definition: target_api.h:2638
void target_monitor_schedule_global_interrupt(void)
Definition: target.c:321
int target_pause_thread(struct target *target, tid_t tid, int nowait)
Definition: target_api.c:1323
int target_contains_real(struct target *target, ADDR addr)
Definition: target.c:3602
int(* thread_snprintf)(struct target *target, struct target_thread *tthread, char *buf, int bufsiz, int detail, char *sep, char *key_val_sep)
Definition: target_api.h:3007
struct symbol * target_create_synthetic_type_pointer(struct target *target, struct symbol *type)
Definition: symbol.c:27
uint8_t isconst
Definition: target_api.h:3300
result_t(* target_debug_bp_handler_t)(struct target *target, struct target_thread *tthread, struct probepoint *probepoint, int was_stepping)
Definition: target_api.h:2308
uint64_t(* get_tsc)(struct target *target)
Definition: target_api.h:3129
void target_location_ctxt_retarget_bsymbol(struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol)
Definition: target.c:5343
int8_t rv_i8(void *buf)
Definition: value.c:1343
void target_dump_all_threads(struct target *target, FILE *stream, int detail)
Definition: target_api.c:1500
int value_refresh_diff(struct value *value, int recurse, value_diff_t *vdiff, char **old_buf, int *old_bufsiz, value_hash_t *old_vhash)
Definition: value.c:378
unsigned char v_uc(struct value *v)
Definition: value.c:386
int value_update_c(struct value *value, signed char v)
Definition: value.c:465
int(* instr_can_switch_context)(struct target *target, ADDR addr)
Definition: target_api.h:3121
struct regcache ** regcaches
Definition: target_api.h:2112
int target_flush_thread(struct target *target, tid_t tid)
Definition: target_api.c:1334
int(* write_symbol)(struct target *target, struct value *value)
Definition: target_api.h:2963
target_location_ctxt_flag_t
Definition: target_api.h:2356
void * personality_state
Definition: target_api.h:2533
int(* loaddebugfiles)(struct target *target, struct addrspace *space, struct memregion *region)
Definition: target_api.h:3147
#define TARGET_TYPE_BITS
Definition: target_api.h:171
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
Definition: target_api.c:1132
int outfd
Definition: target_api.h:2614
tid_t target_lookup_overlay_thread_by_name(struct target *target, char *name)
Definition: target_api.c:713
struct value * target_load_type_reg(struct target *target, struct symbol *type, tid_t tid, REG reg, load_flags_t flags)
Definition: target.c:2910
uintptr_t value_hash_t
Definition: target_api.h:1641
long double rv_dd(void *buf)
Definition: value.c:1349
int(* thread_snprintf)(struct target *target, struct target_thread *tthread, char *buf, int bufsiz, int detail, char *sep, char *key_val_sep)
Definition: target_api.h:3187
uint8_t isstring
Definition: target_api.h:3300
int value_update_u8(struct value *value, uint8_t v)
Definition: value.c:489
struct probepoint * interrupted_ss_probepoint
Definition: target_api.h:2182
REG(* get_unused_debug_reg)(struct target *target, tid_t tid)
Definition: target_api.h:3227
ADDR res_ip
Definition: target_api.h:3316
struct target_thread * current_thread
Definition: target_api.h:2680
int(* change_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod, unsigned char *code, unsigned long code_len)
Definition: target_api.h:3222
struct target_decoder_lib * lib
Definition: target_api.h:1974
void(* handle_event)(struct target *target, struct target_event *event)
Definition: target_api.h:3157
struct target_location_ctxt_frame * target_location_ctxt_get_frame(struct target_location_ctxt *tlctxt, int frame)
Definition: target.c:5742
void bsymbol_dump(struct bsymbol *bsymbol, struct dump_info *ud)
Definition: symbol.c:120
int(* enable_hw_breakpoints)(struct target *target, tid_t tid)
Definition: target_api.h:3235
double rv_d(void *buf)
Definition: value.c:1348
ADDR rv_addr(void *buf)
Definition: value.c:1350
float rv_f(void *buf)
Definition: value.c:1347
void(* handle_event)(struct target *target, struct target_event *event)
Definition: target_api.h:2902
int(* unwind_read_reg)(struct target_location_ctxt *tlctxt, REG reg, REGVAL *o_regval)
Definition: target_api.h:3203
probepoint_watchsize_t
Definition: probe_api.h:241
uint64_t(* get_time)(struct target *target)
Definition: target_api.h:3130
tid_t base_tid
Definition: target_api.h:2657
int value_update_i64(struct value *value, int64_t v)
Definition: value.c:545
struct target_thread * target_load_current_thread(struct target *target, int force)
Definition: target_api.c:1305
int(* probe_register_symbol)(struct target *target, tid_t tid, struct probe *probe, struct bsymbol *bsymbol, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: target_api.h:3209
int(* detach)(struct target *target, int stay_paused)
Definition: target_api.h:2821
int(* load_available_threads)(struct target *target, int force)
Definition: target_api.h:3180
void target_default_cleanup(void)
Definition: target.c:128
uint64_t target_get_counter(struct target *target)
Definition: target_api.c:1943
int(* enable_feature)(struct target *target, int feature, void *arg)
Definition: target_api.h:3262
void target_monitor_clear_global_interrupt(void)
Definition: target.c:235
struct target_location_ctxt_frame * target_location_ctxt_prev(struct target_location_ctxt *tlctxt)
Definition: target.c:5812
char * buf
Definition: target_api.h:3298
unsigned char * target_read_physaddr(struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
Definition: target_api.c:1083
int target_decoder_lib_register(struct target_decoder_lib *lib)
Definition: target.c:6195
int value_refresh(struct value *value, int recursive)
Definition: value.c:329
int(* disable_hw_breakpoints)(struct target *target, tid_t tid)
Definition: target_api.h:3234
int(* loaddebugfiles)(struct target *target, struct addrspace *space, struct memregion *region)
Definition: target_api.h:2838
void(* free_thread_state)(struct target *target, void *state)
Definition: target_api.h:3174
struct target_location_ctxt * global_tlctxt
Definition: target_api.h:2707
clrange_t code_ranges
Definition: target_api.h:2794
unsigned long(* write_phys)(struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
Definition: target_api.h:3171
int target_snprintf(struct target *target, char *buf, int bufsiz)
Definition: target_api.c:829
struct probe * target_lookup_probe(struct target *target, int probe_id)
Definition: target_api.c:1666
unsigned char * buf
Definition: probe.h:418
struct target_location_ctxt * target_global_tlctxt(struct target *target)
Definition: target.c:5299
int value_update_dd(struct value *value, long double v)
Definition: value.c:569
thread_bpmode_t
Definition: target_api.h:366
GHashTable * target_hash_threads(struct target *target)
Definition: target_api.c:1253
int(* flush_thread)(struct target *target, tid_t tid)
Definition: target_api.h:3002
uint32_t live
Definition: target_api.h:2465
int target_kill(struct target *target, int sig)
Definition: target_api.c:1652
target_mode_t
Definition: target_api.h:187
int target_detach_evloop(struct target *target)
Definition: target_api.c:846
int value_update_wc(struct value *value, wchar_t v)
Definition: value.c:481
struct value * parent_value
Definition: target_api.h:3318
int target_disable_hw_breakpoint(struct target *target, tid_t tid, REG dreg)
Definition: target_api.c:1877
int(* set_hw_watchpoint)(struct target *target, tid_t tid, REG reg, ADDR addr, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: target_api.h:3100
REG(* get_unused_debug_reg)(struct target *target, tid_t tid)
Definition: target_api.h:3098
struct memrange * range
Definition: target_api.h:3295
result_t(* target_debug_handler_t)(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
Definition: target_api.h:2312
int(* disable_hw_breakpoint)(struct target *target, tid_t tid, REG dreg)
Definition: target_api.h:3236
int(* postopened)(struct target *target)
Definition: target_api.h:3155
int value_update_uc(struct value *value, unsigned char v)
Definition: value.c:473
struct target_thread * target_load_thread(struct target *target, tid_t tid, int force)
Definition: target_api.c:1311
GHashTable * threads
Definition: target_api.h:2672
tid_t target_lookup_overlay_thread_by_id(struct target *target, int id)
Definition: target_api.c:693
int value_update_i8(struct value *value, int8_t v)
Definition: value.c:521
int(* target_decoder_t)(struct target *target, void *data, struct value *value, char *buf, int buflen)
Definition: target_api.h:1977
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
Definition: target.c:3270
int(* writereg)(struct target *target, tid_t tid, REG reg, REGVAL value)
Definition: target_api.h:3193
obj_flags_t obj_flags
Definition: target_api.h:2087
struct memcache * memcache
Definition: target_api.h:2791
int(* resume)(struct target *target)
Definition: target_api.h:2938
int target_disable_hw_breakpoints(struct target *target, tid_t tid)
Definition: target_api.c:1865
void value_free(struct value *value)
Definition: value.c:282
unsigned char rv_uc(void *buf)
Definition: value.c:1337
REGVAL target_read_creg(struct target *target, tid_t tid, common_reg_t reg)
Definition: target_api.c:1178
struct target_spec * spec
Definition: target_api.h:2296
int target_set_hw_watchpoint(struct target *target, tid_t tid, REG reg, ADDR addr, probepoint_whence_t whence, int watchsize)
Definition: target_api.c:1843
int(* load_all_threads)(struct target *target, int force)
Definition: target_api.h:2998
uint64_t(* get_counter)(struct target *target)
Definition: target_api.h:3260
int target_unset_hw_breakpoint(struct target *target, tid_t tid, REG reg)
Definition: target_api.c:1851
struct array_list * target_list_overlays(struct target *target)
Definition: target_api.c:686
struct target_location_ctxt_frame * target_location_ctxt_current_frame(struct target_location_ctxt *tlctxt)
Definition: target.c:5748
int len
Definition: dumptarget.c:52
int target_notify_sw_breakpoint(struct target *target, ADDR addr, int notification)
Definition: target_api.c:1891
struct value * value_clone(struct value *in)
Definition: value.c:195
ADDR addr
Definition: target.h:392
struct target_memmod * emulating_debug_mmod
Definition: target_api.h:2179
int target_load_all_threads(struct target *target, int force)
Definition: target_api.c:1318
int(* disable_hw_breakpoint)(struct target *target, tid_t tid, REG dreg)
Definition: target_api.h:3107
target_poll_outcome_t
Definition: target_api.h:394
int target_spec_to_argv(struct target_spec *spec, char *arg0, int *argc, char ***argv)
Definition: target.c:416
Definition: probe.h:308
target_type_t target_type
Definition: target_api.h:2203
int target_monitor_was_interrupted(siginfo_t *last_siginfo)
Definition: target.c:226
GList * spaces
Definition: target_api.h:2643
int value_update_u16(struct value *value, uint16_t v)
Definition: value.c:497
REGVAL(* readreg_tidctxt)(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
Definition: target_api.h:3067
struct value * target_load_addr_real(struct target *target, ADDR addr, load_flags_t flags, int len)
Definition: target.c:3758
target_unwind_style_t
Definition: target_api.h:2432
char * THREAD_STATUS_STRINGS[]
Definition: target.c:6945
struct binfile * binfile
Definition: target_api.h:2649
unsigned long(* write)(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
Definition: target_api.h:3166
int(* remove_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3087
struct array_list * tpc_stack
Definition: target_api.h:2169
REG target_get_unused_debug_reg(struct target *target, tid_t tid)
Definition: target_api.c:1822
int(* attach_overlay_thread)(struct target *base, struct target *overlay, tid_t newtid)
Definition: target_api.h:2921
GHashTable * gkv_store
Definition: target_api.h:2199
int(* gc_threads)(struct target *target)
Definition: target_api.h:3006
int base_thread_id
Definition: target_api.h:2207
int(* unchange_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3225
int(* set_active_probing)(struct target *target, active_probe_flags_t flags)
Definition: target_api.h:2853
obj_flags_t
Definition: object.h:43
ADDR v_addr(struct value *v)
Definition: value.c:429
struct target_location_ctxt * target_location_ctxt_create_from_bsymbol(struct target *target, tid_t tid, struct bsymbol *bsymbol)
Definition: target.c:5325
int target_attach_evloop(struct target *target, struct evloop *evloop)
Definition: target_api.c:834
void target_free_spec(struct target_spec *spec)
Definition: target_api.c:453
struct thread_probepoint_context * tpc
Definition: target_api.h:2168
int(* attach_evloop)(struct target *target, struct evloop *evloop)
Definition: target_api.h:2949
int target_set_active_probing(struct target *target, active_probe_flags_t flags)
Definition: target_api.c:633
REGVAL target_read_reg_ctxt(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
Definition: target_api.c:1157
struct value * value_reload_as_type(struct value *value, struct symbol *type, int force)
Definition: value.c:224
int target_unwind_snprintf(char *buf, int buflen, struct target *target, tid_t tid, target_unwind_style_t fstyle, char *frame_sep, char *ksep)
Definition: target.c:5482
struct target_memmod * target_insert_sw_breakpoint(struct target *target, tid_t tid, ADDR addr)
Definition: target_api.c:1729
int target_pause(struct target *target)
Definition: target_api.c:1027
int(* enable_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3089
struct target_spec * target_build_default_overlay_spec(struct target *target, tid_t tid)
Definition: target_api.c:734
int(* unbind)(struct target_decoder_binding *tdb, void *decoder_data)
Definition: target_api.h:1967
int(* loadregions)(struct target *target, struct addrspace *space)
Definition: target_api.h:2833
int target_flush_current_thread(struct target *target)
Definition: target_api.c:1329
unsigned long target_write_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
Definition: target_api.c:1060
int target_cregno(struct target *target, common_reg_t creg, REG *reg)
Definition: target_api.c:1126
void * target_argp_driver_state(struct argp_state *state)
Definition: target.c:716
struct value * target_load_type_regval(struct target *target, struct symbol *type, tid_t tid, REG reg, REGVAL regval, load_flags_t flags)
Definition: target.c:2762
void target_release(struct target *target)
Definition: target_api.c:1661
int(* singlestep_end)(struct target *target, tid_t tid, struct target *overlay)
Definition: target_api.h:3242
ADDR target_addressof_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags, struct memrange **range_saveptr)
Definition: target.c:3490
int(* postloadinit)(struct target *target)
Definition: target_api.h:2844
const char * target_regname(struct target *target, REG reg)
Definition: target_api.c:1114
int(* notify_sw_breakpoint)(struct target *target, ADDR addr, int notification)
Definition: target_api.h:3109
struct arch * arch
Definition: target_api.h:2603
num_t v_num(struct value *v)
Definition: value.c:396
target_status_t target_monitor(struct target *target)
Definition: target_api.c:869
void(* free_thread_state)(struct target *target, void *state)
Definition: target_api.h:2992
int(* unset_hw_watchpoint)(struct target *target, tid_t tid, REG reg)
Definition: target_api.h:3104
char * POLL_STRINGS[]
Definition: target.c:6964
REFCNT refcnt
Definition: target_api.h:2461
struct array_list * debugfile_load_opts_list
Definition: target_api.h:2237
int target_addr_v2p(struct target *target, tid_t tid, ADDR vaddr, ADDR *paddr)
Definition: target_api.c:1072
int value_update_unum(struct value *value, unum_t v)
Definition: value.c:601
unsigned int thread_ctxt_t
Definition: target_api.h:300
int(* addr_v2p)(struct target *target, tid_t tid, ADDR vaddr, ADDR *paddr)
Definition: target_api.h:3168
REGVAL(* readreg_tidctxt)(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg)
Definition: target_api.h:3196
int(* disable_feature)(struct target *target, int feature)
Definition: target_api.h:3263
struct target * target
Definition: target_api.h:2078
GHashTable * overlay_aliases
Definition: target_api.h:2670
REFCNT refcntw
Definition: target_api.h:2089
result_t
Definition: common.h:25
double v_d(struct value *v)
Definition: value.c:427
target_exception_handler_t handle_exception
Definition: target_api.h:2868
uint32_t REGVAL
Definition: common.h:66
int probe_id_counter
Definition: target_api.h:2781
int16_t rv_i16(void *buf)
Definition: value.c:1344
char * REGION_TYPE_STRINGS[]
Definition: target.c:6971
struct target * target_instantiate(struct target_spec *spec, struct evloop *evloop)
Definition: target_api.c:55
struct list_head ss_actions
Definition: target_api.h:2193
uint32_t rv_u32(void *buf)
Definition: value.c:1341
void * personality_state
Definition: target_api.h:2106
int(* probe_register_symbol)(struct target *target, tid_t tid, struct probe *probe, struct bsymbol *bsymbol, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: target_api.h:3080
uint32_t needmonitorinterrupt
Definition: target_api.h:2465
uint64_t target_get_tsc(struct target *target)
Definition: target_api.c:1929
int target_set_hw_breakpoint(struct target *target, tid_t tid, REG reg, ADDR addr)
Definition: target_api.c:1836
int64_t rv_i64(void *buf)
Definition: value.c:1346
int target_is_open(struct target *target)
Definition: target_api.c:1042
target_location_ctxt_flag_t flags
Definition: target_api.h:2405
int target_regno(struct target *target, char *name, REG *reg)
Definition: target_api.c:1120
int(* invalidate_thread)(struct target *target, struct target_thread *tthread)
Definition: target_api.h:3005
REFCNT bsymbol_release(struct bsymbol *bsymbol)
Definition: symbol.c:90
int(* singlestep)(struct target *target, tid_t tid, int isbp, struct target *overlay)
Definition: target_api.h:3240
int target_gc_threads(struct target *target)
Definition: target_api.c:1368
sigset_t ignored
Definition: spf.c:211
struct bsymbol * target_lookup_sym_addr(struct target *target, ADDR addr)
Definition: target.c:2093
char * v_string(struct value *v)
Definition: value.c:430
int8_t exiting
Definition: target_api.h:2081
int target_open(struct target *target)
Definition: target_api.c:513
uint16_t v_u16(struct value *v)
Definition: value.c:389
int8_t REG
Definition: common.h:93
target_type_t
Definition: target_api.h:163
uint64_t(* get_counter)(struct target *target)
Definition: target_api.h:3131
probepoint_style_t
Definition: probe_api.h:228
uint32_t opened
Definition: target_api.h:2465
struct lsymbol * lsymbol
Definition: target_api.h:3292
unsigned long(* write_phys)(struct target *target, ADDR paddr, unsigned long length, unsigned char *buf)
Definition: target_api.h:2981
GHashTable * hard_probepoints
Definition: target_api.h:2117
int(* enable_feature)(struct target *target, int feature, void *arg)
Definition: target_api.h:3133
int8_t attached
Definition: target_api.h:2081
target_personality_t
Definition: target_api.h:180
int(* loadspaces)(struct target *target)
Definition: target_api.h:3144
uint32_t ADDR
Definition: common.h:64
Definition: arch.h:116
char * name
Definition: target_api.h:2521
int target_argp_driver_parse(struct argp *driver_parser, void *driver_state, int argc, char **argv, target_type_t target_types, int filter_quoted, struct target_spec **primary_target_spec, GList **base_target_specs, GList **overlay_target_specs)
Definition: target.c:913
void * __personality_specific_ops
Definition: target_api.h:2592
struct target_ops * ops
Definition: target_api.h:2548
target_status_t target_status(struct target *target)
Definition: target_api.c:1046
struct symbol * type
Definition: target_api.h:3287
char * infile
Definition: target_api.h:2286
target_exception_flags_t
Definition: target_api.h:386
uint64_t v_u64(struct value *v)
Definition: value.c:391
int(* gc_threads)(struct target *target)
Definition: target_api.h:3186
uint64_t rv_u64(void *buf)
Definition: value.c:1342
target_status_t target_notify_overlay(struct target *overlay, target_exception_flags_t flags, tid_t tid, ADDR ipval, int *again)
Definition: target.c:4491
REG spregno
Definition: target_api.h:2507
unsigned char * target_load_code(struct target *target, ADDR start, unsigned int len, int nocache, int force_copy, int *caller_free)
Definition: target.c:3909
int value_update_u64(struct value *value, uint64_t v)
Definition: value.c:513
int(* detach_overlay_thread)(struct target *base, struct target *overlay, tid_t tid)
Definition: target_api.h:2923
thread_ctxt_t tidctxt
Definition: target_api.h:2080
struct value * target_load_symbol_member(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, const char *member, const char *delim, load_flags_t flags)
Definition: target.c:2920
int(* invalidate_thread)(struct target *target, struct target_thread *tthread)
Definition: target_api.h:3185
int target_lookup_safe_disasm_range(struct target *target, ADDR addr, ADDR *start, ADDR *end, void **data)
Definition: target.c:3825
int target_flush_all_threads(struct target *target)
Definition: target_api.c:1340
int(* set_hw_watchpoint)(struct target *target, tid_t tid, REG reg, ADDR addr, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: target_api.h:3229
int32_t rv_i32(void *buf)
Definition: value.c:1345
thread_status_t
Definition: target_api.h:254
target_status_t status
Definition: target_api.h:2503
REGVAL(* readreg)(struct target *target, tid_t tid, REG reg)
Definition: target_api.h:3192
int target_thread_snprintf(struct target *target, tid_t tid, char *buf, int bufsiz, int detail, char *sep, char *key_val_sep)
Definition: target_api.c:1425
struct value * target_load_type(struct target *target, struct symbol *type, ADDR addr, load_flags_t flags)
Definition: target.c:2653
int32_t v_i32(struct value *v)
Definition: value.c:394
uint32_t global_tlctxt_is_dynamic
Definition: target_api.h:2465
char * personality
Definition: target_api.h:2228
REG fbregno
Definition: target_api.h:2506
uint32_t REFCNT
Definition: common.h:124
void target_init(void)
Definition: target.c:69
void target_fini(void)
Definition: target.c:91
struct bsymbol * target_lookup_sym_member(struct target *target, struct bsymbol *bsymbol, const char *name, const char *delim)
Definition: target.c:2248
int(* snprintf)(struct target *target, char *buf, int bufsiz)
Definition: target_api.h:2798
int kill_on_close_sig
Definition: target_api.h:2242
int(* detach_evloop)(struct target *target)
Definition: target_api.h:2950
struct target_spec * spec
Definition: target_api.h:2605
struct array_list * target_list_available_overlay_tids(struct target *target, target_type_t type)
Definition: target_api.c:656
uint8_t v_u8(struct value *v)
Definition: value.c:388
signed char v_c(struct value *v)
Definition: value.c:385
int(* writereg_tidctxt)(struct target *target, tid_t tid, thread_ctxt_t tidctxt, REG reg, REGVAL value)
Definition: target_api.h:3198
load_flags_t
Definition: target_api.h:406
int(* enable_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3218
uint32_t nodisablehwbponss
Definition: target_api.h:2465
void bsymbol_hold(struct bsymbol *bsymbol)
struct bsymbol * bsymbol
Definition: target_api.h:2415
int value_update_u32(struct value *value, uint32_t v)
Definition: value.c:505
value_diff_t
Definition: target_api.h:1634
struct lsymbol * bsymbol_get_lsymbol(struct bsymbol *bsymbol)
Definition: symbol.c:70
REGVAL(* readreg)(struct target *target, tid_t tid, REG reg)
Definition: target_api.h:3063
int(* instr_can_switch_context)(struct target *target, ADDR addr)
Definition: target_api.h:3250
int(* disable_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.h:3220
active_probe_flags_t
Definition: target_api.h:432
struct location_ops * location_ops
Definition: target_api.h:2549
int id
Definition: target_api.h:2514
int value_update_zero(struct value *value, const char *buf, int bufsiz)
Definition: value.c:447
char * debugfile_root_prefix
Definition: target_api.h:2235
int target_id(struct target *target)
Definition: target_api.c:509
GHashTable * target_hash_available_tids(struct target *target)
Definition: target_api.c:1277
uint8_t ismmap
Definition: target_api.h:3300
unsigned int max_thread_ctxt
Definition: target_api.h:2505
int target_unchange_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1814
GHashTable * probes
Definition: target_api.h:2765
struct target_thread * thread
Definition: target_api.h:2383
symbol_type_flag_t
Definition: dwdebug.h:190
uint64_t unum_t
Definition: common.h:88
int(* disable_feature)(struct target *target, int feature)
Definition: target_api.h:3134
unsigned long(* write)(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
Definition: target_api.h:2956
int target_finalize(struct target *target)
Definition: target.c:1955
struct array_list * target_list_available_tids(struct target *target)
Definition: target_api.c:1272
struct target_spec * target_argp_target_spec(struct argp_state *state)
Definition: target.c:709
struct symbol * bsymbol_get_symbol(struct bsymbol *bsymbol)
Definition: symbol.c:66
uint32_t v_u32(struct value *v)
Definition: value.c:390
char * errfile
Definition: target_api.h:2288
struct target_thread * blocking_thread
Definition: target_api.h:2693
target_status_t(* handle_overlay_exception)(struct target *overlay, target_exception_flags_t flags, tid_t tid, ADDR ipval, int *again)
Definition: target_api.h:2929
target_debug_handler_t handle_step
Definition: target_api.h:2870
int(* singlestep_end)(struct target *target, tid_t tid, struct target *overlay)
Definition: target_api.h:3113
REG reg
Definition: target_api.h:3310
struct bsymbol * bsymbol_create_noninline(struct bsymbol *bsymbol)
Definition: symbol.c:80
int(* flush_current_thread)(struct target *target)
Definition: target_api.h:3184
float v_f(struct value *v)
Definition: value.c:426
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:1800
char * outfile
Definition: target_api.h:2287
int8_t resumeat
Definition: target_api.h:2081
int(* loadregions)(struct target *target, struct addrspace *space)
Definition: target_api.h:3145
int(* change_sw_breakpoint)(struct target *target, tid_t tid, struct target_memmod *mmod, unsigned char *code, unsigned long code_len)
Definition: target_api.h:3093
int(* init)(struct target *target)
Definition: target_api.h:2810
int target_enable_hw_breakpoints(struct target *target, tid_t tid)
Definition: target_api.c:1871
int base_id
Definition: target_api.h:2656
ADDR target_load_pointers(struct target *target, ADDR addr, int count, struct memrange **range_saveptr)
Definition: target.c:3617
int(* pause_thread)(struct target *target, tid_t tid, int nowait)
Definition: target_api.h:3000
int(* postloadinit)(struct target *target)
Definition: target_api.h:3151
unum_t v_unum(struct value *v)
Definition: value.c:411
uint8_t start_paused
Definition: target_api.h:2213
ADDR value_addr(struct value *value)
Definition: value.c:302
void target_default_sighandler(int signo, siginfo_t *siginfo, void *x)
Definition: target.c:174
struct value * target_load_value_member(struct target *target, struct target_location_ctxt *tlctxt, struct value *old_value, const char *member, const char *delim, load_flags_t flags)
Definition: target.c:2942
int errfd
Definition: target_api.h:2615
int(* enable_hw_breakpoint)(struct target *target, tid_t tid, REG dreg)
Definition: target_api.h:3108
REG ipregno
Definition: target_api.h:2508
struct target * target_instantiate_overlay(struct target *target, tid_t tid, struct target_spec *spec)
Definition: target_api.c:757
int(* kill)(struct target *target, int sig)
Definition: target_api.h:2823
struct location_ctxt * lctxt
Definition: target_api.h:2377
int target_disable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
Definition: target_api.c:1786
target_status_t(* poll)(struct target *target, struct timeval *tv, target_poll_outcome_t *outcome, int *pstatus)
Definition: target_api.h:2941
target_debug_handler_t handle_interrupted_step
Definition: target_api.h:2893
int target_write_creg(struct target *target, tid_t tid, common_reg_t reg, REGVAL value)
Definition: target_api.c:1187
int(* evloop_handler_t)(int fd, int fdtype, void *state)
Definition: evloop.h:62
int target_monitor_schedule_interrupt(struct target *target)
Definition: target.c:325
int(* loadspaces)(struct target *target)
Definition: target_api.h:2828
int target_install_default_sighandlers(void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
Definition: target.c:240
int target_decoder_binding_add(struct target_decoder_binding *tdb, struct bsymbol *bsymbol, target_decoder_t dfn)
Definition: target.c:6338
active_probe_flags_t ap_flags
Definition: target_api.h:2220
uint8_t read_only
Definition: target_api.h:2213
uint32_t kill_on_close
Definition: target_api.h:2465
int(* enable_hw_breakpoints)(struct target *target, tid_t tid)
Definition: target_api.h:3106
int target_monitor_handling_exception(struct target *target)
Definition: target.c:317
uint32_t writeable
Definition: target_api.h:2465
target_type_t supported_overlay_types
Definition: target_api.h:2085
char * personality_lib
Definition: target_api.h:2233
int value_update_d(struct value *value, double v)
Definition: value.c:561