From patchwork Fri Nov 15 21:33:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35962 Received: (qmail 28441 invoked by alias); 15 Nov 2019 21:33:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28380 invoked by uid 89); 15 Nov 2019 21:33:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Nov 2019 21:33:13 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id E1FB2206E6; Fri, 15 Nov 2019 16:33:11 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 6B9A6203AC; Fri, 15 Nov 2019 16:33:07 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 408EA20AF6; Fri, 15 Nov 2019 16:33:07 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Fri, 15 Nov 2019 16:33:06 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Christian Biesinger , Tom Tromey , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] Use gnulib's strerror_r on MinGW X-Gerrit-Change-Id: I9e6d8a752fc398784201f370cafee65e0ea05474 X-Gerrit-Change-Number: 625 X-Gerrit-ChangeURL: X-Gerrit-Commit: cd850b40cc84ff08c50b8b16a0968b3cd6b33664 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-76-gf8b6da0ab5 Message-Id: <20191115213307.408EA20AF6@gnutoolchain-gerrit.osci.io> The original change was created by Christian Biesinger. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/625 ...................................................................... Use gnulib's strerror_r on MinGW There is no need to keep mingw-strerror around; we can just always use the code from posix-strerror. The main reason we had that code, it seems, is to handle winsock error codes, but gnulib's version handles those. Unfortunately the code can't be moved into common-utils.c because libinproctrace.so uses common-utils but not gnulib. gdb/ChangeLog: 2019-11-15 Christian Biesinger * Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c. * configure: Regenerate. * configure.ac: Don't source common.host. * gdbsupport/common.host: Remove. * gdbsupport/mingw-strerror.c: Remove. * gdbsupport/posix-strerror.c: Rename to... * gdbsupport/safe-strerror.c: ...this. gdb/gdbserver/ChangeLog: 2019-11-15 Christian Biesinger * Makefile.in: Add safe-strerror.c. * configure: Regenerate. * configure.ac: Don't source common.host. Change-Id: I9e6d8a752fc398784201f370cafee65e0ea05474 --- M gdb/ChangeLog M gdb/Makefile.in M gdb/configure M gdb/configure.ac M gdb/gdbserver/ChangeLog M gdb/gdbserver/Makefile.in M gdb/gdbserver/configure M gdb/gdbserver/configure.ac D gdb/gdbsupport/common.host D gdb/gdbsupport/mingw-strerror.c R gdb/gdbsupport/safe-strerror.c 11 files changed, 23 insertions(+), 122 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f727aa4..90a2b64 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,15 @@ 2019-11-15 Christian Biesinger + * Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c. + * configure: Regenerate. + * configure.ac: Don't source common.host. + * gdbsupport/common.host: Remove. + * gdbsupport/mingw-strerror.c: Remove. + * gdbsupport/posix-strerror.c: Rename to... + * gdbsupport/safe-strerror.c: ...this. + +2019-11-15 Christian Biesinger + * maint.c (scoped_command_stats::print_time): Use localtime_r instead of localtime (provided through gnulib if necessary). * nat/linux-osdata.c (time_from_time_t): Use ctime_r instead diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 9ca77f6..5a4ffd5 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -986,6 +986,7 @@ gdbsupport/ptid.c \ gdbsupport/rsp-low.c \ gdbsupport/run-time-clock.c \ + gdbsupport/safe-strerror.c \ gdbsupport/scoped_mmap.c \ gdbsupport/signals.c \ gdbsupport/signals-state-save-restore.c \ @@ -2344,9 +2345,7 @@ xtensa-linux-nat.c \ xtensa-linux-tdep.c \ xtensa-tdep.c \ - xtensa-xtregs.c \ - gdbsupport/mingw-strerror.c \ - gdbsupport/posix-strerror.c + xtensa-xtregs.c # Some files need explicit build rules (due to -Werror problems) or due # to sub-directory fun 'n' games. diff --git a/gdb/configure b/gdb/configure index e805903..4afd7f9 100755 --- a/gdb/configure +++ b/gdb/configure @@ -6556,10 +6556,6 @@ . $srcdir/configure.host -# Add in the common host objects. -. $srcdir/gdbsupport/common.host -gdb_host_obs="$gdb_host_obs $common_host_obs" - # Accumulate some settings from configure.tgt over all enabled targets TARGET_OBS= diff --git a/gdb/configure.ac b/gdb/configure.ac index 354bb7b..6ba7c5c 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -177,10 +177,6 @@ . $srcdir/configure.host -# Add in the common host objects. -. $srcdir/gdbsupport/common.host -gdb_host_obs="$gdb_host_obs $common_host_obs" - # Accumulate some settings from configure.tgt over all enabled targets TARGET_OBS= diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 0f0fc03..fde6abb 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,11 @@ 2019-11-15 Christian Biesinger + * Makefile.in: Add safe-strerror.c. + * configure: Regenerate. + * configure.ac: Don't source common.host. + +2019-11-15 Christian Biesinger + * config.in: Regenerate. * configure: Regenerate. diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index b9b5b89..16012dd 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -220,6 +220,7 @@ $(srcdir)/gdbsupport/print-utils.c \ $(srcdir)/gdbsupport/ptid.c \ $(srcdir)/gdbsupport/rsp-low.c \ + $(srcdir)/gdbsupport/safe-strerror.c \ $(srcdir)/gdbsupport/tdesc.c \ $(srcdir)/gdbsupport/xml-utils.c \ $(srcdir)/nat/aarch64-sve-linux-ptrace.c \ @@ -266,6 +267,7 @@ gdbsupport/print-utils.o \ gdbsupport/ptid.o \ gdbsupport/rsp-low.o \ + gdbsupport/safe-strerror.o \ gdbsupport/signals.o \ gdbsupport/signals-state-save-restore.o \ gdbsupport/tdesc.o \ diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index e513fc5..d1d00a4 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -7825,10 +7825,6 @@ . ${srcdir}/configure.srv -# Add in the common host objects. -. ${srcdir}/../gdbsupport/common.host -srv_host_obs="$common_host_obs" - if test "${srv_mingwce}" = "yes"; then LIBS="$LIBS -lws2" elif test "${srv_mingw}" = "yes"; then @@ -8361,7 +8357,7 @@ done fi -GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs $srv_selftest_objs" +GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_selftest_objs" GDBSERVER_LIBS="$srv_libs" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the target supports __sync_*_compare_and_swap" >&5 diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 7ebc9c3..07c9bd7 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -245,10 +245,6 @@ . ${srcdir}/configure.srv -# Add in the common host objects. -. ${srcdir}/../gdbsupport/common.host -srv_host_obs="$common_host_obs" - if test "${srv_mingwce}" = "yes"; then LIBS="$LIBS -lws2" elif test "${srv_mingw}" = "yes"; then @@ -393,7 +389,7 @@ done fi -GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_host_obs $srv_selftest_objs" +GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_selftest_objs" GDBSERVER_LIBS="$srv_libs" dnl Check whether the target supports __sync_*_compare_and_swap. diff --git a/gdb/gdbsupport/common.host b/gdb/gdbsupport/common.host deleted file mode 100644 index 4839059..0000000 --- a/gdb/gdbsupport/common.host +++ /dev/null @@ -1,36 +0,0 @@ -# Common object files to include for each host. -# -# Copyright (C) 2015-2019 Free Software Foundation, Inc. -# -# This file is part of GDB. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# Map host triplet into the common object files to be included by -# GDB/gdbserver. This is invoked from the autoconf generated -# configure script. - -# This file sets the following shell variables: -# common_host_obs host-specific .o files to include when building -# GDB/gdbserver - -case "${host}" in - -*-mingw*) common_host_obs=gdbsupport/mingw-strerror.o - ;; -*) - common_host_obs=gdbsupport/posix-strerror.o - ;; - -esac diff --git a/gdb/gdbsupport/mingw-strerror.c b/gdb/gdbsupport/mingw-strerror.c deleted file mode 100644 index 893b7ca..0000000 --- a/gdb/gdbsupport/mingw-strerror.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Safe version of strerror for MinGW, for GDB, the GNU debugger. - - Copyright (C) 2006-2019 Free Software Foundation, Inc. - - This file is part of GDB. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include "common-defs.h" - -#include - -/* Implementation of safe_strerror as defined in common-utils.h. - - The Windows runtime implementation of strerror never returns NULL, - but does return a useless string for anything above sys_nerr; - unfortunately this includes all socket-related error codes. - This replacement tries to find a system-provided error message. */ - -const char * -safe_strerror (int errnum) -{ - static char *buffer; - int len; - - if (errnum >= 0 && errnum < sys_nerr) - return strerror (errnum); - - if (buffer) - { - LocalFree (buffer); - buffer = NULL; - } - - if (FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER - | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, errnum, - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &buffer, 0, NULL) == 0) - { - static char buf[32]; - xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum); - return buf; - } - - /* Windows error messages end with a period and a CR-LF; strip that - out. */ - len = strlen (buffer); - if (len > 3 && strcmp (buffer + len - 3, ".\r\n") == 0) - buffer[len - 3] = '\0'; - - return buffer; -} diff --git a/gdb/gdbsupport/posix-strerror.c b/gdb/gdbsupport/safe-strerror.c similarity index 94% rename from gdb/gdbsupport/posix-strerror.c rename to gdb/gdbsupport/safe-strerror.c index 107813f..c37db57 100644 --- a/gdb/gdbsupport/posix-strerror.c +++ b/gdb/gdbsupport/safe-strerror.c @@ -1,4 +1,4 @@ -/* Safe version of strerror for POSIX systems for GDB, the GNU debugger. +/* Safe version of strerror for GDB, the GNU debugger. Copyright (C) 2006-2019 Free Software Foundation, Inc.