Is there a way to retrieve the full assembly execution trace of a C program?

I have a couple C programs that I basically want to disassemble. I was using objdump, but I realized that is static disassembly. Is there anyway to get the full assembly-level trace of the program of the instructions executed in order? I am running on x86-64.

1 answer

  • answered 2020-08-06 20:42 Basile Starynkevitch

    Is there a way to retrieve the full stack trace/execution trace of a C program at the assembly level?

    The call stack might not even exist. Some C implementations could (in some simple cases) inline every function call and work in registers (but Rice's theorem shows that this is not always possible). That might happen with a recent GCC doing whole-program link-time optimizations (e.g. invoked with gcc -O3 -flto -fwhole-program for both compilation and linking steps)

    However, if you use Linux/x86-64 and if you want to retrieve at runtime the call stack, consider using Ian Taylor's libbacktrace. It is part of some recent GCC compilers.

    Is there anyway to get the full assembly-level trace of the program of the instructions executed in order?

    Alternatively, use and/or patch some processor emulator like Qemu.