/** * register a monitor * this function is thread safe * */ void TrexWatchDog::register_monitor(TrexMonitor *monitor) { if (!m_enable){ return; } /* critical section start */ std::unique_lock<std::mutex> lock(m_lock); /* sanity - not a must but why not... */ for (int i = 0; i < m_mon_count; i++) { if ( (monitor == m_monitors[i]) || (m_monitors[i]->get_tid() == pthread_self()) ) { std::stringstream ss; ss << "WATCHDOG: double register detected\n\n" << Backtrace(); throw TrexException(ss.str()); } } /* check capacity */ if (m_mon_count == MAX_MONITORS) { std::stringstream ss; ss << "WATCHDOG: too many registered monitors\n\n" << Backtrace(); throw TrexException(ss.str()); } /* add monitor */ m_monitors[m_mon_count++] = monitor; /* critical section end */ lock.unlock(); }
std::vector<JumpPointSearch::Node*> JumpPointSearch::operator()(IntType startX, IntType startY, IntType endX, IntType endY, Grid<IntType>& grid) { m_Grid = &grid; m_Goal = m_Grid->GetNode(endX, endY); ResetGrid(); Node* start = m_Grid->GetNode(startX, startY); m_Start = start; if (!start || !m_Goal) return std::vector<Node*>(); start->opened = true; m_OpenSet.Push(start); while (!m_OpenSet.Empty()) { Node* current = m_OpenSet.Pop(); if (!current) continue; current->closed = true; if (NearGoal(current, m_Goal)) return Backtrace(current); IdentifySuccessors(current); } return std::vector<Node*>(); }
Statement_Ptr Cssize::operator()(Trace_Ptr t) { traces.push_back(Backtrace(t->pstate())); auto result = t->block()->perform(this); traces.pop_back(); return result; }
static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *exc_info) { printf("Inside exception handler, as expected\n"); Backtrace(exc_info->ContextRecord); printf("Stack backtrace passed sanity checks\n"); if (strcmp(g_crash_type, "NACL_TEST_CRASH_MEMORY") == 0 || strcmp(g_crash_type, "NACL_TEST_CRASH_JUMP_TO_ZERO") == 0 || strcmp(g_crash_type, "NACL_TEST_CRASH_JUMP_INTO_SANDBOX") == 0) { /* * STATUS_ACCESS_VIOLATION is 0xc0000005 but we deliberately * convert this to a signed number since Python's wrapper for * GetExitCodeProcess() treats the STATUS_* values as negative, * although the unsigned values are used in headers and are more * widely recognised */ fprintf(stderr, "** intended_exit_status=%i\n", STATUS_ACCESS_VIOLATION); } else if (strcmp(g_crash_type, "NACL_TEST_CRASH_LOG_FATAL") == 0 || strcmp(g_crash_type, "NACL_TEST_CRASH_CHECK_FAILURE") == 0) { fprintf(stderr, "** intended_exit_status=trusted_sigabrt\n"); } else { NaClLog(LOG_FATAL, "Unknown crash type: \"%s\"\n", g_crash_type); } /* * Continuing is what Breakpad does, but this should cause the * process to exit with an exit status that is appropriate for the * type of exception. We want to test that ExceptionHandler() does * not get called twice, since that does not work with Chrome's * embedding of Breakpad. */ return EXCEPTION_CONTINUE_SEARCH; }
Exception::Exception() { #ifdef XTRAP_EXCEPTION_BACKTRACE if (!IsExceptionStackTrapRegistered()) { *this << ErrorInfo_Backtrace(Backtrace(backtrace_skip)); } #endif }
Exception::Exception(const boost::format& format) { #ifdef XTRAP_EXCEPTION_BACKTRACE if (!IsExceptionStackTrapRegistered()) { *this << ErrorInfo_Backtrace(Backtrace(backtrace_skip)); } #endif *this << ErrorInfo_Message(str(format)); }
Exception::Exception(const std::string& message) { #ifdef XTRAP_EXCEPTION_BACKTRACE if (!IsExceptionStackTrapRegistered()) { *this << ErrorInfo_Backtrace(Backtrace(backtrace_skip)); } #endif *this << ErrorInfo_Message(message); }
Backtrace getStack() { if (stackTable.find(TRACE_PID) == stackTable.end()) { return Backtrace(); } else { return stackTable[TRACE_PID]; } }
void Backtrace_And_Abort(int signal_number,siginfo_t* info,void *data) { LOG::cout<<std::flush;LOG::cerr<<"\n"; Backtrace(); char** names=physbam_catch_signal_names;char *signal_name=0; for(int *i=physbam_catch_signals;*i!=0;i++,names++) if(signal_number==*i) signal_name=*names; LOG::cerr<<"\n*** ERROR: SIGNAL "<<(signal_name?signal_name:"UNKNOWN")<<" ("<<signal_number<<")\n"<<std::endl; if(signal_number!=SIGUSR2){ LOG::Finish_Logging(); exit(signal_number);} }
static void _callstack_signal_handler(int signr, siginfo_t *info, void *secret) { std::stringstream ss; double now = now_sec(); ss << "WATCHDOG: task '" << global_monitor->get_name() << "' has not responded for more than " << global_monitor->get_interval(now) << " seconds - timeout is " << global_monitor->get_timeout_sec() << " seconds"; std::string backtrace = Backtrace(); ss << "\n\n*** traceback follows ***\n\n" << backtrace << "\n"; throw std::runtime_error(ss.str()); }
bool RandomFractionalTrigger::Eval(const string*, ...) { int rand_num = rand(); int prob = 100*(1/probability); if (rand_num % prob == 1) { cout << "Good is: " << good << endl; good = 0; Backtrace(); return true; } good++; return false; }
static void Floating_Point_Exception_Handler(int sig_number,siginfo_t* info,void *data) { if(sig_number!=SIGFPE) PHYSBAM_FATAL_ERROR(); LOG::cerr<<"** ERROR: SIGNAL "<<"SIGFPE ("<<sig_number<<") **"<<std::endl; LOG::cerr<<"Floating point exception: reason "<<info->si_code<<" = \""<< (info->si_code==FPE_INTDIV?"integer divide by zero":info->si_code==FPE_INTOVF?"integer overflow": info->si_code==FPE_FLTDIV?"FP divide by zero":info->si_code==FPE_FLTOVF?"FP overflow": info->si_code==FPE_FLTUND?"FP underflow":info->si_code==FPE_FLTRES?"FP inexact result": info->si_code==FPE_FLTINV?"FP invalid operation":info->si_code==FPE_FLTSUB?"subscript out of range":"unknown") << "\", from address 0x"<<std::hex<<(unsigned long)info->si_addr<<std::endl; Backtrace(); LOG::Finish_Logging(); exit(sig_number); }
void indata(string mod, string d, string m) { if (dataFilters.empty() == false) { debugTable[TRACE_PID] = canDisplayMessages(d); } if (stackTable.find(TRACE_PID) == stackTable.end()) { stackTable[TRACE_PID] = Backtrace(); stackTable[TRACE_PID].push(m); } if (flags["show-data"] == true) { //cout << "INDATA " << d << "\n"; TRACE_COUT_SHOW(mod, "<= " << d << "\n"); } }
static inline Backtrace saveBacktrace() { return Backtrace(); }
string showBacktrace() { Backtrace tmp = Backtrace(); tmp.capture(); return tmp.dump(); }
/** * @brief sixth step after desync * * Called by server once all blockResponses are received. It dumps a backtrace * to the logger for every checksum mismatch in the block which was out of * sync. The backtraces are passed to the logger in a fairly simple form * consisting basically only of hexadecimal addresses. The logger class * resolves those to function, filename & line number. */ void CSyncDebugger::ServerDumpStack() { // first calculate start iterator... unsigned posInHistory = (unsigned)(players[0].remoteFlop % (HISTORY_SIZE * BLOCK_SIZE)); logger.AddLine("Server: position in history: %u", posInHistory); unsigned blockNr = posInHistory / BLOCK_SIZE; unsigned virtualBlockNr = 0; // block nr in remoteHistory (which skips unchanged blocks) for (; virtualBlockNr < requestedBlocks.size() && requestedBlocks[virtualBlockNr] != blockNr; ++virtualBlockNr) {} unsigned virtualPosInHistory = (virtualBlockNr * BLOCK_SIZE) + (posInHistory % BLOCK_SIZE) + 1; unsigned virtualHistorySize = players[0].remoteHistory.size(); if (virtualBlockNr >= requestedBlocks.size()) virtualPosInHistory = virtualHistorySize; unsigned ndif = 0; // number of differences assert(virtualPosInHistory <= virtualHistorySize); // we make a pool of backtraces (to merge identical ones) unsigned curBacktrace = 0; std::map<unsigned, unsigned> checksumToIndex; std::map<unsigned, unsigned> indexToHistPos; // then loop from virtualPosInHistory to virtualHistorySize and from 0 to virtualPosInHistory. for (unsigned i = virtualPosInHistory, c = 0; c < virtualHistorySize; ++i, ++c) { unsigned correctChecksum = 0; if (i == virtualHistorySize) i = 0; bool err = false; for (int j = 0; j < playerHandler->ActivePlayers(); ++j) { if (correctChecksum && players[j].remoteHistory[i] != correctChecksum) { if (historybt) { virtualBlockNr = i / BLOCK_SIZE; blockNr = requestedBlocks[virtualBlockNr]; unsigned histPos = blockNr * BLOCK_SIZE + i % BLOCK_SIZE; unsigned checksum = GetBacktraceChecksum(histPos); std::map<unsigned, unsigned>::iterator it = checksumToIndex.find(checksum); if (it == checksumToIndex.end()) { ++curBacktrace; checksumToIndex[checksum] = curBacktrace; indexToHistPos[curBacktrace] = histPos; } logger.AddLine("Server: chk %08X instead of %08X frame %06u, (value=%08x %15.8e) backtrace %u in \"%s\"", players[j].remoteHistory[i], correctChecksum, historybt[histPos].frameNum, historybt[histPos].data, *(float*)&historybt[histPos].data, checksumToIndex[checksum], historybt[histPos].op); } else { logger.AddLine("Server: chk %08X instead of %08X", players[j].remoteHistory[i], correctChecksum); } err = true; } else { correctChecksum = players[j].remoteHistory[i]; } } if (err) { ++ndif; } } if (ndif) logger.AddLine("Server: chks: %d equal, %d not equal", virtualHistorySize - ndif, ndif); else // This is impossible (internal error). // Server first finds there are differing blocks, then all checksums equal?? // Turns out this can happen if the checksum function is weak. logger.AddLine("Server: huh, all checksums equal?!? (INTERNAL ERROR)"); //cleanup for (playerVec::iterator it = players.begin(); it != players.end(); ++it) it->remoteHistory.clear(); if (historybt) { // output backtraces we collected earlier this function for (std::map<unsigned, unsigned>::iterator it = indexToHistPos.begin(); it != indexToHistPos.end(); ++it) { logger.AddLine("Server: === Backtrace %u ===", it->first); Backtrace(it->second, "Server: "); } } // and reset net->Send(CBaseNetProtocol::Get().SendSdReset()); logger.AddLine("Server: Done!"); logger.CloseSession(); logOutput.Print("[SD] Server: Done!"); }
Backtrace getBacktrace(int levels) { Q_UNUSED(levels); return Backtrace(); }
/* virtual */ OP_STATUS ES_RemoteDebugFrontend::Received(ES_DebugMessage *message) { OpAutoPtr<ES_DebugMessage> anchor(message); ES_DebugMessagePart *part = message->GetFirstPart(); if (part->GetType() == ES_DebugMessagePart::BODY_CONTINUE) { ES_ContinueMessagePart *body = (ES_ContinueMessagePart *) part; return Continue(body->runtime_id, (ES_DebugFrontend::Mode) body->mode); } else if (part->GetType() == ES_DebugMessagePart::BODY_EVAL) { ES_EvalMessagePart *body = (ES_EvalMessagePart *) part; OpString script; RETURN_IF_ERROR(script.SetFromUTF8(body->script, body->script_length)); unsigned variables_count = 0; ES_DebugMessagePart *iter = (ES_DebugMessagePart *) part->Suc(); while (iter) { if (iter->GetType() == ES_DebugMessagePart::AUXILIARY_EVAL_VARIABLE) ++variables_count; iter = (ES_DebugMessagePart *) iter->Suc(); } ES_DebugVariable *variables; if (variables_count != 0) { variables = new ES_DebugVariable[variables_count]; if (variables) { unsigned index = 0; iter = (ES_DebugMessagePart *) part->Suc(); while (iter) { if (iter->GetType() == ES_DebugMessagePart::AUXILIARY_EVAL_VARIABLE) { ES_EvalVariableMessagePart *evalvariable = (ES_EvalVariableMessagePart *) iter; variables[index].name = evalvariable->name; variables[index].name_length = evalvariable->name_length; variables[index].value = evalvariable->value; ++index; } iter = (ES_DebugMessagePart *) iter->Suc(); } } else variables_count = 0; } else variables = NULL; OP_STATUS status = Eval(body->tag, body->runtime_id, body->thread_id, body->frame_index, script.CStr(), script.Length(), variables, variables_count); delete[] variables; if (status == OpStatus::ERR) { ES_DebugValue value; return EvalReply(body->tag, EVAL_STATUS_ABORTED, value); } else return status; } else if (part->GetType() == ES_DebugMessagePart::BODY_EXAMINE) { ES_ExamineMessagePart *body = (ES_ExamineMessagePart *) part; return Examine(body->tag, body->runtime_id, body->in_scope, body->thread_id, body->frame_index, body->objects_count, body->object_ids); } else if (part->GetType() == ES_DebugMessagePart::BODY_BACKTRACE) { ES_BacktraceMessagePart *body = (ES_BacktraceMessagePart *) part; return Backtrace(body->tag, body->runtime_id, body->thread_id, body->max_frames); } else if (part->GetType() == ES_DebugMessagePart::BODY_ADD_BREAKPOINT || part->GetType() == ES_DebugMessagePart::BODY_REMOVE_BREAKPOINT) { ES_ChangeBreakpointMessagePart *body = (ES_ChangeBreakpointMessagePart *) part; if (body->add) return AddBreakpoint(body->id, body->bpdata); else return RemoveBreakpoint(body->id); } else if (part->GetType() == ES_DebugMessagePart::BODY_SET_CONFIGURATION) { ES_SetConfigurationMessagePart *body = (ES_SetConfigurationMessagePart *) part; return SetStopAt(body->stop_at_script, body->stop_at_exception, body->stop_at_error, body->stop_at_abort, body->stop_at_gc); } else if (part->GetType() == ES_DebugMessagePart::BODY_BREAK) { ES_BreakMessagePart *body = (ES_BreakMessagePart *) part; return Break(body->runtime_id, body->thread_id); } OP_ASSERT(FALSE); return OpStatus::OK; }
void func(void) { cout << Backtrace() << endl; }