Commit b6678cdc authored by André Anjos's avatar André Anjos 💬
Browse files

Implement C/C++ debugging with lldb

parent 39189967
Pipeline #16674 passed with stage
in 2 minutes and 36 seconds
#!/usr/bin/env python #!/usr/bin/env python
# vim: set fileencoding=utf-8 : # vim: set fileencoding=utf-8 :
# Andre Anjos <andre.dos.anjos@gmail.com> # Andre Anjos <andre.anjos@idiap.ch>
# Mon 4 Feb 14:12:24 2013 # Wed 7 Feb 12:02:22 2018 CET
"""Builds a custom python script interpreter that is executed inside gdb """Builds a custom python script interpreter that is executed inside gdb/lldb
""" """
import platform
from .python import Recipe as Script from .python import Recipe as Script
# Python interpreter script template # Python interpreter script template
class Recipe(Script): class Recipe(Script):
"""Just creates a gdb executable running a python interpreter with the """Just creates a gdb/lldb executable running a python interpreter with the
"correct" paths "correct" paths
""" """
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
# Preprocess some variables if platform.system() != 'Darwin':
self.interpreter = options.setdefault('interpreter', 'gdb-python') self.interpreter = options.setdefault('interpreter', 'gdb-python')
else:
self.interpreter = options.setdefault('interpreter', 'lldb-python')
# initializes the script infrastructure # initializes the script infrastructure
super(Recipe, self).__init__(buildout, name, options) super(Recipe, self).__init__(buildout, name, options)
self.set_template("""#!%(interpreter)s if platform.system() != 'Darwin':
self.set_template("""#!%(interpreter)s
# %(date)s # %(date)s
'''Dummy program - only starts a new one with a proper environment''' '''Dummy program - only starts a new one with a proper environment'''
...@@ -35,8 +39,27 @@ os.environ["PYTHONPATH"] = os.environ["PYTHONPATH"].strip(os.pathsep) ...@@ -35,8 +39,27 @@ os.environ["PYTHONPATH"] = os.environ["PYTHONPATH"].strip(os.pathsep)
import sys import sys
if sys.argv[1] in ('-?', '-h', '--help'): if sys.argv[1] in ('-?', '-h', '--help'):
os.execvp("gdb", sys.argv) os.execvp('gdb', sys.argv)
else: else:
args = [sys.argv[0], "--ex", "r", "--args", "%(interpreter)s"] + sys.argv[1:] args = [sys.argv[0], 'gdb', '--args', "%(interpreter)s"] + sys.argv[1:]
os.execvp("gdb", args) os.execvp('gdb', args)
""")
else:
self.set_template("""#!%(interpreter)s
# %(date)s
'''Dummy program - only starts a new one with a proper environment'''
import os
existing = os.environ.get("PYTHONPATH", "")
os.environ["PYTHONPATH"] = "%(paths)s" + os.pathsep + existing
os.environ["PYTHONPATH"] = os.environ["PYTHONPATH"].strip(os.pathsep)
import sys
if sys.argv[1] in ('-?', '-h', '--help'):
os.execvp('lldb', sys.argv)
else:
args = [sys.argv[0], 'lldb', '--', "%(interpreter)s"] + sys.argv[1:]
os.execvp('lldb', args)
""") """)
...@@ -14,7 +14,7 @@ import zc.buildout ...@@ -14,7 +14,7 @@ import zc.buildout
from . import tools from . import tools
from .script import Recipe as Script from .script import Recipe as Script
from .python import Recipe as PythonInterpreter from .python import Recipe as PythonInterpreter
from .gdbpy import Recipe as GdbPythonInterpreter from .dbpy import Recipe as DebuggerPythonInterpreter
from .envwrapper import EnvironmentWrapper from .envwrapper import EnvironmentWrapper
def version_is_lessthan(name, version): def version_is_lessthan(name, version):
...@@ -228,7 +228,8 @@ class Recipe(object): ...@@ -228,7 +228,8 @@ class Recipe(object):
self.python = PythonInterpreter(buildout, 'Python', options.copy()) self.python = PythonInterpreter(buildout, 'Python', options.copy())
#self.ipython = IPythonInterpreter(buildout, 'IPython', options.copy()) #self.ipython = IPythonInterpreter(buildout, 'IPython', options.copy())
self.gdbpy = GdbPythonInterpreter(buildout, 'GdbPython', options.copy()) self.dbpy = DebuggerPythonInterpreter(buildout, 'DebugPython',
options.copy())
self.scripts = UserScripts(buildout, 'Scripts', options.copy()) self.scripts = UserScripts(buildout, 'Scripts', options.copy())
self.nose = NoseTests(buildout, 'Nose', options.copy()) self.nose = NoseTests(buildout, 'Nose', options.copy())
self.coverage = Coverage(buildout, 'Coverage', options.copy()) self.coverage = Coverage(buildout, 'Coverage', options.copy())
...@@ -238,7 +239,7 @@ class Recipe(object): ...@@ -238,7 +239,7 @@ class Recipe(object):
with self.envwrapper as ew: with self.envwrapper as ew:
return \ return \
self.python.install_on_wrapped_env() + \ self.python.install_on_wrapped_env() + \
self.gdbpy.install_on_wrapped_env() + \ self.dbpy.install_on_wrapped_env() + \
self.scripts.install_on_wrapped_env() + \ self.scripts.install_on_wrapped_env() + \
self.nose.install_on_wrapped_env() + \ self.nose.install_on_wrapped_env() + \
self.coverage.install_on_wrapped_env() + \ self.coverage.install_on_wrapped_env() + \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment