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_value.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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 #include "log.h"
20 #include "target_api.h"
21 #include "target.h"
22 #include "target_os.h"
23 #include "probe_api.h"
24 #include "glib_wrapper.h"
25 #include "dwdebug.h"
26 #include "dwdebug_priv.h"
27 
28 struct probe_value {
30 
31  uint8_t finished:1,
34 
35  /* name to struct value */
36  GHashTable *nv;
37  /* name to raw value */
38  GHashTable *nr;
39 };
40 
41 void probe_value_clear(struct probe_value *pv) {
42  GHashTableIter iter;
43  gpointer kp,vp;
44 
45  g_hash_table_iter_init(&iter,pv->nv);
46  while (g_hash_table_iter_next(&iter,&kp,&vp)) {
47  free(kp);
48  if (vp)
49  value_free((struct value *)vp);
50  g_hash_table_iter_remove(&iter);
51  }
52 
53  g_hash_table_iter_init(&iter,pv->nr);
54  while (g_hash_table_iter_next(&iter,&kp,&vp)) {
55  free(kp);
56  if (vp)
57  value_free((struct value *)vp);
58  g_hash_table_iter_remove(&iter);
59  }
60 
61  pv->pre_fully_loaded = 0;
62  pv->post_fully_loaded = 0;
63  pv->finished = 0;
64 }
65 
66 void probe_value_free(struct probe_value *pv) {
68  if (pv->nv) {
69  g_hash_table_destroy(pv->nv);
70  pv->nv = NULL;
71  }
72  if (pv->nr) {
73  g_hash_table_destroy(pv->nr);
74  pv->nr = NULL;
75  }
76  free(pv);
77 }
78 
80  struct probe_value *pv;
81 
82  pv = calloc(1,sizeof(*pv));
83  pv->phase = phase;
84  pv->nv = g_hash_table_new(g_str_hash,g_str_equal);
85  pv->nr = g_hash_table_new(g_str_hash,g_str_equal);
86 
87  return pv;
88 }
89 
90 /*
91  * If it's a new pre, mark.
92  * If it's a finished pre, mark.
93  * If it's a new post, mark.
94  * If it's a finished post, mark and mark finished.
95  */
98  GSList *stack;
99  struct probe_value *pv = NULL;
100 
101  if (!probe->values)
102  probe->values = g_hash_table_new(g_direct_hash,g_direct_equal);
103  stack = (GSList *)g_hash_table_lookup(probe->values,(gpointer)(uintptr_t)tid);
104  if (stack)
105  pv = (struct probe_value *)stack->data;
106 
107  if (phase == PHASE_POST_END) {
108  if (pv) {
109  pv->finished = 1;
110  pv->phase = phase;
111  }
112  }
113  else {
114  if (!pv) {
115  pv = probe_value_create(phase);
116  stack = g_slist_prepend(stack,pv);
117  g_hash_table_insert(probe->values,(gpointer)(uintptr_t)tid,stack);
118  }
119  else
120  pv->phase = phase;
121  }
122 }
123 
126  struct probe_value *pv = NULL;
127 
128  if (!probe->values)
129  probe->values = g_hash_table_new(g_direct_hash,g_direct_equal);
130  pv = (struct probe_value *) \
131  g_hash_table_lookup(probe->values,(gpointer)(uintptr_t)tid);
132 
133  if (phase == PHASE_PRE_END) {
134  if (pv) {
135  pv->finished = 1;
136  pv->phase = phase;
137  }
138  }
139  else {
140  if (!pv) {
141  pv = probe_value_create(phase);
142  g_hash_table_insert(probe->values,(gpointer)(uintptr_t)tid,pv);
143  }
144  else
145  pv->phase = phase;
146  }
147 }
148 
150  GHashTableIter iter;
151  gpointer vp;
152  GSList *stack, *gsltmp;
153  struct probe_value *pv;
154 
155  if (!probe->values)
156  return;
157 
158  g_hash_table_iter_init(&iter,probe->values);
159  while (g_hash_table_iter_next(&iter,NULL,&vp)) {
160  stack = (GSList *)vp;
161  if (!stack)
162  continue;
163  v_g_slist_foreach(stack,gsltmp,pv) {
164  probe_value_free(pv);
165  }
166  g_slist_free(stack);
167  }
168  g_hash_table_destroy(probe->values);
169  probe->values = NULL;
170 }
171 
173  GHashTableIter iter;
174  gpointer vp;
175 
176  if (!probe->values)
177  return;
178 
179  g_hash_table_iter_init(&iter,probe->values);
180  while (g_hash_table_iter_next(&iter,NULL,&vp)) {
181  probe_value_free((struct probe_value *)vp);
182  }
183  g_hash_table_destroy(probe->values);
184  probe->values = NULL;
185 }
186 
188  char *name,struct value *value,int israw) {
189  GSList *stack;
190  struct probe_value *pv;
191  struct value *value_prev = NULL;
192  GHashTable *v;
193  char *existing_name = NULL;
194 
195  if (!probe->values)
196  probe->values = g_hash_table_new(g_direct_hash,g_direct_equal);
197  stack = (GSList *)g_hash_table_lookup(probe->values,(gpointer)(uintptr_t)tid);
198 
199  if (stack)
200  pv = (struct probe_value *)stack->data;
201  else {
203  stack = g_slist_prepend(stack,pv);
204  g_hash_table_insert(probe->values,(gpointer)(uintptr_t)tid,stack);
205  }
206 
207  if (pv->finished) {
208  /* clear it and pop it! */
209  probe_value_free(pv);
210  stack = g_slist_delete_link(stack,stack);
211  /* push a new one; just guess on phase */
213  stack = g_slist_prepend(stack,pv);
214  g_hash_table_insert(probe->values,(gpointer)(uintptr_t)tid,stack);
215  }
216 
217  if (israw)
218  v = pv->nr;
219  else
220  v = pv->nv;
221 
222  if (g_hash_table_lookup_extended(v,name,(gpointer *)&existing_name,
223  (gpointer *)&value_prev) == TRUE) {
224  g_hash_table_remove(v,name);
225  free(existing_name);
226  if (value_prev)
227  value_free(value_prev);
228  }
229 
230  g_hash_table_insert(v,strdup(name),value);
231 
232  return 0;
233 }
234 
236  char *name,struct value *value,int israw) {
237  struct probe_value *pv;
238  struct value *value_prev;
239  GHashTable *v;
240 
241  if (!probe->values)
242  probe->values = g_hash_table_new(g_direct_hash,g_direct_equal);
243 
244  pv = (struct probe_value *) \
245  g_hash_table_lookup(probe->values,(gpointer)(uintptr_t)tid);
246  if (!pv) {
247  pv = calloc(1,sizeof(*pv));
248  pv->nv = g_hash_table_new(g_str_hash,g_str_equal);
249  pv->nr = g_hash_table_new(g_str_hash,g_str_equal);
250  g_hash_table_insert(probe->values,(gpointer)(uintptr_t)tid,pv);
251  }
252 
253  if (pv->finished)
254  probe_value_clear(pv);
255 
256  if (israw)
257  v = pv->nr;
258  else
259  v = pv->nv;
260 
261  value_prev = (struct value *)g_hash_table_lookup(v,name);
262  if (value_prev)
263  value_free(value_prev);
264 
265  g_hash_table_insert(v,strdup(name),value);
266 
267  return 0;
268 }
269 
271  int israw,int allowlast) {
272  GSList *args;
273  GSList *gsltmp;
274  struct symbol *symbol;
275  GSList *stack;
276  struct probe_value *pv = NULL;
277  struct symbol *argsym;
278  struct value *v;
279  char *name;
280  load_flags_t flags;
281  struct bsymbol *datatype;
282  struct target_location_ctxt *tlctxt;
283 
284  if (!israw)
286  else
287  flags = LOAD_FLAG_NONE;
288 
289  if (probe->values) {
290  stack = (GSList *) \
291  g_hash_table_lookup(probe->values,(gpointer)(uintptr_t)tid);
292  if (stack) {
293  pv = (struct probe_value *)stack->data;
294  if (pv
295  && (allowlast || !pv->finished)
296  && ((pv->phase == PHASE_PRE_START && pv->pre_fully_loaded)
297  || (pv->phase == PHASE_POST_START && pv->post_fully_loaded))) {
298  if (israw)
299  return pv->nr;
300  else
301  return pv->nv;
302  }
303  }
304  }
305 
306  if (pv && pv->finished) {
307  /* clear it and pop it! */
308  probe_value_free(pv);
309  stack = g_slist_delete_link(stack,stack);
310  /* push a new one; just guess on phase */
312  stack = g_slist_prepend(stack,pv);
313  g_hash_table_insert(probe->values,(gpointer)(uintptr_t)tid,stack);
314  }
315 
316  if (pv->phase == PHASE_PRE_START) {
317  symbol = bsymbol_get_symbol(probe->bsymbol);
319 
320  /*
321  * Load each argument if it hasn't already been loaded.
322  */
324  probe->bsymbol);
325  gsltmp = NULL;
326  v_g_slist_foreach(args,gsltmp,argsym) {
327  name = symbol_get_name(argsym);
328  if (pv && (allowlast || !pv->finished)) {
329  if (israw && g_hash_table_lookup(pv->nr,name))
330  continue;
331  else if (!israw && g_hash_table_lookup(pv->nv,name))
332  continue;
333  }
334 
335  v = target_load_symbol_member(probe->target,tlctxt,probe->bsymbol,name,
336  NULL,flags);
337  /* Always record it even if it's NULL! */
338  probe_value_record_stacked(probe,tid,name,v,israw);
339  }
341 
342  g_slist_free(args);
343  args = NULL;
344 
345  pv->pre_fully_loaded = 1;
346  }
347  else if (pv->phase == PHASE_POST_START) {
348  /* x86 hack: load AX. */
349  datatype = target_lookup_sym(probe->target,"long unsigned int",NULL,NULL,
351  if (datatype) {
352  REG retreg = -1;
353  target_cregno(probe->target,CREG_RET,&retreg);
354  v = target_load_type_reg(probe->target,bsymbol_get_symbol(datatype),
355  tid,retreg,LOAD_FLAG_NONE);
357  /* Always record it even if it's NULL -- should not happen
358  * for retval though!
359  */
360  probe_value_record_stacked(probe,tid,name,v,israw);
361  }
362  bsymbol_release(datatype);
363  pv->post_fully_loaded = 1;
364  }
365 
366  if (israw)
367  return pv->nr;
368  else
369  return pv->nv;
370 }
371 
373  return __probe_value_get_table_function_ee(probe,tid,0,0);
374 }
375 
377  return __probe_value_get_table_function_ee(probe,tid,1,0);
378 }
379 
381  return __probe_value_get_table_function_ee(probe,tid,0,1);
382 }
383 
385  tid_t tid) {
386  return __probe_value_get_table_function_ee(probe,tid,1,1);
387 }
388 
389 static struct value *__probe_value_get_function_ee(struct probe *probe,tid_t tid,
390  char *name,int israw,
391  int allowlast) {
392  GSList *stack;
393  struct value *retval = NULL;
394  struct symbol *symbol;
395  struct bsymbol *bsymbol;
396  struct probe_value *pv = NULL;
397  struct value *v;
398  load_flags_t flags;
399  struct bsymbol *datatype;
400  GHashTable *vt;
401  struct target_location_ctxt *tlctxt;
402 
403  /*
404  * Try to find it in the current hash.
405  */
406  if (probe->values) {
407  stack = (GSList *) \
408  g_hash_table_lookup(probe->values,(gpointer)(uintptr_t)tid);
409  if (stack) {
410  pv = (struct probe_value *)stack->data;
411  if (pv && (allowlast || !pv->finished)) {
412  if (israw)
413  vt = pv->nr;
414  else
415  vt = pv->nv;
416  retval = (struct value *)g_hash_table_lookup(vt,name);
417  if (retval)
418  return retval;
419  }
420  }
421  }
422 
423  if (!israw)
425  else
426  flags = LOAD_FLAG_NONE;
427 
428  /*
429  * Otherwise look up and load! If name is the bsymbol's name, or is
430  * NULL, load the symbol; else load a member if possible.
431  */
432  bsymbol = probe->bsymbol;
433  if (!bsymbol)
434  return NULL;
435  symbol = bsymbol_get_symbol(bsymbol);
436 
437  if (!name
438  || (name && strcmp(name,symbol_get_name(symbol)) == 0)
439  || (name && strcmp(name,PROBE_VALUE_NAME_RETURN) == 0)) {
440  datatype = target_lookup_sym(probe->target,"long unsigned int",NULL,NULL,
442  if (datatype) {
443  REG retreg = -1;
444  target_cregno(probe->target,CREG_RET,&retreg);
445  v = target_load_type_reg(probe->target,bsymbol_get_symbol(datatype),
446  tid,retreg,LOAD_FLAG_NONE);
448  }
449  else
450  v = NULL;
451  }
452  else {
454  bsymbol);
455  v = target_load_symbol_member(probe->target,tlctxt,bsymbol,name,NULL,flags);
457  }
458 
459  /*
460  * Record the value (even if it's NULL!).
461  */
462  probe_value_record_stacked(probe,tid,name,v,israw);
463 
464  return v;
465 }
466 
467 struct value *probe_value_get_function_ee(struct probe *probe,tid_t tid,
468  char *name) {
469  return __probe_value_get_function_ee(probe,tid,name,0,0);
470 }
471 
472 struct value *probe_value_get_raw_function_ee(struct probe *probe,tid_t tid,
473  char *name) {
474  return __probe_value_get_function_ee(probe,tid,name,1,0);
475 }
476 
477 struct value *probe_value_get_last_function_ee(struct probe *probe,tid_t tid,
478  char *name) {
479  return __probe_value_get_function_ee(probe,tid,name,0,1);
480 }
481 
482 struct value *probe_value_get_last_raw_function_ee(struct probe *probe,tid_t tid,
483  char *name) {
484  return __probe_value_get_function_ee(probe,tid,name,1,1);
485 }
486 
487 static struct value *__probe_value_get_basic(struct probe *probe,tid_t tid,
488  char *name,int israw,
489  int allowlast) {
490  struct value *retval = NULL;
491  struct symbol *symbol;
492  struct bsymbol *bsymbol;
493  struct probe_value *pv = NULL;
494  struct value *v;
495  load_flags_t flags;
496  GHashTable *vt;
497  struct target_location_ctxt *tlctxt;
498 
499  bsymbol = probe->bsymbol;
500  if (!name)
501  name = bsymbol_get_name(bsymbol);
502 
503  /*
504  * Try to find it in the current hash.
505  */
506  if (probe->values) {
507  pv = (struct probe_value *) \
508  g_hash_table_lookup(probe->values,(gpointer)(uintptr_t)tid);
509  if (pv && (allowlast || !pv->finished)) {
510  if (israw)
511  vt = pv->nr;
512  else
513  vt = pv->nv;
514  retval = (struct value *)g_hash_table_lookup(vt,name);
515  if (retval)
516  return retval;
517  }
518  }
519 
520  if (!israw)
522  else
523  flags = LOAD_FLAG_NONE;
524 
525  /*
526  * Otherwise look up and load! If name is the bsymbol's name, or is
527  * NULL, load the symbol; else load a member if possible.
528  */
529  if (!bsymbol)
530  return NULL;
531  symbol = bsymbol_get_symbol(bsymbol);
532 
533  tlctxt = target_location_ctxt_create_from_bsymbol(probe->target,tid,bsymbol);
534  if (!name || (name && strcmp(name,symbol_get_name(symbol)) == 0)) {
535  v = target_load_symbol(probe->target,tlctxt,bsymbol,flags);
536  name = symbol_get_name(symbol);
537  }
538  else {
539  v = target_load_symbol_member(probe->target,tlctxt,bsymbol,name,NULL,flags);
540  }
542 
543  /*
544  * Record the value (even if it's NULL!).
545  */
546  probe_value_record_basic(probe,tid,name,v,israw);
547 
548  return v;
549 }
550 
551 struct value *probe_value_get_basic(struct probe *probe,tid_t tid,
552  char *name) {
553  return __probe_value_get_basic(probe,tid,name,0,0);
554 }
555 
556 struct value *probe_value_get_raw_basic(struct probe *probe,tid_t tid,
557  char *name) {
558  return __probe_value_get_basic(probe,tid,name,1,0);
559 }
560 
561 struct value *probe_value_get_last_basic(struct probe *probe,tid_t tid,
562  char *name) {
563  return __probe_value_get_basic(probe,tid,name,0,1);
564 }
565 
566 struct value *probe_value_get_last_raw_basic(struct probe *probe,tid_t tid,
567  char *name) {
568  return __probe_value_get_basic(probe,tid,name,1,1);
569 }
570 
571 GHashTable *probe_value_get_table_basic(struct probe *probe,tid_t tid) {
572  struct probe_value *pv;
573 
574  __probe_value_get_basic(probe,tid,NULL,0,0);
575  pv = (struct probe_value *)g_hash_table_lookup(probe->values,
576  (gpointer)(uintptr_t)tid);
577  if (!pv)
578  return NULL;
579  return pv->nv;
580 }
581 
582 GHashTable *probe_value_get_raw_table_basic(struct probe *probe,tid_t tid) {
583  struct probe_value *pv;
584 
585  __probe_value_get_basic(probe,tid,NULL,1,0);
586  pv = (struct probe_value *)g_hash_table_lookup(probe->values,
587  (gpointer)(uintptr_t)tid);
588  if (!pv)
589  return NULL;
590  return pv->nr;
591 }
592 
593 GHashTable *probe_value_get_last_table_basic(struct probe *probe,tid_t tid) {
594  struct probe_value *pv;
595 
596  __probe_value_get_basic(probe,tid,NULL,0,1);
597  pv = (struct probe_value *)g_hash_table_lookup(probe->values,
598  (gpointer)(uintptr_t)tid);
599  if (!pv)
600  return NULL;
601  return pv->nv;
602 }
603 
604 GHashTable *probe_value_get_last_raw_table_basic(struct probe *probe,tid_t tid) {
605  struct probe_value *pv;
606 
607  __probe_value_get_basic(probe,tid,NULL,1,1);
608  pv = (struct probe_value *)g_hash_table_lookup(probe->values,
609  (gpointer)(uintptr_t)tid);
610  if (!pv)
611  return NULL;
612  return pv->nr;
613 }
614 
618 GHashTable *probe_value_get_table(struct probe *probe,tid_t tid) {
619  return PROBE_SAFE_OP_ARGS(probe,get_value_table,tid);
620 }
621 GHashTable *probe_value_get_raw_table(struct probe *probe,tid_t tid) {
622  return PROBE_SAFE_OP_ARGS(probe,get_raw_value_table,tid);
623 }
624 GHashTable *probe_value_get_last_table(struct probe *probe,tid_t tid) {
625  return PROBE_SAFE_OP_ARGS(probe,get_last_value_table,tid);
626 }
627 GHashTable *probe_value_get_last_raw_table(struct probe *probe,tid_t tid) {
628  return PROBE_SAFE_OP_ARGS(probe,get_last_raw_value_table,tid);
629 }
630 struct value *probe_value_get_raw(struct probe *probe,tid_t tid,char *name) {
631  return PROBE_SAFE_OP_ARGS(probe,get_raw_value,tid,name);
632 }
633 struct value *probe_value_get(struct probe *probe,tid_t tid,char *name) {
634  return PROBE_SAFE_OP_ARGS(probe,get_value,tid,name);
635 }
636 struct value *probe_value_get_last_raw(struct probe *probe,tid_t tid,char *name) {
637  return PROBE_SAFE_OP_ARGS(probe,get_last_raw_value,tid,name);
638 }
639 struct value *probe_value_get_last(struct probe *probe,tid_t tid,char *name) {
640  return PROBE_SAFE_OP_ARGS(probe,get_last_value,tid,name);
641 }
642 
647 struct probe *probe_value_var(struct target *target,tid_t tid,
648  struct bsymbol *bsymbol,
651  void *handler_data);
652 #ifdef ENABLE_DISTORM
653 static struct probe *probe_value_function_ee(struct target *target,tid_t tid,
654  struct bsymbol *bsymbol,
657  void *handler_data);
658 #endif
659 
660 struct probe *probe_value_symbol(struct target *target,tid_t tid,
661  struct bsymbol *bsymbol,
664  void *handler_data) {
665  struct symbol *symbol;
666 
667  symbol = bsymbol_get_symbol(bsymbol);
668 
669  if (SYMBOL_IS_VAR(symbol))
670  return probe_value_var(target,tid,bsymbol,
671  pre_handler,post_handler,handler_data);
672 #ifdef ENABLE_DISTORM
673  else if (SYMBOL_IS_FUNC(symbol))
674  return probe_value_function_ee(target,tid,bsymbol,
675  pre_handler,post_handler,handler_data);
676 #endif
677  else {
678  verror("can only value probe functions or vars!\n");
679  return NULL;
680  }
681 }
682 
683 static const char *probe_value_var_gettype(struct probe *probe) {
684  return "probe_value_var";
685 }
686 
687 struct probe_ops var_ops = {
688  .gettype = probe_value_var_gettype,
689  .get_value_table = probe_value_get_table_basic,
690  .get_raw_value_table = probe_value_get_raw_table_basic,
691  .get_last_value_table = probe_value_get_last_table_basic,
692  .get_last_raw_value_table = probe_value_get_last_raw_table_basic,
693  .get_value = probe_value_get_basic,
694  .get_raw_value = probe_value_get_raw_basic,
695  .get_last_value = probe_value_get_last_basic,
696  .get_last_raw_value = probe_value_get_last_raw_basic,
697  .values_notify_phase = probe_value_notify_phase_watchedvar,
698  .values_free = probe_values_free_basic,
699 };
700 
701 struct probe *probe_value_var(struct target *target,tid_t tid,
702  struct bsymbol *bsymbol,
705  void *handler_data) {
706  struct probe *probe;
707 
708  /*
709  * NB: Value probes *must* have both pre and post handlers so that
710  * they catch phase transitions. So if one is not set, use the
711  * default!
712  */
713  probe = probe_create(target,tid,&var_ops,bsymbol_get_name(bsymbol),
714  pre_handler ? pre_handler : probe_do_sink_pre_handlers,
715  post_handler ? post_handler : probe_do_sink_post_handlers,
716  handler_data,0,1);
717  if (!probe)
718  return NULL;
719 
721  PROBEPOINT_LAUTO)) {
722  verror("could not register probe on %s!\n",bsymbol_get_name(bsymbol));
723  probe_free(probe,1);
724  return NULL;
725  }
726 
727  return probe;
728 }
729 
730 #ifdef ENABLE_DISTORM
731 static const char *probe_value_function_ee_gettype(struct probe *probe) {
732  return "probe_value_function_entry_exit";
733 }
734 
735 struct probe_ops function_ee_ops = {
736  .gettype = probe_value_function_ee_gettype,
737  .get_value_table = probe_value_get_table_function_ee,
738  .get_raw_value_table = probe_value_get_raw_table_function_ee,
739  .get_last_value_table = probe_value_get_last_table_function_ee,
740  .get_last_raw_value_table = probe_value_get_last_raw_table_function_ee,
741  .get_value = probe_value_get_function_ee,
742  .get_raw_value = probe_value_get_raw_function_ee,
743  .get_last_value = probe_value_get_last_function_ee,
744  .get_last_raw_value = probe_value_get_last_raw_function_ee,
745  .values_notify_phase = probe_value_notify_phase_function_ee,
746  .values_free = probe_values_free_stacked,
747 };
748 
749 static struct probe *probe_value_function_ee(struct target *target,tid_t tid,
750  struct bsymbol *bsymbol,
753  void *handler_data) {
754  struct probe *probe;
755 
756  if (!SYMBOL_IS_FUNC(bsymbol->lsymbol->symbol)) {
757  verror("must supply a function symbol!\n");
758  return NULL;
759  }
760 
761  /*
762  * NB: Value probes *must* have both pre and post handlers so that
763  * they catch phase transitions. So if one is not set, use the
764  * default!
765  */
766  probe = probe_create(target,tid,&function_ee_ops,bsymbol_get_name(bsymbol),
767  pre_handler ? pre_handler : probe_do_sink_pre_handlers,
768  post_handler ? post_handler : probe_do_sink_post_handlers,
769  handler_data,0,1);
770 
771  if (!probe_register_function_ee(probe,PROBEPOINT_SW,bsymbol,0,1,1)) {
772  verror("could not register entry/exit probes on function %s!\n",
773  bsymbol_get_name(bsymbol));
774  probe_free(probe,1);
775  return NULL;
776  }
777 
778  return probe;
779 }
780 #endif
GHashTable * __probe_value_get_table_function_ee(struct probe *probe, tid_t tid, int israw, int allowlast)
Definition: probe_value.c:270
struct value * target_load_symbol(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, load_flags_t flags)
Definition: target.c:3270
struct value * probe_value_get_last_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:477
struct value * probe_value_get_last_raw_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:482
result_t pre_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
Definition: spf.c:903
probe_handler_phase_t
Definition: probe_api.h:83
struct probe_value * probe_value_create(probe_handler_phase_t phase)
Definition: probe_value.c:79
GHashTable * nv
Definition: probe_value.c:36
struct lsymbol * lsymbol
Definition: target.h:1017
int32_t tid_t
Definition: common.h:36
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
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
struct value * probe_value_get_last_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:561
struct symbol * symbol
Definition: dwdebug.h:1010
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
#define v_g_slist_foreach(gslhead, gslcur, elm)
Definition: glib_wrapper.h:60
probe_handler_phase_t phase
Definition: probe_value.c:29
void probe_value_notify_phase_function_ee(struct probe *probe, tid_t tid, probe_handler_phase_t phase)
Definition: probe_value.c:96
struct target_location_ctxt * target_location_ctxt_create_from_bsymbol(struct target *target, tid_t tid, struct bsymbol *bsymbol)
Definition: target.c:5325
void probe_values_free_basic(struct probe *probe)
Definition: probe_value.c:172
int target_cregno(struct target *target, common_reg_t creg, REG *reg)
Definition: target_api.c:1126
#define PROBE_VALUE_NAME_RETURN
Definition: probe_api.h:159
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
char * bsymbol_get_name(struct bsymbol *bsymbol)
Definition: symbol.c:62
struct list_head probe
Definition: probe.h:379
#define verror(format,...)
Definition: log.h:30
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
const char *(* gettype)(struct probe *probe)
Definition: probe_api.h:96
GHashTable * probe_value_get_raw_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:376
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
uint8_t pre_fully_loaded
Definition: probe_value.c:31
GHashTable * probe_value_get_raw_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:582
void free(void *ptr)
Definition: debugserver.c:207
GHashTable * probe_value_get_last_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:624
GHashTable * probe_value_get_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:618
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
REFCNT bsymbol_release(struct bsymbol *bsymbol)
Definition: symbol.c:90
int probe_free(struct probe *probe, int force)
Definition: probe.c:777
void probe_value_free(struct probe_value *pv)
Definition: probe_value.c:66
struct value * probe_value_get_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:467
int probe_value_record_stacked(struct probe *probe, tid_t tid, char *name, struct value *value, int israw)
Definition: probe_value.c:187
void value_free(struct value *value)
Definition: value.c:282
struct probe_ops var_ops
Definition: probe_value.c:687
#define PROBE_SAFE_OP_ARGS(probe, op,...)
Definition: probe.h:31
Definition: probe.h:308
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 * values
Definition: probe.h:330
GHashTable * nr
Definition: probe_value.c:38
struct value * probe_value_get_raw(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:630
int probe_value_record_basic(struct probe *probe, tid_t tid, char *name, struct value *value, int israw)
Definition: probe_value.c:235
GHashTable * probe_value_get_last_raw_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:627
void * calloc(size_t nmemb, size_t size)
Definition: debugserver.c:200
result_t post_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
Definition: spf.c:908
GHashTable * probe_value_get_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:372
struct value * probe_value_get(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:633
GHashTable * probe_value_get_last_raw_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:384
int8_t REG
Definition: common.h:93
struct symbol * bsymbol_get_symbol(struct bsymbol *bsymbol)
Definition: symbol.c:66
struct target * target
Definition: probe.h:342
GSList * symbol_get_members(struct symbol *symbol, symbol_type_flag_t flags)
Definition: debug.c:3146
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
void target_location_ctxt_free(struct target_location_ctxt *tlctxt)
Definition: target.c:5348
GHashTable * probe_value_get_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:571
struct bsymbol * bsymbol
Definition: probe.h:389
load_flags_t
Definition: target_api.h:406
struct value * probe_value_get_raw_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:556
char * symbol_get_name(struct symbol *symbol)
Definition: debug.c:2587
void probe_value_clear(struct probe_value *pv)
Definition: probe_value.c:41
uint8_t finished
Definition: probe_value.c:31
GHashTable * probe_value_get_last_raw_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:604
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
struct value * probe_value_get_last_raw(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:636
GHashTable * probe_value_get_last_table_function_ee(struct probe *probe, tid_t tid)
Definition: probe_value.c:380
void probe_values_free_stacked(struct probe *probe)
Definition: probe_value.c:149
#define SYMBOL_IS_FUNC(sym)
uint8_t post_fully_loaded
Definition: probe_value.c:31
struct value * probe_value_get_last_raw_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:566
struct value * probe_value_get_basic(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:551
GHashTable * probe_value_get_raw_table(struct probe *probe, tid_t tid)
Definition: probe_value.c:621
Definition: arch.h:78
#define SYMBOL_IS_VAR(sym)
void probe_value_notify_phase_watchedvar(struct probe *probe, tid_t tid, probe_handler_phase_t phase)
Definition: probe_value.c:124
GHashTable * probe_value_get_last_table_basic(struct probe *probe, tid_t tid)
Definition: probe_value.c:593
struct value * probe_value_get_raw_function_ee(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:472
struct value * probe_value_get_last(struct probe *probe, tid_t tid, char *name)
Definition: probe_value.c:639