blob: 6b0b95066918931f305b9202e57b5713686fcf69 (
plain) (
blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#pragma once
#include <string>
#include <vector>
#include "WAVM/Inline/BasicTypes.h"
#include "WAVM/Inline/InlineArray.h"
#include "WAVM/Platform/Defines.h"
namespace WAVM { namespace Platform {
//
// Call stack and exceptions
//
// Describes a call stack.
struct CallStack
{
static constexpr Uptr maxFrames = 32;
struct Frame
{
Uptr ip;
};
InlineArray<Frame, maxFrames> frames;
~CallStack() = default;
};
// Describes the source of an instruction in a native module.
struct InstructionSource
{
std::string module;
std::string function;
Uptr instructionOffset;
friend std::string asString(const InstructionSource& source)
{
std::string result = source.module;
if(source.function.size())
{
result += '!';
result += source.function;
}
result += '+';
result += std::to_string(source.instructionOffset);
return result;
}
};
// Captures the execution context of the caller.
WAVM_API CallStack captureCallStack(Uptr numOmittedFramesFromTop = 0);
// Looks up the source of an instruction from a native module.
WAVM_API bool getInstructionSourceByAddress(Uptr ip, InstructionSource& outSource);
// Prints a profile of heap and virtual memory allocations.
WAVM_API void printMemoryProfile();
WAVM_API void registerVirtualAllocation(Uptr numBytes);
WAVM_API void deregisterVirtualAllocation(Uptr numBytes);
}}
|