38 static void action_finish_handling(
struct action *
action,
62 ptmp = (
struct probe *)list->data;
102 list = g_list_next(list);
111 struct probe *base) {
123 ptmp = (
struct probe *)list->data;
155 list = g_list_next(list);
172 probepoint = (
struct probepoint *)
malloc(
sizeof(*probepoint));
174 verror(
"failed to allocate a new probepoint");
177 memset(probepoint,0,
sizeof(*probepoint));
182 probepoint->
thread = NULL;
192 RHOLD(bsymbol,probepoint);
206 vwarn(
"could not determine if instr at 0x%"PRIxADDR" can switch"
207 " context; but continuing!\n",addr);
224 static struct probepoint *probepoint_create_break(
struct target *target,
228 struct bsymbol *bsymbol,
230 struct probepoint *probepoint = __probepoint_create(target,addr,range,
233 bsymbol,symbol_addr);
237 static struct probepoint *probepoint_create_watch(
struct target *target,
243 struct bsymbol *bsymbol,
246 verror(
"software watchpoints not supported right now!\n");
252 whence,watchsize,bsymbol,symbol_addr);
255 static void probepoint_free_internal(
struct probepoint *probepoint) {
267 RPUT(action,action,probepoint,trefcnt);
271 RPUT(action,action,probepoint,trefcnt);
275 RPUT(action,action,probepoint,trefcnt);
289 RPUT(probepoint->
bsymbol,bsymbol,probepoint,trefcnt);
297 static int __probepoint_remove(
struct probepoint *probepoint,
int force,
299 struct target *target;
303 int action_did_obviate = 0;
306 target = probepoint->
target;
326 verror(
"no software watchpoint support!\n");
333 "target is not attached; emulating probepoint removal ");
354 else if (!force && !fake) {
355 vwarn(
"probepoint being handled (state %d); not forcing removal yet!\n",
363 vwarn(
"forced probepoint removal while it is running action;"
364 " trying to clean up normally!\n");
369 tpc = probepoint->
tpc;
373 verror(
"could not reenable sw breakpoint to remove action;"
374 " badness will probably ensue!\n");
382 action_did_obviate = 1;
391 "force probepoint removal while prehandling it;"
392 " trying to clean up normally!\n");
396 "force probepoint removal while handling an action;"
397 " trying to clean up normally!\n");
401 "force probepoint removal while posthandling it;"
402 " trying to clean up normally!\n");
406 "forced probepoint removal while it is inserting;"
407 " trying to clean up normally!\n");
431 && !action_did_obviate
442 " forced breakpoint remove; badness will probably"
449 if (probepoint->
tpc) {
452 " after failed sstep for breakpoint!\n",
476 verror(
"failure while removing hw breakpoint; cannot recover!\n");
486 verror(
"failure while removing hw watchpoint; cannot recover!\n");
499 else if (!nohashdelete)
509 else if (probepoint->
thread) {
519 probepoint->
mmod = NULL;
552 static void probepoint_free(
struct probepoint *probepoint) {
553 __probepoint_remove(probepoint,0,0);
555 probepoint_free_internal(probepoint);
571 __probepoint_remove(probepoint,1,1);
573 probepoint_free_internal(probepoint);
596 static int __probepoint_insert(
struct probepoint *probepoint,
598 struct target *target;
603 target = probepoint->
target;
619 verror(
"target %d is not attached!\n",target->
id);
654 vwarn(
"could not get a debug reg!\n");
667 verror(
"no software watchpoint support!\n");
679 probepoint->
addr))) {
680 verror(
"failure inserting hw breakpoint!\n");
692 verror(
"failure inserting hw watchpoint!\n");
709 if (!probepoint->
mmod) {
742 probe = (
struct probe *)
malloc(
sizeof(*probe));
744 verror(
"failed to allocate a new probe\n");
747 memset(probe,0,
sizeof(*probe));
750 probe->
name = (
name) ? strdup(name) : NULL;
763 verror(
"probe %s init failed, calling fini!\n",probe->
name);
785 if (probe->
sinks && !force) {
787 "could not free probe %s with sinks remaining!\n",
793 "could not free probe %s with probepoint remaining!\n",
799 vwarn(
"forcefully freeing probe %s that had sinks remaining;"
800 " removing this source from those sinks!\n",
805 sink = (
struct probe *)list->data;
809 vwarn(
"sink probe %s has no sources; although probe %s thinks"
810 " it's a source -- BUG!\n",sink->
name,probe->
name);
819 verror(
"probe %s: unregistered failed!\n",
833 list = g_list_next(list);
836 g_list_free(probe->
sinks);
852 verror(
"probe_unregister %s failed, forcing free to continue\n",
855 verror(
"probe_unregister %s failed, not forcing!\n",probe->
name);
876 verror(
"probe %s fini failed, aborting!\n",probe->
name);
905 probe->
name = (
name) ? strdup(name) : NULL;
921 ptmp = (
struct probe *)list->data;
930 if (((
struct probe *)(list->data))->enabled) {
933 list2 = g_list_next(list2);
935 if (!anyenabled || force) {
943 else if (anyenabled) {
949 list = g_list_next(list);
954 verror(
"failed to remove probepoint under probe (%d)\n!",force);
969 ptmp = (
struct probe *)list->data;
973 list = g_list_next(list);
979 verror(
"failed to insert probepoint under probe\n!");
986 static int __probe_unregister(
struct probe *probe,
int force,
int onlyone) {
987 struct probepoint *probepoint = probe->
probepoint;
988 struct target *target = probe->
target;
1003 if (probe->
sinks && !force) {
1004 verror(
"could not unregister a probe that had sinks remaining!\n");
1007 else if (probe->
sinks) {
1008 vwarn(
"forcefully unregistering a probe that had sinks remaining!\n");
1015 verror(
"target not paused (%d), cannot remove!\n",status);
1029 list_del(&probe->
probe);
1035 RPUT(action,action,probepoint,trefcnt);
1039 RPUT(action,action,probepoint,trefcnt);
1043 RPUT(action,action,probepoint,trefcnt);
1049 list = probe->
sinks;
1051 ptmp = (
struct probe *)list->data;
1053 list = g_list_next(list);
1055 probe->
sinks = NULL;
1063 ptmp = (
struct probe *)list->data;
1068 list = g_list_next(list);
1090 verror(
"probe '%s': unregistered failed, aborting\n",probe->
name);
1097 verror(
"could not autofree probe; continuing anyway!\n");
1108 if (!list_empty(&probepoint->
probes))
1115 if (!__probepoint_remove(probepoint,force,0))
1116 probepoint_free(probepoint);
1118 verror(
"probepoint_remove failed, but force freeing!\n");
1120 probepoint_free(probepoint);
1124 verror(
"probepoint_remove failed; not force freeing!\n");
1138 return __probe_unregister(probe,force,0);
1142 return __probe_unregister(probe,force,1);
1147 struct target *target = sink->
target;
1150 verror(
"probe %s has no sources!\n",sink->
name);
1158 verror(
"target not paused (%d), cannot remove!\n",status);
1169 __probe_unregister(src,force,0);
1172 verror(
"probe %s: unregistered failed, aborting\n",sink->
name);
1189 verror(
"probe %s has no sources!\n",sink->
name);
1197 verror(
"probe %s: unregistered failed, aborting\n",sink->
name);
1218 int listlen,
int force) {
1231 verror(
"target not paused!\n");
1236 for (i = 0; i < listlen; ++
i) {
1238 if (probelist[i] == NULL)
1241 if (__probe_unregister(probelist[i],force,1)) {
1244 probelist[
i] = NULL;
1256 struct bsymbol *bsymbol,
ADDR symbol_addr) {
1257 struct probepoint *probepoint;
1259 struct target *target = probe->
target;
1266 verror(
"software watchpoints are unsupported!\n");
1274 verror(
"target not paused (%d)!\n",status);
1284 memset(&tloc,0,
sizeof(tloc));
1290 (!range) ? &range : NULL);
1296 RHOLD(bsymbol,probe);
1314 && type == probepoint->
type
1322 && type == probepoint->
type
1323 && style == probepoint->
style
1324 && whence == probepoint->
whence
1325 && watchsize == probepoint->
watchsize))) {
1326 verror(
"addr 0x%"PRIxADDR" already has a probepoint with different properties!\n",addr);
1333 if (!(probepoint = probepoint_create_break(target,addr,range,style,
1334 bsymbol,symbol_addr))) {
1343 if (!(probepoint = probepoint_create_watch(target,addr,range,
1344 style,whence,watchsize,
1345 bsymbol,symbol_addr))) {
1355 if (__probepoint_insert(probepoint,probe->
thread)) {
1358 probepoint_free(probepoint);
1366 verror(
"probe '%s': registered failed, aborting\n",probe->
name);
1368 probepoint_free(probepoint);
1373 probepoint_free(probepoint);
1398 struct bsymbol *bsymbol) {
1407 struct target *target = probe->
target;
1412 struct bsymbol *bsymbol = NULL;
1419 symbol = lsymbol_last_symbol(bsymbol->
lsymbol);
1426 verror(
"cannot probe a partial symbol!\n");
1436 &start,NULL,NULL,&alt_start,NULL)) {
1437 vwarn(
"could not resolve base addr for symbol %s!\n",
1454 verror(
"unknown symbol type '%s'!\n",
1474 struct target *target = probe->
target;
1486 symbol = lsymbol_last_symbol(bsymbol->
lsymbol);
1489 verror(
"cannot probe a partial symbol!\n");
1498 style,whence,watchsize);
1500 verror(
"could not register probe for symbol '%s' breakpoint!\n",
1511 &start,NULL,NULL,&alt_start,NULL)) {
1512 verror(
"could not resolve base addr for symbol %s!\n",
1517 probeaddr = alt_start;
1537 verror(
"bad size (%d) for type of %s!\n",
1545 memset(&tloc,0,
sizeof(tloc));
1556 verror(
"could not resolve base addr for var %s (loctype %s)!\n",
1575 verror(
"unknown symbol type '%s'!\n",
1594 struct target *target = src->
target;
1595 int held_src_bsymbol = 0;
1605 held_src_bsymbol = 1;
1622 verror(
"target not paused!\n");
1629 src->
sinks = g_list_prepend(src->
sinks,sink);
1632 verror(
"probe '%s': registered failed, aborting\n",sink->
name);
1638 verror(
"failed to enable sink probe '%s', aborting\n",sink->
name);
1645 if (held_src_bsymbol) {
1660 while ((tsrc = va_arg(ap,
struct probe *))) {
1662 verror(
"sink %s and src %s targets differ!\n",sink->
name,src->
name);
1672 while ((tsrc = va_arg(ap,
struct probe *))) {
1686 ADDR *addrlist,
int listlen,
1693 struct probe **probelist,
1694 int failureaction) {
1697 struct probe *
probe;
1707 verror(
"software watchpoints are unsupported!\n");
1715 verror(
"target not paused!\n");
1720 for (i = 0; i < listlen; ++
i) {
1722 if (addrlist[i] == 0)
1726 sprintf(buf,
"probe@%"PRIxADDR,addrlist[i]);
1727 probe =
probe_create(target,tid,NULL,buf,pre_handler,post_handler,
1731 type,style,whence,watchsize,
1733 if (failureaction == 2) {
1737 else if (failureaction == 1) {
1750 for (i = 0; i < listlen; ++
i) {
1751 if (addrlist[i] == 0)
1754 if (probelist[i] == NULL)
1762 __probe_unregister(probelist[i],0,1);
1775 #if __WORDSIZE == 64
1804 verror(
"probe '%s': disabled failed, ignoring\n",probe->
name);
1824 ptmp = (
struct probe *)list->data;
1830 list2 = ptmp->
sinks;
1832 if (((
struct probe *)(list->data))->enabled) {
1836 list2 = g_list_next(list2);
1842 list = g_list_next(list);
1853 verror(
"probe '%s': enabled failed, disabling!\n",probe->
name);
1870 ptmp = (
struct probe *)list->data;
1873 list = g_list_next(list);
1880 verror(
"probe '%s': enabled failed, disabling\n",probe->
name);
1885 ptmp = (
struct probe *)list->data;
1889 list2 = ptmp->
sinks;
1891 if (((
struct probe *)(list->data))->enabled) {
1895 list2 = g_list_next(list2);
1901 list = g_list_next(list);
1925 return g_list_length(probe->
sources);
1931 return g_list_length(probe->
sinks);
1987 static int run_post_handlers(
struct target *target,
1989 struct probepoint *probepoint);
1990 static int setup_post_single_step(
struct target *target,
1992 struct probepoint *probepoint);
1993 static int handle_simple_actions(
struct target *target,
1995 struct probepoint *probepoint);
1996 static int handle_complex_actions(
struct target *target,
1998 struct probepoint *probepoint);
2005 static int handle_simple_actions(
struct target *target,
2007 struct probepoint *probepoint) {
2009 struct action *taction;
2050 verror(
"BUG: unsupported action type %d -- not doing it!\n",
2058 action->
handler(action,tthread,action->
probe,probepoint,
2062 action->
handler(action,tthread,action->
probe,probepoint,
2067 action_finish_handling(action,NULL);
2075 static int setup_single_step_actions(
struct target *target,
2077 struct probepoint *probepoint,
2078 int isbp,
int stepping) {
2080 struct action *
action, *taction;
2115 verror(
"could not keep single stepping target!\n");
2128 verror(
"could not stop single stepping target"
2129 " after failed sstep!\n");
2139 action->
handler(action,tthread,action->
probe,probepoint,
2142 action_finish_handling(action,NULL);
2157 "already stepping; building tacs for single step actions for ");
2167 if (stepping == 1) {
2183 static int run_post_handlers(
struct target *target,
2185 struct probepoint *probepoint) {
2188 struct probe *
probe;
2211 else if (0 && probe->
sinks) {
2213 "running default probe sink post_handler at ");
2224 if (i > 1 && noreinject) {
2225 vwarn(
"cannot skip reinjection of breakpoint because multiple probes present!\n");
2233 struct probepoint *probepoint) {
2235 if (probepoint->
tpc == tthread->
tpc)
2236 probepoint->
tpc = NULL;
2241 struct probepoint *probepoint,
2244 && probepoint->
tpc != NULL
2246 return probepoint->
tpc;
2248 probepoint->
tpc = tpc;
2254 struct probepoint *probepoint,
2258 "pausing thread %"PRIiTID" (%d) until thread %"PRIiTID" finishes"
2270 struct probepoint *probepoint) {
2294 static int setup_post_single_step(
struct target *target,
2296 struct probepoint *probepoint) {
2298 struct probe *
probe;
2319 noreinject = run_post_handlers(target,tthread,probepoint);
2348 __probepoint_remove(probepoint,0,0);
2430 " handling it; target failed to ctl thread!\n",
2448 vwarn(
"could not pause the target for blocking thread"
2456 probepoint->
mmod)) {
2457 verror(
"could not disable breakpoint before singlestep;"
2458 " assuming breakpoint is left in place and"
2459 " skipping single step, but badness will ensue!");
2484 if (probepoint->
tpc == tthread->
tpc) {
2510 verror(
"could not single step target after BP!\n");
2513 verror(
"could not stop single stepping target"
2514 " after failed sstep for breakpoint!\n");
2526 probepoint->
mmod)) {
2527 verror(
"could not enable sw breakpoint after failed singlestep;"
2528 " assuming breakpoint is left in place and"
2529 " skipping single step, but badness will ensue!");
2595 struct probepoint *probepoint,
2597 struct probe *
probe;
2606 int already_ran_prehandlers_for_interrupted = 0;
2620 vwarn(
"existing thread probepoint same as bp probepoint;"
2621 " BUG or recursion due to action?\n");
2629 already_ran_prehandlers_for_interrupted = 1;
2648 if (action->
steps == -2
2654 action_finish_handling(action,tac);
2656 list_del(&tac->
tac);
2674 tpc = tpc_new(tthread,probepoint);
2679 "already handling %d probepoints in thread %d; most recent"
2726 if (!probepoint->
tpc) {
2727 verror(
"probepoint state is not BP_SET; BUG!\n");
2734 " handling it; target could not pause thread!\n",
2762 verror(
"could not read EIP to reset it for SW probepoint; skipping!");
2784 verror(
"could not reset EIP before pre handlers; skipping!\n");
2803 if (!already_ran_prehandlers_for_interrupted) {
2818 else if (0 && probe->
sinks) {
2820 "running default probe sink pre_handler at ");
2834 "already ran pre handlers in interrupted thread %"PRIiTID" at ",
2846 verror(
"could not reset EIP after pre handlers!\n");
2857 "ip 0x%"PRIxREGVAL" restored after pre handlers at ",ipval);
2868 if ((rc = handle_simple_actions(target,tthread,probepoint)))
2869 vwarn(
"failed to handle %d simple actions!\n",rc);
2915 if ((stepping = handle_complex_actions(target,tthread,probepoint)) < 0)
2916 vwarn(
"failed to handle %d complex actions!\n",rc);
2932 rc = setup_single_step_actions(target,tthread,probepoint,_isbp,stepping);
2948 rc = setup_post_single_step(target,tthread,probepoint);
2963 "thread %"PRIiTID" skipped orig instruction; clearing tpc!\n",
2970 rc = setup_single_step_actions(target,tthread,probepoint,1,0);
2988 rc = setup_single_step_actions(target,tthread,probepoint,1,1);
2999 "thread %"PRIiTID" blocked before single step; thread"
3000 " %"PRIiTID" owned probepoint -- BUG!!!\n",
3004 verror(
"could not setup single step; badness will probably ensue!\n");
3025 struct probepoint *probepoint) {
3030 int handled_ss_actions = 0;
3031 int keep_stepping = 0;
3035 struct probepoint *aprobepoint;
3063 handled_ss_actions = 1;
3090 action_finish_handling(action,tac);
3092 list_del(&tac->
tac);
3104 else if (!probepoint) {
3118 && probepoint->
tpc == tpc
3121 noreinject = run_post_handlers(target,tthread,probepoint);
3127 probepoint->
mmod)) {
3128 verror(
"could not enable sw breakpoint instrs for bp re-insert, disabling!\n");
3149 __probepoint_remove(probepoint,0,0);
3153 verror(
"could not stop single stepping target"
3154 " after failed sstep!\n");
3165 "thread %"PRIiTID" ran orig instruction; cleared tpc!\n",
3181 rc = handle_complex_actions(target,tthread,probepoint);
3206 rc = setup_post_single_step(target,tthread,probepoint);
3221 "thread %"PRIiTID" skipping orig instruction; clearing tpc!\n",
3244 "thread %"PRIiTID" blocked before single step real; thread"
3245 " %"PRIiTID" owned probepoint\n",
3250 verror(
"could not setup single step; badness will probably ensue!\n");
3263 else if (keep_stepping) {
3272 "continuing single step after probepoint\n");
3275 verror(
"could not keep single stepping target!\n");
3278 verror(
"could not stop single stepping target"
3279 " after failed sstep!\n");
3293 action_finish_handling(tac->
action,tac);
3295 list_del(&tac->
tac);
3315 "sstep command succeeded after probepoint\n");
3327 else if (!probepoint && !tpc && handled_ss_actions && !keep_stepping) {
3329 "finished single step actions after probepoint\n");
3332 verror(
"could not stop single stepping target after single step"
3333 " actions after probepoint!\n");
3336 verror(
"unexpected state! BUG?\n");
3361 struct probepoint *probepoint) {
3398 action_finish_handling(action,tac);
3400 list_del(&tac->
tac);
3413 if (probepoint->
tpc == tpc) {
3423 "finished %d steps; done and removing interrupted"
3435 action_finish_handling(action,tac);
3437 list_del(&tac->
tac);
3445 probepoint->
mmod)) {
3446 verror(
"could not enable sw breakpoint instrs for bp re-insert, disabling!\n");
3470 " cannot adjust probepoint state!!\n",
3475 verror(
"could not stop single stepping target"
3476 " after interrupted sstep!\n");
3492 "thread %"PRIiTID
" interrupted before running orig instruction;"
3506 struct probepoint *probepoint;
3518 return setup_post_single_step(target,tthread,tthread->
tpc->
probepoint);
3527 handle_complex_actions(target,tthread,probepoint);
3532 rc = setup_post_single_step(target,tthread,probepoint);
3547 "thread %"PRIiTID" skipping orig instruction; clearing tpc!\n",
3559 "thread %"PRIiTID" blocked before single step real; thread"
3560 " %"PRIiTID" owned probepoint\n",
3565 verror(
"could not setup single step; badness will probably ensue!\n");
3572 "continuing single step after probepoint\n");
3575 verror(
"could not keep single stepping target!\n");
3578 verror(
"could not stop single stepping target"
3579 " after failed sstep!\n");
3594 action_finish_handling(tac->
action,tac);
3596 list_del(&tac->
tac);
3616 "finished handling after resumeat\n");
3619 verror(
"could not stop single stepping target after single step"
3620 " actions after probepoint!\n");
3630 static int __remove_action(
struct target *target,
struct probepoint *probepoint,
3631 struct action *action) {
3641 probepoint->
mmod)) {
3642 verror(
"could not remove action code at the breakpoint;"
3643 " badness will probably ensue!\n");
3646 probepoint->
mmod)) {
3647 verror(
"could not reenable the breakpoint;"
3648 " badness will probably ensue!\n");
3652 else if (probepoint->
mmod) {
3654 probepoint->
mmod) < 0) {
3655 verror(
"could not remove action code at HW breakpoint;"
3656 " badness will probably ensue!\n");
3660 probepoint->
mmod = NULL;
3669 static int __insert_action(
struct target *target,
struct target_thread *tthread,
3670 struct probepoint *probepoint,
struct action *action) {
3671 unsigned int buflen;
3677 verror(
"could not set EIP to action's first instruction (0x%"PRIxADDR")!\n",
3698 if (action->
detail.
ret.prologue_uses_bp) {
3700 "setting ESP to EBP and returning (prologue uses EBP) at ");
3707 verror(
"read EBP failed; action failed!\n");
3712 verror(
"set ESP to EBP failed; action failed and badness will ensue!\n");
3722 "undoing prologue ESP changes (%d) and returning at ",
3730 verror(
"read ESP failed; action failed!\n");
3736 verror(
"undoing prologue ESP changes failed; action failed!\n");
3756 verror(
"cannot handle unknown action type %d!\n",action->
type);
3762 probepoint->
mmod,buf,buflen)) {
3763 verror(
"could not insert action code; action failed!\n");
3768 if (!probepoint->
mmod) {
3772 if (!probepoint->
mmod) {
3773 verror(
"could not create memmod for HW breakpoint code"
3779 verror(
"could not create memmod for HW breakpoint code"
3791 struct action *current) {
3794 if (list_empty(head))
3827 static int handle_complex_actions(
struct target *target,
3829 struct probepoint *probepoint) {
3830 struct action *
action,*nextaction = NULL;
3852 if (probepoint->
tpc == tpc
3855 "resetting actions state after bp hit at ");
3889 "did %d steps; still more at ",tpc->
tac.
stepped);
3894 action->
handler(action,tthread,action->
probe,probepoint,
3900 "finished %d steps; done and removing action at ",
3909 action->
handler(action,tthread,action->
probe,probepoint,
3913 __remove_action(target,probepoint,action);
3916 verror(
"could not stop single stepping target"
3917 " after single stepped action!\n");
3922 action_finish_handling(action,&tpc->
tac);
3924 action = nextaction;
3938 vwarn(
"unexpected single step!\n");
3964 " handling it; target does not support thread ctl!\n",
3983 && (action->
steps > 1
3987 vwarn(
"could not pause the target for blocking thread"
4005 __insert_action(target,tthread,probepoint,nextaction);
4011 action = nextaction;
4038 verror(
"could not keep single stepping target!\n");
4051 verror(
"could not stop single stepping target"
4052 " after failed sstep!\n");
4066 action_finish_handling(action,tac);
4068 list_del(&tac->
tac);
4123 unsigned char *
code;
4124 unsigned int code_len = 0;
4125 struct probepoint *probepoint;
4126 struct target *target;
4131 if (action->
probe != NULL) {
4132 verror(
"action already associated with probe!\n");
4138 verror(
"probe not attached to a probepoint!\n");
4144 verror(
"unknown whence %d for action\n",whence);
4150 target = probepoint->
target;
4169 verror(
"probepoint already has return action\n");
4173 verror(
"probepoint already has customcode action\n");
4182 vwarn(
"probepoint symbol addr < probepoint addr -- bad\n");
4194 code = (
unsigned char *)
malloc(code_len);
4195 memset(code,0,code_len);
4199 vwarn(
"could not read prologue code; skipping disasm!\n");
4218 action->
detail.
ret.prologue_uses_bp = 1;
4220 &idata_list,1) == 0) {
4221 for (i = 0; i < array_list_len(idata_list); ++
i) {
4223 array_list_item(idata_list,i);
4224 if (idata->
type == 0x55) {
4225 action->
detail.
ret.prologue_uses_bp = 1;
4230 array_list_deep_free(idata_list);
4234 "could not disassemble code in range"
4236 " for function %s!\n",
4241 if (action->
detail.
ret.prologue_uses_bp) {
4243 "function %s: pushes EBP (can leave; ret)\n",
4246 #ifdef ENABLE_DISTORM
4252 &action->
detail.
ret.prologue_sp_offset)) {
4253 verror(
"could not disassemble function prologue"
4254 " to track stack growth for return action!\n");
4257 action->
detail.
ret.prologue_has_sp_offset = 1;
4260 "disassembled prologue for function %s: sp moved %d\n",
4266 verror(
"disasm support disabled; cannot check prologue"
4267 " to unwind stack frame function %s!\n",
4286 verror(
"cannot do return on strict target without threadctl!\n");
4295 if (action->
detail.
ret.prologue_has_sp_offset) {
4297 "cannot use multi-instr full return; but can use SP"
4298 " adjustment and single-instr return\n");
4300 action->
detail.
ret.prologue_uses_bp = 0;
4303 verror(
"cannot do non-boosted, multi-instruction return"
4304 " on strict target without threadctl!\n");
4339 verror(
"probepoint already has return action\n");
4343 verror(
"probepoint already has customcode action\n");
4353 verror(
"cannot do return on strict target without threadctl!\n");
4369 action->
probe = probe;
4373 RHOLD(action,probe);
4416 if (!action->
probe) {
4417 verror(
"cannot cancel action not associated with a probe!\n");
4444 list_del(&action->
action);
4445 action->
probe = NULL;
4460 action = (
struct action *)
calloc(1,
sizeof(
struct action));
4462 verror(
"could not malloc action: %s\n",strerror(errno));
4474 RHOLD(action,action);
4492 action = (
struct action *)
calloc(1,
sizeof(
struct action));
4494 verror(
"could not malloc action: %s\n",strerror(errno));
4502 action->
steps = nsteps;
4504 RHOLD(action,action);
4512 action = (
struct action *)
calloc(1,
sizeof(
struct action));
4514 verror(
"could not malloc action: %s\n",strerror(errno));
4527 RHOLD(action,action);
4535 action = (
struct action *)
calloc(1,
sizeof(
struct action));
4537 verror(
"could not malloc action: %s\n",strerror(errno));
4548 RHOLD(action,action);
4556 action = (
struct action *)
calloc(1,
sizeof(
struct action));
4558 verror(
"could not malloc action: %s\n",strerror(errno));
4571 RHOLD(action,action);
4578 RPUT(action,action,action,refcnt);
4582 static void action_finish_handling(
struct action *action,
4591 RPUT(action,action,tac,trefcnt);
4601 int retval = action->
refcnt;
4603 if (action->
probe) {
4605 verror(
"could not cancel action; cannot destroy!\n");
4612 vwarn(
"cannot free action (%d refs)!\n",retval);
4616 verror(
"forced free action (%d refs)\n",retval);
#define LOGDUMPPROBEPOINT(dl, la, lt, pp)
#define LOCATION_ADDR(loc)
unsigned int ret_instrs_len
tid_t probe_tid(struct probe *probe)
struct action * action_return(REGVAL retval)
#define vwarnopt(level, area, flags, format,...)
result_t pre_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
int target_change_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod, unsigned char *code, unsigned long code_len)
int disasm_generic(struct target *target, unsigned char *inst_buf, unsigned int buf_len, struct array_list **idata_list_saveptr, int noabort)
int probe_unregister(struct probe *probe, int force)
struct bsymbol * target_lookup_sym_line(struct target *target, char *filename, int line, SMOFFSET *offset, ADDR *addr)
int probe_unregister_source(struct probe *sink, struct probe *src, int force)
probepoint_style_t probe_style(struct probe *probe)
#define PROBE_SAFE_OP(probe, op)
probe_handler_t pre_handler
int probe_unregister_batch(struct target *target, struct probe **probelist, int listlen, int force)
REFCNT action_free(struct action *action, int force)
int target_insert_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
result_t probepoint_ss_handler(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
#define SINGLESTEP_INFINITE
struct probe * __probe_register_addr(struct probe *probe, ADDR addr, struct memrange *range, probepoint_type_t type, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize, struct bsymbol *bsymbol, ADDR symbol_addr)
struct bsymbol * probe_symbol(struct probe *probe)
int target_detach_probe(struct target *target, struct probe *probe)
int target_lsymbol_resolve_bounds(struct target *target, struct target_location_ctxt *tlctxt, struct lsymbol *lsymbol, ADDR base_addr, ADDR *start, ADDR *end, int *is_noncontiguous, ADDR *alt_start, ADDR *alt_end)
int target_set_hw_watchpoint(struct target *target, tid_t tid, REG reg, ADDR addr, probepoint_whence_t whence, int watchsize)
struct target_nv_filter * post_filter
static uint64_t unsigned int i
struct target_thread * thread
int target_remove_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
REFCNT action_release(struct action *action)
struct probepoint * target_lookup_probepoint(struct target *target, struct target_thread *tthread, ADDR addr)
void location_internal_free(struct location *location)
struct target_location_ctxt * target_location_ctxt_create_from_bsymbol(struct target *target, tid_t tid, struct bsymbol *bsymbol)
int probe_is_base(struct probe *probe)
#define SYMBOL_IS_FULL(sym)
int target_pause(struct target *target)
struct target_memmod * target_memmod_create(struct target *target, tid_t tid, ADDR addr, int is_phys, target_memmod_type_t mmt, unsigned char *code, unsigned int code_len, int nowrite)
struct action * __get_next_complex_action(struct probepoint *probepoint, struct action *current)
result_t probe_do_sink_post_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
char * bsymbol_get_name(struct bsymbol *bsymbol)
int target_unchange_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
int probe_register_batch(struct target *target, tid_t tid, ADDR *addrlist, int listlen, 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)
int target_remove_probepoint(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
int target_detach_action(struct target *target, struct action *action)
#define verror(format,...)
struct target_memmod * mmod
result_t probe_do_sink_pre_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
unsigned char * target_read_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
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)
int target_singlestep(struct target *target, tid_t tid, int isbp)
struct symbol * symbol_get_datatype(struct symbol *symbol)
int target_find_memory_real(struct target *target, ADDR addr, struct addrspace **space_saveptr, struct memregion **region_saveptr, struct memrange **range_saveptr)
int target_is_open(struct target *target)
struct action * action_memmod(ADDR dest, char *data, uint32_t len)
void probepoint_free_ext(struct probepoint *probepoint)
result_t(* probe_handler_t)(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
struct list_head ss_actions
probepoint_whence_t probe_whence(struct probe *probe)
void *(* summarize_tid)(struct probe *probe, tid_t tid)
int probe_unregister_one(struct probe *probe, int force)
#define vwarn(format,...)
struct target_thread * thread
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
result_t probepoint_bp_handler(struct target *target, struct target_thread *tthread, struct probepoint *probepoint, int was_stepping)
ADDR probe_addr(struct probe *probe)
#define LOGDUMPPROBE(dl, la, lt, p)
REG target_get_unused_debug_reg(struct target *target, tid_t tid)
#define SYMBOL_IS_LABEL(sym)
int(* instr_can_switch_context)(struct target *target, ADDR addr)
int target_singlestep_end(struct target *target, tid_t tid)
struct probe * probe_register_source(struct probe *sink, struct probe *src)
char * lsymbol_get_name(struct lsymbol *lsymbol)
#define list_for_each_entry(pos, head, member)
probepoint_watchsize_t probepoint_closest_watchsize(int size)
struct action * action_regmod(REG regnum, REGVAL regval)
struct probepoint * interrupted_ss_probepoint
int probe_unregister_source_one(struct probe *sink, struct probe *src, int force)
REFCNT bsymbol_release(struct bsymbol *bsymbol)
struct action::@17::@21 memmod
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)
int probe_hard_enable(struct probe *probe)
int target_enable_hw_breakpoint(struct target *target, tid_t tid, REG dreg)
int probe_free(struct probe *probe, int force)
int probe_disable_one(struct probe *probe)
struct action::@17::@19 code
void * probe_summarize_tid(struct probe *probe, tid_t tid)
void * probe_priv(struct probe *probe)
#define SYMBOL_IS_BLOCK(sym)
struct list_head complex_actions
#define LOGDUMPPROBE_NL(dl, la, lt, p)
struct action * action_singlestep(int nsteps)
struct action::@17::@20 regmod
probepoint_type_t probe_type(struct probe *probe)
#define LOGDUMPPROBEPOINT_NL(dl, la, lt, p)
int probe_enable(struct probe *probe)
#define PROBE_SAFE_OP_ARGS(probe, op,...)
int probe_num_sources(struct probe *probe)
void * probe_summarize(struct probe *probe)
struct thread_action_context tac
int probe_enable_one(struct probe *probe)
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)
struct target * probe_target(struct probe *probe)
struct target_thread * thread
struct array_list * tpc_stack
int target_attach_probe(struct target *target, struct target_thread *thread, struct probe *probe)
#define vdebug(devel, areas, flags, format,...)
unsigned int full_ret_instrs_len
struct thread_probepoint_context * tpc
struct thread_probepoint_context * tpc
#define vdebugc(devel, areas, flags, format,...)
result_t probepoint_resumeat_handler(struct target *target, struct target_thread *tthread)
struct target_nv_filter * pre_filter
void * calloc(size_t nmemb, size_t size)
result_t post_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
#define list_for_each_entry_safe(pos, n, head, member)
int probe_disable(struct probe *probe)
void *(* summarize)(struct probe *probe)
struct action * action_code(char *buf, uint32_t buflen, action_flag_t flags)
int action_cancel(struct action *action)
struct list_head ss_actions
int target_memmod_release(struct target *target, tid_t tid, struct target_memmod *mmod)
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)
int target_attach_action(struct target *target, struct action *action)
unsigned int symbol_type_full_bytesize(struct symbol *type)
target_status_t target_status(struct target *target)
int target_disable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
int target_disable_hw_breakpoint(struct target *target, tid_t tid, REG dreg)
unsigned int breakpoint_instrs_len
void target_nv_filter_free(struct target_nv_filter *pf)
void probepoint_release(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
struct target_memmod * target_insert_sw_breakpoint(struct target *target, tid_t tid, ADDR addr)
void tpc_free(struct thread_probepoint_context *tpc)
struct thread_probepoint_context * probepoint_hold(struct target *target, struct target_thread *tthread, struct probepoint *probepoint, struct thread_probepoint_context *tpc)
int target_unset_hw_breakpoint(struct target *target, tid_t tid, REG reg)
uint8_t * full_ret_instrs
probepoint_watchsize_t watchsize
void target_location_ctxt_free(struct target_location_ctxt *tlctxt)
#define list_entry(ptr, type, member)
char * SYMBOL_TYPE(int n)
struct target_spec * spec
int probe_filter_check(struct probe *probe, tid_t tid, struct probe *trigger, int whence)
int probe_enabled(struct probe *probe)
struct probe * probe_register_sources(struct probe *sink, struct probe *src,...)
uint32_t nodisablehwbponss
int disasm_get_prologue_stack_size(struct target *target, unsigned char *inst_buf, unsigned int buf_len, int *sp)
struct probe * probe_register_line(struct probe *probe, char *filename, int line, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
#define RPUT(x, objtype, hx, rc)
int target_set_hw_breakpoint(struct target *target, tid_t tid, REG reg, ADDR addr)
void * malloc(size_t size)
void probe_rename(struct probe *probe, const char *name)
struct action::@17::@18 ret
struct list_head simple_actions
struct target_thread * target_lookup_thread(struct target *target, tid_t tid)
unsigned long target_write_addr(struct target *target, ADDR addr, unsigned long length, unsigned char *buf)
struct target_thread * blocking_thread
char * probe_name(struct probe *probe)
result_t probepoint_interrupted_ss_handler(struct target *target, struct target_thread *tthread, struct probepoint *probepoint)
struct probe * probe_register_symbol(struct probe *probe, struct bsymbol *bsymbol, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
#define INIT_LIST_HEAD(ptr)
int target_enable_sw_breakpoint(struct target *target, tid_t tid, struct target_memmod *mmod)
#define SYMBOL_IS_FUNC(sym)
int target_unset_hw_watchpoint(struct target *target, tid_t tid, REG reg)
int probepoint_pause_handling(struct target *target, struct target_thread *tthread, struct probepoint *probepoint, thread_resumeat_t resumeat)
probepoint_style_t orig_style
int action_sched(struct probe *probe, struct action *action, action_whence_t whence, action_handler_t handler, void *handler_data)
int target_write_reg(struct target *target, tid_t tid, REG reg, REGVAL value)
probe_handler_t post_handler
#define SYMBOL_IS_VAR(sym)
struct probepoint * probepoint
loctype_t target_lsymbol_resolve_location(struct target *target, struct target_location_ctxt *tlctxt, struct lsymbol *lsymbol, ADDR base_addr, load_flags_t flags, struct location *o_loc, struct symbol **o_datatype, struct memrange **o_range)
#define SINGLESTEP_NEXTBP
struct probepoint * probepoint
unsigned int full_ret_instr_count
int probe_hard_disable(struct probe *probe, int force)
probepoint_whence_t whence
int probe_num_sinks(struct probe *probe)
unsigned int ret_instr_count