From 2bb15c8d75a75f1d75d52ca63017e9492753b8ef Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Fri, 20 Dec 2024 23:35:12 +0100 Subject: disasm: move out and implement on asm/rt --- src/asm.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/asm.rs') diff --git a/src/asm.rs b/src/asm.rs index 8647e83..1790e4e 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -42,6 +42,19 @@ impl Asm { self.buf } + /// Disassemble the code currently added to the runtime, using + /// [`ndisasm`](https://nasm.us/index.php) and print it to _stdout_. If + /// `ndisasm` is not available on the system this prints a warning and + /// becomes a nop. + /// + /// # Panics + /// + /// Panics if anything goes wrong with spawning, writing to or reading from + /// the `ndisasm` child process. + pub fn disasm(&self) { + crate::disasm::disasm(&self.buf); + } + /// Emit a slice of bytes. pub(crate) fn emit(&mut self, bytes: &[u8]) { self.buf.extend_from_slice(bytes); -- cgit v1.2.3