Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>,
	brobecker@adacore.com, simon.marchi@polymtl.ca
Cc: gdb-patches@sourceware.org
Subject: Re: GDB 7.99.91 MinGW compilation error in cli-script.c
Date: Fri, 19 May 2017 09:49:00 -0000	[thread overview]
Message-ID: <dbb230e2-b3bb-993c-3500-4d1ca8004014@redhat.com> (raw)
In-Reply-To: <83y3tt2ow0.fsf@gnu.org>

On 05/19/2017 10:10 AM, Eli Zaretskii wrote:
>> Date: Wed, 17 May 2017 19:01:23 +0300
>> From: Eli Zaretskii <eliz@gnu.org>
>> CC: simon.marchi@polymtl.ca, gdb-patches@sourceware.org
>>
>> I will probably post later a workaround patch for older versions,
>> but that's for master.  I see no reason to delay the release or to
>> have the fix on the branch.
> 
> Is the below OK?  It's a bit ugly, and a small fix is needed even for
> the latest MinGW runtime.

Messing with libstdc++ internal macros and changing what libstdc++
defines is recipe for undefined behavior and trouble.  I'd prefer
avoiding it if possible.

How about going back to the original gdb::to_string, implemented
in terms of stringstring:

 https://sourceware.org/ml/gdb-patches/2016-10/msg00535.html

... with a tweak to only use if it the host compiler doesn't support
std::to_string, like the patchlet below.  (It's functionally equivalent,
it's just that std::to_string is potentially cheaper.)   We'd use
gdb::to_string instead of std::to_string until compilers that miss
std::to_string are phased out.

From bf3b8c9199965d15ddf8f0435fab6b6af3b08bda Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Fri, 19 May 2017 10:34:51 +0100
Subject: [PATCH] to_string

---
 gdb/cli/cli-script.c      |  2 +-
 gdb/common/common-utils.h | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index e0e27ef..3a2ae15 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -806,7 +806,7 @@ user_args::insert_args (const char *line) const
 
       if (p[4] == 'c')
 	{
-	  new_line += std::to_string (m_args.size ());
+	  new_line += gdb::to_string (m_args.size ());
 	  line = p + 5;
 	}
       else
diff --git a/gdb/common/common-utils.h b/gdb/common/common-utils.h
index c331f0d..2c35de8 100644
--- a/gdb/common/common-utils.h
+++ b/gdb/common/common-utils.h
@@ -22,6 +22,7 @@
 
 #include <string>
 #include <vector>
+#include <sstream>
 
 /* If possible, define FUNCTION_NAME, a macro containing the name of
    the function being defined.  Since this macro may not always be
@@ -63,6 +64,30 @@ int xsnprintf (char *str, size_t size, const char *format, ...)
 std::string string_printf (const char* fmt, ...)
   ATTRIBUTE_PRINTF (1, 2);
 
+/* Returns a string representation of VAL.  Replacement for C++11
+   std::to_string on hosts that miss it.  */
+
+namespace gdb {
+
+#if 0 // some check here
+
+template <class T>
+inline std::string
+to_string (const T &val)
+{
+  std::stringstream ss;
+
+  ss << val;
+  return ss.str ();
+}
+
+#else
+
+using std::to_string;
+
+#endif
+
+}
 /* Make a copy of the string at PTR with LEN characters
    (and add a null character at the end in the copy).
    Uses malloc to get the space.  Returns the address of the copy.  */
-- 
2.5.5



  reply	other threads:[~2017-05-19  9:49 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 19:44 GDB 7.99.91 available for testing Joel Brobecker
2017-05-08 14:53 ` Eli Zaretskii
2017-05-17 11:36   ` Yao Qi
2017-05-17 14:39     ` Eli Zaretskii
2017-05-08 15:00 ` GDB 7.99.91 MinGW compilation error in cli-script.c Eli Zaretskii
2017-05-14  3:19   ` Simon Marchi
2017-05-14 14:13     ` Eli Zaretskii
2017-05-17 14:31       ` Joel Brobecker
2017-05-17 16:01         ` Eli Zaretskii
2017-05-19  9:10           ` Eli Zaretskii
2017-05-19  9:49             ` Pedro Alves [this message]
2017-05-19 11:17               ` Eli Zaretskii
2017-05-19 11:23                 ` Pedro Alves
2017-05-21 15:33                   ` Eli Zaretskii
2017-05-22 15:26                     ` Pedro Alves
2017-05-22 18:43                       ` Eli Zaretskii
2017-05-23  9:53                         ` Pedro Alves
2017-05-24  2:44                           ` Eli Zaretskii
2017-05-25 10:05                             ` Pedro Alves
2017-05-26  7:57                               ` Eli Zaretskii
2017-05-26 11:52                                 ` Pedro Alves
2017-05-26 12:57                                   ` Eli Zaretskii
2017-05-26 13:58                                     ` Pedro Alves
2017-05-24 18:28                           ` Eli Zaretskii
2017-05-24 19:37                             ` Joel Brobecker
2017-05-25 10:12                               ` Pedro Alves
2017-05-26  7:47                                 ` Eli Zaretskii
2017-05-26 10:54                                   ` Pedro Alves
2017-05-26 13:03                                     ` Eli Zaretskii
2017-05-26 14:10                                       ` Pedro Alves
2017-05-26 14:35                                         ` Eli Zaretskii
2017-05-26 14:45                                           ` Pedro Alves
2017-05-08 15:02 ` GDB 7.99.91 MinGW compilation warning in tui.c Eli Zaretskii
2017-05-09 10:17   ` Yao Qi
2017-05-13  8:12     ` Eli Zaretskii
2017-05-17 16:26       ` Yao Qi
2017-05-17 16:45         ` Eli Zaretskii
2017-05-17 18:21           ` Joel Brobecker
2017-05-19  8:02             ` Eli Zaretskii
2017-05-19  9:54               ` Pedro Alves
2017-05-19 11:14                 ` Eli Zaretskii
2017-05-19 11:25                   ` Pedro Alves
2017-05-19 12:51                     ` Eli Zaretskii
2017-05-19 13:58                       ` Pedro Alves
2017-05-19 14:40                         ` Eli Zaretskii
2017-05-19 17:50               ` DJ Delorie
2017-05-19 17:55                 ` Eli Zaretskii
2017-05-15 21:11 ` GDB 7.99.91 available for testing Simon Marchi
2017-05-16 13:51   ` Simon Marchi
2017-05-16 20:50     ` Yao Qi
2017-05-16 21:22       ` Simon Marchi
2017-05-16 21:40         ` Yao Qi
2017-05-17 11:31           ` [PATCH master/8.0] Add alias command to cmd_list_element Yao Qi
2017-05-17 12:16             ` Simon Marchi
2017-05-17 13:36               ` Yao Qi
2017-05-16 14:28   ` GDB 7.99.91 available for testing Joel Brobecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbb230e2-b3bb-993c-3500-4d1ca8004014@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox