/** * Debugger callback that handles events that are necessary for profiling. **/ int debuggerCallback(void *user_data, int notification_code, va_list va) { UserData* userData = (UserData*)user_data; IdaFile file; Debugger debugger = file.getDebugger(); if (notification_code == Debugger::EVENT_BREAKPOINT) { // Get the Thread ID thread_id_t tid = va_arg(va, thread_id_t); // Get the address of where the breakpoint was hit ea_t addr = va_arg(va, ea_t); _timeb timebuffer; _ftime64_s( &timebuffer ); userData->getEventList().addEvent(Event(addr, timebuffer)); debugger.resumeProcess(true); } else if (notification_code == Debugger::EVENT_PROCESS_SUSPENDED) { setBreakpoints(); msg("Resuming target process...\n"); debugger.resumeProcess(true); } else if (notification_code == Debugger::EVENT_PROCESS_EXIT) { handleExitProcess(userData); } return 0; }
void MetaInfo::load( KConfig * conf ) { setBookmarks( conf->readIntListEntry("Bookmarks") ); setBreakpoints( conf->readIntListEntry("Breakpoints") ); m_outputMethodInfo.setMethod( toMethod( conf->readEntry("OutputMethod") ) ); m_outputMethodInfo.setOutputFile( conf->readPathEntry("OutputPath") ); m_outputMethodInfo.setPicID( conf->readEntry("OutputPicID") ); setCursorLine( conf->readNumEntry( "CursorLine", 0 ) ); setCursorColumn( conf->readNumEntry( "CursorColumn", 0 ) ); }
void IDAP_run(int) { IdaFile file; msg("Starting to profile %s\n", file.getName().c_str()); Debugger debugger = file.getDebugger(); debugger.addEventCallback(&debuggerCallback, new UserData); if (debugger.isActive() && !debugger.isSuspended()) { // If the target process is already running, suspend it to set the breakpoints msg("Suspending the target process...\n"); debugger.suspendProcess(true); } else if (debugger.isActive() && debugger.isSuspended()) { // If the target is already suspended, set the breakpoints and resume the process. setBreakpoints(); debugger.resumeProcess(true); } else { // If the debugger is not yet running, set the breakpoints and start the process. setBreakpoints(); msg("Starting target process\n"); debugger.startProcess(file.getInputfilePath(), "", ""); } }