static void refreshSymbolsAndDumpStack(HANDLE hProcess, HANDLE hThread) { assert(hProcess); assert(hThread); loadSymbols(hProcess); dumpStack(hProcess, hThread, NULL); }
static bool loadSO(const char *filename) { void *handle = dlopen(filename, RTLD_LAZY | RTLD_LOCAL); if (handle == NULL) { ALOGV("couldn't dlopen %s, %s", filename, dlerror()); return false; } if (loadSymbols(handle, *dispatch, getProp("ro.build.version.sdk")) == false) { ALOGV("%s init failed!", filename); return false; } ALOGV("Successfully loaded %s", filename); return true; }
bool measureMemoryUsage(Sample& sample) { PROCESS_MEMORY_COUNTERS pmc; bool success = false; loadSymbols(); if (openProcess() && GetProcessMemoryInfo) { success = GetProcessMemoryInfo(m_hProcess, &pmc, sizeof(pmc)) == TRUE; if (success) sample.pagefileUsage = pmc.PagefileUsage; } return success; }
bool MDBCode::loadSymbols(const char *fileName) { MDBMachFile *file = new MDBMachFile(fileName); if (file->parse() == false) { return false; } files.add(file); for (uint32_t i = 0; i < file->dylibs.length(); i++) { MDBMatchMachFileName predicate(file->dylibs[i]->fileName); if (files.indexOf(predicate) < 0) { loadSymbols(file->dylibs[i]->fileName); } } return true; }
static jboolean nLoadSO(JNIEnv *_env, jobject _this, jboolean useNative) { void* handle = NULL; if (useNative) { handle = dlopen("libRS.so", RTLD_LAZY | RTLD_LOCAL); } else { handle = dlopen("libRSSupport.so", RTLD_LAZY | RTLD_LOCAL); } if (handle == NULL) { LOG_API("couldn't dlopen %s, %s", filename, dlerror()); return false; } if (loadSymbols(handle, dispatchTab) == false) { LOG_API("%s init failed!", filename); return false; } LOG_API("Successfully loaded %s", filename); return true; }
int main(int argc, char **argv) { signal(SIGUSR1, reload); signal(SIGINT, die); signal(SIGSEGV, segfault); signal(SIGPIPE, SIG_IGN); for (;;) { if ((fanbot.library = dlopen("base/config.so", RTLD_NOW | RTLD_GLOBAL)) == NULL) { fprintf(stderr, "Unable to load base/config.so. Fanbot is nothing without config.so\n%s\n", dlerror()); return -1; } loadSymbols(); fanbot.handle = (fanbot.init)(); (fanbot.destroy)(fanbot.handle, "SIGUSR1 received - Bot is going down for complete reload"); dlclose(fanbot.library); } fprintf(stderr, "THE WORLD IS GOING UNDER! INFINITE LOOPS AREN'T INFINITE ANYMORE! SAVE YOURSELF! ETC!!\n"); return -1; }
int BingoApp::generate() { // Card svg file QFile cardSvgFile(cardSvgFilename); if ( ! cardSvgFile.open(QIODevice::Text | QIODevice::ReadOnly) ) { cerr << "bingo: could not open " << cardSvgFilename << endl; return 20; } // Load symbols file and generate calling card if asked if (int result = loadSymbols() ) return result; if (int result = generateCallingCard() ) return result; // Actual processing cout << "Generating " << numberCardsToGenerate << " bingo cards...\n"; QTextStream cardSvg(&cardSvgFile); for ( size_t i = 1; i <= numberCardsToGenerate; ++i ) { if (int result = generateCard(cardSvg, i)) return result; cardSvg.seek(0); } cout << "Done\n"; return 0; }
XYVirtualKeyboard::XYVirtualKeyboard(QWidget *parent) : QWidget(parent), triangleBtnPressed(false), resizeType(No) { this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool); #if QT_VERSION >= 0x050000 this->setWindowFlags(this->windowFlags() | Qt::WindowDoesNotAcceptFocus); #endif connect(this, SIGNAL(triangleBtnClicked()), this, SLOT(triangleBtnClickedOP())); letterWidget = new QWidget; numberWidget = new QWidget; letterLabel = new XYMovableLabel; letterLabel->setMinimumWidth(30); QFont font = letterLabel->font(); font.setPixelSize(20); font.setUnderline(true); letterLabel->setFont(font); translateHView = new XYHDragableTranslateView; connect(translateHView, SIGNAL(clicked(QString,int)), this, SLOT(userSelectChinese(QString,int))); translateHDragableWidget = new XYDragableWidget(translateHView, XYDragableWidget::HORIZONTAL); translateHDragableWidget->setMinimumHeight(30); translateHDragableWidget->setMouseSensitivity(5); translateVView = new XYVDragableTranslateView; translateVView->setUnitMinWidth(50); translateVView->setUnitMinHeight(40); connect(translateVView, SIGNAL(clicked(QString,int)), this, SLOT(userSelectChinese(QString,int))); connect(translateVView, SIGNAL(stringPressed(QString,QPoint)), this, SLOT(showTempWindow(QString,QPoint))); translateVDragableWidget = new XYDragableWidget(translateVView, XYDragableWidget::VERTICAL); translateVDragableWidget->setMouseSensitivity(5); translateVDragableWidget->setHidden(true); symbolView = new XYVDragableTranslateView; symbolView->setUnitMinWidth(50); symbolView->setUnitMinHeight(40); symbolView->dataStrings = loadSymbols(":/symbol.txt"); connect(symbolView, SIGNAL(clicked(QString,int)), this, SLOT(symbolSeleted(QString,int))); connect(symbolView, SIGNAL(stringPressed(QString,QPoint)), this, SLOT(showTempWindow(QString,QPoint))); symbolDragableWidget = new XYDragableWidget(symbolView, XYDragableWidget::VERTICAL); symbolDragableWidget->setMouseSensitivity(15); funcHView = new XYHDragableTranslateView; funcHView->setUnitMinWidth(50); funcHView->setUnitMinHeight(40); #if QT_VERSION < 0x050000 funcHView->dataStrings << QString::fromUtf8("换肤") << QString::fromUtf8("表情") << QString::fromUtf8("设置") << QString::fromUtf8("功能") << QString::fromUtf8("手势") << QString::fromUtf8("搜索") << QString::fromUtf8("更多"); #else funcHView->dataStrings << QStringLiteral("换肤") << QStringLiteral("表情") << QStringLiteral("设置") << QStringLiteral("功能") << QStringLiteral("手势") << QStringLiteral("搜索") << QStringLiteral("更多"); #endif connect(funcHView, SIGNAL(clicked(QString,int)), this, SLOT(funcClicked(QString,int))); funcDragableWidget = new XYDragableWidget(funcHView, XYDragableWidget::HORIZONTAL); funcDragableWidget->setMinimumHeight(30); funcDragableWidget->setMouseSensitivity(5); QGridLayout *letter_layout = new QGridLayout(letterWidget); letter_layout->setContentsMargins(3, 0, 3, 0); letter_layout->setHorizontalSpacing(5); letter_layout->setVerticalSpacing(5); int row = 0; int column = 0; // 字母控件 XYPushButton *main_letterQ = new XYPushButton("Q", Qt::Key_Q); XYPushButton *main_letterW = new XYPushButton("W", Qt::Key_W); XYPushButton *main_letterE = new XYPushButton("E", Qt::Key_E); XYPushButton *main_letterR = new XYPushButton("R", Qt::Key_R); XYPushButton *main_letterT = new XYPushButton("T", Qt::Key_T); XYPushButton *main_letterY = new XYPushButton("Y", Qt::Key_Y); XYPushButton *main_letterU = new XYPushButton("U", Qt::Key_U); XYPushButton *main_letterI = new XYPushButton("I", Qt::Key_I); XYPushButton *main_letterO = new XYPushButton("O", Qt::Key_O); XYPushButton *main_letterP = new XYPushButton("P", Qt::Key_P); row = 0; column = 0; letter_layout->addWidget(main_letterQ, row, column++); letter_layout->addWidget(main_letterW, row, column++); letter_layout->addWidget(main_letterE, row, column++); letter_layout->addWidget(main_letterR, row, column++); letter_layout->addWidget(main_letterT, row, column++); letter_layout->addWidget(main_letterY, row, column++); letter_layout->addWidget(main_letterU, row, column++); letter_layout->addWidget(main_letterI, row, column++); letter_layout->addWidget(main_letterO, row, column++); letter_layout->addWidget(main_letterP, row, column++); XYPushButton *main_tab = new XYPushButton("Tab", Qt::Key_Tab); XYPushButton *main_letterA = new XYPushButton("A", Qt::Key_A); XYPushButton *main_letterS = new XYPushButton("S", Qt::Key_S); XYPushButton *main_letterD = new XYPushButton("D", Qt::Key_D); XYPushButton *main_letterF = new XYPushButton("F", Qt::Key_F); XYPushButton *main_letterG = new XYPushButton("G", Qt::Key_G); XYPushButton *main_letterH = new XYPushButton("H", Qt::Key_H); XYPushButton *main_letterJ = new XYPushButton("J", Qt::Key_J); XYPushButton *main_letterK = new XYPushButton("K", Qt::Key_K); XYPushButton *main_letterL = new XYPushButton("L", Qt::Key_L); row = 1; column = 0; letter_layout->addWidget(main_tab, row, column++); letter_layout->addWidget(main_letterA, row, column++); letter_layout->addWidget(main_letterS, row, column++); letter_layout->addWidget(main_letterD, row, column++); letter_layout->addWidget(main_letterF, row, column++); letter_layout->addWidget(main_letterG, row, column++); letter_layout->addWidget(main_letterH, row, column++); letter_layout->addWidget(main_letterJ, row, column++); letter_layout->addWidget(main_letterK, row, column++); letter_layout->addWidget(main_letterL, row, column++); XYPushButton *main_shift = new XYPushButton("Shift", Qt::Key_Shift); main_shift->setCheckable(true); connect(main_shift, SIGNAL(checkedChanged(bool)), this, SLOT(caseChanged(bool))); XYPushButton *main_letterZ = new XYPushButton("Z", Qt::Key_Z); XYPushButton *main_letterX = new XYPushButton("X", Qt::Key_X); XYPushButton *main_letterC = new XYPushButton("C", Qt::Key_C); XYPushButton *main_letterV = new XYPushButton("V", Qt::Key_V); XYPushButton *main_letterB = new XYPushButton("B", Qt::Key_B); XYPushButton *main_letterN = new XYPushButton("N", Qt::Key_N); XYPushButton *main_letterM = new XYPushButton("M", Qt::Key_M); XYPushButton *main_Exclam = new XYPushButton("!", Qt::Key_Exclam); XYPushButton *main_backspace = new XYPushButton("", Qt::Key_Backspace); row = 2; column = 0; letter_layout->addWidget(main_shift, row, column++); letter_layout->addWidget(main_Exclam, row, column++); letter_layout->addWidget(main_letterZ, row, column++); letter_layout->addWidget(main_letterX, row, column++); letter_layout->addWidget(main_letterC, row, column++); letter_layout->addWidget(main_letterV, row, column++); letter_layout->addWidget(main_letterB, row, column++); letter_layout->addWidget(main_letterN, row, column++); letter_layout->addWidget(main_letterM, row, column++); letter_layout->addWidget(main_backspace, row, column++); XYPushButton *main_ctrl = new XYPushButton("Ctrl", Qt::Key_Control); main_ctrl->setCheckable(true); XYPushButton *main_alt = new XYPushButton("Alt", Qt::Key_Alt); main_alt->setCheckable(true); XYPushButton *main_symbol = new XYPushButton("#+-=", Qt::Key_Meta); connect(main_symbol, SIGNAL(clicked()), this, SLOT(showSymbols())); XYPushButton *main_angleComma = new XYPushButton(",", Qt::Key_Comma); XYPushButton *main_space = new XYPushButton(" ", Qt::Key_Space); XYPushButton *main_anglePeriod = new XYPushButton(".", Qt::Key_Period); XYPushButton *showNumBtn = new XYPushButton("123", Qt::Key_Meta); connect(showNumBtn, SIGNAL(clicked()), this, SLOT(showNumberWidget())); switchLanguageBtn = new XYPushButton("", Qt::Key_Menu); connect(switchLanguageBtn, SIGNAL(clicked()), this, SLOT(languageChanged())); XYPushButton *main_Return = new XYPushButton("", Qt::Key_Return); row = 3; column = 0; letter_layout->addWidget(showNumBtn, row, column++); letter_layout->addWidget(main_ctrl, row, column++); letter_layout->addWidget(main_alt, row, column++); letter_layout->addWidget(main_symbol, row, column++); letter_layout->addWidget(main_space, row, column++, 1, 2); column++; letter_layout->addWidget(main_anglePeriod, row, column++); letter_layout->addWidget(main_angleComma, row, column++); letter_layout->addWidget(switchLanguageBtn, row, column++); letter_layout->addWidget(main_Return, row, column++); // 装入shift需要改变内容的控件 allShiftChangeKeys.append(main_letterA); allShiftChangeKeys.append(main_letterB); allShiftChangeKeys.append(main_letterC); allShiftChangeKeys.append(main_letterD); allShiftChangeKeys.append(main_letterE); allShiftChangeKeys.append(main_letterF); allShiftChangeKeys.append(main_letterG); allShiftChangeKeys.append(main_letterH); allShiftChangeKeys.append(main_letterI); allShiftChangeKeys.append(main_letterJ); allShiftChangeKeys.append(main_letterK); allShiftChangeKeys.append(main_letterL); allShiftChangeKeys.append(main_letterM); allShiftChangeKeys.append(main_letterN); allShiftChangeKeys.append(main_letterO); allShiftChangeKeys.append(main_letterP); allShiftChangeKeys.append(main_letterQ); allShiftChangeKeys.append(main_letterR); allShiftChangeKeys.append(main_letterS); allShiftChangeKeys.append(main_letterT); allShiftChangeKeys.append(main_letterU); allShiftChangeKeys.append(main_letterV); allShiftChangeKeys.append(main_letterW); allShiftChangeKeys.append(main_letterX); allShiftChangeKeys.append(main_letterY); allShiftChangeKeys.append(main_letterZ); QGridLayout *numbers_layout = new QGridLayout(numberWidget); numbers_layout->setContentsMargins(3, 0, 3, 0); numbers_layout->setHorizontalSpacing(5); numbers_layout->setVerticalSpacing(5); // 数字控件 XYPushButton *main_Underscore = new XYPushButton("_", Qt::Key_Underscore); XYPushButton *main_AsciiTilde = new XYPushButton("~", Qt::Key_AsciiTilde); XYPushButton *main_Percent = new XYPushButton("%", Qt::Key_Percent); XYPushButton *main_Asterisk = new XYPushButton("*", Qt::Key_Asterisk); XYPushButton *main_number1 = new XYPushButton("1", Qt::Key_1); XYPushButton *main_number2 = new XYPushButton("2", Qt::Key_2); XYPushButton *main_number3 = new XYPushButton("3", Qt::Key_3); XYPushButton *main_Question = new XYPushButton("?", Qt::Key_Question); XYPushButton *main_At = new XYPushButton("@", Qt::Key_At); XYPushButton *main_ParenLeft = new XYPushButton("(", Qt::Key_ParenLeft); XYPushButton *main_backspace1 = new XYPushButton("", Qt::Key_Backspace); row = 0; column = 0; numbers_layout->addWidget(main_Underscore, row, column++); numbers_layout->addWidget(main_AsciiTilde, row, column++); numbers_layout->addWidget(main_Percent, row, column++); numbers_layout->addWidget(main_Asterisk, row, column++); numbers_layout->addWidget(main_number1, row, column++); numbers_layout->addWidget(main_number2, row, column++); numbers_layout->addWidget(main_number3, row, column++); numbers_layout->addWidget(main_Question, row, column++); numbers_layout->addWidget(main_At, row, column++); numbers_layout->addWidget(main_ParenLeft, row, column++); numbers_layout->addWidget(main_backspace1, row, column++); XYPushButton *main_QuoteDbl = new XYPushButton("\"", Qt::Key_QuoteDbl); XYPushButton *main_Exclam1 = new XYPushButton("!", Qt::Key_Exclam); XYPushButton *main_Bar = new XYPushButton("|", Qt::Key_Bar); XYPushButton *main_Minus = new XYPushButton("-", Qt::Key_Minus); XYPushButton *main_number4 = new XYPushButton("4", Qt::Key_4); XYPushButton *main_number5 = new XYPushButton("5", Qt::Key_5); XYPushButton *main_number6 = new XYPushButton("6", Qt::Key_6); XYPushButton *main_BracketLeft = new XYPushButton("[", Qt::Key_BracketLeft); XYPushButton *main_NumberSign = new XYPushButton("#", Qt::Key_NumberSign); XYPushButton *main_ParenRight = new XYPushButton(")", Qt::Key_ParenRight); XYPushButton *main_Dollar = new XYPushButton("$", Qt::Key_Dollar); row = 1; column = 0; numbers_layout->addWidget(main_QuoteDbl, row, column++); numbers_layout->addWidget(main_Exclam1, row, column++); numbers_layout->addWidget(main_Bar, row, column++); numbers_layout->addWidget(main_Minus, row, column++); numbers_layout->addWidget(main_number4, row, column++); numbers_layout->addWidget(main_number5, row, column++); numbers_layout->addWidget(main_number6, row, column++); numbers_layout->addWidget(main_BracketLeft, row, column++); numbers_layout->addWidget(main_NumberSign, row, column++); numbers_layout->addWidget(main_ParenRight, row, column++); numbers_layout->addWidget(main_Dollar, row, column++); XYPushButton *main_QuoteLeft = new XYPushButton("`", Qt::Key_QuoteLeft); XYPushButton *main_Ampersand = new XYPushButton("&", Qt::Key_Ampersand); XYPushButton *main_Less = new XYPushButton("<", Qt::Key_Less); XYPushButton *main_Plus = new XYPushButton("+", Qt::Key_Plus); XYPushButton *main_number7 = new XYPushButton("7", Qt::Key_7); XYPushButton *main_number8 = new XYPushButton("8", Qt::Key_8); XYPushButton *main_number9 = new XYPushButton("9", Qt::Key_9); XYPushButton *main_BracketRight = new XYPushButton("]", Qt::Key_BracketRight); XYPushButton *main_AsciiCircum = new XYPushButton("^", Qt::Key_AsciiCircum); XYPushButton *main_BraceLeft = new XYPushButton("{", Qt::Key_BraceLeft); XYPushButton *main_Comma = new XYPushButton(",", Qt::Key_Comma); row = 2; column = 0; numbers_layout->addWidget(main_QuoteLeft, row, column++); numbers_layout->addWidget(main_Ampersand, row, column++); numbers_layout->addWidget(main_Less, row, column++); numbers_layout->addWidget(main_Plus, row, column++); numbers_layout->addWidget(main_number7, row, column++); numbers_layout->addWidget(main_number8, row, column++); numbers_layout->addWidget(main_number9, row, column++); numbers_layout->addWidget(main_BracketRight, row, column++); numbers_layout->addWidget(main_AsciiCircum, row, column++); numbers_layout->addWidget(main_BraceLeft, row, column++); numbers_layout->addWidget(main_Comma, row, column++); XYPushButton *showLetterBtn = new XYPushButton("ABC", Qt::Key_Meta); connect(showLetterBtn, SIGNAL(clicked()), this, SLOT(showLetterWidget())); XYPushButton *main_Backslash = new XYPushButton("\\", Qt::Key_Backslash); XYPushButton *main_Greater = new XYPushButton(">", Qt::Key_Greater); XYPushButton *main_Slash = new XYPushButton("/", Qt::Key_Slash); XYPushButton *main_Period = new XYPushButton(".", Qt::Key_Period); XYPushButton *main_number0 = new XYPushButton("0", Qt::Key_0); XYPushButton *main_Equal = new XYPushButton("=", Qt::Key_Equal); XYPushButton *main_Colon = new XYPushButton(":", Qt::Key_Colon); XYPushButton *main_Semicolon = new XYPushButton(";", Qt::Key_Semicolon); XYPushButton *main_BraceRight = new XYPushButton("}", Qt::Key_BraceRight); XYPushButton *main_enter = new XYPushButton("", Qt::Key_Enter); row = 3; column = 0; numbers_layout->addWidget(showLetterBtn, row, column++); numbers_layout->addWidget(main_Backslash, row, column++); numbers_layout->addWidget(main_Greater, row, column++); numbers_layout->addWidget(main_Slash, row, column++); numbers_layout->addWidget(main_Period, row, column++); numbers_layout->addWidget(main_number0, row, column++); numbers_layout->addWidget(main_Equal, row, column++); numbers_layout->addWidget(main_Colon, row, column++); numbers_layout->addWidget(main_Semicolon, row, column++); numbers_layout->addWidget(main_BraceRight, row, column++); numbers_layout->addWidget(main_enter, row, column++); stackedWidget = new QStackedWidget; stackedWidget->addWidget(letterWidget); stackedWidget->addWidget(numberWidget); stackedWidget->addWidget(translateVDragableWidget); stackedWidget->addWidget(symbolDragableWidget); stackedWidget->setCurrentWidget(letterWidget); QHBoxLayout *top_layout = new QHBoxLayout; top_layout->setContentsMargins(10, 2, 60, 2); top_layout->addWidget(letterLabel); top_layout->addSpacing(10); top_layout->addWidget(translateHDragableWidget, 1); top_layout->addWidget(funcDragableWidget, 1); QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setContentsMargins(5, 2, 5, 8); main_layout->addLayout(top_layout); main_layout->addSpacing(4); main_layout->addWidget(stackedWidget); // 关联按键信号 for (int i = 0; i < XYPushButton::allKeyBtns.size(); ++i) { XYPushButton::allKeyBtns.at(i)->installEventFilter(this); connect(XYPushButton::allKeyBtns.at(i), SIGNAL(clicked(int,int,Qt::KeyboardModifiers,bool)), this, SLOT(keyClicked(int,int,Qt::KeyboardModifiers,bool))); connect(XYPushButton::allKeyBtns.at(i), SIGNAL(mousePressed(XYPushButton*)), this, SLOT(keyPressed(XYPushButton*))); connect(XYPushButton::allKeyBtns.at(i), SIGNAL(mouseReleaseed(XYPushButton*)), this, SLOT(keyReleaseed(XYPushButton*))); } connect(XYSKIN, SIGNAL(skinChanged()), this, SLOT(skinChanged())); caseChanged(false); skinChanged(); initPinyinDictionary(); }
BOOL DebugMainLoop(const DebugOptions *pOptions) { BOOL fFinished = FALSE; BOOL fTerminating = FALSE; while(!fFinished) { DEBUG_EVENT DebugEvent; // debugging event information DWORD dwContinueStatus = DBG_CONTINUE; // exception continuation PPROCESS_INFO pProcessInfo; PTHREAD_INFO pThreadInfo; HANDLE hProcess; // Wait for a debugging event to occur. The second parameter indicates // that the function does not return until a debugging event occurs. if(!WaitForDebugEvent(&DebugEvent, INFINITE)) { OutputDebug("WaitForDebugEvent: 0x%08lx", GetLastError()); return FALSE; } // Process the debugging event code. switch (DebugEvent.dwDebugEventCode) { case EXCEPTION_DEBUG_EVENT: { PEXCEPTION_RECORD pExceptionRecord = &DebugEvent.u.Exception.ExceptionRecord; NTSTATUS ExceptionCode = pExceptionRecord->ExceptionCode; // Process the exception code. When handling // exceptions, remember to set the continuation // status parameter (dwContinueStatus). This value // is used by the ContinueDebugEvent function. if (pOptions->verbose_flag) { lprintf("EXCEPTION PID=%lu TID=%lu ExceptionCode=0x%lx dwFirstChance=%lu\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId, pExceptionRecord->ExceptionCode, DebugEvent.u.Exception.dwFirstChance ); } // Find the process in the process list pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED; if (DebugEvent.u.Exception.dwFirstChance) { if (pExceptionRecord->ExceptionCode == (DWORD)STATUS_BREAKPOINT) { // Signal the aedebug event if (!pProcessInfo->fBreakpointSignalled) { pProcessInfo->fBreakpointSignalled = TRUE; if (pOptions->hEvent) { SetEvent(pOptions->hEvent); CloseHandle(pOptions->hEvent); } if (pOptions->dwThreadId) { DWORD dwThreadId = pOptions->dwThreadId; const DWORD dwFailed = (DWORD)-1; DWORD dwRet = dwFailed; pThreadInfo = &pProcessInfo->Threads[dwThreadId]; HANDLE hThread = pThreadInfo->hThread; if (hThread != NULL) { dwRet = ResumeThread(hThread); } if (dwRet == dwFailed) { lprintf("error: failed to resume thread %lu\n", dwThreadId); } } /* * We ignore first-chance breakpoints by default. * * We get one of these whenever we attach to a process. * But in some cases, we never get a second-chance, e.g., * when we're attached through MSVCRT's abort(). */ if (!pOptions->breakpoint_flag) { dwContinueStatus = DBG_CONTINUE; break; } } } if (ExceptionCode == STATUS_WX86_BREAKPOINT) { if (!pProcessInfo->fWowBreakpointSignalled) { pProcessInfo->fWowBreakpointSignalled = TRUE; dwContinueStatus = DBG_CONTINUE; break; } } /* * Ignore thread naming exception. * * http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx * * TODO: Note down the thread name */ if (ExceptionCode == 0x406d1388) { dwContinueStatus = DBG_CONTINUE; break; } if (!pOptions->first_chance) { break; } } dumpException(pProcessInfo->hProcess, &DebugEvent.u.Exception.ExceptionRecord); loadSymbols(hProcess); // Find the thread in the thread list THREAD_INFO_LIST::const_iterator it; for (it = pProcessInfo->Threads.begin(); it != pProcessInfo->Threads.end(); ++it) { DWORD dwThreadId = it->first; HANDLE hThread = it->second.hThread; if (dwThreadId != DebugEvent.dwThreadId && ExceptionCode != STATUS_BREAKPOINT && ExceptionCode != STATUS_WX86_BREAKPOINT) { continue; } dumpStack(pProcessInfo->hProcess, hThread, NULL); } if (!DebugEvent.u.Exception.dwFirstChance) { /* * Terminate the process. As continuing would cause the JIT debugger * to be invoked again. */ fTerminating = TRUE; TerminateProcess(pProcessInfo->hProcess, (UINT)ExceptionCode); } break; } case CREATE_THREAD_DEBUG_EVENT: if (pOptions->verbose_flag) { lprintf("CREATE_THREAD PID=%lu TID=%lu\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId ); } // Add the thread to the thread list pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; pThreadInfo = &pProcessInfo->Threads[DebugEvent.dwThreadId]; pThreadInfo->hThread = DebugEvent.u.CreateThread.hThread; break; case CREATE_PROCESS_DEBUG_EVENT: { HANDLE hFile = DebugEvent.u.CreateProcessInfo.hFile; char szImageName[MAX_PATH]; char *lpImageName = NULL; if (hFile && GetFileNameFromHandle(hFile, szImageName, _countof(szImageName))) { lpImageName = szImageName; } if (pOptions->verbose_flag) { PCSTR lpModuleName = lpImageName ? getBaseName(lpImageName) : ""; lprintf("CREATE_PROCESS PID=%lu TID=%lu lpBaseOfImage=%p %s\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId, DebugEvent.u.CreateProcessInfo.lpBaseOfImage, lpModuleName ); } hProcess = DebugEvent.u.CreateProcessInfo.hProcess; pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; pProcessInfo->hProcess = hProcess; pThreadInfo = &pProcessInfo->Threads[DebugEvent.dwThreadId]; pThreadInfo->hThread = DebugEvent.u.CreateProcessInfo.hThread; if (!InitializeSym(hProcess, FALSE)) { OutputDebug("error: SymInitialize failed: 0x%08lx\n", GetLastError()); exit(EXIT_FAILURE); } SymRegisterCallback64(hProcess, &symCallback, 0); loadModule(hProcess, hFile, lpImageName, DebugEvent.u.CreateProcessInfo.lpBaseOfImage); break; } case EXIT_THREAD_DEBUG_EVENT: if (pOptions->verbose_flag) { lprintf("EXIT_THREAD PID=%lu TID=%lu dwExitCode=0x%lx\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId, DebugEvent.u.ExitThread.dwExitCode ); } // Remove the thread from the thread list pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; hProcess = pProcessInfo->hProcess; // Dump the stack on abort() if (!fTerminating && isAbnormalExitCode(DebugEvent.u.ExitThread.dwExitCode)) { pThreadInfo = &pProcessInfo->Threads[DebugEvent.dwThreadId]; refreshSymbolsAndDumpStack(hProcess, pThreadInfo->hThread); } pProcessInfo->Threads.erase(DebugEvent.dwThreadId); break; case EXIT_PROCESS_DEBUG_EVENT: { if (pOptions->verbose_flag) { lprintf("EXIT_PROCESS PID=%lu TID=%lu dwExitCode=0x%lx\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId, DebugEvent.u.ExitProcess.dwExitCode ); } pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; hProcess = pProcessInfo->hProcess; // Dump the stack on abort() if (!fTerminating && isAbnormalExitCode(DebugEvent.u.ExitThread.dwExitCode)) { pThreadInfo = &pProcessInfo->Threads[DebugEvent.dwThreadId]; refreshSymbolsAndDumpStack(hProcess, pThreadInfo->hThread); } // Remove the process from the process list g_Processes.erase(DebugEvent.dwProcessId); if (!SymCleanup(hProcess)) { OutputDebug("SymCleanup failed with 0x%08lx\n", GetLastError()); } if (g_Processes.empty()) { fFinished = TRUE; } break; } case LOAD_DLL_DEBUG_EVENT: { HANDLE hFile = DebugEvent.u.LoadDll.hFile; char szImageName[MAX_PATH]; char *lpImageName = NULL; if (hFile && GetFileNameFromHandle(hFile, szImageName, _countof(szImageName))) { lpImageName = szImageName; } if (pOptions->verbose_flag) { PCSTR lpModuleName = lpImageName ? getBaseName(lpImageName) : ""; lprintf("LOAD_DLL PID=%lu TID=%lu lpBaseOfDll=%p %s\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId, DebugEvent.u.LoadDll.lpBaseOfDll, lpModuleName ); } pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; hProcess = pProcessInfo->hProcess; loadModule(hProcess, hFile, lpImageName, DebugEvent.u.LoadDll.lpBaseOfDll); break; } case UNLOAD_DLL_DEBUG_EVENT: if (pOptions->verbose_flag) { lprintf("UNLOAD_DLL PID=%lu TID=%lu lpBaseOfDll=%p\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId, DebugEvent.u.UnloadDll.lpBaseOfDll ); } pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; hProcess = pProcessInfo->hProcess; SymUnloadModule64(hProcess, (UINT_PTR)DebugEvent.u.UnloadDll.lpBaseOfDll); break; case OUTPUT_DEBUG_STRING_EVENT: { if (pOptions->verbose_flag) { lprintf("OUTPUT_DEBUG_STRING PID=%lu TID=%lu\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId ); } pProcessInfo = &g_Processes[DebugEvent.dwProcessId]; assert(!DebugEvent.u.DebugString.fUnicode); LPSTR lpDebugStringData = readProcessString(pProcessInfo->hProcess, DebugEvent.u.DebugString.lpDebugStringData, DebugEvent.u.DebugString.nDebugStringLength); lprintf("%s", lpDebugStringData); free(lpDebugStringData); break; } case RIP_EVENT: if (pOptions->verbose_flag) { lprintf("RIP PID=%lu TID=%lu\n", DebugEvent.dwProcessId, DebugEvent.dwThreadId ); } break; default: if (pOptions->verbose_flag) { lprintf("EVENT%lu PID=%lu TID=%lu\n", DebugEvent.dwDebugEventCode, DebugEvent.dwProcessId, DebugEvent.dwThreadId ); } break; } // Resume executing the thread that reported the debugging event. ContinueDebugEvent( DebugEvent.dwProcessId, DebugEvent.dwThreadId, dwContinueStatus ); } return TRUE; }
bool Database::loadFromPath(const std::wstring& _profilepath, bool collapseOSCalls) { if(_profilepath != profilepath) { profilepath = _profilepath; } clear(); wxFFileInputStream in(profilepath); wxZipInputStream zip(in); wxZipInputStream zipver(in); if (!in.IsOk() || !zip.IsOk() || !zipver.IsOk()) { wxLogError("The profile data cannot be read."); return false; } // Check the version number required. while(true) { wxZipEntry *entry = zipver.GetNextEntry(); if ( !entry ) break; wxString name = entry->GetInternalName(); if (name.Left(8) == "Version " && name.Right(9) == " required") { wxString ver = name.Mid(8, name.Length()-(8+9)); // Add other versions here any time the file format changes. const char *supportedVersions[] = { "0.7", "0.8", "0.81", "0.82", }; bool isSupported = false; for (int n=0; n<sizeof(supportedVersions)/sizeof(char*); n++) { if (ver == supportedVersions[n]) { isSupported = true; break; } } if (!isSupported) { wxLogWarning("Cannot load capture file: %s", name.c_str()); return false; } } } while(true) { wxZipEntry *entry = zip.GetNextEntry(); if ( !entry ) break; wxString name = entry->GetInternalName(); if (name == "Symbols.txt") loadSymbols(zip); else if (name == "Callstacks.txt") loadProcList(zip,collapseOSCalls); else if (name == "IPCounts.txt") loadIpCounts(zip); else if (name == "Stats.txt") loadStats(zip); else if (name.Left(8) == "Version ") {} else { wxLogWarning("Other fluff found in capture file (%s)", name.c_str()); } } setRoot(NULL); return true; }