38 static void action_finish_handling(
struct action *
action,
49 void *handler_data,
struct probe *trigger,
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)
1725 buf = malloc(5+1+16+1);
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) {
2272 calloc(1,
sizeof(*tpc));
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 ",
2845 verror(
"could not reset EIP after pre handlers!\n");
2855 "ip 0x%"PRIxREGVAL" restored after pre handlers at ",ipval);
2866 if ((rc = handle_simple_actions(target,tthread,probepoint)))
2867 vwarn(
"failed to handle %d simple actions!\n",rc);
2913 if ((stepping = handle_complex_actions(target,tthread,probepoint)) < 0)
2914 vwarn(
"failed to handle %d complex actions!\n",rc);
2930 rc = setup_single_step_actions(target,tthread,probepoint,_isbp,stepping);
2946 rc = setup_post_single_step(target,tthread,probepoint);
2961 "thread %"PRIiTID" skipped orig instruction; clearing tpc!\n",
2968 rc = setup_single_step_actions(target,tthread,probepoint,1,0);
2986 rc = setup_single_step_actions(target,tthread,probepoint,1,1);
2997 "thread %"PRIiTID" blocked before single step; thread"
2998 " %"PRIiTID" owned probepoint -- BUG!!!\n",
3002 verror(
"could not setup single step; badness will probably ensue!\n");
3023 struct probepoint *probepoint) {
3028 int handled_ss_actions = 0;
3029 int keep_stepping = 0;
3033 struct probepoint *aprobepoint;
3061 handled_ss_actions = 1;
3088 action_finish_handling(action,tac);
3090 list_del(&tac->
tac);
3102 else if (!probepoint) {
3116 && probepoint->
tpc == tpc
3119 noreinject = run_post_handlers(target,tthread,probepoint);
3125 probepoint->
mmod)) {
3126 verror(
"could not enable sw breakpoint instrs for bp re-insert, disabling!\n");
3147 __probepoint_remove(probepoint,0,0);
3151 verror(
"could not stop single stepping target"
3152 " after failed sstep!\n");
3163 "thread %"PRIiTID" ran orig instruction; cleared tpc!\n",
3179 rc = handle_complex_actions(target,tthread,probepoint);
3204 rc = setup_post_single_step(target,tthread,probepoint);
3219 "thread %"PRIiTID" skipping orig instruction; clearing tpc!\n",
3242 "thread %"PRIiTID" blocked before single step real; thread"
3243 " %"PRIiTID" owned probepoint\n",
3248 verror(
"could not setup single step; badness will probably ensue!\n");
3261 else if (keep_stepping) {
3270 "continuing single step after probepoint\n");
3273 verror(
"could not keep single stepping target!\n");
3276 verror(
"could not stop single stepping target"
3277 " after failed sstep!\n");
3291 action_finish_handling(tac->
action,tac);
3293 list_del(&tac->
tac);
3313 "sstep command succeeded after probepoint\n");
3325 else if (!probepoint && !tpc && handled_ss_actions && !keep_stepping) {
3327 "finished single step actions after probepoint\n");
3330 verror(
"could not stop single stepping target after single step"
3331 " actions after probepoint!\n");
3334 verror(
"unexpected state! BUG?\n");
3359 struct probepoint *probepoint) {
3396 action_finish_handling(action,tac);
3398 list_del(&tac->
tac);
3411 if (probepoint->
tpc == tpc) {
3421 "finished %d steps; done and removing interrupted"
3433 action_finish_handling(action,tac);
3435 list_del(&tac->
tac);
3443 probepoint->
mmod)) {
3444 verror(
"could not enable sw breakpoint instrs for bp re-insert, disabling!\n");
3468 " cannot adjust probepoint state!!\n",
3473 verror(
"could not stop single stepping target"
3474 " after interrupted sstep!\n");
3490 "thread %"PRIiTID
" interrupted before running orig instruction;"
3504 struct probepoint *probepoint;
3516 return setup_post_single_step(target,tthread,tthread->
tpc->
probepoint);
3525 handle_complex_actions(target,tthread,probepoint);
3530 rc = setup_post_single_step(target,tthread,probepoint);
3545 "thread %"PRIiTID" skipping orig instruction; clearing tpc!\n",
3557 "thread %"PRIiTID" blocked before single step real; thread"
3558 " %"PRIiTID" owned probepoint\n",
3563 verror(
"could not setup single step; badness will probably ensue!\n");
3570 "continuing single step after probepoint\n");
3573 verror(
"could not keep single stepping target!\n");
3576 verror(
"could not stop single stepping target"
3577 " after failed sstep!\n");
3592 action_finish_handling(tac->
action,tac);
3594 list_del(&tac->
tac);
3614 "finished handling after resumeat\n");
3617 verror(
"could not stop single stepping target after single step"
3618 " actions after probepoint!\n");
3628 static int __remove_action(
struct target *target,
struct probepoint *probepoint,
3629 struct action *action) {
3639 probepoint->
mmod)) {
3640 verror(
"could not remove action code at the breakpoint;"
3641 " badness will probably ensue!\n");
3644 probepoint->
mmod)) {
3645 verror(
"could not reenable the breakpoint;"
3646 " badness will probably ensue!\n");
3650 else if (probepoint->
mmod) {
3652 probepoint->
mmod) < 0) {
3653 verror(
"could not remove action code at HW breakpoint;"
3654 " badness will probably ensue!\n");
3658 probepoint->
mmod = NULL;
3667 static int __insert_action(
struct target *target,
struct target_thread *tthread,
3668 struct probepoint *probepoint,
struct action *action) {
3669 unsigned int buflen;
3675 verror(
"could not set EIP to action's first instruction (0x%"PRIxADDR")!\n",
3696 if (action->
detail.
ret.prologue_uses_bp) {
3698 "setting ESP to EBP and returning (prologue uses EBP) at ");
3705 verror(
"read EBP failed; action failed!\n");
3710 verror(
"set ESP to EBP failed; action failed and badness will ensue!\n");
3720 "undoing prologue ESP changes (%d) and returning at ",
3728 verror(
"read ESP failed; action failed!\n");
3734 verror(
"undoing prologue ESP changes failed; action failed!\n");
3754 verror(
"cannot handle unknown action type %d!\n",action->
type);
3760 probepoint->
mmod,buf,buflen)) {
3761 verror(
"could not insert action code; action failed!\n");
3766 if (!probepoint->
mmod) {
3770 if (!probepoint->
mmod) {
3771 verror(
"could not create memmod for HW breakpoint code"
3777 verror(
"could not create memmod for HW breakpoint code"
3789 struct action *current) {
3792 if (list_empty(head))
3825 static int handle_complex_actions(
struct target *target,
3827 struct probepoint *probepoint) {
3828 struct action *
action,*nextaction = NULL;
3850 if (probepoint->
tpc == tpc
3853 "resetting actions state after bp hit at ");
3887 "did %d steps; still more at ",tpc->
tac.
stepped);
3892 action->
handler(action,tthread,action->
probe,probepoint,
3898 "finished %d steps; done and removing action at ",
3907 action->
handler(action,tthread,action->
probe,probepoint,
3911 __remove_action(target,probepoint,action);
3914 verror(
"could not stop single stepping target"
3915 " after single stepped action!\n");
3920 action_finish_handling(action,&tpc->
tac);
3922 action = nextaction;
3936 vwarn(
"unexpected single step!\n");
3962 " handling it; target does not support thread ctl!\n",
3981 && (action->
steps > 1
3985 vwarn(
"could not pause the target for blocking thread"
4003 __insert_action(target,tthread,probepoint,nextaction);
4009 action = nextaction;
4036 verror(
"could not keep single stepping target!\n");
4049 verror(
"could not stop single stepping target"
4050 " after failed sstep!\n");
4064 action_finish_handling(action,tac);
4066 list_del(&tac->
tac);
4121 unsigned char *
code;
4122 unsigned int code_len = 0;
4123 struct probepoint *probepoint;
4124 struct target *target;
4129 if (action->
probe != NULL) {
4130 verror(
"action already associated with probe!\n");
4136 verror(
"probe not attached to a probepoint!\n");
4142 verror(
"unknown whence %d for action\n",whence);
4148 target = probepoint->
target;
4167 verror(
"probepoint already has return action\n");
4171 verror(
"probepoint already has customcode action\n");
4180 vwarn(
"probepoint symbol addr < probepoint addr -- bad\n");
4192 code = (
unsigned char *)malloc(code_len);
4193 memset(code,0,code_len);
4197 vwarn(
"could not read prologue code; skipping disasm!\n");
4216 action->
detail.
ret.prologue_uses_bp = 1;
4218 &idata_list,1) == 0) {
4219 for (i = 0; i < array_list_len(idata_list); ++i) {
4221 array_list_item(idata_list,i);
4222 if (idata->
type == 0x55) {
4223 action->
detail.
ret.prologue_uses_bp = 1;
4228 array_list_deep_free(idata_list);
4232 "could not disassemble code in range"
4234 " for function %s!\n",
4239 if (action->
detail.
ret.prologue_uses_bp) {
4241 "function %s: pushes EBP (can leave; ret)\n",
4244 #ifdef ENABLE_DISTORM
4250 &action->
detail.
ret.prologue_sp_offset)) {
4251 verror(
"could not disassemble function prologue"
4252 " to track stack growth for return action!\n");
4255 action->
detail.
ret.prologue_has_sp_offset = 1;
4258 "disassembled prologue for function %s: sp moved %d\n",
4264 verror(
"disasm support disabled; cannot check prologue"
4265 " to unwind stack frame function %s!\n",
4284 verror(
"cannot do return on strict target without threadctl!\n");
4293 if (action->
detail.
ret.prologue_has_sp_offset) {
4295 "cannot use multi-instr full return; but can use SP"
4296 " adjustment and single-instr return\n");
4298 action->
detail.
ret.prologue_uses_bp = 0;
4301 verror(
"cannot do non-boosted, multi-instruction return"
4302 " on strict target without threadctl!\n");
4337 verror(
"probepoint already has return action\n");
4341 verror(
"probepoint already has customcode action\n");
4351 verror(
"cannot do return on strict target without threadctl!\n");
4367 action->
probe = probe;
4371 RHOLD(action,probe);
4414 if (!action->
probe) {
4415 verror(
"cannot cancel action not associated with a probe!\n");
4442 list_del(&action->
action);
4443 action->
probe = NULL;
4458 action = (
struct action *)calloc(1,
sizeof(
struct action));
4460 verror(
"could not malloc action: %s\n",strerror(errno));
4472 RHOLD(action,action);
4490 action = (
struct action *)calloc(1,
sizeof(
struct action));
4492 verror(
"could not malloc action: %s\n",strerror(errno));
4500 action->
steps = nsteps;
4502 RHOLD(action,action);
4510 action = (
struct action *)calloc(1,
sizeof(
struct action));
4512 verror(
"could not malloc action: %s\n",strerror(errno));
4525 RHOLD(action,action);
4533 action = (
struct action *)calloc(1,
sizeof(
struct action));
4535 verror(
"could not malloc action: %s\n",strerror(errno));
4546 RHOLD(action,action);
4554 action = (
struct action *)calloc(1,
sizeof(
struct action));
4556 verror(
"could not malloc action: %s\n",strerror(errno));
4569 RHOLD(action,action);
4576 RPUT(action,action,action,refcnt);
4580 static void action_finish_handling(
struct action *action,
4589 RPUT(action,action,tac,trefcnt);
4599 int retval = action->
refcnt;
4601 if (action->
probe) {
4603 verror(
"could not cancel action; cannot destroy!\n");
4610 vwarn(
"cannot free action (%d refs)!\n",retval);
4614 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
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
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 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