Assuming I have my working folder as ~/X/ and the binaries after compiling are in ~/X/bin/ I usually first get the objdump like so:

objdump -D ~/X/bin/bin1 > bin1.list

then emacs bin1.list&

How is it possible to assign a function in .emacs to open a temporary buffer in Emacs and execute objdump -D in on the binary in it directly?

有帮助吗?

解决方案

Sure, by default the command M-! (shell-command) outputs shell output to a default output buffer.

M-! objdump -D /bin/ls

If you want to change the name of the output buffer, you can invoke shell-command through some elisp:

(shell-command "objdump -D /bin/ls" "ls.dump")

or

C-x C-w (write-file) - to write the shell output buffer to a file

Edit:

Example which grabs file at point if available, or prompts the user

(defun my-objdump-file (&optional file)
  (interactive)
  (unless file 
    (setq file (expand-file-name (or (thing-at-point 'filename)
                     (read-file-name "File: ")))))
  (when file
    (shell-command (concat "objdump -D "
               file)
           "*Objdump Output*")))
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top