From 6da16dc8248fd92b65e83cef235e5205d70e4642 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 9 Sep 2013 18:10:34 +0300 Subject: Upgrade to GDB 7.6.1 Change-Id: I9865d7d941719ddc228b6e4dea9abf0d702e3653 Reviewed-by: hjk Reviewed-by: David Schulz --- dist/gdb/Makefile.linux | 4 +- dist/gdb/Makefile.mingw | 15 ++-- dist/gdb/Makefile.osx | 2 +- dist/gdb/patches/datadir.patch | 142 ++++++++++++++++++++++++++++++++++ dist/gdb/patches/gdb-ipv6.patch | 34 ++++---- dist/gdb/patches/pythonhome-7.4.patch | 38 --------- dist/gdb/patches/pythonhome.patch | 19 +++++ 7 files changed, 190 insertions(+), 64 deletions(-) create mode 100644 dist/gdb/patches/datadir.patch delete mode 100644 dist/gdb/patches/pythonhome-7.4.patch create mode 100644 dist/gdb/patches/pythonhome.patch diff --git a/dist/gdb/Makefile.linux b/dist/gdb/Makefile.linux index 6f78d2b19e..7f5e78a5ab 100644 --- a/dist/gdb/Makefile.linux +++ b/dist/gdb/Makefile.linux @@ -5,7 +5,7 @@ staging=${broot}/staging pyversion=2.7 expatversion=2.0.1 arch=`uname -sm | sed 's/ /-/g' | tr A-Z a-z` -version=7.5 +version=7.6.1 targetdir=${broot}/qtcreator-gdb-${version} gdbtargets=$(addprefix ${targetdir}/gdb-, ${targets}) packagename=qtcreator-gdb-${version}-${arch}.tar.gz @@ -67,7 +67,7 @@ ${staging}/gdb-${version}/configure: ${source}/gdb-${version}.tar.bz2 | makestag tar xf ${source}/gdb-${version}.tar.bz2 && \ cd gdb-${version} && \ touch configure && \ - patch -p2 < ${broot}/patches/pythonhome-7.4.patch && \ + patch -p1 < ${broot}/patches/pythonhome.patch && \ patch -p2 < ${broot}/patches/gdb-ipv6.patch ${gdbtargets}: ${targetdir}/gdb-%: ${staging}/gdb-${version}/configure ${staging}/lib/libpython${pyversion}.a ${staging}/lib/libexpat.a | maketargetdir diff --git a/dist/gdb/Makefile.mingw b/dist/gdb/Makefile.mingw index 239205b0e0..af2fcb83af 100644 --- a/dist/gdb/Makefile.mingw +++ b/dist/gdb/Makefile.mingw @@ -6,10 +6,10 @@ pyversion=2.7 pydir=${broot}/python expatversion=2.0.1 iconvversion=1.14 -version=7.5 +version=7.6.1 targetdir=${broot}/qtcreator-gdb-${version} gdbtargets=$(addprefix ${targetdir}/gdb-, ${targets}) -packageparts=${targetdir}/lib ${targetdir}/lib ${targetdir}/libiconv-2.dll ${targetdir}/python27.dll ${targetdir}/libexpat-1.dll +packageparts=${targetdir}/lib ${targetdir}/data-directory ${targetdir}/libiconv-2.dll ${targetdir}/python27.dll ${targetdir}/libexpat-1.dll arch=`uname -sm | sed 's/ /-/g' | tr A-Z a-z` packagename=qtcreator-gdb-${version}-${arch}.tar.gz @@ -73,14 +73,15 @@ ${staging}/gdb-${version}/configure: ${source}/gdb-${version}.tar.bz2 | makestag tar xf ${source}/gdb-${version}.tar.bz2 && \ cd gdb-${version} && \ touch configure && \ - patch -p2 < ${broot}/patches/gdb-ipv6.patch + patch -p2 < ${broot}/patches/gdb-ipv6.patch && \ + patch -p1 < ${broot}/patches/datadir.patch ${staging}/lib/libiconv.a: ${source}/libiconv-${iconvversion}.tar.gz | makestagingdir cd ${staging} && \ echo "Extracting iconv..." && \ tar xf ${source}/libiconv-${iconvversion}.tar.gz && \ cd libiconv-${iconvversion} && \ - ./configure -prefix=${staging} --enable-static && \ + ./configure -prefix=${staging} --enable-static --build=i686-pc-mingw32 && \ ${MAKE} && ${MAKE} install ${staging}/lib/libexpat.a: ${source}/expat-${expatversion}.tar.gz | makestagingdir @@ -88,7 +89,7 @@ ${staging}/lib/libexpat.a: ${source}/expat-${expatversion}.tar.gz | makestagingd echo "Extracting expat..." && \ tar xf ${source}/expat-${expatversion}.tar.gz && \ cd expat-${expatversion} && \ - ./configure -prefix=${staging} --enable-static && \ + ./configure -prefix=${staging} --enable-static --build=i686-pc-mingw32 && \ ${MAKE} && ${MAKE} install ${gdbtargets}: ${targetdir}/gdb-%: ${staging}/lib/libexpat.a ${staging}/lib/libiconv.a ${staging}/gdb-${version}/configure | maketargetdir ${broot}/python/python.exe @@ -97,7 +98,7 @@ ${gdbtargets}: ${targetdir}/gdb-%: ${staging}/lib/libexpat.a ${staging}/lib/libi LDFLAGS="L${pydir} -lpthread -ldl -lutil -lpython27" && \ CFLAGS="-I${pydir}/include" && \ cd ${staging}/gdb-${version}-$* && \ - ${staging}/gdb-${version}/configure --target=$* --disable-nls --disable-werror \ + ${staging}/gdb-${version}/configure --target=$* --disable-nls --disable-werror --build=i686-pc-mingw32 \ --with-libiconv-prefix=${staging} \ --with-expat --with-libexpat-prefix=${staging} \ --with-separate-debug-dir="" \ @@ -110,6 +111,8 @@ package: ${gdbtargets} ${broot}/python/python.exe cp ${staging}/bin/libexpat* ${targetdir} && \ cp ${pydir}/python*.dll ${targetdir} && \ cp -r ${pydir}/lib ${targetdir} && \ + mkdir -p ${targetdir}/data-directory && \ + cp -r ${staging}/gdb-${version}-i686-pc-mingw32/gdb/data-directory/{python,syscalls} ${targetdir}/data-directory && \ mv ${targetdir} ${targetdir}-${arch} && \ echo "Packing..." && \ tar czf ${packagename} qtcreator-gdb-${version}-${arch} && \ diff --git a/dist/gdb/Makefile.osx b/dist/gdb/Makefile.osx index 4e74192be9..7ce587eb05 100644 --- a/dist/gdb/Makefile.osx +++ b/dist/gdb/Makefile.osx @@ -5,7 +5,7 @@ staging=${broot}/staging pyversion=2.7 expatversion=2.0.1 arch=`uname -sm | sed 's/ /-/g' | tr A-Z a-z` -version=7.5 +version=7.6.1 targetdir=${broot}/qtcreator-gdb-${version} gdbtargets=$(addprefix ${targetdir}/gdb-, ${targets}) packagename=qtcreator-gdb-${version}-${arch}.tar.gz diff --git a/dist/gdb/patches/datadir.patch b/dist/gdb/patches/datadir.patch new file mode 100644 index 0000000000..a688ceccc5 --- /dev/null +++ b/dist/gdb/patches/datadir.patch @@ -0,0 +1,142 @@ +Source: http://sourceware-org.1504.n7.nabble.com/PATCH-Try-to-initialize-data-directory-by-first-searching-for-quot-data-directory-quot-in-the-same-dy-td73462.html + +orgads: Removed last dir separator before calling stat +diff --git a/gdb/main.c b/gdb/main.c +--- a/gdb/main.c ++++ b/gdb/main.c +@@ -98,17 +98,38 @@ static char *gdb_program_name; + + static void print_gdb_help (struct ui_file *); + +-/* Relocate a file or directory. PROGNAME is the name by which gdb +- was invoked (i.e., argv[0]). INITIAL is the default value for the +- file or directory. FLAG is true if the value is relocatable, false +- otherwise. Returns a newly allocated string; this may return NULL +- under the same conditions as make_relative_prefix. */ ++/* Relocate a file or directory, checking if it exists. PROGNAME is the ++ name by which gdb was invoked (i.e., argv[0]). INITIAL is the default ++ value for the file or directory. ISDIR is true if INITIAL is a ++ directory. FLAG is true if the value is relocatable, false otherwise. ++ Returns a newly allocated string; this may return NULL under the same ++ conditions as make_relative_prefix, or if the relocated path does not ++ exist. */ + + static char * +-relocate_path (const char *progname, const char *initial, int flag) ++relocate_path (const char *progname, const char *initial, int isdir, ++ int flag) + { + if (flag) +- return make_relative_prefix (progname, BINDIR, initial); ++ { ++ char *path; ++ path = make_relative_prefix (progname, BINDIR, initial); ++ if (path) ++ { ++ struct stat s; ++ ++ char *last = path + strlen(path) - 1; ++ if (IS_DIR_SEPARATOR(*last)) ++ *last = '\0'; ++ ++ if (*path == 0 || stat (path, &s) != 0 || (!isdir != !S_ISDIR (s.st_mode))) ++ { ++ xfree (path); ++ path = NULL; ++ } ++ } ++ return path; ++ } + return xstrdup (initial); + } + +@@ -123,19 +144,52 @@ relocate_gdb_directory (const char *init + { + char *dir; + +- dir = relocate_path (gdb_program_name, initial, flag); +- if (dir) ++ dir = relocate_path (gdb_program_name, initial, 1, flag); ++ if (!dir) ++ dir = xstrdup (initial); ++ ++ /* Canonicalize the directory. */ ++ if (*dir) + { +- struct stat s; ++ char *canon_sysroot = lrealpath (dir); + +- if (*dir == '\0' || stat (dir, &s) != 0 || !S_ISDIR (s.st_mode)) ++ if (canon_sysroot) + { + xfree (dir); +- dir = NULL; ++ dir = canon_sysroot; + } + } ++ ++ return dir; ++} ++ ++/* Like relocate_gdb_path, but specifically for data-directory. */ ++ ++static char * ++relocate_gdb_data_directory (void) ++{ ++ char *dir; ++ ++ /* First try to find "data-directory" in the same directory as gdb. ++ ++ Use relocate_path only to resolve the parent directory of ++ gdb_program_name (i.e., based on PATH if necessary); relocate_path ++ (gdb_program_name, BINDIR "/data-directory") cannot be used to resolve ++ data-directory as it returns a path relative to the _grandparent ++ directory_ of gdb_program_name (munging the parent directory). */ ++ ++ dir = relocate_path (gdb_program_name, BINDIR, 1, 1); ++ if (dir) ++ dir = reconcat (dir, dir, SLASH_STRING, "data-directory", NULL); ++ ++ /* Then try to find GDB_DATADIR relocated relative to gdb. */ + if (!dir) +- dir = xstrdup (initial); ++ dir = relocate_path (gdb_program_name, GDB_DATADIR, 1, ++ GDB_DATADIR_RELOCATABLE); ++ ++ /* Otherwise use GDB_DATADIR as is. */ ++ if (!dir) ++ dir = xstrdup (GDB_DATADIR); + + /* Canonicalize the directory. */ + if (*dir) +@@ -169,7 +223,7 @@ get_init_files (char **system_gdbinit, + + if (!initialized) + { +- struct stat homebuf, cwdbuf, s; ++ struct stat homebuf, cwdbuf; + char *homedir; + + if (SYSTEM_GDBINIT[0]) +@@ -200,9 +254,10 @@ get_init_files (char **system_gdbinit, + { + relocated_sysgdbinit = relocate_path (gdb_program_name, + SYSTEM_GDBINIT, ++ 0, + SYSTEM_GDBINIT_RELOCATABLE); + } +- if (relocated_sysgdbinit && stat (relocated_sysgdbinit, &s) == 0) ++ if (relocated_sysgdbinit) + sysgdbinit = relocated_sysgdbinit; + else + xfree (relocated_sysgdbinit); +@@ -404,8 +459,7 @@ captured_main (void *data) + debug_file_directory = relocate_gdb_directory (DEBUGDIR, + DEBUGDIR_RELOCATABLE); + +- gdb_datadir = relocate_gdb_directory (GDB_DATADIR, +- GDB_DATADIR_RELOCATABLE); ++ gdb_datadir = relocate_gdb_data_directory (); + + #ifdef WITH_PYTHON_PATH + { diff --git a/dist/gdb/patches/gdb-ipv6.patch b/dist/gdb/patches/gdb-ipv6.patch index 92d92bbd90..d595f7edd1 100644 --- a/dist/gdb/patches/gdb-ipv6.patch +++ b/dist/gdb/patches/gdb-ipv6.patch @@ -1,7 +1,7 @@ -diff -Nru a/gdb-7.5.1/gdb/gdbserver/gdbreplay.c b/gdb-7.5.1/gdb/gdbserver/gdbreplay.c ---- a/gdb-7.5.1/gdb/gdbserver/gdbreplay.c 2012-08-22 13:05:02 -0700 -+++ b/gdb-7.5.1/gdb/gdbserver/gdbreplay.c 2013-04-15 03:20:40 -0700 -@@ -190,14 +190,41 @@ +diff -Nru a/gdb-7.6.1/gdb/gdbserver/gdbreplay.c b/gdb-7.6.1/gdb/gdbserver/gdbreplay.c +--- a/gdb-7.6.1/gdb/gdbserver/gdbreplay.c 2012-08-22 13:05:02 -0700 ++++ b/gdb-7.6.1/gdb/gdbserver/gdbreplay.c 2013-04-15 03:20:40 -0700 +@@ -189,14 +189,41 @@ remote_close (void) static void remote_open (char *name) { @@ -47,9 +47,9 @@ diff -Nru a/gdb-7.5.1/gdb/gdbserver/gdbreplay.c b/gdb-7.5.1/gdb/gdbserver/gdbrep #ifdef USE_WIN32API static int winsock_initialized; #endif -diff -Nru a/gdb-7.5.1/gdb/gdbserver/remote-utils.c b/gdb-7.5.1/gdb/gdbserver/remote-utils.c ---- a/gdb-7.5.1/gdb/gdbserver/remote-utils.c 2012-04-28 23:28:30 -0700 -+++ b/gdb-7.5.1/gdb/gdbserver/remote-utils.c 2013-04-16 06:25:07 -0700 +diff -Nru a/gdb-7.6.1/gdb/gdbserver/remote-utils.c b/gdb-7.6.1/gdb/gdbserver/remote-utils.c +--- a/gdb-7.6.1/gdb/gdbserver/remote-utils.c 2012-04-28 23:28:30 -0700 ++++ b/gdb-7.6.1/gdb/gdbserver/remote-utils.c 2013-04-16 06:25:07 -0700 @@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -76,8 +76,8 @@ diff -Nru a/gdb-7.5.1/gdb/gdbserver/remote-utils.c b/gdb-7.5.1/gdb/gdbserver/rem @@ -109,7 +118,7 @@ static int remote_is_stdio = 0; - static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; --static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; + gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; +-gdb_fildes_t listen_desc = INVALID_DESCRIPTOR; +gdb_fildes_t *listening_sockets = NULL; /* FIXME headerize? */ @@ -474,10 +474,10 @@ diff -Nru a/gdb-7.5.1/gdb/gdbserver/remote-utils.c b/gdb-7.5.1/gdb/gdbserver/rem } } -diff -Nru a/gdb-7.5.1/gdb/ser-tcp.c b/gdb-7.5.1/gdb/ser-tcp.c ---- a/gdb-7.5.1/gdb/ser-tcp.c 2012-01-04 00:17:10 -0800 -+++ b/gdb-7.5.1/gdb/ser-tcp.c 2013-04-15 03:20:40 -0700 -@@ -38,7 +38,9 @@ +diff -Nru a/gdb-7.6.1/gdb/ser-tcp.c b/gdb-7.6.1/gdb/ser-tcp.c +--- a/gdb-7.6.1/gdb/ser-tcp.c 2012-01-04 00:17:10 -0800 ++++ b/gdb-7.6.1/gdb/ser-tcp.c 2013-04-15 03:20:40 -0700 +@@ -37,7 +37,9 @@ #include #ifdef USE_WIN32API @@ -487,7 +487,7 @@ diff -Nru a/gdb-7.5.1/gdb/ser-tcp.c b/gdb-7.5.1/gdb/ser-tcp.c #ifndef ETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT #endif -@@ -50,6 +52,7 @@ +@@ -49,6 +51,7 @@ #include #include #include @@ -495,7 +495,7 @@ diff -Nru a/gdb-7.5.1/gdb/ser-tcp.c b/gdb-7.5.1/gdb/ser-tcp.c #endif #include -@@ -79,76 +82,49 @@ +@@ -78,76 +81,49 @@ static unsigned int tcp_retry_limit = 15 #define POLL_INTERVAL 5 @@ -609,7 +609,7 @@ diff -Nru a/gdb-7.5.1/gdb/ser-tcp.c b/gdb-7.5.1/gdb/ser-tcp.c } /* Open a tcp socket. */ -@@ -156,18 +132,24 @@ +@@ -155,18 +131,24 @@ wait_for_connect (struct serial *scb, in int net_open (struct serial *scb, const char *name) { @@ -637,7 +637,7 @@ diff -Nru a/gdb-7.5.1/gdb/ser-tcp.c b/gdb-7.5.1/gdb/ser-tcp.c use_udp = 0; if (strncmp (name, "udp:", 4) == 0) { -@@ -177,134 +159,286 @@ +@@ -176,134 +158,286 @@ net_open (struct serial *scb, const char else if (strncmp (name, "tcp:", 4) == 0) name = name + 4; diff --git a/dist/gdb/patches/pythonhome-7.4.patch b/dist/gdb/patches/pythonhome-7.4.patch deleted file mode 100644 index 28a6ed3e91..0000000000 --- a/dist/gdb/patches/pythonhome-7.4.patch +++ /dev/null @@ -1,38 +0,0 @@ -*** source/gdb-7.4/gdb/python/python.c 2012-02-01 10:39:59.812953656 +0100 ---- staging/gdb-7.4/gdb/python/python.c 2012-02-01 10:33:45.842953480 +0100 -*************** -*** 32,38 **** - #include "serial.h" - #include "readline/tilde.h" - #include "python.h" -! - #include - - /* Declared constants and enum for python stack printing. */ ---- 32,38 ---- - #include "serial.h" - #include "readline/tilde.h" - #include "python.h" -! #include - #include - - /* Declared constants and enum for python stack printing. */ -*************** -*** 1273,1278 **** ---- 1273,1288 ---- - SLASH_STRING, "python", NULL)); - #endif - -+ -+ char readlinkbuffer[BUFSIZ]; -+ int readlinks = readlink("/proc/self/exe", readlinkbuffer, BUFSIZ - 1); -+ readlinkbuffer[readlinks] = 0; -+ char *executeablepath = dirname(readlinkbuffer); -+ char *pythonhome = malloc(strlen(executeablepath) + strlen("/python/") + 2); -+ strcpy(pythonhome, executeablepath); -+ strcat(pythonhome, "/python/"); -+ setenv("PYTHONHOME", pythonhome, 1); -+ - Py_Initialize (); - PyEval_InitThreads (); - diff --git a/dist/gdb/patches/pythonhome.patch b/dist/gdb/patches/pythonhome.patch new file mode 100644 index 0000000000..97f1acf2c4 --- /dev/null +++ b/dist/gdb/patches/pythonhome.patch @@ -0,0 +1,19 @@ +--- a/gdb/python/python.c 2013-03-28 18:46:53.000000000 +0200 ++++ b/gdb/python/python.c 2013-10-27 05:28:35.761204091 +0200 +@@ -1568,6 +1568,16 @@ message == an error message without a st + #endif + #endif + ++ ++ char readlinkbuffer[BUFSIZ]; ++ int readlinks = readlink("/proc/self/exe", readlinkbuffer, BUFSIZ - 1); ++ readlinkbuffer[readlinks] = 0; ++ char *executeablepath = dirname(readlinkbuffer); ++ char *pythonhome = malloc(strlen(executeablepath) + strlen("/python/") + 2); ++ strcpy(pythonhome, executeablepath); ++ strcat(pythonhome, "/python/"); ++ setenv("PYTHONHOME", pythonhome, 1); ++ + Py_Initialize (); + PyEval_InitThreads (); + -- cgit v1.2.1