GDB: Better Python debugging support (#20486)
* GDB: Better Python debugging support * Auto-load safe path * Use gdbinit instead
This commit is contained in:
parent
8f92970714
commit
b421080c03
@ -4,6 +4,7 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack import *
|
||||
import os
|
||||
|
||||
|
||||
class Gdb(AutotoolsPackage, GNUMirrorPackage):
|
||||
@ -15,6 +16,9 @@ class Gdb(AutotoolsPackage, GNUMirrorPackage):
|
||||
homepage = "https://www.gnu.org/software/gdb"
|
||||
gnu_mirror_path = "gdb/gdb-7.10.tar.gz"
|
||||
|
||||
maintainers = ['robertu94']
|
||||
|
||||
version('10.1', sha256='f12f388b99e1408c01308c3f753313fafa45517740c81ab7ed0d511b13e2cf55')
|
||||
version('9.2', sha256='38ef247d41ba7cc3f6f93a612a78bab9484de9accecbe3b0150a3c0391a3faf0')
|
||||
version('9.1', sha256='fcda54d4f35bc53fb24b50009a71ca98410d71ff2620942e3c829a7f5d614252')
|
||||
version('8.3.1', sha256='26ce655216cd03f4611518a7a1c31d80ec8e884c16715e9ba8b436822e51434b')
|
||||
@ -45,7 +49,7 @@ class Gdb(AutotoolsPackage, GNUMirrorPackage):
|
||||
depends_on('texinfo', type='build')
|
||||
|
||||
# Optional dependencies
|
||||
depends_on('python', when='+python')
|
||||
depends_on('python+debug', when='+python', type=('build', 'link', 'run'))
|
||||
depends_on('xz', when='+xz')
|
||||
depends_on('source-highlight', when='+source-highlight')
|
||||
depends_on('ncurses', when='+tui')
|
||||
@ -53,7 +57,10 @@ class Gdb(AutotoolsPackage, GNUMirrorPackage):
|
||||
build_directory = 'spack-build'
|
||||
|
||||
def configure_args(self):
|
||||
args = []
|
||||
args = [
|
||||
'--with-system-gdbinit={0}'.format(self.prefix.etc.gdbinit)
|
||||
]
|
||||
|
||||
if '+python' in self.spec:
|
||||
args.append('--with-python')
|
||||
args.append('LDFLAGS={0}'.format(
|
||||
@ -75,3 +82,12 @@ def configure_args(self):
|
||||
args.append('--enable-tui')
|
||||
|
||||
return args
|
||||
|
||||
@run_after('install')
|
||||
def gdbinit(self):
|
||||
if '+python' in self.spec:
|
||||
tool = self.spec['python'].command.path + '-gdb.py'
|
||||
if os.path.exists(tool):
|
||||
mkdir(self.prefix.etc)
|
||||
with open(self.prefix.etc.gdbinit, 'w') as gdbinit:
|
||||
gdbinit.write('add-auto-load-safe-path {0}\n'.format(tool))
|
||||
|
@ -619,6 +619,13 @@ def symlink(self):
|
||||
os.symlink(os.path.join(prefix.bin, 'python3-config'),
|
||||
os.path.join(prefix.bin, 'python-config'))
|
||||
|
||||
@run_after('install')
|
||||
def install_python_gdb(self):
|
||||
# https://devguide.python.org/gdb/
|
||||
src = os.path.join('Tools', 'gdb', 'libpython.py')
|
||||
if os.path.exists(src):
|
||||
install(src, self.command.path + '-gdb.py')
|
||||
|
||||
@run_after('install')
|
||||
@on_package_attributes(run_tests=True)
|
||||
def import_tests(self):
|
||||
|
Loading…
Reference in New Issue
Block a user