From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18873 invoked by alias); 16 Jul 2010 20:49:22 -0000 Received: (qmail 18862 invoked by uid 22791); 16 Jul 2010 20:49:21 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,TW_XS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-ey0-f169.google.com (HELO mail-ey0-f169.google.com) (209.85.215.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Jul 2010 20:49:14 +0000 Received: by eydd26 with SMTP id d26so763310eyd.0 for ; Fri, 16 Jul 2010 13:49:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.25.138 with SMTP id z10mr4698804ebb.84.1279313351546; Fri, 16 Jul 2010 13:49:11 -0700 (PDT) Received: by 10.213.11.1 with HTTP; Fri, 16 Jul 2010 13:49:11 -0700 (PDT) Date: Fri, 16 Jul 2010 20:49:00 -0000 Message-ID: Subject: [RFC] [gdbserver] paddress() can truncate its argument From: Ozkan Sezer To: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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-07/txt/msg00254.txt.bz2 Hi: Noticed this while messing around with win64 support: paddress() casts its CORE_ADDR argument (which is specifically defined as long long in gdbserver) to long, probably assuming LP64 convention. For win64, which is LLP64, it is not true (sizeof(long) == 4 always) and it truncates its argument. Shouldn't paddress() just return phex_nz() instead, like the following: Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/utils.c,v retrieving revision 1.23 diff -u -p -r1.23 utils.c --- utils.c 1 Jun 2010 13:20:52 -0000 1.23 +++ utils.c 16 Jul 2010 20:41:14 -0000 @@ -257,17 +257,6 @@ xsnprintf (char *str, size_t size, const return ret; } -/* Convert a CORE_ADDR into a HEX string, like %lx. - The result is stored in a circular static buffer, NUMCELLS deep. */ - -char * -paddress (CORE_ADDR addr) -{ - char *str = get_cell (); - xsnprintf (str, CELLSIZE, "%lx", (long) addr); - return str; -} - static char * decimal2str (char *sign, ULONGEST addr, int width) { @@ -372,3 +361,12 @@ phex_nz (ULONGEST l, int sizeof_l) return str; } + +/* Convert a CORE_ADDR into a HEX string, like %lx. + The result is stored in a circular static buffer, NUMCELLS deep. */ + +char * +paddress (CORE_ADDR addr) +{ + return phex_nz (addr, sizeof (CORE_ADDR)); +} Comments? -- Ozkan