From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25630 invoked by alias); 19 Nov 2008 22:53:28 -0000 Received: (qmail 25524 invoked by uid 22791); 19 Nov 2008 22:53:26 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 19 Nov 2008 22:52:41 +0000 Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id mAJMqdhV007446 for ; Wed, 19 Nov 2008 14:52:39 -0800 Received: from localhost (ruffy.corp.google.com [172.18.118.116]) by wpaz24.hot.corp.google.com with ESMTP id mAJMqbK8001252; Wed, 19 Nov 2008 14:52:37 -0800 Received: by localhost (Postfix, from userid 67641) id 1D8751C799D; Wed, 19 Nov 2008 14:52:36 -0800 (PST) To: ppluzhnikov@google.com, gdb-patches@sourceware.org Subject: [RFA] fix thinko in sym info Message-Id: <20081119225237.1D8751C799D@localhost> Date: Thu, 20 Nov 2008 02:03:00 -0000 From: dje@google.com (Doug Evans) 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: 2008-11/txt/msg00514.txt.bz2 Hi. I noticed this while testing a thinko of my own (blech). asm-source.exp is now failing because it doesn't expect the offset to be printed if its zero. One could update the testcase, but the old behaviour is more user-friendly. The outstanding question is, of course, whether "%s + %u", msym_name, offset needs i18n. This patch assumes it doesn't. 2008-11-19 Doug Evans * printcmd.c (sym_info): Don't print the offset if it's zero. Index: printcmd.c =================================================================== RCS file: /cvs/src/src/gdb/printcmd.c,v retrieving revision 1.137 diff -u -p -r1.137 printcmd.c --- printcmd.c 18 Nov 2008 21:31:26 -0000 1.137 +++ printcmd.c 19 Nov 2008 22:47:41 -0000 @@ -1013,6 +1013,7 @@ sym_info (char *arg, int from_tty) && (msymbol = lookup_minimal_symbol_by_pc_section (sect_addr, osect))) { const char *obj_name, *mapped, *sec_name, *msym_name; + char *loc_string; matches = 1; offset = sect_addr - SYMBOL_VALUE_ADDRESS (msymbol); @@ -1020,43 +1021,51 @@ sym_info (char *arg, int from_tty) sec_name = osect->the_bfd_section->name; msym_name = SYMBOL_PRINT_NAME (msymbol); + /* Don't print the offset if it is zero. + We assume there's no need to handle i18n of "sym + offset". */ + if (offset) + xasprintf (&loc_string, "%s + %u", msym_name, offset); + else + xasprintf (&loc_string, "%s", msym_name); + gdb_assert (osect->objfile && osect->objfile->name); obj_name = osect->objfile->name; if (MULTI_OBJFILE_P ()) if (pc_in_unmapped_range (addr, osect)) if (section_is_overlay (osect)) - printf_filtered (_("%s + %u in load address range of " + printf_filtered (_("%s in load address range of " "%s overlay section %s of %s\n"), - msym_name, offset, - mapped, sec_name, obj_name); + loc_string, mapped, sec_name, obj_name); else - printf_filtered (_("%s + %u in load address range of " + printf_filtered (_("%s in load address range of " "section %s of %s\n"), - msym_name, offset, sec_name, obj_name); + loc_string, sec_name, obj_name); else if (section_is_overlay (osect)) - printf_filtered (_("%s + %u in %s overlay section %s of %s\n"), - msym_name, offset, mapped, sec_name, obj_name); + printf_filtered (_("%s in %s overlay section %s of %s\n"), + loc_string, mapped, sec_name, obj_name); else - printf_filtered (_("%s + %u in section %s of %s\n"), - msym_name, offset, sec_name, obj_name); + printf_filtered (_("%s in section %s of %s\n"), + loc_string, sec_name, obj_name); else if (pc_in_unmapped_range (addr, osect)) if (section_is_overlay (osect)) - printf_filtered (_("%s + %u in load address range of %s overlay " + printf_filtered (_("%s in load address range of %s overlay " "section %s\n"), - msym_name, offset, mapped, sec_name); + loc_string, mapped, sec_name); else - printf_filtered (_("%s + %u in load address range of section %s\n"), - msym_name, offset, sec_name); + printf_filtered (_("%s in load address range of section %s\n"), + loc_string, sec_name); else if (section_is_overlay (osect)) - printf_filtered (_("%s + %u in %s overlay section %s\n"), - msym_name, offset, mapped, sec_name); + printf_filtered (_("%s in %s overlay section %s\n"), + loc_string, mapped, sec_name); else - printf_filtered (_("%s + %u in section %s\n"), - msym_name, offset, sec_name); + printf_filtered (_("%s in section %s\n"), + loc_string, sec_name); + + free (loc_string); } } if (matches == 0)