diff options
| -rw-r--r-- | lldb/utils/vim-lldb/plugin/lldb.vim | 2 | ||||
| -rw-r--r-- | lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py | 27 | 
2 files changed, 29 insertions, 0 deletions
diff --git a/lldb/utils/vim-lldb/plugin/lldb.vim b/lldb/utils/vim-lldb/plugin/lldb.vim index c69fe7b2255..8121a73d025 100644 --- a/lldb/utils/vim-lldb/plugin/lldb.vim +++ b/lldb/utils/vim-lldb/plugin/lldb.vim @@ -47,6 +47,8 @@ function! s:InitLldbPlugin()    " Launching convenience commands (no autocompletion)    command -nargs=* Lstart                                                python ctrl.doLaunch(True,  '<args>')    command -nargs=* Lrun                                                  python ctrl.doLaunch(False, '<args>') +  command -nargs=1 Lattach                                               python ctrl.doAttach('<args>') +  command -nargs=0 Ldetach                                               python ctrl.doDetach()    " Regexp-commands: because vim's command mode does not support '_' or '-'    " characters in command names, we omit them when creating the :L<cmd> diff --git a/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py b/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py index 77f556361c7..acc24b44a49 100644 --- a/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py +++ b/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py @@ -141,6 +141,33 @@ class LLDBController(object):      else:        self.doLaunch('-s' not in args, "") +  def doAttach(self, process_name): +    """ Handle process attach.  """ +    error = lldb.SBError() +     +    self.processListener = lldb.SBListener("process_event_listener") +    self.target = self.dbg.CreateTarget('') +    self.process = self.target.AttachToProcessWithName(self.processListener, process_name, False, error) +    if not error.Success(): +      sys.stderr.write("Error during attach: " + str(error)) +      return + +    self.ui.activate() + +    # attach succeeded, store pid and add some event listeners +    self.pid = self.process.GetProcessID() +    self.process.GetBroadcaster().AddListener(self.processListener, lldb.SBProcess.eBroadcastBitStateChanged) +    self.doContinue() + +    print "Attached to %s (pid=%d)" % (process_name, self.pid) + +  def doDetach(self): +    if self.process is not None and self.process.IsValid(): +      pid = self.process.GetProcessID() +      state = state_type_to_str(self.process.GetState()) +      self.process.Detach() +      self.processPendingEvents(self.eventDelayLaunch) +    def doLaunch(self, stop_at_entry, args):      """ Handle process launch.  """      error = lldb.SBError()  | 

