From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11974 invoked by alias); 13 Jun 2011 12:21:54 -0000 Received: (qmail 11964 invoked by uid 22791); 13 Jun 2011 12:21:52 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Jun 2011 12:21:37 +0000 Received: (qmail 19602 invoked from network); 13 Jun 2011 12:21:37 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 13 Jun 2011 12:21:37 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [RFA] tracepoint remote.c:remote_trace_set_readonly_regions give up some regions if it is number is too big Date: Mon, 13 Jun 2011 12:21:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-8-generic; KDE/4.6.2; x86_64; ; ) Cc: Hui Zhu References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201106131321.33532.pedro@codesourcery.com> 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: 2011-06/txt/msg00157.txt.bz2 On Sunday 12 June 2011 15:01:07, Hui Zhu wrote: > Hi, > > My GDB got crash with a ELF file when I use tracepoint with it. I > found that it have 12898 sections. > So in remote_trace_set_readonly_regions: > sprintf (target_buf + strlen (target_buf), > ":%s,%s", tmp1, tmp2); > It will over write other val, it make GDB crash. > So I add a check before it to fix it: > if (strlen (target_buf) + strlen(tmp1) + strlen(tmp2) + 3 > > target_buf_size) > { > warning (_("Give up some read only regions.")); > break; > } > Note that if your stub supports qXfer:traceframe-info:read, this packet is no longer necessary to support, as GDB will handle reading from readonly sections out of live memory itself. I think this means that the warning should only be output if remote_protocol_packets[PACKET_qXfer_traceframe_info].support is not PACKET_ENABLE? > Please help me review it. > > And this issue affect 7.3 too. Does it can check in to 7.3? > > Thanks, > Hui > > 2011-06-12 Hui Zhu > > * remote.c (remote_trace_set_readonly_regions): Add a check for > target_buf_size. > --- > remote.c | 5 +++++ > 1 file changed, 5 insertions(+) > > --- a/remote.c > +++ b/remote.c > @@ -9996,6 +9996,11 @@ remote_trace_set_readonly_regions (void) > size = bfd_get_section_size (s); > sprintf_vma (tmp1, vma); > sprintf_vma (tmp2, vma + size); if (strlen (target_buf) + strlen(tmp1) + strlen(tmp2) + 3 > target_buf_size) Space before `('. Too long line, split the length calc into a local out of the if predicate. Should be simple to keep the current length of target_buf in a variable and increment it on each iteration so you don't need to compute it everytime. size = bfd_get_section_size (s); sprintf_vma (tmp1, vma); sprintf_vma (tmp2, vma + size); sec_length = 1 + strlen (tmp1) + 1 + strlen (tmp2); if (offset + sec_length >= target_buf_size) { warning(); break; } sprintf (target_buf + offset, ":%s,%s", tmp1, tmp2); offset += sec_length; > + { > + warning (_("Give up some read only regions.")); Make that: "Too many sections for read-only sections definition packet". > + break; > + } > sprintf (target_buf + strlen (target_buf), > ":%s,%s", tmp1, tmp2); > } > -- Pedro Alves