]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
New --enable-threading configure option to control use of threads in GDB/GDBserver
authorLuis Machado <luis.machado@linaro.org>
Fri, 26 Nov 2021 14:31:18 +0000 (11:31 -0300)
committerLuis Machado <luis.machado@linaro.org>
Mon, 20 Dec 2021 13:54:48 +0000 (10:54 -0300)
Add the --enable-threading configure option so multithreading can be disabled
at configure time. This is useful for statically-linked builds of
GDB/GDBserver, since the thread library doesn't play well with that setup.

If you try to run a statically-linked GDB built with threading, it will crash
when setting up the number of worker threads.

This new option is also convenient when debugging GDB in a system with lots of
threads, where the thread discovery code in GDB will emit too many messages,
like so:

[New Thread 0xfffff74d3a50 (LWP 2625599)]

If you have X threads, that message will be repeated X times.

The default for --enable-threading is "yes".

gdb/configure
gdbserver/configure
gdbsupport/common.m4
gdbsupport/configure

index a8942ecbd5d654ec522b769adeab2a5cdc03d7c6..34bf97a14d573c827ad27407cf54f5839fc8de4a 100755 (executable)
@@ -903,6 +903,7 @@ with_python
 with_python_libdir
 with_guile
 enable_source_highlight
+enable_threading
 with_intel_pt
 with_libipt_prefix
 with_libipt_type
@@ -1590,6 +1591,8 @@ Optional Features:
   --disable-rpath         do not hardcode runtime library paths
   --enable-source-highlight
                           enable source-highlight for source listings
+  --enable-threading      include support for parallel processing of data
+                          (yes/no)
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings if gcc is used
   --enable-gdb-build-warnings
 done
 
 
+  # ----------------------- #
+  # Check for threading.    #
+  # ----------------------- #
+
+  # Check whether --enable-threading was given.
+if test "${enable_threading+set}" = set; then :
+  enableval=$enable_threading; case "$enableval" in
+    yes) want_threading=yes ;;
+    no) want_threading=no ;;
+    *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;;
+    esac
+else
+  want_threading=yes
+fi
+
+
   # Check for std::thread.  This does not work on some platforms, like
   # mingw and DJGPP.
   ac_ext=cpp
@@ -14276,10 +14295,13 @@ done
     LIBS="$save_LIBS"
     CXXFLAGS="$save_CXXFLAGS"
   fi
-  if test "$gdb_cv_cxx_std_thread" = "yes"; then
+
+  if test "$want_threading" = "yes"; then
+    if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
+    fi
   fi
   ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
index 6e24cc4e156f42f5c866a9fe9faa769f360e3fd8..babf33af07ce97664db0de35bae843a933a561bc 100755 (executable)
@@ -746,6 +746,7 @@ ac_user_opts='
 enable_option_checking
 enable_maintainer_mode
 enable_largefile
+enable_threading
 with_intel_pt
 with_gnu_ld
 enable_rpath
@@ -1396,6 +1397,8 @@ Optional Features:
                           enable make rules and dependencies not useful (and
                           sometimes confusing) to the casual installer
   --disable-largefile     omit support for large files
+  --enable-threading      include support for parallel processing of data
+                          (yes/no)
   --disable-rpath         do not hardcode runtime library paths
   --enable-unit-tests     Enable the inclusion of unit tests when compiling
                           GDB
@@ -7295,6 +7298,22 @@ $as_echo "#define HAVE_KINFO_GETFILE 1" >>confdefs.h
 fi
 
 
+  # ----------------------- #
+  # Check for threading.    #
+  # ----------------------- #
+
+  # Check whether --enable-threading was given.
+if test "${enable_threading+set}" = set; then :
+  enableval=$enable_threading; case "$enableval" in
+    yes) want_threading=yes ;;
+    no) want_threading=no ;;
+    *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;;
+    esac
+else
+  want_threading=yes
+fi
+
+
   # Check for std::thread.  This does not work on some platforms, like
   # mingw and DJGPP.
   ac_ext=cpp
