jart / jart/disaster

Mixed source/assembly on Mac OS X?

Open
#6 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
348
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Hi there,

somehow I can't get mixed source/assembly on Mac OS X to work, at least not using gobjdump or otool. Is there a 'canonical' way to do this? If not, the following kludge more-or-less works if gdb has been compiled with Python support (v3 in this case, also using use-package to load disaster):

== .gdbinit part

``` python
python
import re
class DisassembleLine(gdb.Command):

"""Disassemble around given line specification."""

def __init__(self):
super(DisassembleLine, self).__init__(
"disassemble-line", gdb.COMMAND_USER)

def address_for_line(self, linespec):
lineinfo = gdb.execute('info line ' + linespec, to_string=True)
address_match = re.match('.* starts at address (.*?) ', lineinfo)
if address_match is None:
return None
else:
return address_match.group(1)

def invoke(self, arg, from_tty):
address = self.address_for_line(arg)
if address is None:
print("Error: location {0} could not be found".format(arg))
else:
print(gdb.execute('disassemble /m ' + address, to_string=True))

DisassembleLine()
end
```

== elisp part

``` elisp
(use-package disaster
:config (progn
(add-c-hook (lambda () (local-set-key (kbd "C-c C-d") 'disaster)))
(defadvice disaster (before disaster-point-gdb-to-function)
(setq disaster-objdump
(format "gdb --batch -ex \"disassemble-line %s:%s\""
(file-name-nondirectory buffer-file-truename)
(line-number-at-pos (point))))
(ad-activate 'disaster)))
```

If there is a better way, please tell me; if not, maybe this workaround could find its way into the disaster repo for the convenience of my fellow Mac users?
best,
Sebastian

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the .gdbinit Python command and the Emacs Lisp disaster configuration shown in the issue, then inspect disaster's existing disassembly entry point. Determine whether the reported Mac OS X mixed source/assembly workflow can be supported directly; done means the workflow works without the described workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp, macos
Domain
desktop, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.