I write a program using assembly language and compile it by GCC
as following:
gcc -g sha256-avx.S main256.c -o test.exe
Now, I need to debug it. But I don't know how to the content of macro. The following is my method about using GDB
.
(gdb) s
400 vmovdqa XFER, _XFER(%rsp)
(gdb) s
401 FOUR_ROUNDS_AND_SCHED
(gdb) s
403 vpaddd 1*16(TBL), X0, XFER
(gdb) s
404 vmovdqa XFER, _XFER(%rsp)
(gdb) s
405 FOUR_ROUNDS_AND_SCHED
FOUR_ROUNDS_AND_SCHED
is a macro defined by myself.
.macro FOUR_ROUNDS_AND_SCHED
## compute s0 four at a time and s1 two at a time
## compute W[-16] + W[-7] 4 at a time
mov e, y0 # y0 = e
MY_ROR (25-11), y0 # y0 = e >> (25-11)
mov a, y1 # y1 = a
vpalignr $4, X2, X3, XTMP0 # XTMP0 = W[-7]
MY_ROR (22-13), y1 # y1 = a >> (22-13)
xor e, y0 # y0 = e ^ (e >> (25-11))
mov f, y2 # y2 = f
MY_ROR (11-6), y0 # y0 = (e >> (11-6)) ^ (e >> (25-6))
xor a, y1 # y1 = a ^ (a >> (22-13)
// ...
.endm
In fact, My_ROR
is also a macro defined in my program.
I want to watch the every instruction in macro(FOUR_ROUNDS_AND_SCHED
and My_ROR
) when debug program step-by-step using GDB. How should I compile my program?
How should I compile my program?
You can compile the program as you do now, but use x/4i $pc
to see actual instructions, and stepi
to single step instructions instead of lines.