From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5225 invoked by alias); 1 Mar 2012 18:49:44 -0000 Received: (qmail 5216 invoked by uid 22791); 1 Mar 2012 18:49:43 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Mar 2012 18:49:22 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q21InJOL025813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Mar 2012 13:49:19 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q21InHQh012410; Thu, 1 Mar 2012 13:49:18 -0500 Message-ID: <4F4FC4AD.3020501@redhat.com> Date: Thu, 01 Mar 2012 18:49:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 MIME-Version: 1.0 To: Pedro Alves CC: Hui Zhu , gdb-patches@sourceware.org, Yao Qi Subject: Re: Fix error when gdb connect to a stub that tracepoint is running[1/2] Add a flag initialized to struct trace_status References: <4F4F8BE2.7030503@mentor.com> <4F4FB2F9.80200@redhat.com> In-Reply-To: <4F4FB2F9.80200@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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/msg00027.txt.bz2 On 03/01/2012 05:33 PM, Pedro Alves wrote: > I think this is close, but still not quite right. This isn't fundamentally > about the remote side's trace status; so having remote_get_trace_status > return something different while going through initialization feels wrong. > Let me try tweaking this a bit. I'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_location_list > to know that it shouldn't try to install tracepoints yet (cause we're still going > through startup)? This is closer to what I was thinking. Would you like to write a test case for this (please :-)) ? WDYT? 2012-03-01 Pedro Alves Hui Zhu Yao Qi * remote.c (struct remote_state): New field `starting_up'. (remote_start_remote): Set and clear it. (remote_can_download_tracepoint): If starting up, return false. --- gdb/remote.c | 28 ++++++++++++++++++++++++++-- 1 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 char *buf; long buf_size; + /* True if we're going through initial connection setup (finding out + about the remote side's threads, relocating symbols, etc.). */ + int starting_up; + /* If we negotiated packet size explicitly (and thus can bypass heuristics for the largest packet size that will not overflow a 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) /* Ack any packet which the remote side has already sent. */ serial_write (remote_desc, "+", 1); + /* Signal other parts that we're going through the initial setup, + and so things may not be stable yet. */ + rs->starting_up = 1; + /* The first packet we send to the target is the optional "supported packets" request. If the target can answer this, it will tell us which later probes to skip. */ @@ -3462,6 +3470,12 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p) merge_uploaded_tracepoints (&uploaded_tps); } + /* The thread and inferior lists are now synchronized with the + target, our symbols have been relocated, and we're merged the + target's tracepoints with ours. We're done with basic start + up. */ + rs->starting_up = 0; + /* If breakpoints are global, insert them now. */ if (gdbarch_has_global_breakpoints (target_gdbarch) && breakpoints_always_inserted_mode ()) @@ -10221,8 +10235,18 @@ remote_download_tracepoint (struct bp_location *loc) static int remote_can_download_tracepoint (void) { - struct trace_status *ts = current_trace_status (); - int status = remote_get_trace_status (ts); + struct remote_state *rs = get_remote_state (); + struct trace_status *ts; + int status; + + /* Don't try to install tracepoints until we've relocated our + symbols, and fetched and merged the target's tracepoint list with + ours. */ + if (rs->starting_up) + return 0; + + ts = current_trace_status (); + status = remote_get_trace_status (ts); if (status == -1 || !ts->running_known || !ts->running) return 0;