-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmemtrace.h
144 lines (126 loc) · 2.96 KB
/
memtrace.h
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* This file is part of mtrace-ng.
* Copyright (C) 2018 Stefani Seibold <[email protected]>
*
* This work was sponsored by Rohde & Schwarz GmbH & Co. KG, Munich/Germany.
*
* This program 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 2 of the
* License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef _INC_MEMTRACE_H
#define _INC_MEMTRACE_H
#include <stdint.h>
#if __LP64__
#define IS64BIT 1
#else
#define IS64BIT 0
#endif
#define MEMTRACE_SI_VERSION 9
#define MEMTRACE_SI_FORK 1
#define MEMTRACE_SI_EXEC 2
#define MEMTRACE_SI_VERBOSE 4
enum mt_operation {
MT_INFO = 0,
MT_DISCONNECT,
MT_ADD_MAP,
MT_DEL_MAP,
MT_ATTACH,
MT_ATTACH64,
MT_FORK,
MT_ABOUT_EXIT,
MT_EXIT,
MT_NOFOLLOW,
MT_MALLOC,
MT_REALLOC_ENTER,
MT_REALLOC_DONE,
MT_REALLOC,
MT_FREE,
MT_MMAP,
MT_MMAP64,
MT_MUNMAP,
MT_MEMALIGN,
MT_POSIX_MEMALIGN,
MT_ALIGNED_ALLOC,
MT_VALLOC,
MT_PVALLOC,
MT_SCAN,
MT_STOP,
MT_START,
MT_DETACH,
MT_NEW,
MT_NEW_ARRAY,
MT_DELETE,
MT_DELETE_ARRAY,
MT_DEPTH,
};
struct __attribute__((packed)) mt_msg {
uint16_t operation;
uint16_t pid;
uint32_t payload_len;
};
struct __attribute__((packed)) mt_attached_payload {
uint8_t attached;
};
struct __attribute__((packed)) mt_alloc_payload_64 {
uint64_t ptr;
uint64_t size;
uint64_t data[0];
};
struct __attribute__((packed)) mt_alloc_payload_32 {
uint32_t ptr;
uint32_t size;
uint32_t data[0];
};
struct __attribute__((packed)) mt_pid_payload {
uint32_t pid;
};
struct __attribute__((packed)) mt_scan_payload {
uint32_t ptr_size;
uint32_t pad; // for 64 bit alignment
uint64_t mask;
char data[0];
};
struct __attribute__((packed)) memtrace_timer_info {
uint32_t max;
uint32_t count;
uint64_t culminate;
};
struct __attribute__((packed)) memtrace_info {
uint8_t version;
uint8_t mode;
uint8_t do_trace;
uint8_t stack_depth;
uint8_t verbose;
uint8_t unused[3];
struct memtrace_timer_info stop_time;
struct memtrace_timer_info sw_bp_time;
struct memtrace_timer_info hw_bp_time;
struct memtrace_timer_info backtrace_time;
struct memtrace_timer_info reorder_time;
struct memtrace_timer_info report_in_time;
struct memtrace_timer_info report_out_time;
struct memtrace_timer_info skip_bp_time;
};
struct __attribute__((packed)) memtrace_depth {
uint8_t stack_depth;
};
struct __attribute__((packed)) mt_map_payload {
uint64_t addr;
uint64_t offset;
uint64_t size;
uint64_t bias;
char filename[0];
};
#endif