-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallstackInternal.h
More file actions
89 lines (79 loc) · 2.97 KB
/
callstackInternal.h
File metadata and controls
89 lines (79 loc) · 2.97 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* CallstackLibrary - Library creating human-readable call stacks.
*
* Copyright (C) 2022 - 2025 mhahnFr
*
* This file is part of the CallstackLibrary.
*
* The CallstackLibrary is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The CallstackLibrary is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with the
* CallstackLibrary, see the file LICENSE. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef callstackInternal_h
#define callstackInternal_h
#include <stdbool.h>
#include <stdlib.h>
#include <callstack.h>
/**
* Allocates an uninitialized callstack object.
*
* @return A newly allocated callstack object.
*/
static inline struct callstack * callstack_allocate(void) {
return malloc(sizeof(struct callstack));
}
/**
* @brief Initializes the given callstack object using the given backtrace.
*
* The given callstack object has to have enough memory to hold the given backtrace.
*
* @param self The callstack object.
* @param trace The backtrace, an array of return addresses.
* @param traceLength The length of the trace array.
*/
void callstack_createWithBacktrace(struct callstack * self,
void * trace[], size_t traceLength);
/**
* @brief Creates a backtrace into the given buffer.
*
* All frames upon the given address are removed from the generated backtrace.
*
* @param buffer the buffer to store the frame addresses in
* @param bufferSize the count of available elements in the given buffer
* @param address the address upon which frames are removed from the backtrace
* @return the count of frame addresses stored in the given buffer
*/
int callstack_backtrace(void* buffer[], int bufferSize, const void* address);
/**
* @brief Translates the given callstack object into a human-readable format.
*
* Returns the status of the translation, which is also set into the given callstack object.
*
* @param self The callstack object.
* @return The status of the translation.
*/
enum callstack_type callstack_translate(struct callstack * self);
/**
* Translates the callstack frames of the given callstack to their corresponding binary files.
*
* @param self the callstack object
* @param useCache whether to use cached values instead of copies
* @return whether the binaries where translated
*/
enum callstack_type callstack_translateBinaries(struct callstack* self, bool useCache);
/**
* Removes all translated callstack frames from the given callstack object.
*
* @param self the callstack object
*/
void callstack_reset(struct callstack * self);
#endif /* callstackInternal_h */