static struct gdb_exception run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) { volatile struct gdb_exception e; int saved_in_infcall = call_thread->control.in_infcall; ptid_t call_thread_ptid = call_thread->ptid; call_thread->control.in_infcall = 1; clear_proceed_status (); disable_watchpoints_before_interactive_call_start (); /* We want stop_registers, please... */ call_thread->control.proceed_to_finish = 1; TRY_CATCH (e, RETURN_MASK_ALL) { proceed (real_pc, TARGET_SIGNAL_0, 0); /* Inferior function calls are always synchronous, even if the target supports asynchronous execution. Do here what `proceed' itself does in sync mode. */ if (target_can_async_p () && is_running (inferior_ptid)) { wait_for_inferior (); normal_stop (); } }
static struct gdb_exception run_inferior_call (struct thread_info *call_thread, CORE_ADDR real_pc) { volatile struct gdb_exception e; int saved_in_infcall = call_thread->control.in_infcall; ptid_t call_thread_ptid = call_thread->ptid; int saved_sync_execution = sync_execution; /* Infcalls run synchronously, in the foreground. */ if (target_can_async_p ()) sync_execution = 1; call_thread->control.in_infcall = 1; clear_proceed_status (); disable_watchpoints_before_interactive_call_start (); /* We want stop_registers, please... */ call_thread->control.proceed_to_finish = 1; TRY_CATCH (e, RETURN_MASK_ALL) { int was_sync = sync_execution; proceed (real_pc, GDB_SIGNAL_0, 0); /* Inferior function calls are always synchronous, even if the target supports asynchronous execution. Do here what `proceed' itself does in sync mode. */ if (target_can_async_p ()) { wait_for_inferior (); normal_stop (); /* If GDB was previously in sync execution mode, then ensure that it remains so. normal_stop calls async_enable_stdin, so reset it again here. In other cases, stdin will be re-enabled by inferior_event_handler, when an exception is thrown. */ if (was_sync) async_disable_stdin (); } }
void BE_hook_kill(BE_hook * hook) { if (!hook) return; BE_hook_disable(hook); if (hook->event->type == BE_EVENT_B) { //remove breakpoint //TODO What happens if there is more than one event for this breakpoint?? //interrupt and delete breakpoint execute_command("interrupt",0); wait_for_inferior(); normal_stop(); char arg[15]; sprintf(arg, "%d", hook->event->edata.b.bp_id); delete_command(arg,0); //continue continue_command_JG(); } }
void BE_update_callgraph() { printf("\nUpdate Call Graph!\n"); execute_command("interrupt",0); wait_for_inferior(); normal_stop(); struct ME_CG * stack; BE_get_call_stack_as_CG(NULL, 0, 0, 1, &stack, the_context.FT); continue_command_JG(); if (!the_context.CG) { the_context.CG = stack; } else { ME_CG_merge_stack(the_context.CG,stack); ME_CG_delete(stack); } ME_CG_print(the_context.CG,the_context.FT); //execute_command("detach",1); }
/*============================================================*/ void BE_hook_array_handle(int breaked, char * filename, int line, int bp_id) { //check event_t int i = 0; for (i=0; i<the_context.hook_array.count;i++) { BE_hook * curr = BE_hook_array_get(i); clock_t t = clock(); if (curr->enabled) { switch (curr->event->type) { case BE_EVENT_T: if (t >= curr->event->edata.t.start + curr->event->edata.t.delay) { //stop if not stopped if (!the_context.stopped) { //Abstract this away execute_command("interrupt",0); wait_for_inferior(); normal_stop(); BE_get_file_and_line(get_selected_frame(NULL), &filename, &line); //put these in the BEC the_context.stopped = true; //continue_command_JG(); } BE_hook_handle(curr); if (curr->event->repeat) { curr->event->edata.t.start = t; } else { curr->enabled = false; } } break; case BE_EVENT_B: break; } } } //check event_b for (i=0; i<the_context.hook_array.count;i++) { BE_hook * curr = BE_hook_array_get(i); if (curr->enabled) { switch (curr->event->type) { case BE_EVENT_T: break; case BE_EVENT_B: if (breaked) { if (bp_id == curr->event->edata.b.bp_id) { printf("At the breakpoint for this event!\n"); BE_hook_handle(curr); printf("Event handled\n"); if (!curr->event->repeat) { char arg[15]; sprintf(arg, "%d", curr->event->edata.b.bp_id); delete_command(arg,0); curr->enabled = 0; } } } } } } }