forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackBackTrace.cpp
More file actions
46 lines (38 loc) · 1.59 KB
/
StackBackTrace.cpp
File metadata and controls
46 lines (38 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "CommonCorePch.h"
#ifdef STACK_BACK_TRACE
#include "core\StackBackTrace.h"
#include "core\DbgHelpSymbolManager.h"
StackBackTrace::StackBackTrace(ULONG framesToSkip, ULONG framesToCapture) : requestedFramesToCapture(framesToCapture)
{
this->Capture(framesToSkip);
}
// Don't capture, just remember requestedFramesToCapture/allocate buffer for them.
StackBackTrace::StackBackTrace(ULONG framesToCaptureLater) : requestedFramesToCapture(framesToCaptureLater), framesCount(0)
{
}
// This can be called multiple times, together with Create, in which case we will use (overwrite) same buffer.
ULONG StackBackTrace::Capture(ULONG framesToSkip)
{
this->framesCount = CaptureStackBackTrace(framesToSkip + BaseFramesToSkip, this->requestedFramesToCapture, this->stackBackTrace, NULL);
return this->framesCount;
}
size_t
StackBackTrace::Print()
{
DbgHelpSymbolManager::EnsureInitialized();
size_t retValue = 0;
for(ULONG i = 0; i < this->framesCount; i++)
{
PVOID address = this->stackBackTrace[i];
retValue += Output::Print(L" ");
retValue += DbgHelpSymbolManager::PrintSymbol(address);
retValue += Output::Print(L"\n");
}
retValue += Output::Print(L"\n");
return retValue;
}
#endif