VOID check_unpacked_cb(VOID * ip, const CONTEXT *ctxt, THREADID tid) { // we clear the current instruction map write_address.clear(); cerr << "Layer unpacked: " << ip << endl; PIN_ApplicationBreakpoint(ctxt, tid, false, "Layer unpacked!"); }
static void DoBreakpoint(CONTEXT *ctxt, THREADID tid) { if (IsFirstBreakpoint) { IsFirstBreakpoint = FALSE; PIN_ApplicationBreakpoint(ctxt, tid, KnobWaitForDebugger.Value(), "The tool wants to stop"); } }
static void DoBreakpoint(CONTEXT *ctxt, THREADID tid) { if (IsFirstBreakpoint) { std::cout << "Tool stopping at breakpoint" << std::endl; IsFirstBreakpoint = FALSE; PIN_ApplicationBreakpoint(ctxt, tid, KnobWaitForDebugger.Value(), "The tool wants to stop"); } }
//-------------------------------------------------------------------------- VOID check_unpacked_cb(VOID * ip, const CONTEXT *ctxt, THREADID tid) { ADDRINT ea = (ADDRINT)ip; addrdeq_t::iterator it = std::find(write_address.begin(), write_address.end(), ea); if ( it != write_address.end() ) write_address.erase(it); fprintf(stderr, "Layer unpacked: %p\n", ip); PIN_ApplicationBreakpoint(ctxt, tid, false, "Layer unpacked!"); }
static void DoBreakpoint(CONTEXT *ctxt, THREADID tid) { if (!IsFirstBreakpoint) { return; } IsFirstBreakpoint = FALSE; fprintf (fp, "DoBreakpoint\n"); fflush (fp); setApplicationBreakpoint = TRUE; PIN_ApplicationBreakpoint(ctxt, tid, 0, "The tool wants to stop"); }
/* ===================================================================== * Called on each thread when it calls GlobalFunction() * ===================================================================== */ static void DoBreakpoint(THREADID tid, CONTEXT *context) { // If all thread were started then this is the second time we're entering // this function for the thread 'tid'. // We enter this function twice for the same thread because we hit the same // instrumentation we the debugger was returned from the break-point that // we mock to the same address. In this case we need to return and don't // repeat the test (unless we'll end up with an infinite test). if (AllThreadsWereStarted) return; WaitForAllThreadsToStart(tid); // All threads are synchronized to this point PIN_MutexLock(&MtxActiveThread); WaitForThisThreadToBeActive(tid); Out << "Performing check on thread ID " << tid << std::endl; for (unsigned i = 0; i < KnobThreads.Value(); i++) { THREADID otherTid = VecThreadIds[i]; if (i < ActiveThreadIndex) { // All threads that were already active should be stopped in the debugger ASSERT(PIN_IsThreadStoppedInDebugger(otherTid), "Thread " + decstr(otherTid) + " should be stopped"); } else { // All threads that weren't already active should be running ASSERT(!PIN_IsThreadStoppedInDebugger(otherTid), "Thread " + decstr(otherTid) + " shouldn't be stopped"); } } ActiveThreadIndex++; PIN_MutexUnlock(&MtxActiveThread); // Stop this thread in the debugger // Note that because we add the instrumentation at IPOINT_AFTER, the program counter // at 'context' will not lead us to run this instrumentation function again PIN_ApplicationBreakpoint(context, tid, FALSE, "Stopping in Worker Thread " + decstr(tid) + "\n"); }
static void DoBreakpoint(CONTEXT *ctxt, THREADID tid) { static bool IsReplayedInstruction = false; static bool IsDebuggerLaunched = false; // When resuming from a breakpoint, we re-execute the instruction at // the breakpoint. Skip over the breakpoint in this case. // if (IsReplayedInstruction) { IsReplayedInstruction = false; return; } // If the debugger isn't launched yet, launch it now. // if (PIN_GetDebugStatus() == DEBUG_STATUS_UNCONNECTED) { // This is a sanity check to make sure PIN_GetDebugStatus() doesn't // have a bug. Once the debugger is launched, the status should // no longer be DEBUG_STATUS_UNCONNECTED. // if (IsDebuggerLaunched) { std::cerr << "Got wrong Debug Status from Pin" << std::endl; exit(1); } if (!LaunchGdb()) { std::cerr << "GDB did not connect within the timeout period." << std::endl; exit(1); } IsDebuggerLaunched = true; } IsReplayedInstruction = true; // Stop at a debugger breakpoint. // PIN_ApplicationBreakpoint(ctxt, tid, TRUE, "Tool stopped at breakpoint"); /* does not return */ }