本文整理汇总了C++中VisualLeakDetector::GetOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualLeakDetector::GetOptions方法的具体用法?C++ VisualLeakDetector::GetOptions怎么用?C++ VisualLeakDetector::GetOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualLeakDetector
的用法示例。
在下文中一共展示了VisualLeakDetector::GetOptions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create
CallStack* CallStack::Create()
{
CallStack* result = NULL;
if (g_vld.GetOptions() & VLD_OPT_SAFE_STACK_WALK) {
result = new SafeCallStack();
}
else {
result = new FastCallStack();
}
return result;
}
示例2: VLDGetOptions
__declspec(dllexport) UINT VLDGetOptions()
{
return g_vld.GetOptions();
}
示例3: resolve
// Resolve - Creates a nicely formatted rendition of the CallStack, including
// symbolic information (function names and line numbers) if available. and
// saves it for later retrieval. This is almost identical to Callstack::dump above.
//
// Note: The symbol handler must be initialized prior to calling this
// function.
//
// - showInternalFrames (IN): If true, then all frames in the CallStack will be
// dumped. Otherwise, frames internal to the heap will not be dumped.
//
// Return Value:
//
// None.
//
int CallStack::resolve(BOOL showInternalFrames)
{
if (m_resolved)
{
// already resolved, no need to do it again
// resolving twice may report an incorrect module for the stack frames
// if the memory was leaked in a dynamic library that was already unloaded.
return 0;
}
if (m_status & CALLSTACK_STATUS_STARTUPCRT) {
// there is no need to resolve a leak that will not be reported
return 0;
}
if (m_status & CALLSTACK_STATUS_INCOMPLETE) {
// This call stack appears to be incomplete. Using StackWalk64 may be
// more reliable.
Report(L" HINT: The following call stack may be incomplete. Setting \"StackWalkMethod\"\n"
L" in the vld.ini file to \"safe\" instead of \"fast\" may result in a more\n"
L" complete stack trace.\n");
}
int unresolvedFunctionsCount = 0;
IMAGEHLP_LINE64 sourceInfo = { 0 };
sourceInfo.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
bool skipStartupLeaks = !!(g_vld.GetOptions() & VLD_OPT_SKIP_CRTSTARTUP_LEAKS);
// Use static here to increase performance, and avoid heap allocs.
// It's thread safe because of g_heapMapLock lock.
static WCHAR stack_line[MAXREPORTLENGTH + 1] = L"";
bool isPrevFrameInternal = false;
bool isDynamicInitializer = false;
DWORD NumChars = 0;
CriticalSectionLocker<DbgHelp> locker(g_DbgHelp);
const size_t max_line_length = MAXREPORTLENGTH + 1;
m_resolvedCapacity = m_size * max_line_length;
const size_t allocedBytes = m_resolvedCapacity * sizeof(WCHAR);
m_resolved = new WCHAR[m_resolvedCapacity];
if (m_resolved) {
ZeroMemory(m_resolved, allocedBytes);
}
// Iterate through each frame in the call stack.
for (UINT32 frame = 0; frame < m_size; frame++)
{
// Try to get the source file and line number associated with
// this program counter address.
SIZE_T programCounter = (*this)[frame];
DWORD displacement = 0;
// It turns out that calls to SymGetLineFromAddrW64 may free the very memory we are scrutinizing here
// in this method. If this is the case, m_Resolved will be null after SymGetLineFromAddrW64 returns.
// When that happens there is nothing we can do except crash.
DbgTrace(L"dbghelp32.dll %i: SymGetLineFromAddrW64\n", GetCurrentThreadId());
BOOL foundline = g_DbgHelp.SymGetLineFromAddrW64(g_currentProcess, programCounter, &displacement, &sourceInfo, locker);
if (skipStartupLeaks && foundline && !isDynamicInitializer &&
!(m_status & CALLSTACK_STATUS_NOTSTARTUPCRT) && isCrtStartupModule(sourceInfo.FileName)) {
m_status |= CALLSTACK_STATUS_STARTUPCRT;
delete[] m_resolved;
m_resolved = NULL;
m_resolvedCapacity = 0;
m_resolvedLength = 0;
return 0;
}
bool isFrameInternal = false;
if (foundline && !showInternalFrames) {
if (isInternalModule(sourceInfo.FileName)) {
// Don't show frames in files internal to the heap.
isFrameInternal = true;
}
}
// show one allocation function for context
if (NumChars > 0 && !isFrameInternal && isPrevFrameInternal) {
m_resolvedLength += NumChars;
if (m_resolved) {
wcsncat_s(m_resolved, m_resolvedCapacity, stack_line, NumChars);
}
}
isPrevFrameInternal = isFrameInternal;
//.........这里部分代码省略.........