From: Corinna Vinschen <vinschen@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFA] defs.h: Define GDB_DEFAULT_TARGET_[WIDE_]CHARSET for Cygwin and MingW builds
Date: Mon, 01 Mar 2010 10:31:00 -0000 [thread overview]
Message-ID: <20100301103125.GB9730@calimero.vinschen.de> (raw)
In-Reply-To: <20100228222702.GC29360@caradoc.them.org>
On Feb 28 17:27, Daniel Jacobowitz wrote:
> On Sun, Feb 28, 2010 at 08:21:59PM +0100, Corinna Vinschen wrote:
> > On Feb 28 13:47, Daniel Jacobowitz wrote:
> > > On Sun, Feb 28, 2010 at 04:03:18PM +0100, Corinna Vinschen wrote:
> > > > If the codeset is target-specific anyway, then the idea of the
> > > > GDB_DEFAULT_TARGET_WIDE_CHARSET and GDB_DEFAULT_TARGET_CHARSET variables
> > > > is either wrong, or it must be possible to define them somewhere
> > > > on a per-target base. What about windows-tdep.h?
> > >
> > > If it has to be per-target at all, it needs to go in gdbarch; it can't
> > > be a #define any more, because we support multiple compiled-in
> > > architectures. This is going to be significantly more complicated,
> > > though; there needs to be an "auto (currently cp1252)" style setting.
> >
> > There is already a setting for the target charsets. We're just
> > talking about setting a sane default.
>
> We're talking past each other. Compare show_host_charset_name
> (which has an auto setting) to show_target_charset_name (which does
> not).
>
> If the default becomes dependent on the target, we need to distinguish
> "user specified iso-8859-1" or "user didn't say anything, but now
> we're debugging i686-mingw32, and that usually uses cp1252".
Ok. Would the below be sufficient for a start?
Corinna
* charset.c (auto_target_charset_name): New variable.
(target_charset_name): Set to "auto" by default.
(show_target_charset_name): Take "auto" setting into account.
(auto_target_wide_charset_name): New variable.
(target_wide_charset_name): Set to "auto" by default.
(show_target_wide_charset_name): Take "auto" setting into account.
(set_be_le_names): Ditto.
(validate): Ditto.
(set_auto_target_wide_charset): New function to set
auto_target_wide_charset_name.
(set_auto_target_charset): New function to set auto_target_charset_name.
(target_charset): Take "auto" setting into account.
(target_wide_charset): Ditto.
(_initialize_charset): Initialize auto_target_charset_name rather than
target_charset_name with value of auto_host_charset_name.
* charset.h (set_auto_target_wide_charset): Declare.
(set_auto_target_charset): Declare.
* windows-nat.c: Include charset.h.
(_initialize_windows_nat): Initialize auto target charsets to sane
values for native targets.
Index: charset.c
===================================================================
RCS file: /cvs/src/src/gdb/charset.c,v
retrieving revision 1.28
diff -u -p -r1.28 charset.c
--- charset.c 1 Jan 2010 07:31:30 -0000 1.28
+++ charset.c 1 Mar 2010 10:27:57 -0000
@@ -213,22 +213,37 @@ show_host_charset_name (struct ui_file *
fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
}
-static const char *target_charset_name = GDB_DEFAULT_TARGET_CHARSET;
+static const char *auto_target_charset_name = GDB_DEFAULT_TARGET_CHARSET;
+static const char *target_charset_name = "auto";
static void
show_target_charset_name (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- fprintf_filtered (file, _("The target character set is \"%s\".\n"),
- value);
+ if (!strcmp (value, "auto"))
+ fprintf_filtered (file,
+ _("The target character set is \"auto; "
+ "currently %s\".\n"),
+ auto_target_charset_name);
+ else
+ fprintf_filtered (file, _("The target character set is \"%s\".\n"),
+ value);
}
-static const char *target_wide_charset_name = GDB_DEFAULT_TARGET_WIDE_CHARSET;
+static const char *auto_target_wide_charset_name
+ = GDB_DEFAULT_TARGET_WIDE_CHARSET;
+static const char *target_wide_charset_name = "auto";
static void
show_target_wide_charset_name (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- fprintf_filtered (file, _("The target wide character set is \"%s\".\n"),
- value);
+ if (!strcmp (value, "auto"))
+ fprintf_filtered (file,
+ _("The target wide character set is \"auto; "
+ "currently %s\".\n"),
+ auto_target_wide_charset_name);
+ else
+ fprintf_filtered (file, _("The target wide character set is \"%s\".\n"),
+ value);
}
static const char *default_charset_names[] =
@@ -252,14 +267,19 @@ static void
set_be_le_names (void)
{
int i, len;
+ const char *target_wide;
target_wide_charset_le_name = NULL;
target_wide_charset_be_name = NULL;
- len = strlen (target_wide_charset_name);
+ target_wide = target_wide_charset_name;
+ if (!strcmp (target_wide, "auto"))
+ target_wide = auto_target_wide_charset_name;
+
+ len = strlen (target_wide);
for (i = 0; charset_enum[i]; ++i)
{
- if (strncmp (target_wide_charset_name, charset_enum[i], len))
+ if (strncmp (target_wide, charset_enum[i], len))
continue;
if ((charset_enum[i][len] == 'B'
|| charset_enum[i][len] == 'L')
@@ -282,17 +302,21 @@ validate (void)
{
iconv_t desc;
const char *host_cset = host_charset ();
+ const char *target_cset = target_charset ();
+ const char *target_wide_cset = target_wide_charset_name;
+ if (!strcmp (target_wide_cset, "auto"))
+ target_wide_cset = auto_target_wide_charset_name;
- desc = iconv_open (target_wide_charset_name, host_cset);
+ desc = iconv_open (target_wide_cset, host_cset);
if (desc == (iconv_t) -1)
error ("Cannot convert between character sets `%s' and `%s'",
- target_wide_charset_name, host_cset);
+ target_wide_cset, host_cset);
iconv_close (desc);
- desc = iconv_open (target_charset_name, host_cset);
+ desc = iconv_open (target_cset, host_cset);
if (desc == (iconv_t) -1)
error ("Cannot convert between character sets `%s' and `%s'",
- target_charset_name, host_cset);
+ target_cset, host_cset);
iconv_close (desc);
set_be_le_names ();
@@ -342,6 +366,21 @@ show_charset (struct ui_file *file, int
show_target_wide_charset_name (file, from_tty, c, target_wide_charset_name);
}
+/* These functions allow to set the auto target charsets. This isn't for
+ the user, rather it's to be used to set the auto target charsets from
+ target-specific code. */
+void
+set_auto_target_wide_charset (char *charset)
+{
+ auto_target_wide_charset_name = charset;
+}
+
+void
+set_auto_target_charset (char *charset)
+{
+ auto_target_charset_name = charset;
+}
+
\f
/* Accessor functions. */
@@ -356,6 +395,8 @@ host_charset (void)
const char *
target_charset (void)
{
+ if (!strcmp (target_charset_name, "auto"))
+ return auto_target_charset_name;
return target_charset_name;
}
@@ -373,6 +414,8 @@ target_wide_charset (enum bfd_endian byt
return target_wide_charset_le_name;
}
+ if (!strcmp (target_wide_charset_name, "auto"))
+ return auto_target_wide_charset_name;
return target_wide_charset_name;
}
@@ -874,7 +917,7 @@ _initialize_charset (void)
which GNU libiconv doesn't like (infinite loop). */
if (!strcmp (auto_host_charset_name, "646") || !*auto_host_charset_name)
auto_host_charset_name = "ASCII";
- target_charset_name = auto_host_charset_name;
+ auto_target_charset_name = auto_host_charset_name;
set_be_le_names ();
#endif
Index: charset.h
===================================================================
RCS file: /cvs/src/src/gdb/charset.h,v
retrieving revision 1.10
diff -u -p -r1.10 charset.h
--- charset.h 1 Jan 2010 07:31:30 -0000 1.10
+++ charset.h 1 Mar 2010 10:27:57 -0000
@@ -36,6 +36,12 @@ const char *host_charset (void);
const char *target_charset (void);
const char *target_wide_charset (enum bfd_endian byte_order);
+/* These functions allow to set the auto target charsets. This isn't for
+ the user, rather it's to be used to set the auto target charsets from
+ target-specific code. */
+void set_auto_target_wide_charset (char *charset);
+void set_auto_target_charset (char *charset);
+
/* These values are used to specify the type of transliteration done
by convert_between_encodings. */
enum transliterations
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.204
diff -u -p -r1.204 windows-nat.c
--- windows-nat.c 1 Mar 2010 09:09:24 -0000 1.204
+++ windows-nat.c 1 Mar 2010 10:27:57 -0000
@@ -65,6 +65,7 @@
#include "windows-nat.h"
#include "i386-nat.h"
#include "complaints.h"
+#include "charset.h"
#define AdjustTokenPrivileges dyn_AdjustTokenPrivileges
#define DebugActiveProcessStop dyn_DebugActiveProcessStop
@@ -2296,12 +2297,20 @@ void
_initialize_windows_nat (void)
{
struct cmd_list_element *c;
+#ifndef __CYGWIN__
+ static char codepage[32];
+#endif
init_windows_ops ();
#ifdef __CYGWIN__
cygwin_internal (CW_SET_DOS_FILE_WARNING, 0);
+ set_auto_target_charset ("UTF-8");
+#else
+ snprintf (codepage, 32, "CP%u", GetACP ());
+ set_auto_target_charset (codepage);
#endif
+ set_auto_target_wide_charset ("UTF-16");
c = add_com ("dll-symbols", class_files, dll_symbol_command,
_("Load dll library symbols from FILE."));
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
next prev parent reply other threads:[~2010-03-01 10:31 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-28 13:05 Corinna Vinschen
2010-02-28 14:29 ` Daniel Jacobowitz
2010-02-28 15:03 ` Corinna Vinschen
2010-02-28 18:48 ` Daniel Jacobowitz
2010-02-28 19:22 ` Corinna Vinschen
2010-02-28 22:27 ` Daniel Jacobowitz
2010-03-01 10:31 ` Corinna Vinschen [this message]
2010-03-01 17:11 ` Eli Zaretskii
2010-03-01 17:28 ` Corinna Vinschen
2010-03-01 17:21 ` Tom Tromey
2010-03-01 17:23 ` Daniel Jacobowitz
2010-03-01 17:27 ` Corinna Vinschen
2010-03-01 17:31 ` Corinna Vinschen
2010-03-01 19:25 ` Tom Tromey
2010-03-01 19:31 ` Daniel Jacobowitz
2010-03-01 20:06 ` Corinna Vinschen
2010-03-01 20:44 ` Eli Zaretskii
2010-03-01 21:50 ` Daniel Jacobowitz
2010-03-02 10:44 ` Corinna Vinschen
2010-03-02 13:54 ` Daniel Jacobowitz
2010-03-02 14:13 ` Corinna Vinschen
2010-03-02 15:03 ` Daniel Jacobowitz
2010-03-02 17:43 ` Corinna Vinschen
2010-03-02 17:59 ` Tom Tromey
2010-03-02 18:22 ` Corinna Vinschen
2010-03-02 18:28 ` Corinna Vinschen
2010-03-02 22:55 ` Tom Tromey
2010-03-02 22:57 ` Tom Tromey
2010-03-03 10:16 ` Corinna Vinschen
2010-03-03 10:41 ` Corinna Vinschen
2010-03-03 10:59 ` Corinna Vinschen
2010-03-03 16:26 ` Tom Tromey
2010-03-03 10:16 ` Corinna Vinschen
2010-03-03 16:25 ` Tom Tromey
2010-03-03 16:46 ` Corinna Vinschen
2010-03-05 8:55 ` Charles Wilson
2010-03-03 21:15 ` Tom Tromey
2010-03-04 9:34 ` Corinna Vinschen
2010-03-04 15:24 ` Christopher Faylor
2010-03-04 15:38 ` Corinna Vinschen
2010-03-03 17:08 ` Daniel Jacobowitz
2010-03-03 17:22 ` Corinna Vinschen
2010-03-03 17:27 ` Corinna Vinschen
2010-03-03 17:33 ` Daniel Jacobowitz
2010-03-03 17:42 ` Eli Zaretskii
2010-03-03 18:00 ` Corinna Vinschen
2010-03-03 18:05 ` Daniel Jacobowitz
2010-03-03 18:22 ` Corinna Vinschen
2010-03-03 19:39 ` Daniel Jacobowitz
2010-03-03 20:16 ` Eli Zaretskii
2010-03-03 20:26 ` Daniel Jacobowitz
2010-03-03 21:08 ` Tom Tromey
2010-03-01 17:12 ` Tom Tromey
2010-03-01 17:21 ` Daniel Jacobowitz
2010-03-01 17:28 ` Tom Tromey
2010-03-01 17:50 ` Corinna Vinschen
2010-02-28 16:56 ` Eli Zaretskii
2010-02-28 17:05 ` Corinna Vinschen
2010-02-28 17:45 ` Eli Zaretskii
2010-02-28 17:52 ` Corinna Vinschen
2010-02-28 18:11 ` Corinna Vinschen
2010-02-28 18:59 ` Eli Zaretskii
2010-02-28 19:23 ` Corinna Vinschen
2010-02-28 18:59 ` Eli Zaretskii
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=20100301103125.GB9730@calimero.vinschen.de \
--to=vinschen@redhat.com \
--cc=gdb-patches@sourceware.org \
/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