Last active
March 27, 2016 02:15
-
-
Save ytomino/a6e7a406cdfd41d2f4b3 to your computer and use it in GitHub Desktop.
Open gdb's current line with TextWrangler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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