diff options
author | Christian Biesinger <cbiesinger@google.com> | 2019-11-06 12:49:52 -0600 |
---|---|---|
committer | Christian Biesinger <cbiesinger@google.com> | 2019-11-15 11:12:24 -0800 |
commit | 5abebf3c3fd28a148e43be587c4e4065a0e53ae9 (patch) | |
tree | 4a8def2e81bc2676d63f9a0247700f82a097eb92 /gdb | |
parent | 33bd0102c190c1331804c12774e578e33c367552 (diff) | |
download | binutils-5abebf3c3fd28a148e43be587c4e4065a0e53ae9.zip binutils-5abebf3c3fd28a148e43be587c4e4065a0e53ae9.tar.gz binutils-5abebf3c3fd28a148e43be587c4e4065a0e53ae9.tar.bz2 |
Import the strerror_r-posix module and use it in GDB.
Makes sure to assign the return value of strerror_r to an int,
so that we get a compile error if we accidentally get the
wrong version.
gdb/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
* gdbsupport/common.m4: No longer check for strerror_r.
* gdbsupport/posix-strerror.c (safe_strerror): Always call the
POSIX version of strerror_r, now that gnulib provides it if
necessary.
gdb/gdbserver/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
gnulib/ChangeLog:
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* import/Makefile.am: Update.
* import/Makefile.in: Regenerate.
* import/extra/config.rpath: New file.
* import/glthread/lock.c: New file.
* import/glthread/lock.h: New file.
* import/glthread/threadlib.c: New file.
* import/m4/gnulib-cache.m4: Update.
* import/m4/gnulib-comp.m4: Update.
* import/m4/lib-ld.m4: New file.
* import/m4/lib-link.m4: New file.
* import/m4/lib-prefix.m4: New file.
* import/m4/lock.m4: New file.
* import/m4/strerror_r.m4: New file.
* import/m4/threadlib.m4: New file.
* import/strerror_r.c: New file.
* update-gnulib.sh: Import strerror_r-posix.
Change-Id: I5cfeb12a5203a4cd94a78581541e6085a68685c3
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/config.in | 3 | ||||
-rwxr-xr-x | gdb/configure | 2 | ||||
-rw-r--r-- | gdb/gdbserver/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/gdbserver/config.in | 3 | ||||
-rwxr-xr-x | gdb/gdbserver/configure | 2 | ||||
-rw-r--r-- | gdb/gdbsupport/common.m4 | 2 | ||||
-rw-r--r-- | gdb/gdbsupport/posix-strerror.c | 28 |
8 files changed, 26 insertions, 28 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 134c883..0f92504 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2019-11-15 Christian Biesinger <cbiesinger@google.com> + + * config.in: Regenerate. + * configure: Regenerate. + * gdbsupport/common.m4: No longer check for strerror_r. + * gdbsupport/posix-strerror.c (safe_strerror): Always call the + POSIX version of strerror_r, now that gnulib provides it if + necessary. + 2019-11-14 Christian Biesinger <cbiesinger@google.com> * README (`configure' options): Update. diff --git a/gdb/config.in b/gdb/config.in index 5a21fca..fc05f15 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -423,9 +423,6 @@ /* Define to 1 if you have the <stdlib.h> header file. */ #undef HAVE_STDLIB_H -/* Define to 1 if you have the `strerror_r' function. */ -#undef HAVE_STRERROR_R - /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H diff --git a/gdb/configure b/gdb/configure index 512f016..e805903 100755 --- a/gdb/configure +++ b/gdb/configure @@ -13480,7 +13480,7 @@ done for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction \ - sigprocmask strerror_r + sigprocmask do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index e17a7ca..0f0fc03 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2019-11-15 Christian Biesinger <cbiesinger@google.com> + + * config.in: Regenerate. + * configure: Regenerate. + 2019-11-12 Andrew Burgess <andrew.burgess@embecosm.com> * ax.c (ax_printf): Handle size_t_arg. diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 2984281..0bce18d 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -229,9 +229,6 @@ /* Define to 1 if you have the <stdlib.h> header file. */ #undef HAVE_STDLIB_H -/* Define to 1 if you have the `strerror_r' function. */ -#undef HAVE_STRERROR_R - /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index 3f1f1c1..e513fc5 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -6822,7 +6822,7 @@ done for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction \ - sigprocmask strerror_r + sigprocmask do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/gdb/gdbsupport/common.m4 b/gdb/gdbsupport/common.m4 index 2e44cf4..471d705 100644 --- a/gdb/gdbsupport/common.m4 +++ b/gdb/gdbsupport/common.m4 @@ -33,7 +33,7 @@ AC_DEFUN([GDB_AC_COMMON], [ dlfcn.h) AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction \ - sigprocmask strerror_r]) + sigprocmask]) AC_CHECK_DECLS([strerror, strstr]) diff --git a/gdb/gdbsupport/posix-strerror.c b/gdb/gdbsupport/posix-strerror.c index 34420cf..107813f 100644 --- a/gdb/gdbsupport/posix-strerror.c +++ b/gdb/gdbsupport/posix-strerror.c @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "common-defs.h" +#include <string.h> /* Implementation of safe_strerror as defined in common-utils.h. */ @@ -26,23 +27,12 @@ safe_strerror (int errnum) { static thread_local char buf[1024]; - char *msg = nullptr; -#ifdef HAVE_STRERROR_R -# if !__GLIBC__ || ((_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE) - /* Glibc has two different, incompatible versions of strerror_r. */ - if (strerror_r (errnum, buf, sizeof (buf)) == 0) - msg = buf; -# else - msg = strerror_r (errnum, buf, sizeof (buf)); -# endif -#else - msg = strerror (errnum); -#endif - if (msg == nullptr) - { - - xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum); - msg = buf; - } - return (msg); + /* Assign the return value to an int, so we get an error if we accidentally + get the wrong version of this function (glibc has two of them...). */ + int ret = strerror_r (errnum, buf, sizeof (buf)); + if (ret == 0) + return buf; + + xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum); + return buf; } |