本文整理汇总了C++中ProfileData::intern方法的典型用法代码示例。如果您正苦于以下问题:C++ ProfileData::intern方法的具体用法?C++ ProfileData::intern怎么用?C++ ProfileData::intern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProfileData
的用法示例。
在下文中一共展示了ProfileData::intern方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trace
void StackTrace::trace(ProfileData &data){
CaptureStackBackTrace(0, backtraceSize, backtrace, &hash);
auto stk = data.stacks.find(hash);
if (stk != data.stacks.end()) { idx = stk->second; return; };
HANDLE process = GetCurrentProcess();
const int MAXSYMBOLNAME = 128 - sizeof(IMAGEHLP_SYMBOL);
char symbol64_buf[sizeof(IMAGEHLP_SYMBOL) + MAXSYMBOLNAME] = { 0 };
IMAGEHLP_SYMBOL *symbol = reinterpret_cast<IMAGEHLP_SYMBOL*>(symbol64_buf);
symbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
symbol->MaxNameLength = MAXSYMBOLNAME - 1;
IMAGEHLP_MODULE module;
module.SizeOfStruct = sizeof(IMAGEHLP_MODULE);
for (size_t i = backtraceSize - 1; i > 0; --i){
int fileidx = 0;
int linenum = 0;
int symidx = 0;
int modidx = 0;
if (backtrace[i]){
// Output stack frame symbols if available.
if (SymGetSymFromAddr(process, (DWORD64)backtrace[i], 0, symbol)){
std::string symbol_name = symbol->Name;
if (strncmp("mallocHook<", symbol->Name, 11) == 0)
{
symbol_name = "malloc";
}
if (strncmp("freeHook<", symbol->Name, 9) == 0)
{
symbol_name = "free";
}
symidx = data.intern(symbol_name);
if (SymGetModuleInfo(process, (DWORD64)backtrace[i], &module))
{
modidx = data.intern(module.ModuleName);
}
// Output filename + line info if available.
IMAGEHLP_LINE lineSymbol = { 0 };
lineSymbol.SizeOfStruct = sizeof(IMAGEHLP_LINE);
DWORD displacement;
if (SymGetLineFromAddr(process, (DWORD64)backtrace[i], &displacement, &lineSymbol)){
fileidx = data.intern(lineSymbol.FileName);
linenum = lineSymbol.LineNumber;
}
}
fprintf(data.output, "i %lx %lx", symbol->Address, modidx);
if (symidx || fileidx)
{
fprintf(data.output, " %lx", symidx);
if (fileidx) fprintf(data.output, " %lx %lx", fileidx, linenum);
}
fprintf(data.output, "\n");
}
else{
continue;
}
}
idx = data.instGraph.index((intptr_t*)backtrace, data.output);
data.stacks.insert(std::make_pair(hash, idx));
}