From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19186 invoked by alias); 3 Mar 2010 10:41:07 -0000 Received: (qmail 19173 invoked by uid 22791); 3 Mar 2010 10:41:06 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.83/v0.83-20-g38e4449) with ESMTP; Wed, 03 Mar 2010 10:41:02 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 354086D42F5; Wed, 3 Mar 2010 11:41:00 +0100 (CET) Date: Wed, 03 Mar 2010 10:41:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: Re: [RFA] defs.h: Define GDB_DEFAULT_TARGET_[WIDE_]CHARSET for Cygwin and MingW builds Message-ID: <20100303104100.GJ17293@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org References: <20100228222702.GC29360@caradoc.them.org> <20100301103125.GB9730@calimero.vinschen.de> <20100301173054.GD5683@calimero.vinschen.de> <20100301193126.GA9416@caradoc.them.org> <20100303101630.GI17293@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100303101630.GI17293@calimero.vinschen.de> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00096.txt.bz2 On Mar 3 11:16, Corinna Vinschen wrote: > On Mar 2 15:57, Tom Tromey wrote: > > >>>>> "Tom" == Tom Tromey writes: > > > > Tom> Here's a patch, please let me know what you think. > > > > Tom> 2010-03-02 Tom Tromey > > Tom> * utils.c (host_char_to_target): Add 'gdbarch' argument. > > > > [...] > > > > Oops! I took some code from Corinna's earlier patch but then neglected > > to put her name on the ChangeLog entry. I've corrected that locally. > > No worries. I tested your code on the latest Cygwin release and it > works fine. However, there's a problem in GDB which spoils the effort a bit. When GDB is started, setlocale() is called from captured_main(). Afterwards, _initialize_charset() and, in turn, nl_langinfo() is called, and the pointer returned by nl_langinfo(CODESET) is stored as the name of the codeset. So the codeset name is not copied into a safe storage area here, just the pointer is memorized. Later, while captured_main() is still initializing GDB, the interp_set() function is called, which calls tui_init(), which in turn initializes readline. Readline calls setlocale(). Oops. The old pointer to nl_langinfo(CODESET) might not be valid anymore afterwards. See the Linux manpage for nl_langinfo: RETURN VALUE [...] This pointer may point to static data that may be overwritten on the next call to nl_langinfo() or setlocale(3). So, does anything speak against copying the codeset name into some local storage, rather than just storing the pointer returned by nl_langinfo? Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat