-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gdbinit
243 lines (221 loc) · 4.88 KB
/
.gdbinit
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
set libthread-db-search-path /dev/null
define print-lone-memory
set var $memory = $arg0
output $memory
printf "\n"
output $memory->size
printf "\n[ "
if $memory->free
printf "."
else
printf "!"
end
printf " "
output *$memory->pointer@$memory->size
printf " ]\n"
printf "\n"
end
define lone-memory-walk
set var $memory = $arg0->memory.general
set var $total = 0
set var $free = 0
while $memory
set var $total += sizeof(struct lone_memory) + $memory->size
if $memory->free
set var $free += $memory->size
end
print-lone-memory $memory
printf " "
set var $memory = $memory->next
end
set var $used = $total - $free
output $free
printf " free, "
output $used
printf " used, "
output $total
printf " total\n"
end
macro define offset_of(type, member) ((size_t) (&(((type *) 0)->member)))
macro define container_of(type, member, pointer) ((type *) (((unsigned char *) pointer) - offset_of(type, member)))
define plv
print-lone-value $arg0
printf "\n"
end
define print-lone-value
if $arg0
set var $type = $arg0->type
if $type == LONE_LIST
if ($arg0->list.first == 0) && ($arg0->list.rest == 0)
printf "nil"
else
print-lone-list $arg0
end
else
if $type == LONE_BYTES
print-lone-bytes $arg0
else
if $type == LONE_TEXT
print-lone-text $arg0
else
if $type == LONE_SYMBOL
print-lone-symbol $arg0
else
if $type == LONE_INTEGER
print-lone-integer $arg0
else
if $type == LONE_POINTER
print-lone-pointer $arg0
else
if $type == LONE_TABLE
print-lone-table $arg0
else
if $type == LONE_FUNCTION
print-lone-function $arg0
else
if $type == LONE_PRIMITIVE
print-lone-primitive $arg0
else
if $type == LONE_MODULE
print-lone-module $arg0
else
if $type == LONE_VECTOR
print-lone-vector $arg0
end
end
end
end
end
end
end
end
end
end
end
else
printf "NULL"
end
end
define print-lone-module
set var $module = $arg0->module
printf "m["
print-lone-value $module.name
printf "]"
end
define print-lone-function
set var $f = $arg0->function
printf "f["
print-lone-value $f.arguments
printf " = "
print-lone-value $f.code
printf "]"
end
define print-lone-primitive
printf "p["
output $arg0->primitive.function
printf "]"
end
define print-lone-list
printf "("
print-lone-list-recursive $arg0
printf ")"
end
define print-lone-list-recursive
set var $list = $arg0
set var $first = $list->list.first
set var $rest = $list->list.rest
print-lone-value $first
if $rest.type == LONE_LIST
if !($rest->list.first == 0) && !($rest->list.rest == 0)
printf " "
print-lone-list-recursive $rest
end
else
printf ". "
print-lone-value $rest
end
end
define print-lone-vector
set var $vector = $arg0->vector
if $vector.count == 0
printf "[]"
else
print-lone-vector-values $vector
end
end
define print-lone-vector-values
set var $vector = $arg0
set var $i = 0
printf "[ "
while $i < $vector.count
print-lone-value $vector.values[$i]
printf " "
set var $i = $i + 1
end
printf "]"
end
define print-lone-table
set var $table = $arg0->table
printf "table["
output $table.count
printf ", "
output $table.capacity
printf "]={\n"
set var $i = 0
while $i < $table.capacity
set var $index = &$table.indexes[$i]
if $index.used
printf "\t"
output $i
printf "\t=>\t"
output $index.index
printf "\n"
end
set var $i = $i + 1
end
printf "\n\n"
set var $i = 0
while $i < $table.count
set var $entry = &$table.entries[$i]
printf "\t"
output $i
printf "\t=>\t"
print-lone-table-entry $entry
printf "\n"
set var $i = $i + 1
end
printf "}"
end
define print-lone-table-entry
set var $key = $arg0->key
set var $value = $arg0->value
print-lone-value $key
printf " => "
print-lone-value $value
end
define print-lone-bytes
printf "b["
print-lone-buffer $arg0
printf "]"
end
define print-lone-text
printf "t["
print-lone-buffer $arg0
printf "]"
end
define print-lone-symbol
printf "s["
print-lone-buffer $arg0
printf "]"
end
define print-lone-buffer
set var $pointer = $arg0->bytes.pointer
set var $count = $arg0->bytes.count
output *$pointer@$count
end
define print-lone-integer
output $arg0->integer
end
define print-lone-pointer
output $arg0->pointer
end