@@ -7992,10 +8011,13 @@ done
     LIBS="$save_LIBS"
     CXXFLAGS="$save_CXXFLAGS"
   fi
-  if test "$gdb_cv_cxx_std_thread" = "yes"; then
+
+  if test "$want_threading" = "yes"; then
+    if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
+    fi
   fi
   ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
index 2b5750e81d1f855f46c9f0cb65a43823552b1220..875d51f7247413eaff33b0d1216c5a80d188daa0 100644 (file)
@@ -94,6 +94,19 @@ AC_DEFUN([GDB_AC_COMMON], [
   # Define HAVE_KINFO_GETFILE if kinfo_getfile is available.
   AC_CHECK_FUNCS(kinfo_getfile)
 
+  # ----------------------- #
+  # Check for threading.    #
+  # ----------------------- #
+
+  AC_ARG_ENABLE(threading,
+    AS_HELP_STRING([--enable-threading], [include support for parallel processing of data (yes/no)]),
+    [case "$enableval" in
+    yes) want_threading=yes ;;
+    no) want_threading=no ;;
+    *) AC_MSG_ERROR([bad value $enableval for threading]) ;;
+    esac],
+    [want_threading=yes])
+
   # Check for std::thread.  This does not work on some platforms, like
   # mingw and DJGPP.
   AC_LANG_PUSH([C++])
@@ -119,9 +132,12 @@ AC_DEFUN([GDB_AC_COMMON], [
     LIBS="$save_LIBS"
     CXXFLAGS="$save_CXXFLAGS"
   fi
-  if test "$gdb_cv_cxx_std_thread" = "yes"; then
-    AC_DEFINE(CXX_STD_THREAD, 1,
-             [Define to 1 if std::thread works.])
+
+  if test "$want_threading" = "yes"; then
+    if test "$gdb_cv_cxx_std_thread" = "yes"; then
+      AC_DEFINE(CXX_STD_THREAD, 1,
+               [Define to 1 if std::thread works.])
+    fi
   fi
   AC_LANG_POP
 
index a37f3c232ce525f8e59a8698a3a9511e463ad2a5..1fe642f88efc871fca2783070ec367443c33b07a 100755 (executable)
@@ -767,6 +767,7 @@ enable_silent_rules
 enable_dependency_tracking
 enable_plugins
 enable_largefile
+enable_threading
 with_intel_pt
 with_gnu_ld
 enable_rpath
@@ -1419,6 +1420,8 @@ Optional Features:
                           speeds up one-time build
   --enable-plugins        Enable support for plugins
   --disable-largefile     omit support for large files
+  --enable-threading      include support for parallel processing of data
+                          (yes/no)
   --disable-rpath         do not hardcode runtime library paths
   --enable-unit-tests     Enable the inclusion of unit tests when compiling
                           GDB
@@ -9049,6 +9052,22 @@ fi
 done
 
 
+  # ----------------------- #
+  # Check for threading.    #
+  # ----------------------- #
+
+  # Check whether --enable-threading was given.
+if test "${enable_threading+set}" = set; then :
+  enableval=$enable_threading; case "$enableval" in
+    yes) want_threading=yes ;;
+    no) want_threading=no ;;
+    *) as_fn_error $? "bad value $enableval for threading" "$LINENO" 5 ;;
+    esac
+else
+  want_threading=yes
+fi
+
+
   # Check for std::thread.  This does not work on some platforms, like
   # mingw and DJGPP.
   ac_ext=cpp
@@ -9746,10 +9765,13 @@ done
     LIBS="$save_LIBS"
     CXXFLAGS="$save_CXXFLAGS"
   fi
-  if test "$gdb_cv_cxx_std_thread" = "yes"; then
+
+  if test "$want_threading" = "yes"; then
+    if test "$gdb_cv_cxx_std_thread" = "yes"; then
 
 $as_echo "#define CXX_STD_THREAD 1" >>confdefs.h
 
+    fi
   fi
   ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'