summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2014-09-15 22:50:10 +0200
committerPeter Korsgaard <peter@korsgaard.com>2014-09-16 22:52:37 +0200
commit84d584ea0dcdec8e9d2ca1ecd6c4df2e4bd7642f (patch)
tree34310de460bbe4644db2b3a5a9c07e78c37d9662
parentd79cc3cdef06365d8f15361beb4758c3c314a1b1 (diff)
downloadbuildroot-84d584ea0dcdec8e9d2ca1ecd6c4df2e4bd7642f.tar.gz
buildroot-84d584ea0dcdec8e9d2ca1ecd6c4df2e4bd7642f.zip
gdb: add support for Python in target gdb
This commit adds a new option BR2_PACKAGE_GDB_PYTHON to enable Python support in the target gdb. Since we can assume that the user will be aware that Python is needed to get Python support in gdb, we chose to use a "depends on" dependency instead of a "select" dependency. The other weird thing is the need for a wrapper shell script to replace gdb's provided python-config.py script. See the shell script comment itself for all the details. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
-rw-r--r--package/gdb/Config.in7
-rwxr-xr-xpackage/gdb/gdb-python-config36
-rw-r--r--package/gdb/gdb.mk7
3 files changed, 50 insertions, 0 deletions
diff --git a/package/gdb/Config.in b/package/gdb/Config.in
index 9622948b48..a96df1e464 100644
--- a/package/gdb/Config.in
+++ b/package/gdb/Config.in
@@ -60,6 +60,13 @@ config BR2_PACKAGE_GDB_TUI
https://sourceware.org/gdb/current/onlinedocs/gdb/TUI.html
+config BR2_PACKAGE_GDB_PYTHON
+ bool "Python support"
+ # Only Python 2.x is supported by gdb for now
+ depends on BR2_PACKAGE_PYTHON
+ help
+ This option enables Python support in the target gdb.
+
endif
endif
diff --git a/package/gdb/gdb-python-config b/package/gdb/gdb-python-config
new file mode 100755
index 0000000000..0f002281d7
--- /dev/null
+++ b/package/gdb/gdb-python-config
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# This shell script is used to fake Python. Gdb wants to be passed a
+# Python interpreter, to run its own python-config.py program, which
+# uses sysconfig. However, when cross-compiling, this doesn't work
+# well since we would have to use the host Python, whose sysconfig
+# module would return host values.
+#
+# As recommended at
+# https://sourceware.org/gdb/wiki/CrossCompilingWithPythonSupport,
+# this wrapper shell script can be used as a replacement. It ignores
+# the python-config.py script passed as first arguments, and
+# "emulates" its behavior.
+
+if [ $# -ne 2 ] ; then
+ echo "Bad # args." >&2
+ exit 1
+fi
+
+# The first argument is the path to python-config.py, ignore it.
+
+case "$2" in
+ --includes)
+ echo "-I${STAGING_DIR}/usr/include/python2.7"
+ ;;
+ --ldflags)
+ echo "-lpthread -ldl -lutil -lm -lpython2.7"
+ ;;
+ --exec-prefix)
+ echo "/usr"
+ ;;
+ *)
+ echo "Bad arg $2." >&2
+ exit 1
+ ;;
+esac
diff --git a/package/gdb/gdb.mk b/package/gdb/gdb.mk
index e12b12b477..e01431bb25 100644
--- a/package/gdb/gdb.mk
+++ b/package/gdb/gdb.mk
@@ -91,6 +91,13 @@ else
GDB_CONF_OPT += --disable-tui
endif
+ifeq ($(BR2_PACKAGE_GDB_PYTHON),y)
+ GDB_CONF_OPT += --with-python=$(TOPDIR)/package/gdb/gdb-python-config
+ GDB_DEPENDENCIES += python
+else
+ GDB_CONF_OPT += --without-python
+endif
+
# This removes some unneeded Python scripts and XML target description
# files that are not useful for a normal usage of the debugger.
define GDB_REMOVE_UNNEEDED_FILES
OpenPOWER on IntegriCloud