From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13810 invoked by alias); 11 Mar 2012 16:13:08 -0000 Received: (qmail 13794 invoked by uid 22791); 11 Mar 2012 16:12:58 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-wi0-f171.google.com (HELO mail-wi0-f171.google.com) (209.85.212.171) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 11 Mar 2012 16:12:45 +0000 Received: by wibhj13 with SMTP id hj13so2100691wib.12 for ; Sun, 11 Mar 2012 09:12:43 -0700 (PDT) Received: by 10.180.24.7 with SMTP id q7mr20466575wif.11.1331482363301; Sun, 11 Mar 2012 09:12:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.69.138 with HTTP; Sun, 11 Mar 2012 09:12:03 -0700 (PDT) In-Reply-To: References: <4F4F8BE2.7030503@mentor.com> <4F4FB2F9.80200@redhat.com> <4F4FC4AD.3020501@redhat.com> From: Hui Zhu Date: Sun, 11 Mar 2012 16:13:00 -0000 Message-ID: Subject: Re: Fix error when gdb connect to a stub that tracepoint is running[1/2] Add a flag initialized to struct trace_status To: Pedro Alves Cc: Hui Zhu , gdb-patches@sourceware.org, Yao Qi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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-03/txt/msg00379.txt.bz2 Hi Pedro, I had made sure that the FSF acknowledged my copyright assignment mid february. So this email is OK now. And I found that this issue affect 7.4 too. I suggest commit this patch to 7.4 branch too. Thanks, Hui On Mon, Mar 5, 2012 at 10:25, Hui Zhu wrote: > On Fri, Mar 2, 2012 at 02:49, Pedro Alves wrote: >> On 03/01/2012 05:33 PM, Pedro Alves wrote: >> >>> I think this is close, but still not quite right. =A0This isn't fundame= ntally >>> about the remote side's trace status; so having remote_get_trace_status >>> return something different while going through initialization feels wro= ng. >>> Let me try tweaking this a bit. =A0I'll also hack a bit on patch 2/2. >> >> On 02/08/2012 06:31 PM, Pedro Alves wrote: >> >>> It may be simpler and safer to just have a way for update_global_locati= on_list >>> to know that it shouldn't try to install tracepoints yet (cause we're s= till going >>> through startup)? >> >> This is closer to what I was thinking. >> >> Would you like to write a test case for this (please :-)) ? >> >> WDYT? > > I think this patch is better. =A0Thanks. > > I will write the testsuite. > > I still have some copyright issue with hui_zhu@mentor.com email > address, please use teawater@gmail.com if you commit this patch. > Sorry for it. > > Best, > Hui > >> >> 2012-03-01 =A0Pedro Alves =A0 >> =A0 =A0 =A0 =A0 =A0 =A0Hui Zhu =A0 >> =A0 =A0 =A0 =A0 =A0 =A0Yao Qi =A0 >> >> =A0 =A0 =A0 =A0* remote.c (struct remote_state): New field `starting_up'. >> =A0 =A0 =A0 =A0(remote_start_remote): Set and clear it. >> =A0 =A0 =A0 =A0(remote_can_download_tracepoint): If starting up, return = false. >> >> --- >> >> =A0gdb/remote.c | =A0 28 ++++++++++++++++++++++++++-- >> =A01 files changed, 26 insertions(+), 2 deletions(-) >> >> diff --git a/gdb/remote.c b/gdb/remote.c >> index 2719241..611921d 100644 >> --- a/gdb/remote.c >> +++ b/gdb/remote.c >> @@ -273,6 +273,10 @@ struct remote_state >> =A0 char *buf; >> =A0 long buf_size; >> >> + =A0/* True if we're going through initial connection setup (finding out >> + =A0 =A0 about the remote side's threads, relocating symbols, etc.). = =A0*/ >> + =A0int starting_up; >> + >> =A0 /* If we negotiated packet size explicitly (and thus can bypass >> =A0 =A0 =A0heuristics for the largest packet size that will not overflow >> =A0 =A0 =A0a buffer in the stub), this will be set to that packet size. >> @@ -3219,6 +3223,10 @@ remote_start_remote (int from_tty, struct target_= ops *target, int extended_p) >> =A0 /* Ack any packet which the remote side has already sent. =A0*/ >> =A0 serial_write (remote_desc, "+", 1); >> >> + =A0/* Signal other parts that we're going through the initial setup, >> + =A0 =A0 and so things may not be stable yet. =A0*/ >> + =A0rs->starting_up =3D 1; >> + >> =A0 /* The first packet we send to the target is the optional "supported >> =A0 =A0 =A0packets" request. =A0If the target can answer this, it will t= ell us >> =A0 =A0 =A0which later probes to skip. =A0*/ >> @@ -3462,6 +3470,12 @@ remote_start_remote (int from_tty, struct target_= ops *target, int extended_p) >> =A0 =A0 =A0 merge_uploaded_tracepoints (&uploaded_tps); >> =A0 =A0 } >> >> + =A0/* The thread and inferior lists are now synchronized with the >> + =A0 =A0 target, our symbols have been relocated, and we're merged the >> + =A0 =A0 target's tracepoints with ours. =A0We're done with basic start >> + =A0 =A0 up. =A0*/ >> + =A0rs->starting_up =3D 0; >> + >> =A0 /* If breakpoints are global, insert them now. =A0*/ >> =A0 if (gdbarch_has_global_breakpoints (target_gdbarch) >> =A0 =A0 =A0 && breakpoints_always_inserted_mode ()) >> @@ -10221,8 +10235,18 @@ remote_download_tracepoint (struct bp_location = *loc) >> =A0static int >> =A0remote_can_download_tracepoint (void) >> =A0{ >> - =A0struct trace_status *ts =3D current_trace_status (); >> - =A0int status =3D remote_get_trace_status (ts); >> + =A0struct remote_state *rs =3D get_remote_state (); >> + =A0struct trace_status *ts; >> + =A0int status; >> + >> + =A0/* Don't try to install tracepoints until we've relocated our >> + =A0 =A0 symbols, and fetched and merged the target's tracepoint list w= ith >> + =A0 =A0 ours. =A0*/ >> + =A0if (rs->starting_up) >> + =A0 =A0return 0; >> + >> + =A0ts =3D current_trace_status (); >> + =A0status =3D remote_get_trace_status (ts); >> >> =A0 if (status =3D=3D -1 || !ts->running_known || !ts->running) >> =A0 =A0 return 0;