-
Notifications
You must be signed in to change notification settings - Fork 1
Explain
Matt Windsor edited this page Nov 13, 2018
·
6 revisions
The explain
command takes a C or assembly file and prints an annotated assembly listing with comments explaining how act
's language analysis interpreted each line. This is useful for debugging act
's language analysis and sanitisation processes.
$ act explain [FLAGS] (-compiler COMPILER_ID | -arch ARCH_NAME) FILE
If the input file is C, act
runs the compiler associated with the compiler ID, then processes the resulting assembly as if it were passed to explain
directly.
explain
takes the standard flags, as well as the following:
- One of
-compiler COMPILER_ID
or-arch ARCH_NAME
, whereCOMPILER_ID
is any compiler ID in the config file, andARCH_NAME
is any of the supported architectures. Note thatact
can only explain a C file if given a-compiler
.
-
-sanitise
: if present and true,act
does some basic sanitisation on the assembly (for example, removing directives and unused labels). -
-c
or-asm
: overridesact
's default file type behaviour, which is to consider the input as C if its name ends in.c
, or assembly otherwise. -
-track SYMBOLS
: asksact
to try to locate the given symbols (a single comma-delimited string) in the assembly. If any tracked symbols were located,act
will print out the mapping.
$ act explain -track "x,y,P1" -sanitise -compiler local.clang.x86.normal local/clang/x86/normal/asm/test_5.s
_P0: # <-- label (unused label, program boundary)
pushl %EBP # <-- stack (manipulates stack)
movl %ESP, %EBP # <-- move (manipulates stack)
subl $16, %ESP # <-- arith (manipulates stack)
movl $2, -4(%EBP) # <-- move
movl -4(%EBP), %EAX # <-- move
xchgl %EAX, _x # <-- RMW
movl $1, -8(%EBP) # <-- move
movl -8(%EBP), %ECX # <-- move
xchgl %ECX, _y # <-- RMW
movl %EAX, -12(%EBP) # <-- move
movl %ECX, -16(%EBP) # <-- move
addl $16, %ESP # <-- arith (manipulates stack)
popl %EBP # <-- stack (manipulates stack)
retl # <-- return
_P1: # <-- label (unused label, program boundary)
pushl %EBP # <-- stack (manipulates stack)
movl %ESP, %EBP # <-- move (manipulates stack)
subl $16, %ESP # <-- arith (manipulates stack)
movl $2, -4(%EBP) # <-- move
movl -4(%EBP), %EAX # <-- move
xchgl %EAX, _y # <-- RMW
movl $1, -8(%EBP) # <-- move
movl -8(%EBP), %ECX # <-- move
xchgl %ECX, _x # <-- RMW
movl %EAX, -12(%EBP) # <-- move
movl %ECX, -16(%EBP) # <-- move
addl $16, %ESP # <-- arith (manipulates stack)
popl %EBP # <-- stack (manipulates stack)
retl # <-- return
Symbol map:
x -> _x
y -> _y
P1 -> _P1