From c442a5ad806b6cccbb3ec4c5744b14b0c1f31a01 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 25 Feb 2019 00:17:46 -0800 Subject: 4987 - support `browse_trace` tool in SubX I've extracted it into a separate binary, independent of my Mu prototype. I also cleaned up my tracing layer to be a little nicer. Major improvements: - Realized that incremental tracing really ought to be the default. And to minimize printing traces to screen. - Finally figured out how to combine layers and call stack frames in a single dimension of depth. The answer: optimize for the experience of `browse_trace`. Instructions occupy a range of depths based on their call stack frame, and minor details of an instruction lie one level deeper in each case. Other than that, I spent some time adjusting levels everywhere to make `browse_trace` useful. --- subx/012elf.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'subx/012elf.cc') diff --git a/subx/012elf.cc b/subx/012elf.cc index 5220d18d..c9bbfc70 100644 --- a/subx/012elf.cc +++ b/subx/012elf.cc @@ -6,6 +6,7 @@ assert(argc > 1); if (is_equal(argv[1], "run")) { START_TRACING_UNTIL_END_OF_SCOPE; + trace(2, "run") << "=== Starting to run" << end(); assert(argc > 2); reset(); cerr << std::hex; @@ -88,8 +89,8 @@ void load_elf_contents(uint8_t* elf_contents, size_t size, int argc, char* argv[ void push(uint32_t val) { Reg[ESP].u -= 4; - trace(90, "run") << "decrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end(); - trace(90, "run") << "pushing value 0x" << HEXWORD << val << end(); + trace(Callstack_depth+1, "run") << "decrementing ESP to 0x" << HEXWORD << Reg[ESP].u << end(); + trace(Callstack_depth+1, "run") << "pushing value 0x" << HEXWORD << val << end(); write_mem_u32(Reg[ESP].u, val); } @@ -142,12 +143,12 @@ const int ARGV_DATA_SEGMENT = 0x0c000000; :(code) void dump_stack() { ostringstream out; - trace(91, "run") << "stack:" << end(); + trace(Callstack_depth+1, "run") << "stack:" << end(); for (uint32_t a = AFTER_STACK-4; a > Reg[ESP].u; a -= 4) - trace(91, "run") << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << end(); - trace(91, "run") << " 0x" << HEXWORD << Reg[ESP].u << " => 0x" << HEXWORD << read_mem_u32(Reg[ESP].u) << " <=== ESP" << end(); + trace(Callstack_depth+1, "run") << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << end(); + trace(Callstack_depth+1, "run") << " 0x" << HEXWORD << Reg[ESP].u << " => 0x" << HEXWORD << read_mem_u32(Reg[ESP].u) << " <=== ESP" << end(); for (uint32_t a = Reg[ESP].u-4; a > Reg[ESP].u-40; a -= 4) - trace(91, "run") << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << end(); + trace(Callstack_depth+1, "run") << " 0x" << HEXWORD << a << " => 0x" << HEXWORD << read_mem_u32(a) << end(); } inline uint32_t u32_in(uint8_t* p) { -- cgit 1.4.1-2-gfad0 c@akkartik.com> 2022-09-03 14:13:22 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2022-09-03 14:13:22 -0700 editing source code from within the app' href='/akkartik/text.love/commit/commands.lua?id=e1c5a42f311fdafd88506726bbe480f3fcc2d1a3'>e1c5a42 ^
f9bea77 ^
e1c5a42 ^
c112b8f ^
e1c5a42 ^
c112b8f ^
e1c5a42 ^
c112b8f ^
e1c5a42 ^












4ab901c ^
a54e594 ^
e1c5a42 ^


4ab901c ^
e1c5a42 ^



d141822 ^
4ab901c ^

9013eaa ^
bc464fe ^
9013eaa ^

bc464fe ^
9013eaa ^
36bde53 ^
9013eaa ^
b00232e ^


e1c5a42 ^


d141822 ^




















bc464fe ^
9013eaa ^

bc464fe ^
4ab901c ^
5c0ce8e ^





9013eaa ^




4ab901c ^
9013eaa ^



89b30a6 ^
e1c5a42 ^
89b30a6 ^
e1c5a42 ^
4b3f359 ^
89b30a6 ^
fd7d36f ^
89b30a6 ^

e1c5a42 ^
4ab901c ^
9013eaa ^

e1c5a42 ^

fd7d36f ^
690a1c3 ^
6ed6084 ^
715c6fd ^
fd7d36f ^


690a1c3 ^

007b965 ^
690a1c3 ^



fd7d36f ^






2b3e09c ^
21b1583 ^
bc464fe ^
e1c5a42 ^
fd7d36f ^
e1c5a42 ^
fd7d36f ^
d141822 ^





e1c5a42 ^







21b1583 ^



e1c5a42 ^

21b1583 ^
bc464fe ^









4ab901c ^
bc464fe ^















4ab901c ^
bc464fe ^









4ab901c ^
bc464fe ^






21b1583 ^


















4ab901c ^
21b1583 ^
















4ab901c ^
21b1583 ^






















d141822 ^
2b3e09c ^
d141822 ^


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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290