From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10720 invoked by alias); 5 Mar 2012 02:26:24 -0000 Received: (qmail 10710 invoked by uid 22791); 5 Mar 2012 02:26:23 -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-ww0-f43.google.com (HELO mail-ww0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 05 Mar 2012 02:26:10 +0000 Received: by wgbdr12 with SMTP id dr12so2529890wgb.12 for ; Sun, 04 Mar 2012 18:26:09 -0800 (PST) Received-SPF: pass (google.com: domain of teawater@gmail.com designates 10.180.83.42 as permitted sender) client-ip=10.180.83.42; Authentication-Results: mr.google.com; spf=pass (google.com: domain of teawater@gmail.com designates 10.180.83.42 as permitted sender) smtp.mail=teawater@gmail.com; dkim=pass header.i=teawater@gmail.com Received: from mr.google.com ([10.180.83.42]) by 10.180.83.42 with SMTP id n10mr11761514wiy.9.1330914369404 (num_hops = 1); Sun, 04 Mar 2012 18:26:09 -0800 (PST) Received: by 10.180.83.42 with SMTP id n10mr9385421wiy.9.1330914369275; Sun, 04 Mar 2012 18:26:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.115.75 with HTTP; Sun, 4 Mar 2012 18:25:29 -0800 (PST) In-Reply-To: <4F4FC4AD.3020501@redhat.com> References: <4F4F8BE2.7030503@mentor.com> <4F4FB2F9.80200@redhat.com> <4F4FC4AD.3020501@redhat.com> From: Hui Zhu Date: Mon, 05 Mar 2012 02:26: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/msg00130.txt.bz2 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 fundamen= tally >> about the remote side's trace status; so having remote_get_trace_status >> return something different while going through initialization feels wron= g. >> 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_locatio= n_list >> to know that it shouldn't try to install tracepoints yet (cause we're st= ill 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. Thanks. 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 f= alse. > > --- > > =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_o= ps *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 te= ll us > =A0 =A0 =A0which later probes to skip. =A0*/ > @@ -3462,6 +3470,12 @@ remote_start_remote (int from_tty, struct target_o= ps *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 wi= th > + =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;