Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request: gdb-python #993

Closed
skysider opened this issue May 6, 2017 · 3 comments · Fixed by #4718
Closed

Package request: gdb-python #993

skysider opened this issue May 6, 2017 · 3 comments · Fixed by #4718
Labels
package request A new package was requested.

Comments

@skysider
Copy link

skysider commented May 6, 2017

I notice that gdb installed doesn't support python scripting when I execute
gdb -batch -q --nx -ex 'pi import platform; print(".".join(platform.python_version_tuple()[:2]))'
it says Python scripting is not supported in this copy of GDB.

@fornwall fornwall added the package request A new package was requested. label May 7, 2017
@liamwhite
Copy link

liamwhite commented Dec 12, 2018

I was able to build gdb with python support by first building python2, then replacing packages/gdb/build.sh with

TERMUX_PKG_HOMEPAGE=https://www.gnu.org/software/gdb/
TERMUX_PKG_DESCRIPTION="The standard GNU Debugger that runs on many Unix-like systems and works for many programming languages"
TERMUX_PKG_DEPENDS="liblzma, libexpat, readline, ncurses, libmpfr, python2"
TERMUX_PKG_VERSION=8.2
TERMUX_PKG_SHA256=c3a441a29c7c89720b734e5a9c6289c0a06be7e0c76ef538f7bbcef389347c39
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/gdb/gdb-${TERMUX_PKG_VERSION}.tar.xz
# gdb can not build with our normal --disable-static: https://sourceware.org/bugzilla/show_bug.cgi?id=15916
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--with-system-readline
--with-curses
--with-python
--enable-static
ac_cv_func_getpwent=no
ac_cv_func_getpwnam=no
"
TERMUX_PKG_MAKE_INSTALL_TARGET="-C gdb install"
TERMUX_PKG_BUILD_IN_SRC="yes"

termux_step_pre_configure() {
    # Fix "undefined reference to 'rpl_gettimeofday'" when building:
    export gl_cv_func_gettimeofday_clobber=no
    export gl_cv_func_gettimeofday_posix_signature=yes
    export gl_cv_func_realpath_works=yes
    export gl_cv_func_lstat_dereferences_slashed_symlink=yes
    export gl_cv_func_memchr_works=yes
    export gl_cv_func_stat_file_slash=yes
    export gl_cv_func_frexp_no_libm=no
    export gl_cv_func_strerror_0_works=yes
    export gl_cv_func_working_strerror=yes
    export gl_cv_func_getcwd_path_max=yes
    export CFLAGS="$CFLAGS -I/home/builder/.termux-build/python2/src/Include -I/home/builder/.termux-build/python2/build"
    export CXXFLAGS="$CXXFLAGS -I/home/builder/.termux-build/python2/src/Include -I/home/builder/.termux-build/python2/build"
}

Here's a built package instead if you don't want to build it yourself
gdb_8.2_aarch64.zip

(note that it doesn't seem to have curses for tui, but if you care about that then just install cgdb, it's better anyway)

@liamwhite
Copy link

liamwhite commented Dec 14, 2018

I also added this patch to get the warning about unusable hardware breakpoints to go away as it was interfering with my work

diff -u -r ../gdb-8.1/gdb/nat/aarch64-linux-hw-point.c ./gdb/nat/aarch64-linux-hw-point.c
--- ../gdb-8.1/gdb/nat/aarch64-linux-hw-point.c	2018-09-05 07:27:13.000000000 +0000
+++ ./gdb/nat/aarch64-linux-hw-point.c	2018-12-14 04:23:56.153249285 +0000
@@ -780,8 +780,8 @@
     }
   else
     {
-      warning (_("Unable to determine the number of hardware watchpoints"
-		 " available."));
+      //warning (_("Unable to determine the number of hardware watchpoints"
+	//	 " available."));
       aarch64_num_wp_regs = 0;
     }
 
@@ -802,8 +802,8 @@
     }
   else
     {
-      warning (_("Unable to determine the number of hardware breakpoints"
-		 " available."));
+      //warning (_("Unable to determine the number of hardware breakpoints"
+	//	 " available."));
       aarch64_num_bp_regs = 0;
     }
 }

If you really want/need hardware breakpoint or watchpoint support, you will need to recompile your kernel. Modify this setting in the default arch Kconfig (not the one for your board):

diff --git a/arch/Kconfig b/arch/Kconfig
index 240bda0276b..8093bdaa8af 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -239,7 +239,7 @@ config HAVE_DMA_API_DEBUG
        bool
 
 config HAVE_HW_BREAKPOINT
-       bool
+       def_bool y
        depends on PERF_EVENTS
 
 config HAVE_MIXED_BREAKPOINTS_REGS

Then clean, build it, flash the resulting boot image and you should be set.

@delmarocks
Copy link

delmarocks commented Oct 23, 2019

@liamwhite Can you build the package for arm i tried to compile it on my device but all i get was error. How can i compile it if i have already installed gdb with no python-support?

I want to use gef to practice binary exploitation

Sent from my Galaxy J1(2016) using FastHub

@Auxilus Auxilus mentioned this issue Nov 18, 2019
@ghost ghost mentioned this issue Dec 30, 2019
@termux termux locked and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package request A new package was requested.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants