Disaster lets you press C-c d
to see the compiled assembly code for the
C/C++ file you're currently editing. It even jumps to and highlights the
line of assembly corresponding to the line beneath your cursor.
It works by creating a .o
file using make (if you have a Makefile) or the
default system compiler. It then runs that file through objdump to generate
the human-readable assembly.
Make sure to place disaster.el
somewhere in the load-path and add the
following lines to your .emacs
file to enable the C-c d
shortcut to
invoke disaster
:
(add-to-list 'load-path "/PATH/TO/DISASTER")
(require 'disaster)
(define-key c-mode-base-map (kbd "C-c d") 'disaster)
Shows assembly code for current line of C/C++ file.
Here's the logic path it follows:
- Is there a Makefile in this directory? Run
make bufname.o
. - Or is there a Makefile in a parent directory? Run
make -C .. bufname.o
. - Or is this a C file? Run
cc -g -O3 -c -o bufname.o bufname.c
- Or is this a C++ file? Run
c++ -g -O3 -c -o bufname.o bufname.c
- If build failed, display errors in compile-mode.
- Run objdump inside a new window while maintaining focus.
- Jump to line matching current line.
If FILE and LINE are not specified, the current editing location is used.
General-purpose Heuristic to detect bottom directory of project.
This works by scanning parent directories of FILE (using
disaster--find-parent-dirs
) for certain types of files like a
.git/
directory or a Makefile
(which is less preferred).
The canonical structure of LOOKS is a list of lists of files
to look for in each parent directory where sublists are ordered
from highest precedence to lowest. However you may specify
LOOKS as a single string or a list of strings for your
convenience. If LOOKS is not specified, it'll default to
disaster-project-root-files
.