Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit e8ccf57

Browse files
committed
intercept_template.s - add more debug information
Add some dwarf information on the whereabouts of some register values saved on the stack. The faked return address points a debugger to a backtrace_placeholder routine, where the return address (in debug builds) is found on the top of the stack, and with this patch the values of some other registers are also found on the stack by a debugger. These registers are pushed on the stack by an instance generated from the assembly template, so the offsets in the placeholder routines (which are never actually executed) must match the offsets resulting from the push instructions in the actually executed code.
1 parent 69494d9 commit e8ccf57

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/intercept_template.s

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,25 @@
248248

249249
backtrace_placeholder:
250250
.cfi_startproc
251+
/*
252+
* Call Frame Information. The stack size is 0x580,
253+
* and the cfi_offset entries mark the place of a each
254+
* register's previous value in the call frame.
255+
*/
251256
.cfi_def_cfa_offset 0x580
257+
.cfi_offset 6, -136 /* rbp */
258+
.cfi_offset 15, -152 /* r15 */
259+
.cfi_offset 14, -160 /* r14 */
260+
.cfi_offset 13, -168 /* r13 */
261+
.cfi_offset 12, -176 /* r12 */
262+
.cfi_offset 10, -184 /* r10 */
263+
.cfi_offset 9, -192 /* r9 */
264+
.cfi_offset 8, -200 /* r8 */
265+
.cfi_offset 2, -208 /* rcx */
266+
.cfi_offset 4, -216 /* rdx */
267+
/* rsi at -224 */
268+
/* rdi at -232 */
269+
.cfi_offset 3, -240 /* rbx */
252270
nop
253271
nop
254272
nop
@@ -260,6 +278,19 @@ backtrace_placeholder:
260278
backtrace_placeholder_2:
261279
.cfi_startproc
262280
.cfi_def_cfa_offset 0x588
281+
.cfi_offset 6, -136 /* rbp */
282+
.cfi_offset 15, -152 /* r15 */
283+
.cfi_offset 14, -160 /* r14 */
284+
.cfi_offset 13, -168 /* r13 */
285+
.cfi_offset 12, -176 /* r12 */
286+
.cfi_offset 10, -184 /* r10 */
287+
.cfi_offset 9, -192 /* r9 */
288+
.cfi_offset 8, -200 /* r8 */
289+
.cfi_offset 2, -208 /* rcx */
290+
.cfi_offset 4, -216 /* rdx */
291+
/* rsi at -224 */
292+
/* rdi at -232 */
293+
.cfi_offset 3, -240 /* rbx */
263294
nop
264295
nop
265296
nop

0 commit comments

Comments
 (0)