Inspired by emacs plugin disaster, disenchant lets you see asm of the current C, C++, or Rust file.
Assembly code is generated by compiling the target containing the current file. The compilation method for C and C++ is chosen based on the following order of precedence:
compile_commands.json > Makefile > direct gcc/g++ invocation
Rust files in Cargo packages are compiled in their crate context. The package and target are
detected through cargo metadata, including library, binary, example, integration test, benchmark,
proc-macro, and build script targets. Required target features are enabled automatically. Standalone
Rust files are compiled directly with rustc.
The compiled artifact is passed to the configured objdump. If it cannot disassemble the artifact,
the plugin falls back to rust-objdump or llvm-objdump when either is available. The asm is then
shown in a split window.
Values inside opts are defaults. If you don't want to change them, opts can be {}.
{
"evilwaveforms/disenchant",
opts = {
keymap = {
disassemble = "<leader>om",
},
compile_command_c = "gcc -g3 -c %s -o %s",
compile_command_cpp = "g++ -g3 -c %s -o %s",
compile_command_rust = "rustc -g --emit=obj %s -o %s",
compile_command_rust_lib = "rustc -g --crate-type=lib --emit=obj %s -o %s",
cargo_command = "cargo",
cargo_args = {},
objdump_command = "objdump -Sl --demangle -Mintel --source-comment --no-show-raw-insn -d %s",
},
},Use cargo_args for project-specific Cargo options such as features, profiles, or target triples:
cargo_args = { "--all-features", "--release" }