-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntimeTracker.h
More file actions
69 lines (56 loc) · 1.93 KB
/
runtimeTracker.h
File metadata and controls
69 lines (56 loc) · 1.93 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
//
// Created by Congyu Luo on 5/4/23.
//
#ifndef TEST_RUNTIMETRACKER_H
#define TEST_RUNTIMETRACKER_H
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "allocTracker.h"
// Enum for runtime action types
enum runtimeActionType {
DEREFERENCE, // Pointer dereference at runtime
SCOPE_ENTER, // Scope enter
SCOPE_EXIT, // Scope exit
RETURN, // Return
EXT_PARAM, // External parameter
FREE, // Free
MALLOC, // Malloc
CALLOC, // Calloc
VALLOC, // Valloc
ALIGNED_ALLOC, // Aligned Alloc
REALLOC, // Realloc
EXIT // Program Exit
};
// LL for tracking runtime
typedef struct runtimeNode {
int id;
enum runtimeActionType type;
struct timespec time;
struct runtimeNode *next;
// For allocation & dereference actions, pointer to aList node.
allocNode* alocNode;
// For Free / realloc actions, pointer to the old aList node.
allocNode* freedAllocNode;
} runtimeNode;
typedef struct runtimeList {
runtimeNode *head;
runtimeNode *tail;
int size;
} runtimeList;
// Helper functions for determining node action types
bool isAllocAction(enum runtimeActionType type);
bool isReallocAction(enum runtimeActionType type);
bool isDerefAction(enum runtimeActionType type);
bool isFreeAction(enum runtimeActionType type);
void addRuntimeNode(runtimeNode *node);
runtimeNode* basicRuntimeNode(enum runtimeActionType type, int id);
void logRuntimeGeneral(enum runtimeActionType type, int id);
void logRuntimeAlloc(enum runtimeActionType type, int id, allocNode* newAlloc);
void logRuntimeRealloc(enum runtimeActionType type, int id, allocNode* newAlloc, allocNode* oldAlloc);
void logRuntimeDeref(enum runtimeActionType type, int id, allocNode* alloc);
void logRuntimeFree(enum runtimeActionType type, int id, allocNode* alloc);
void deleteRuntimeList();
void printRuntimeList();
void exportRuntimeList();
#endif //TEST_RUNTIMETRACKER_H