GitHub - jart/disaster: Disassemble C/C++ code under cursor in Emacs
source link: https://github.com/jart/disaster
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
disaster.el – Disassemble C/C++ code under cursor in Emacs
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.
Installation
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)
Function Documentation
(disaster &optional FILE LINE)
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.
(disaster-find-project-root &optional LOOKS FILE)
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
.
Recommend
-
62
README.md Ace Jump Mode Ace jump mode is a minor mode of emacs, which help you to move the cursor within Emacs. You can move your cursor to AN...
-
49
README.md ninja-feet.vim In Practical Vim by Drew Neil, a...
-
77
How To: Disassemble Microsoft Sculpt Ergonomic keyboard and make it wired I could not find any tutorials on how to disassemble this keyboard so I thought I’d take pics along the way to disassembling mine. I also decided to mak...
-
5
Cosmopolitan Cosmopolitan Libc makes C a build-once run-anywhere language, like Java, except it doesn't need an interpreter or virtual machine. Instead, it reconfigures stock...
-
6
Copy link Contributor soerenmeier com...
-
3
vim-qf-preview A plugin for the quickfix and location list window to quickly preview the file with the quickfix item under the cursor in a popup window. Requirements Vim >= 8.1.2250 Usage...
-
5
sectorlisp sectorlisp is a 512-byte implementation of LISP that's able to bootstrap John McCarthy's meta-circular evaluator on bare metal.
-
5
Microsoft shows how to disassemble and repair Surface Laptop Studio Microsoft has published a new video on its Surface YouTube channel detailing the process of disassembling a...
-
6
Microsoft's new video shows how to disassemble Surface Laptop Go 2...
-
4
Open File Path Under Cursor 🚀nothing Xah Emacs Commands Emacs: Open File Path Under C...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK