Skip to content

Instantly share code, notes, and snippets.

@ytomino
Last active March 27, 2016 02:15
Show Gist options
  • Save ytomino/a6e7a406cdfd41d2f4b3 to your computer and use it in GitHub Desktop.
Save ytomino/a6e7a406cdfd41d2f4b3 to your computer and use it in GitHub Desktop.
Open gdb's current line with TextWrangler
import subprocess
edit = "/usr/local/bin/edit"
last_filename = None
def stop_handler(event):
global last_filename
line_info = gdb.decode_line()[1][0]
window = "--new-window"
if last_filename != None:
try:
command = [edit, "-b", last_filename]
r = subprocess.call(command)
if(r != 0): raise OSError(command)
window = "--front-window"
except OSError as e:
print e.value
last_filename = line_info.symtab.fullname()
command = [edit, "-b", window,
last_filename + ":" + str(line_info.line)]
try:
r = subprocess.call(command)
if(r != 0): raise OSError(command)
except OSError as e:
print e.value
gdb.events.stop.connect(stop_handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment