def emacs_updater(ignore): "Automatically update Emacs with the current location." # Don't bother if inside emacs. if not gdbhelpers.in_emacs(): try: frame = gdb.selected_frame() except: frame = None if frame and frame.find_sal(): sal = frame.find_sal() if sal.symtab and sal.symtab.filename and sal.line: global _last_command command = 'emacsclient -n +%d %s' % (sal.line, sal.symtab.filename) if command is not _last_command: _last_command = command os.system(command) return ''
import gdb import gdbhelpers import os if gdbhelpers.in_emacs(): # The blocking behavior of "edit" doesn't seem too useful, # especially when running inside Emacs, so this just disables it. # See the "ecomm" command though. os.environ["EDITOR"] = "emacsclient -n" os.environ["BLOCKING_EDITOR"] = "emacsclient" # At some point this stopped working automatically. # Maybe because Emacs switched back to --fullname? gdb.execute('set pagination off', to_string = True)