aboutsummaryrefslogtreecommitdiff
path: root/lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py
diff options
context:
space:
mode:
authorDaniel Malea <daniel.malea@intel.com>2013-05-22 16:04:28 +0000
committerDaniel Malea <daniel.malea@intel.com>2013-05-22 16:04:28 +0000
commita7c86e1553be21cec9723156cec806a0743b8845 (patch)
tree66bb8cff246a7b4519163a5c2c5b144f8954ce23 /lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py
parente3d83fb8c35ebaaaec3256095cc3591c1297ab8c (diff)
downloadllvm-a7c86e1553be21cec9723156cec806a0743b8845.zip
llvm-a7c86e1553be21cec9723156cec806a0743b8845.tar.gz
llvm-a7c86e1553be21cec9723156cec806a0743b8845.tar.bz2
Implement attach by name in LLDB Vim plugin using ":Lattach <process-name>"
patch by Arthur Evstifeev llvm-svn: 182483
Diffstat (limited to 'lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py')
-rw-r--r--lldb/utils/vim-lldb/python-vim-lldb/lldb_controller.py27
1 files changed, 27 insertions, 0 deletions
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 77f5563..acc24b4 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()