From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29324 invoked by alias); 5 Oct 2012 14:15:21 -0000 Received: (qmail 29312 invoked by uid 22791); 5 Oct 2012 14:15:19 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 05 Oct 2012 14:15:12 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1TK8gJ-0005eL-L6 from Ali_Anwar@mentor.com for gdb-patches@sourceware.org; Fri, 05 Oct 2012 07:15:11 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 5 Oct 2012 07:15:11 -0700 Received: from [137.202.157.121] (147.34.91.1) by SVR-ORW-FEM-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server (TLS) id 14.1.289.1; Fri, 5 Oct 2012 07:14:30 -0700 Message-ID: <506EEAEC.2010604@codesourcery.com> Date: Fri, 05 Oct 2012 14:15:00 -0000 From: ali_anwar User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.28) Gecko/20120313 Thunderbird/3.1.20 MIME-Version: 1.0 To: Subject: "maint print arch" causing gdb crash Content-Type: multipart/mixed; boundary="------------070509090705080108040600" 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: 2012-10/txt/msg00098.txt.bz2 --------------070509090705080108040600 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 610 Hi, 'gdbarch_dump' is in some cases passing a NULL pointer to 'sprintf' when printing 'gdbarch->stap_gdb_register_suffix' etc. Printing NULL pointers like this is undefined behavior. With glibc passing a NULL pointer just prints "(null)". With the MSVC libc, however, GDB crashes. Attached patch fixes this issue using the similar approach discussed in following scenario: http://sourceware.org/ml/gdb-patches/2011-10/msg00662.html There are some newly added variables due to which "maint print arch" command was causing gdb crash on whindows host. This patch takes care of them. OK? Thanks, -Ali --------------070509090705080108040600 Content-Type: text/x-patch; name="gdb_crash.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gdb_crash.patch" Content-length: 6359 Index: ChangeLog =================================================================== RCS file: /cvs/src/src/ChangeLog,v retrieving revision 1.1037 diff -u -r1.1037 ChangeLog --- ChangeLog 29 Sep 2012 15:35:50 -0000 1.1037 +++ ChangeLog 5 Oct 2012 12:48:14 -0000 @@ -1,3 +1,10 @@ +2012-10-05 Ali Anwar + + gdb/ + * gdbarch.sh (function_list): Use 'pstring' when printing + variable which could return NULL. + * gdbarch.c: Regenerate. + 2012-09-28 Ian Lance Taylor * Makefile.def: Make all-target-libgo depend on Index: gdb/gdbarch.c =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.c,v retrieving revision 1.495 diff -u -r1.495 gdbarch.c --- gdb/gdbarch.c 2 Aug 2012 09:36:38 -0000 1.495 +++ gdb/gdbarch.c 5 Oct 2012 12:48:15 -0000 @@ -1315,16 +1315,16 @@ host_address_to_string (gdbarch->stabs_argument_has_addr)); fprintf_unfiltered (file, "gdbarch_dump: stap_gdb_register_prefix = %s\n", - gdbarch->stap_gdb_register_prefix); + pstring (gdbarch->stap_gdb_register_prefix)); fprintf_unfiltered (file, "gdbarch_dump: stap_gdb_register_suffix = %s\n", - gdbarch->stap_gdb_register_suffix); + pstring (gdbarch->stap_gdb_register_suffix)); fprintf_unfiltered (file, "gdbarch_dump: stap_integer_prefix = %s\n", - gdbarch->stap_integer_prefix); + pstring (gdbarch->stap_integer_prefix)); fprintf_unfiltered (file, "gdbarch_dump: stap_integer_suffix = %s\n", - gdbarch->stap_integer_suffix); + pstring (gdbarch->stap_integer_suffix)); fprintf_unfiltered (file, "gdbarch_dump: gdbarch_stap_is_single_operand_p() = %d\n", gdbarch_stap_is_single_operand_p (gdbarch)); @@ -1339,16 +1339,16 @@ host_address_to_string (gdbarch->stap_parse_special_token)); fprintf_unfiltered (file, "gdbarch_dump: stap_register_indirection_prefix = %s\n", - gdbarch->stap_register_indirection_prefix); + pstring (gdbarch->stap_register_indirection_prefix)); fprintf_unfiltered (file, "gdbarch_dump: stap_register_indirection_suffix = %s\n", - gdbarch->stap_register_indirection_suffix); + pstring (gdbarch->stap_register_indirection_suffix)); fprintf_unfiltered (file, "gdbarch_dump: stap_register_prefix = %s\n", - gdbarch->stap_register_prefix); + pstring (gdbarch->stap_register_prefix)); fprintf_unfiltered (file, "gdbarch_dump: stap_register_suffix = %s\n", - gdbarch->stap_register_suffix); + pstring (gdbarch->stap_register_suffix)); fprintf_unfiltered (file, "gdbarch_dump: gdbarch_static_transform_name_p() = %d\n", gdbarch_static_transform_name_p (gdbarch)); Index: gdb/gdbarch.sh =================================================================== RCS file: /cvs/src/src/gdb/gdbarch.sh,v retrieving revision 1.544 diff -u -r1.544 gdbarch.sh --- gdb/gdbarch.sh 2 Aug 2012 09:36:39 -0000 1.544 +++ gdb/gdbarch.sh 5 Oct 2012 12:48:16 -0000 @@ -809,10 +809,10 @@ # \$10 ;; integer constant 10 # # in this case, this prefix would be the character \`\$\'. -v:const char *:stap_integer_prefix:::0:0::0:gdbarch->stap_integer_prefix +v:const char *:stap_integer_prefix:::0:0::0:pstring (gdbarch->stap_integer_prefix) # Suffix used to mark an integer constant on the architecture's assembly. -v:const char *:stap_integer_suffix:::0:0::0:gdbarch->stap_integer_suffix +v:const char *:stap_integer_suffix:::0:0::0:pstring (gdbarch->stap_integer_suffix) # Prefix used to mark a register name on the architecture's assembly. # For example, on x86 the register name is written as: @@ -820,10 +820,10 @@ # \%eax ;; register eax # # in this case, this prefix would be the character \`\%\'. -v:const char *:stap_register_prefix:::0:0::0:gdbarch->stap_register_prefix +v:const char *:stap_register_prefix:::0:0::0:pstring (gdbarch->stap_register_prefix) # Suffix used to mark a register name on the architecture's assembly -v:const char *:stap_register_suffix:::0:0::0:gdbarch->stap_register_suffix +v:const char *:stap_register_suffix:::0:0::0:pstring (gdbarch->stap_register_suffix) # Prefix used to mark a register indirection on the architecture's assembly. # For example, on x86 the register indirection is written as: @@ -834,7 +834,7 @@ # # Please note that we use the indirection prefix also for register # displacement, e.g., \`4\(\%eax\)\' on x86. -v:const char *:stap_register_indirection_prefix:::0:0::0:gdbarch->stap_register_indirection_prefix +v:const char *:stap_register_indirection_prefix:::0:0::0:pstring (gdbarch->stap_register_indirection_prefix) # Suffix used to mark a register indirection on the architecture's assembly. # For example, on x86 the register indirection is written as: @@ -845,7 +845,7 @@ # # Please note that we use the indirection suffix also for register # displacement, e.g., \`4\(\%eax\)\' on x86. -v:const char *:stap_register_indirection_suffix:::0:0::0:gdbarch->stap_register_indirection_suffix +v:const char *:stap_register_indirection_suffix:::0:0::0:pstring (gdbarch->stap_register_indirection_suffix) # Prefix used to name a register using GDB's nomenclature. # @@ -853,10 +853,10 @@ # language (e.g., \`10\' is the 10th general-purpose register). However, # inside GDB this same register has an \`r\' appended to its name, so the 10th # register would be represented as \`r10\' internally. -v:const char *:stap_gdb_register_prefix:::0:0::0:gdbarch->stap_gdb_register_prefix +v:const char *:stap_gdb_register_prefix:::0:0::0:pstring (gdbarch->stap_gdb_register_prefix) # Suffix used to name a register using GDB's nomenclature. -v:const char *:stap_gdb_register_suffix:::0:0::0:gdbarch->stap_gdb_register_suffix +v:const char *:stap_gdb_register_suffix:::0:0::0:pstring (gdbarch->stap_gdb_register_suffix) --------------070509090705080108040600--