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
probe_api.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, 2012, 2013, 2014 The University of Utah
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of
7  * the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef __PROBE_API_H__
20 #define __PROBE_API_H__
21 
22 #include "common.h"
23 #ifdef ENABLE_DISTORM
24 #include <disasm.h>
25 #endif
26 
27 #include <glib.h>
28 
37 struct probepoint;
38 struct probe;
39 struct probe_value;
40 struct probeset;
41 struct action;
42 struct target;
43 struct target_thread;
44 struct memrange;
45 struct target_nv_filter;
46 struct lsymbol;
47 struct bsymbol;
48 
49 /*
50  * Messages sent to handlers.
51  */
52 typedef enum {
53  MSG_NONE = 0,
60 
61 /*
62  * The type of function to be used for probe pre- and post-handlers.
63  *
64  * @probe is the probe that the pre/post handler being called belonged to;
65  * @tid is the thread in @probe->target that had the probed event;
66  * @handler_data is @probe's private data;
67  * @trigger is the source probe underlying @probe, if any;
68  * @base is the lowest-level basic probe that started this whole event chain.
69  */
70 typedef result_t (*probe_handler_t)(struct probe *probe,
71  tid_t tid,void *handler_data,
72  struct probe *trigger,struct probe *base);
73 /*
74  * The type of function to be used for action handlers.
75  */
77  struct target_thread *thread,
78  struct probe *probe,
79  struct probepoint *probepoint,
80  handler_msg_t msg,int msg_detail,
81  void *handler_data);
82 
83 typedef enum {
89 
90 /*
91  * Each probe type must define this operations table. The operations
92  * may be called at the appropriate times during the probe's lifecycle.
93  */
94 struct probe_ops {
95  /* Should return a unique type string. */
96  const char *(*gettype)(struct probe *probe);
97  /* Called after a probe has been freshly malloc'd and its base
98  * fields have been initialized.
99  */
100  int (*init)(struct probe *probe);
101  /* Called after a probe has been registered -- either when
102  * registered on a probepoint, or when registered on a new source.
103  */
104  int (*registered)(struct probe *probe);
105  /* Called whenever this probe is enabled. */
106  int (*enabled)(struct probe *probe);
107  /* Called whenever this probe is disabled. */
108  int (*disabled)(struct probe *probe);
109  /* Called after this probe has been unregistered. */
110  int (*unregistered)(struct probe *probe);
111  /* Called when the user calls probe_summarize(). */
112  void *(*summarize)(struct probe *probe);
113  /* Called when the user calls probe_summarize_tid(). */
114  void *(*summarize_tid)(struct probe *probe,tid_t tid);
115 
116  /*
117  * Value autoloading. Some probes, when they are hit, fundamentally
118  * have a concept of "value" associated with them -- for instance,
119  * function entry (arguments), function exit (return value), or
120  * watchpoints (the watched symbol/addr's value). These interfaces
121  * support loading and caching values in pre/post handlers.
122  *
123  * The only basic probe types that support values are watchpoints
124  * and breakpoints on function symbols.
125  *
126  * Values are not loaded until these functions are invoked.
127  */
128 
129  /*
130  * Get all available values. If in a prehandler, this returns
131  * whatever values for the probe can be loaded in its prehandler.
132  * These values can be "interpreted" -- for instance, if if a value
133  * is a pointer arg to a function, the "interpreted" value will
134  * likely be the value of the pointer-to type. If you don't want
135  * that, though, there are the raw value functions.
136  */
137  GHashTable *(*get_value_table)(struct probe *probe,tid_t tid);
138  /*
139  * Returns the values in unloaded form -- i.e.,
140  */
141  GHashTable *(*get_raw_value_table)(struct probe *probe,tid_t tid);
142  GHashTable *(*get_last_value_table)(struct probe *probe,tid_t tid);
143  GHashTable *(*get_last_raw_value_table)(struct probe *probe,tid_t tid);
144  /*
145  * Get the value with @name. For instance, this would let you
146  * obtain function arguments, or the special __RETURN__ value. For
147  * watchpoints, if you supplied NULL or the symbol's name, you would
148  * get the watched value. There is one special value name:
149  * __RETURN__; this exposes return values from functions, if the
150  * probe is attached to a return-ish instruction. Otherwise, @name
151  * is a "member" of the probed symbol, if there is one.
152  *
153  * In general, it is a good idea to use get_value_name() instead of
154  * trying to lookup and load a member in the symbol obtained by
155  * get_value_symbol(). The reason for that is that a particular
156  * symbol might indeed be associated with this value probe, BUT the
157  * IP might not be in the symbol's body. The
158  */
159 #define PROBE_VALUE_NAME_RETURN "__RETURN__"
160  struct value *(*get_value)(struct probe *probe,tid_t tid,char *name);
161  struct value *(*get_raw_value)(struct probe *probe,tid_t tid,char *name);
162  struct value *(*get_last_value)(struct probe *probe,tid_t tid,char *name);
163  struct value *(*get_last_raw_value)(struct probe *probe,tid_t tid,char *name);
164  /*
165  * The default probe handlers call this function with @phase set to
166  * one of the enum values.
167  *
168  * This lets the probe_value implementor decide when to collect
169  * values from the last "hit" of this probe. So for instance, we
170  * want to replace the old value for a watchpoint once the
171  * prehandlers have been run. For a function entry/exit probe, we
172  * want to replace the old values only once the exit (posthandlers)
173  * handlers have been called (i.e., once the frame has exited).
174  */
175  void (*values_notify_phase)(struct probe *probe,tid_t tid,
176  probe_handler_phase_t phase);
177  /*
178  * Called to cleanup and destroy probe->values. Called just before @fini.
179  */
180  void (*values_free)(struct probe *probe);
181 
182  /* Called just before this probe is deallocated. If you allocated
183  * any probe-specific data structures, or took a reference to this
184  * probe and it is an autofree probe, you must free those
185  * probe-specific data structures, and release your references.
186  */
187  int (*fini)(struct probe *probe);
188 };
189 
190 /*
191  * Prototypes of functions that probe type implementers may want to
192  * use. Probes are hierarchical, and if the type does not have a
193  * complex handler for pre/post events, it might just pass these
194  * functions to the probes it builds on. They simply invoke any
195  * handlers for any sink probes registered on @probe after checking @tid
196  * and any filters @probe has, given @trigger's values.
197  *
198  * (Eventually they'll check target thread context too, once it's implemented.)
199  */
200 result_t probe_do_sink_pre_handlers (struct probe *probe,tid_t tid,
201  void *handler_data,struct probe *trigger,
202  struct probe *base);
203 result_t probe_do_sink_post_handlers(struct probe *probe,tid_t tid,
204  void *handler_data,struct probe *trigger,
205  struct probe *base);
206 
207 int probe_filter_check(struct probe *probe,tid_t tid,struct probe *trigger,
208  int whence);
209 
210 /*
211  * Is the probepoint a breakpoint or a watchpoint.
212  */
213 typedef enum {
217 
218 /*
219  * If when registering a probe, you want either a hardware or software
220  * probe specifically, use PROBEPOINT_HW or PROBEPOINT_SW. If you want
221  * the fastest available *at time of registration*, use
222  * PROBEPOINT_FASTEST (if you do, the choice the library makes (HW or
223  * SW) at registration sticks with the probe forever, and never changes
224  * again.
225  *
226  * XXX: this is bad, of course.
227  */
228 typedef enum {
233 
234 typedef enum {
240 
241 typedef enum {
248 
249 typedef enum {
255 } action_type_t;
256 
257 typedef enum {
263 
264 /*
265  * Future flags for actions.
266  */
267 typedef enum {
272  ACTION_FLAG_NORET = 8, /* action does not return */
273 } action_flag_t;
274 
279 /*
280  * Creates a probe named @name on @target, with the given @pre_handler
281  * and @post_handler handlers, which will be called with @handler_data.
282  * The type of probe will be determined automatically (break or watch);
283  * we will use the fastest kind of probe possible (i.e., prefer
284  * hardware); if a watchpoint is chosen, the size of the watch will be
285  * sized appropriately to the symbol's type, and we will watch for
286  * read/write.
287  *
288  * DWDEBUG_DEF_DELIM is used as the delimiter when looking up the symbol.
289  *
290  * The created probe is NOT autofreed, so the user must probe_free() it
291  * later! Or they can probe_unregister() it and probe_register*() it
292  * later before probe_free()'ing it.
293  */
294 struct probe *probe_simple(struct target *target,tid_t tid,char *name,
297  void *handler_data);
298 
299 /*
300  * Like the above, but accepts a pre-created @probe, a @delim, and more
301  * probe controls (@style, @whence, @watchsize). Not all these controls
302  * may be used; @whence and @watchsize are only used in the event that a
303  * watchpoint probe is created (i.e., if @name is a variable).
304  */
305 struct probe *probe_register_symbol_name(struct probe *probe,
306  char *name,const char *delim,
307  probepoint_style_t style,
308  probepoint_whence_t whence,
309  probepoint_watchsize_t watchsize);
310 
311 struct probe *probe_register_symbol(struct probe *probe,struct bsymbol *bsymbol,
312  probepoint_style_t style,
313  probepoint_whence_t whence,
314  probepoint_watchsize_t watchsize);
315 
316 struct probe *probe_register_line(struct probe *probe,char *filename,int line,
317  probepoint_style_t style,
318  probepoint_whence_t whence,
319  probepoint_watchsize_t watchsize);
320 
321 struct probe *probe_register_inlined_symbol(struct probe *probe,
322  struct bsymbol *bsymbol,
323  int do_primary,
324  probepoint_style_t style,
325  probepoint_whence_t whence,
326  probepoint_watchsize_t watchsize);
327 
328 #ifdef ENABLE_DISTORM
329 /*
330  * Registers @probe in such a way that probe->pre_handler is called when
331  * the function entry point is hit (if @force_at_entry is set, the entry
332  * point is the entry point -- which may be the entry point as set in
333  * the debuginfo, or the lowest address if not set in debuginfo; if
334  * @force_at_entry is NOT set, we try to use the end of prologue address
335  * in preference to the entry point). probe->post_handler is called
336  * when any of the return sites are hit.
337  *
338  * Note that @probe->(pre|post)_handler is called from the pre_handler
339  * of the triggering probe, not the post_handler! This gives you time
340  * to tweak args or the return value before the function executes or
341  * returns.
342  */
343 struct probe *probe_register_function_ee(struct probe *probe,
344  probepoint_style_t style,
345  struct bsymbol *bsymbol,
346  int force_at_entry,int noabort,
347  int follow_jumps);
348 
349 /*
350  * This function disassembles the function pointed to by @bsymbol if it
351  * can. Then, for each @inst,@probe tuple, it registers @probe at the
352  * address of that instruction type. The user can supply as many
353  * @inst,@type tuples as they wish, but each @inst must be unique
354  * (unchecked, so don't shoot yourself in the foot!). If you set
355  * @noabort to nonzero, the disassembler will continue even if it sees
356  * an undecodeable instruction (it just skips one byte and tries to keep
357  * going).
358  *
359  * IMPORTANT: you *must* end the list with INST_NONE !!!
360  *
361  * If you specify @handler, you get to choose on an
362  * instruction-by-instruction basis if that instruction is probed or
363  * not, AND you can specify an alternate sink probe to be attached to
364  * the per-instruction probe. If you don't specify an alternate probe,
365  * the default one that you supplied for that type will be used.
366  * @handler will be invoked with @handler_data.
367  *
368  * XXX: add support for using a cached disassembly of some sort...
369  */
370 typedef int (*probe_register_disasm_handler_t)(struct cf_inst_data *id,
371  ADDR iaddr,void *handler_data,
372  struct probe **probe_alt);
373 
374 struct probe *probe_register_function_instrs(struct bsymbol *bsymbol,
375  probepoint_style_t style,
376  int noabort,
377  probe_register_disasm_handler_t handler,
378  void *handler_data,
379  inst_type_t inst,
380  struct probe *probe,...);
381 
382 /*
383  * Same as above, but disassembles the block of code indicated by
384  * start,end, and places probes there.
385  */
386 struct probe *probe_register_block_instrs(struct target *target,
387  ADDR start,ADDR end,
388  probepoint_style_t style,
389  int noabort,
390  probe_register_disasm_handler_t handler,
391  void *handler_data,
392  inst_type_t inst,
393  struct probe *probe,...);
394 /*
395  * There are two ways a callee can be "invoked" by a caller. First, it
396  * might be directly called. Second, it might have been inlined in the
397  * caller. We try to support both cause we're crazy :).
398  *
399  * If @probe has a pre_handler, we put a breakpoint on the call, or on
400  * the first instruction of the inline instance. If @probe has a
401  * post_handler, we put a breakpoint on the instruction following the
402  * call, or on the first instruction after the inline instance.
403  *
404  * If @noabort is set, it means that even if disasm fails, we should not
405  * abort the operation.
406  */
407 struct probe *probe_register_function_invocations(struct probe *probe,
408  probepoint_style_t style,
409  struct bsymbol *caller,
410  struct bsymbol *callee,
411  int noabort);
412 #endif
413 
427 /*
428  * Probe functions -- create value-enabled probes. These are not
429  * autofree probes, so you'll have to probe_free() them when finished.
430  */
431 struct probe *probe_value_var(struct target *target,tid_t tid,
432  struct bsymbol *bsymbol,
435  void *handler_data);
436 #ifdef ENABLE_DISTORM
437 static struct probe *probe_value_function_ee(struct target *target,tid_t tid,
438  struct bsymbol *bsymbol,
441  void *handler_data);
442 #endif
443 /* Wraps the above two functions. */
444 struct probe *probe_value_symbol(struct target *target,tid_t tid,
445  struct bsymbol *bsymbol,
448  void *handler_data);
449 
450 /*
451  * Loads and returns the current value table for the probe. If the full
452  * table wasn't loaded, finish loading it (according to the probe's
453  * probe_ops). Returns it. If you want to save any of the values,
454  * clone them -- they will be destroyed next time this probe is "hit".
455  *
456  * (If a new value record has been started, this will destroy the last
457  * values and create a new populated record.)
458  */
459 GHashTable *probe_value_get_table(struct probe *probe,tid_t tid);
460 GHashTable *probe_value_get_raw_table(struct probe *probe,tid_t tid);
461 /*
462  * Returns the value table for the probe, without loading anything new.
463  * This is useful grab the "last" values without loading the new ones --
464  * like probe_value_get_table() will do.
465  */
466 GHashTable *probe_value_get_last_table(struct probe *probe,tid_t tid);
467 GHashTable *probe_value_get_last_raw_table(struct probe *probe,tid_t tid);
468 /*
469  * These retrieve individual named values, if they exist. There are a
470  * couple of special things here. If you pass @name == NULL, the
471  * "default" value of the probe is returned. For a watchpoint, that
472  * would be the value of the variable. For a function entry/exit probe,
473  * that would be
474  */
475 struct value *probe_value_get(struct probe *probe,tid_t tid,char *name);
476 struct value *probe_value_get_raw(struct probe *probe,tid_t tid,char *name);
477 struct value *probe_value_get_last(struct probe *probe,tid_t tid,char *name);
478 struct value *probe_value_get_last_raw(struct probe *probe,tid_t tid,char *name);
479 
493 /*
494  * Creates a new probe, filtered by @tid, and by @pre_filter and
495  * @post_filter .
496  *
497  *
498  */
499 struct probe *probe_create_filtered(struct target *target,tid_t tid,
500  struct probe_ops *pops,
501  const char *name,
507  void *handler_data,
508  int autofree,int tracked);
509 
514 void probe_value_clear(struct probe_value *pv);
515 void probe_value_free(struct probe_value *pv);
517 /*
518  * Some probes require a stack -- i.e., a function that might be
519  * recursive. So we have two basic implementations of probe_value
520  * storage that control probe->values (of course you are free to write
521  * another!).
522  */
523 /*
524  * Only these two _stacked() functions are generic enough to share; the
525  * _function_ee() functions also use the stacked mode but they are
526  * function entry/exit metaprobe-specific. If you write a metaprobe
527  * that acts like a function entry/exit probe (the linux per-syscall
528  * probes are an example), you can reuse lots of the _function_ee()
529  * calls.
530  */
531 void probe_values_free_stacked(struct probe *probe);
532 int probe_value_record_stacked(struct probe *probe,tid_t tid,
533  char *name,struct value *value,int israw);
534 /*
535  * We use the _basic() calls to implement watched var metaprobes. But,
536  * they are trivial; they don't maintain a stack. Usually if you use
537  * these, the only thing you'll need to reimplement is the
538  * probe_value_notify_phase_watchedvar() function (and maybe the
539  * getters).
540  */
541 void probe_values_free_basic(struct probe *probe);
542 int probe_value_record_basic(struct probe *probe,tid_t tid,
543  char *name,struct value *value,int israw);
544 GHashTable *probe_value_get_table_basic(struct probe *probe,tid_t tid);
545 GHashTable *probe_value_get_raw_table_basic(struct probe *probe,tid_t tid);
546 GHashTable *probe_value_get_last_table_basic(struct probe *probe,tid_t tid);
547 GHashTable *probe_value_get_last_raw_table_basic(struct probe *probe,tid_t tid);
548 struct value *probe_value_get_basic(struct probe *probe,tid_t tid,
549  char *name);
550 struct value *probe_value_get_raw_basic(struct probe *probe,tid_t tid,
551  char *name);
552 struct value *probe_value_get_last_basic(struct probe *probe,tid_t tid,
553  char *name);
554 struct value *probe_value_get_last_raw_basic(struct probe *probe,tid_t tid,
555  char *name);
556 
557 GHashTable *probe_value_get_table_function_ee(struct probe *probe,tid_t tid);
558 GHashTable *probe_value_get_raw_table_function_ee(struct probe *probe,tid_t tid);
559 GHashTable *probe_value_get_last_table_function_ee(struct probe *probe,tid_t tid);
560 GHashTable *probe_value_get_last_raw_table_function_ee(struct probe *probe,
561  tid_t tid);
562 struct value *probe_value_get_function_ee(struct probe *probe,tid_t tid,
563  char *name);
564 struct value *probe_value_get_raw_function_ee(struct probe *probe,tid_t tid,
565  char *name);
566 struct value *probe_value_get_last_function_ee(struct probe *probe,tid_t tid,
567  char *name);
568 struct value *probe_value_get_last_raw_function_ee(struct probe *probe,tid_t tid,
569  char *name);
570 void probe_value_notify_phase_function_ee(struct probe *probe,tid_t tid,
571  probe_handler_phase_t phase);
572 
573 
574 void probe_value_notify_phase_watchedvar(struct probe *probe,tid_t tid,
575  probe_handler_phase_t phase);
576 
581 /*
582  * Creates a probe with the given name (should not be NULL, but need not
583  * be unique), based on the probe_ops specified (all or part possibly
584  * NULL), with the pre and post handlers (at least one must be non-NULL)
585  * and handler_data (may be NULL). If @autofree is set to non-zero, the
586  * probe core library will handle destruction for you. This is useful
587  * when you don't care about maintaining a handle to your probe, because
588  * it is a source probe of some other sink probe you *do* keep a handle
589  * to. In this way, the library can try to automatically
590  * garbage-collect probes that were created merely to serve as sinks for
591  * other sources... when there are no more sinks on a particular source,
592  * that source probe (and any of its children) can be auto-freed.
593  *
594  * NOTE: probes are only autofreed when all sinks attached to them have
595  * been detached. There is no magic that frees probes if the process
596  * crashes, for instance. We don't internally track probes that have
597  * been created. We *do* call the @pops.fini function just before
598  * destroying a probe, though, so the creator can be notified if it
599  * cares, and remove the probe from any place it is referenced.
600  *
601  * A good rule of thumb: if you set autofree, and the probe is
602  * successfully initialized (which you can know about if your
603  * @pops.init() function is called), the probe library will autofree the
604  * probe on *any* subsequent errors involving the probe -- like a
605  * failure to register it; or if it no longer has any consumers (i.e.,
606  * its last sink is unregistered).
607  *
608  * This is syntactic sugar, and may be too complicated to be useful.
609  */
610 struct probe *probe_create(struct target *target,tid_t tid,struct probe_ops *pops,
611  const char *name,
614  void *handler_data,int autofree,int tracked);
615 
616 void probe_rename(struct probe *probe,const char *name);
617 
618 /*
619  * If the probe was not specified as an @autofree probe, anybody who
620  * calls probe_create must call this function to avoid leaking memory.
621  *
622  * If the probe is still registered, we try to unregister if we can.
623  */
624 int probe_free(struct probe *probe,int force);
625 
626 /*
627  * Registers a probe (created with probe_create()) on some symbol. It
628  * will create a breakpoint or watchpoint depending on the type of
629  * symbol. @style, @whence determine how the break/watchpoint is
630  * configured; and @watchsize configures a watchpoint.
631  */
632 struct probe *probe_register_symbol(struct probe *probe,struct bsymbol *bsymbol,
633  probepoint_style_t style,
634  probepoint_whence_t whence,
635  probepoint_watchsize_t watchsize);
636 
637 /*
638  * If you have a specific address in mind, use this function instead.
639  * If @addr is within a symbol (i.e., a function offset), you can
640  * specify the symbol itself for better debug messages, etc.
641  */
642 struct probe *probe_register_addr(struct probe *probe,ADDR addr,
643  probepoint_type_t type,
644  probepoint_style_t style,
645  probepoint_whence_t whence,
646  probepoint_watchsize_t watchsize,
647  struct bsymbol *bsymbol);
648 
649 /*
650  * Fully unregisters a probe. If it is connected to a probepoint,
651  * unregister from that. If it is connected to sources, unregister from
652  * each of them. If the probepoint is not in use by any other sources,
653  * unregister it. If the sources it was connected to are not in use,
654  * unregister them recursively.
655  */
656 int probe_unregister(struct probe *probe,int force);
657 
658 /*
659  * Unregister one probe; do not attempt to unregister anything beneath
660  * it, even if its probepoint or sources are not in use!
661  */
662 int probe_unregister_one(struct probe *probe,int force);
663 
664 /*
665  * Registers a sink probe on one source.
666  */
667 struct probe *probe_register_source(struct probe *sink,struct probe *src);
668 
669 /*
670  * Registers a sink probe on each source.
671  */
672 struct probe *probe_register_sources(struct probe *sink,struct probe *src,...);
673 
674 /*
675  * Unregisters one sink probe from one of its sources. This function
676  * also recursively unregisters and frees all autofreeable source probes
677  * that are not already in use, and could ultimately remove any
678  * probepoints.
679  */
680 int probe_unregister_source(struct probe *sink,struct probe *src,int force);
681 
682 /*
683  * Unregisters only this source from this sink; no recursion.
684  */
685 int probe_unregister_source_one(struct probe *sink,struct probe *src,
686  int force);
687 
688 /*
689  * For the following functions: when a probe is disabled, its handlers
690  * will not be invoked. When a probe is hard disabled, its underlying
691  * sources/probepoints are all disabled/removed.
692  */
693 
694 /*
695  * Hard enable/disable (i.e., remove the underlying probepoint). This
696  * only works for probes that are directly attached to an address --
697  * i.e., not a sink probe attached to a source.
698  *
699  * The idea is that sometimes a higher-level probe library might want to
700  * temporarily insert/delete probes. Of course, since we allow probes
701  * to be shared, we have to be careful about who can call
702  * probe_hard_disable with @force set!
703  */
704 int probe_hard_disable(struct probe *probe,int force);
705 int probe_hard_enable(struct probe *probe);
706 
707 /*
708  * Enable this probe, and all its sources (all the way to the base
709  * probes).
710  */
711 int probe_enable_all(struct probe *probe);
712 
713 /*
714  * Disable not only this probe, but all its source probes that do not
715  * themselves have enabled sinks. So, we push the disable operation
716  * as low as we can each time.
717  */
718 int probe_disable(struct probe *probe);
719 
721  ADDR *addrlist,int count,
723  probepoint_whence_t whence,
724  probepoint_watchsize_t watchsize,
727  void *handler_data,
728  struct probe **probelist,
729  int failureaction);
730 
731 int probe_unregister_batch(struct target *target,struct probe **probelist,
732  int listlen,int force);
733 
735 
736 /*
737  * Calls the summarize handler probe operation for this probe type, if
738  * it has one. If no such handler exists, it returns NULL.
739  */
740 void *probe_summarize(struct probe *probe);
741 
742 /*
743  * Calls the summarize_tid handler probe operation for this probe type, if
744  * it has one. If no such handler exists, it returns NULL.
745  */
746 void *probe_summarize_tid(struct probe *probe,tid_t tid);
747 
748 /*
749  * Disables a running probe. When disabled, both pre- and post-handlers are
750  * ignored until the probe is enabled back.
751  *
752  * NOTE: To enable a probe, call enable_vmprobe() function below.
753  */
754 int probe_disable_one(struct probe *probe);
755 
756 /*
757  * Enables an inactive probe.
758  * Returns a value of 0 upon successful completion, or a value of -1 if the
759  * given handle is invalid.
760  */
761 int probe_enable(struct probe *probe);
762 
763 /*
764  * Indicates whether a probe is enabled or not.
765  * Returns a non-zero value if the probe is active, a value of 0 if the
766  * probe is inactive, or a value of -1 if the given handle is invalid.
767  */
768 int probe_enabled(struct probe *probe);
769 
770 /*
771  * Returns non-zero if the probe is a "base" probe; if it is directly
772  * attached to a probepoint.
773  */
774 int probe_is_base(struct probe *probe);
775 
776 int probe_num_sources(struct probe *probe);
777 
778 int probe_num_sinks(struct probe *probe);
779 
780 /*
781  * Returns the name of the probe, if any.
782  */
783 char *probe_name(struct probe *probe);
784 
785 /*
786  * Returns the symbol associated with the probe, if any.
787  */
788 struct bsymbol *probe_symbol(struct probe *probe);
789 
790 /*
791  * Returns the probe's target.
792  */
793 struct target *probe_target(struct probe *probe);
794 
795 /*
796  * Returns the probe's thread id.
797  */
798 tid_t probe_tid(struct probe *probe);
799 
800 /*
801  * Returns the private data of the probe, if any.
802  */
803 void *probe_priv(struct probe *probe);
804 
805 /*
806  * Returns the address the a probe is targeting.
807  * If the given handle is invalid, the function returns a value of 0.
808  */
809 ADDR probe_addr(struct probe *probe);
810 
811 /*
812  * Returns the type of the probe.
813  */
814 probepoint_type_t probe_type(struct probe *probe);
815 
816 /*
817  * Returns the style of the probe.
818  */
819 probepoint_style_t probe_style(struct probe *probe);
820 
821 /*
822  * Returns the whence of the probe.
823  */
824 probepoint_whence_t probe_whence(struct probe *probe);
825 
826 /*
827  * Schedules an action to occur, given a probe handler. Actions can
828  * only occur when a domain is paused after a probe breakpoint has been
829  * hit. Actions can be scheduled prior to beginning probing, or they
830  * can be scheduled at probe handler runtime.
831  *
832  * Some actions may preclude others in the future. For instance, a
833  * return action depends greatly on the body of the called function NOT
834  * being executed at all, so that %eax may be set and a 'ret'
835  * instruction executed (so it's immediately after the 'call'
836  * instruction; there is no state to clean up, etc. Allowing a custom
837  * code action prior to a return action might change the validity of
838  * this assumption.
839  *
840  * But for now, the only restriction is
841  * - one return action per handle, and it will be performed after
842  * execution of the pre handler.
843  *
844  * Actions do not have priorities; they are executed in the order
845  * scheduled.
846  *
847  * Actions are refcnt'd; when you create an action, a ref is taken on
848  * your behalf; you must release it with action_release().
849  */
850 int action_sched(struct probe *probe,struct action *action,
851  action_whence_t whence,
852  action_handler_t handler,void *handler_data);
853 
854 /*
855  * Cancel an action.
856  */
857 int action_cancel(struct action *action);
858 
859 /*
860  * High-level actions that require little ASM knowledge.
861  */
862 struct action *action_return(REGVAL retval);
863 
864 /*
865  * Low-level actions that require little ASM knowledge, and may or may
866  * not be permitted.
867  */
868 struct action *action_regmod(REG regnum,REGVAL regval);
869 struct action *action_memmod(ADDR destaddr,char *data,uint32_t len);
870 
871 #define SINGLESTEP_INFINITE -1
872 #define SINGLESTEP_NEXTBP -2
873 
874 /*
875  * Single steps @nsteps unless canceled first. If @nsteps is -1, it
876  * single steps until canceled.
877  */
878 struct action *action_singlestep(int nsteps);
879 /*
880  * XXX: this is not yet implemented!
881  *
882  * Writes the @code into a scratch buf. How this works: (we must have a
883  * scratch text segment) we singlestep a JMP to the scratch buf. The
884  * scratch buf has a little prefix that disables interrupts if
885  * requested; CALLs the user code; and the postfix reenables interrupts
886  * if necessary and triggers an int 0x3 to let the debugger know that
887  * the custom code is done and can be garbage collected.
888  *
889  * This does not help if an NMI fires; we would have to override the NMI
890  * handler to maintain control, which we don't care enough to do.
891  */
892 struct action *action_code(char *buf,uint32_t len,uint32_t flags);
893 
894 /*
895  * Destroy an action (and cancel it first if necessary!).
896  */
897 REFCNT action_free(struct action *action,int force);
898 
899 
900 void action_hold(struct action *action);
901 REFCNT action_release(struct action *action);
902 
903 #endif /* __PROBE_API_H__ */
struct target * probe_target(struct probe *probe)
Definition: probe.c:1943
GHashTable * probe_value_get_last_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:624
GHashTable * probe_value_get_raw_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:582
struct probe * probe_register_symbol_name(struct probe *probe, char *name, const char *delim, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: probe_lib.c:51
result_t pre_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
Definition: spf.c:903
int probe_unregister_source(struct probe *sink, struct probe *src, int force)
Definition: probe.c:1145
int action_sched(struct probe *probe, struct action *action, action_whence_t whence, action_handler_t handler, void *handler_data)
Definition: probe.c:4119
struct probe * probe_value_symbol(struct target *target, tid_t tid, struct bsymbol *bsymbol, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
Definition: probe_value.c:660
probe_handler_phase_t
Definition: probe_api.h:83
int(* registered)(struct probe *probe)
Definition: probe_api.h:104
int32_t tid_t
Definition: common.h:36
probepoint_type_t
Definition: probe_api.h:213
void action_hold(struct action *action)
void * probe_summarize_tid(struct probe *probe, tid_t tid)
Definition: probe.c:1793
struct probe * probe_value_var(struct target *target, tid_t tid, struct bsymbol *bsymbol, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
Definition: probe_value.c:701
action_whence_t
Definition: probe_api.h:257
GHashTable * probe_value_get_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:571
void(* values_notify_phase)(struct probe *probe, tid_t tid, probe_handler_phase_t phase)
Definition: probe_api.h:175
struct value * probe_value_get_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:467
Definition: probe.h:392
struct probe * probe_register_addr(struct probe *probe, ADDR addr, probepoint_type_t type, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize, struct bsymbol *bsymbol)
Definition: probe.c:1393
int probe_unregister(struct probe *probe, int force)
Definition: probe.c:1137
char * name
Definition: probe.h:314
int(* enabled)(struct probe *probe)
Definition: probe_api.h:106
struct target_nv_filter * post_filter
Definition: probe.h:355
int probe_value_record_basic(struct probe *probe, tid_t tid, char *name, struct value *value, int israw)
Definition: probe_value.c:235
void probe_values_free_stacked(struct probe *probe)
Definition: probe_value.c:149
REGVAL retval
Definition: probe.h:411
probe_handler_phase_t phase
Definition: probe_value.c:29
void probe_values_free_basic(struct probe *probe)
Definition: probe_value.c:172
probepoint_whence_t
Definition: probe_api.h:234
struct value * probe_value_get_last(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:639
struct action * action_regmod(REG regnum, REGVAL regval)
Definition: probe.c:4532
int probe_is_base(struct probe *probe)
Definition: probe.c:1919
REFCNT action_free(struct action *action, int force)
Definition: probe.c:4600
int probe_num_sinks(struct probe *probe)
Definition: probe.c:1929
struct probe * probe_create_filtered(struct target *target, tid_t tid, struct probe_ops *pops, const char *name, probe_handler_t pre_handler, struct target_nv_filter *pre_filter, probe_handler_t post_handler, struct target_nv_filter *post_filter, struct target_nv_filter *thread_filter, void *handler_data, int autofree, int tracked)
Definition: probe_filter.c:95
GHashTable * probe_value_get_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:618
tid_t probe_tid(struct probe *probe)
Definition: probe.c:1947
ADDR destaddr
Definition: probe.h:428
struct list_head probe
Definition: probe.h:379
int(* unregistered)(struct probe *probe)
Definition: probe_api.h:110
struct target_nv_filter * thread_filter
Definition: probe.h:357
int probe_unregister_one(struct probe *probe, int force)
Definition: probe.c:1141
int probe_enable(struct probe *probe)
Definition: probe.c:1861
result_t probe_do_sink_pre_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
Definition: probe.c:48
result_t(* probe_handler_t)(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
Definition: probe_api.h:70
action_flag_t flags
Definition: probe.h:420
REGVAL regval
Definition: probe.h:425
int probe_disable_one(struct probe *probe)
Definition: probe.c:1800
ADDR probe_addr(struct probe *probe)
Definition: probe.c:1959
probepoint_type_t probe_type(struct probe *probe)
Definition: probe.c:1968
struct probe * probe_register_source(struct probe *sink, struct probe *src)
Definition: probe.c:1593
void probe_value_free(struct probe_value *pv)
Definition: probe_value.c:66
int probe_value_record_stacked(struct probe *probe, tid_t tid, char *name, struct value *value, int israw)
Definition: probe_value.c:187
struct value * probe_value_get_last_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:477
int probe_unregister_source_one(struct probe *sink, struct probe *src, int force)
Definition: probe.c:1186
tid_t tid
Definition: probe.h:344
struct value * probe_value_get_last_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:561
GHashTable * probe_value_get_last_raw_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:604
struct action * action_singlestep(int nsteps)
Definition: probe.c:4483
unsigned char * data
Definition: probe.h:429
int(* init)(struct probe *probe)
Definition: probe_api.h:100
struct probe * probe_register_sources(struct probe *sink, struct probe *src,...)
Definition: probe.c:1654
result_t(* action_handler_t)(struct action *action, struct target_thread *thread, struct probe *probe, struct probepoint *probepoint, handler_msg_t msg, int msg_detail, void *handler_data)
Definition: probe_api.h:76
void probe_rename(struct probe *probe, const char *name)
Definition: probe.c:898
GHashTable * probe_value_get_raw_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:376
struct value * probe_value_get_last_raw_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:566
probepoint_watchsize_t
Definition: probe_api.h:241
int probe_disable(struct probe *probe)
Definition: probe.c:1811
result_t probe_do_sink_post_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
Definition: probe.c:109
unsigned char * buf
Definition: probe.h:418
int probe_free(struct probe *probe, int force)
Definition: probe.c:777
struct probe * probe_create(struct target *target, tid_t tid, struct probe_ops *pops, const char *name, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data, int autofree, int tracked)
Definition: probe.c:729
GHashTable * probe_value_get_raw_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:621
int(* fini)(struct probe *probe)
Definition: probe_api.h:187
GHashTable * probe_value_get_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:372
struct value * probe_value_get_raw_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:556
probepoint_whence_t probe_whence(struct probe *probe)
Definition: probe.c:1982
int probe_hard_enable(struct probe *probe)
Definition: probe.c:961
void probe_value_clear(struct probe_value *pv)
Definition: probe_value.c:41
int len
Definition: dumptarget.c:52
GHashTable * probe_value_get_last_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:593
Definition: probe.h:308
struct bsymbol * probe_symbol(struct probe *probe)
Definition: probe.c:1939
struct value * probe_value_get_last_raw(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:636
struct value * probe_value_get_raw(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:630
void probe_value_notify_phase_function_ee(struct probe *probe, tid_t tid, probe_handler_phase_t phase)
Definition: probe_value.c:96
int probe_register_batch(struct target *target, tid_t tid, ADDR *addrlist, int count, probepoint_type_t type, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data, struct probe **probelist, int failureaction)
Definition: probe.c:1685
probepoint_watchsize_t probepoint_closest_watchsize(int size)
Definition: probe.c:1769
struct probe * probe_register_inlined_symbol(struct probe *probe, struct bsymbol *bsymbol, int do_primary, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: probe_lib.c:1089
handler_msg_t
Definition: probe_api.h:52
int(* disabled)(struct probe *probe)
Definition: probe_api.h:108
struct action * action_return(REGVAL retval)
Definition: probe.c:4457
struct probe * probe_register_line(struct probe *probe, char *filename, int line, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: probe.c:1403
struct target_nv_filter * pre_filter
Definition: probe.h:351
struct value * probe_value_get(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:633
result_t post_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
Definition: spf.c:908
int action_cancel(struct action *action)
Definition: probe.c:4413
void(* values_free)(struct probe *probe)
Definition: probe_api.h:180
void * probe_priv(struct probe *probe)
Definition: probe.c:1951
REFCNT action_release(struct action *action)
Definition: probe.c:4576
result_t
Definition: common.h:25
char * probe_name(struct probe *probe)
Definition: probe.c:1935
action_flag_t
Definition: probe_api.h:267
uint32_t REGVAL
Definition: common.h:66
struct value * probe_value_get_last_raw_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:482
struct value * probe_value_get_raw_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:472
uint8_t autofree
Definition: probe.h:364
int8_t REG
Definition: common.h:93
probepoint_style_t
Definition: probe_api.h:228
struct action * action_memmod(ADDR destaddr, char *data, uint32_t len)
Definition: probe.c:4553
struct list_head action
Definition: probe.h:449
probepoint_style_t probe_style(struct probe *probe)
Definition: probe.c:1975
uint32_t ADDR
Definition: common.h:64
void probe_value_notify_phase_watchedvar(struct probe *probe, tid_t tid, probe_handler_phase_t phase)
Definition: probe_value.c:124
uint32_t REFCNT
Definition: common.h:124
GHashTable * probe_value_get_last_raw_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:627
int probe_filter_check(struct probe *probe, tid_t tid, struct probe *trigger, int whence)
Definition: probe_filter.c:35
GHashTable * probe_value_get_last_raw_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:384
inst_type_t
Definition: disasm.h:46
REG regnum
Definition: probe.h:424
GHashTable * probe_value_get_last_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:380
struct value * probe_value_get_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:551
int probe_enabled(struct probe *probe)
Definition: probe.c:1915
void * handler_data
Definition: probe.h:359
struct action * action_code(char *buf, uint32_t len, uint32_t flags)
struct probe * probe_register_symbol(struct probe *probe, struct bsymbol *bsymbol, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
Definition: probe.c:1470
int probe_hard_disable(struct probe *probe, int force)
Definition: probe.c:912
int probe_unregister_batch(struct target *target, struct probe **probelist, int listlen, int force)
Definition: probe.c:1217
struct probe_value * probe_value_create(probe_handler_phase_t phase)
Definition: probe_value.c:79
action_type_t
Definition: probe_api.h:249
int probe_num_sources(struct probe *probe)
Definition: probe.c:1923
uint8_t tracked
Definition: probe.h:376
void * probe_summarize(struct probe *probe)
Definition: probe.c:1786
struct probe * probe_simple(struct target *target, tid_t tid, char *name, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
Definition: probe_lib.c:37
int probe_enable_all(struct probe *probe)