From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24904 invoked by alias); 11 Oct 2006 15:12:58 -0000 Received: (qmail 24895 invoked by uid 22791); 11 Oct 2006 15:12:57 -0000 X-Spam-Check-By: sourceware.org Received: from lon-del-04.spheriq.net (HELO lon-del-04.spheriq.net) (195.46.50.101) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Oct 2006 15:12:48 +0000 Received: from lon-out-03.spheriq.net ([195.46.50.131]) by lon-del-04.spheriq.net with ESMTP id k9BFCiMS011529 for ; Wed, 11 Oct 2006 15:12:44 GMT Received: from lon-cus-02.spheriq.net (lon-cus-02.spheriq.net [195.46.50.38]) by lon-out-03.spheriq.net with ESMTP id k9BFChQj010191 for ; Wed, 11 Oct 2006 15:12:44 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-02.spheriq.net with ESMTP id k9BFCgYO023082 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Wed, 11 Oct 2006 15:12:43 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 169E7DA42 for ; Wed, 11 Oct 2006 15:12:42 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B5326473EE for ; Wed, 11 Oct 2006 15:12:41 +0000 (GMT) Received: from [164.129.15.13] (bri1043.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CIC25104 (AUTH stubbsa); Wed, 11 Oct 2006 16:12:40 +0100 (BST) Message-ID: <452D09E8.5090005@st.com> Date: Wed, 11 Oct 2006 15:12:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: GDB Patches Subject: Re: [PATCH] long long for printf on MinGW References: <452CCE2D.8070806@st.com> <20061011130330.GA24187@nevyn.them.org> In-Reply-To: <20061011130330.GA24187@nevyn.them.org> Content-Type: multipart/mixed; boundary="------------070409010200000702030905" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00117.txt.bz2 This is a multi-part message in MIME format. --------------070409010200000702030905 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 159 Daniel Jacobowitz wrote: > Could you at least do something like this? Ok, how about the attached. I believe I have done it just how you asked. Andrew Stubbs --------------070409010200000702030905 Content-Type: text/plain; name="printf.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="printf.patch" Content-length: 1660 2006-10-11 Andrew Stubbs * printcmd.c: Define USE_PRINTF_I64 and PRINTF_HAS_LONG_LONG on MinGW. (printf_command): Convert %lld to %I64d when USE_PRINTF_I64 set. Index: src/gdb/printcmd.c =================================================================== --- src.orig/gdb/printcmd.c 2006-07-17 23:15:55.000000000 +0100 +++ src/gdb/printcmd.c 2006-10-11 14:47:57.000000000 +0100 @@ -48,6 +48,13 @@ #include "tui/tui.h" /* For tui_active et.al. */ #endif +#if defined(__MINGW32__) +# define USE_PRINTF_I64 1 +# define PRINTF_HAS_LONG_LONG +#else +# define USE_PRINTF_I64 0 +#endif + extern int asm_demangle; /* Whether to demangle syms in asm printouts */ extern int addressprint; /* Whether to print hex addresses in HLL " */ @@ -1967,8 +1974,23 @@ printf_command (char *arg, int from_tty) *f); f++; - strncpy (current_substring, last_arg, f - last_arg); - current_substring += f - last_arg; + + if (lcount > 1 && USE_PRINTF_I64) + { + /* Windows' printf does support long long, but not the usual way. + Convert %lld to %I64d. */ + int length_before_ll = f - last_arg - 1 - lcount; + strncpy (current_substring, last_arg, length_before_ll); + strcpy (current_substring + length_before_ll, "I64"); + current_substring[length_before_ll + 3] = + last_arg[length_before_ll + lcount]; + current_substring += length_before_ll + 4; + } + else + { + strncpy (current_substring, last_arg, f - last_arg); + current_substring += f - last_arg; + } *current_substring++ = '\0'; last_arg = f; argclass[nargs_wanted++] = this_argclass; --------------070409010200000702030905--