From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18994 invoked by alias); 14 Aug 2011 13:41:29 -0000 Received: (qmail 18986 invoked by uid 22791); 14 Aug 2011 13:41:28 -0000 X-SWARE-Spam-Status: No, hits=-2.1 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-fx0-f41.google.com (HELO mail-fx0-f41.google.com) (209.85.161.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 14 Aug 2011 13:41:14 +0000 Received: by fxg9 with SMTP id 9so3686263fxg.0 for ; Sun, 14 Aug 2011 06:41:13 -0700 (PDT) Received: by 10.223.159.4 with SMTP id h4mr4201795fax.57.1313329273073; Sun, 14 Aug 2011 06:41:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.115.11 with HTTP; Sun, 14 Aug 2011 06:40:32 -0700 (PDT) In-Reply-To: <4E406AE9.100@earthlink.net> References: <4E406AE9.100@earthlink.net> From: Hui Zhu Date: Sun, 14 Aug 2011 13:41:00 -0000 Message-ID: Subject: Re: [PATCH]tracepoint.c: Add conditionals num to find_matching_tracepoint To: Stan Shebs Cc: gdb-patches@sourceware.org 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: 2011-08/txt/msg00285.txt.bz2 On Tue, Aug 9, 2011 at 07:02, Stan Shebs wrote: > On 8/7/11 9:28 AM, Hui Zhu wrote: >> >> Hi, >> >> I found that when I set some tracepoint to a same address, and use >> tsave. =A0 And use "target tfile " to open it. =A0It will only one >> tracepoint available. >> And output some words like: >> Created tracepoint 1 for target's tracepoint 1 at 0x40050a. >> Assuming tracepoint 1 is same as target's tracepoint 2 at 0x40050a. >> Assuming tracepoint 1 is same as target's tracepoint 3 at 0x40050a. >> >> This is because find_matching_tracepoint didn't check the num. > > > The number is exactly the one property that tracepoint upload must never > consider when looking for matching tracepoints, since the numbers vary > depending on what the user has been doing during the current GDB session. > =A0Addressing the FIXME will help the multiple-tracepoint case, although = it's > kind of messy. > > There is another useful heuristic that would be easy to add, which is to > exclude matching on a tracepoint that has already been uploaded. =A0Having > created tracepoint 1 from the uploaded info, it's never going to be the c= ase > that uploaded tracepoints 2 and 3 are the same as 1. =A0It might be as si= mple > as testing number_on_target, but beware that it might be nonzero due to > other trace runs or some such. > > Stan > stan@codesourcery.com > >> >> And I think the tracepoint have the same address is really helpful for >> user. =A0Because we can set different condition to make tracepoint more >> powerful. >> So I make following patch. >> >> Please help me review it. >> >> Thanks, >> Hui >> >> >> 2011-08-08 =A0Hui Zhu >> >> =A0 =A0 =A0 =A0* tracepoint.c (find_matching_tracepoint): Add number che= ck. > > Hi Stan, Thanks for your review. I make a new patch that check the condition according to your mail. Best, Hui 2011-08-14 Hui Zhu * tracepoint.c (cond_string_is_same): New function. (find_matching_tracepoint): Add condition check by cond_string_is_same. --- tracepoint.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) --- a/tracepoint.c +++ b/tracepoint.c @@ -3091,6 +3091,22 @@ free_uploaded_tsvs (struct uploaded_tsv } } +static int +cond_string_is_same(char *str1, char *str2) +{ + if (str1 =3D=3D NULL || str2 =3D=3D NULL) + { + if (str1 =3D=3D str2) + return 1; + else + return 0; + } + if (strcmp (str1, str2)) + return 0; + + return 1; +} + /* Look for an existing tracepoint that seems similar enough to the uploaded one. Enablement isn't compared, because the user can toggle that freely, and may have done so in anticipation of the @@ -3111,7 +3127,8 @@ find_matching_tracepoint (struct uploade if (b->type =3D=3D utp->type && t->step_count =3D=3D utp->step && t->pass_count =3D=3D utp->pass - /* FIXME also test conditionals and actions. */ + && cond_string_is_same (t->base.cond_string, utp->cond_string) + /* FIXME also test actions. */ ) { /* Scan the locations for an address match. */