From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22556 invoked by alias); 19 Dec 2013 03:30:05 -0000 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 Received: (qmail 22535 invoked by uid 89); 19 Dec 2013 03:30:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 19 Dec 2013 03:30:02 +0000 Received: by mail-pa0-f54.google.com with SMTP id rd3so564007pab.13 for ; Wed, 18 Dec 2013 19:30:00 -0800 (PST) X-Received: by 10.66.119.136 with SMTP id ku8mr38068088pab.121.1387423800389; Wed, 18 Dec 2013 19:30:00 -0800 (PST) Received: from [192.168.1.20] ([123.118.199.25]) by mx.google.com with ESMTPSA id vn10sm3468204pbc.21.2013.12.18.19.29.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Dec 2013 19:29:59 -0800 (PST) Message-ID: <52B26826.4090806@gmail.com> Date: Thu, 19 Dec 2013 03:30:00 -0000 From: Hui Zhu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: gdb-patches ml Subject: [PATCH v2 2/4] tracepoint multithread and multiprocess support (gdbserver) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00731.txt.bz2 This version doesn't have big change, just update follow GDB trunk and update Changelog. This patch is for the gdbserver. It will send ";MultiProcessTracepoint+" back to GDB if this gdbserver support tracepoint. When cmd_qtdp got a "QTDP" packets that have P@var{thread-id}. 1. Get ptid from thread-id. 2. If this ptid's pid is not same with current process, send exx packets back to GDB. 3. If this ptid's lwp and tip is 0, set it to minus_one_ptid because this ptid just has process info, gdbserver has done with process check. 3. Save this ptid to tracepoint. Before GDB trigger a tracepoint, it will check if its ptid is same with minus_one_ptid or tinfo->entry.id. If not, doesn't trigger it. Please help me review it. Thanks, Hui 2013-12-19 Hui Zhu * server.c (handle_query): Send ";MultiProcessTracepoint+". * tracepoint.c (tracepoint): Add ptid. (add_tracepoint): Initialize ptid. (cmd_qtdp): Handle 'P'. (tracepoint_was_hit): Add check if tpoint->ptid is same with minus_one_ptid or tinfo->entry.id. --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1804,6 +1804,7 @@ handle_query (char *own_buf, int packet_ strcat (own_buf, ";EnableDisableTracepoints+"); strcat (own_buf, ";QTBuffer:size+"); strcat (own_buf, ";tracenz+"); + strcat (own_buf, ";MultiProcessTracepoint+"); } /* Support target-side breakpoint conditions and commands. */ --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -766,6 +766,8 @@ struct tracepoint CORE_ADDR compiled_cond; + ptid_t ptid; + /* Link to the next tracepoint in the list. */ struct tracepoint *next; @@ -1822,6 +1824,7 @@ add_tracepoint (int num, CORE_ADDR addr) tpoint->source_strings = NULL; tpoint->compiled_cond = 0; tpoint->handle = NULL; + tpoint->ptid = minus_one_ptid; tpoint->next = NULL; /* Find a place to insert this tracepoint into list in order to keep @@ -2551,6 +2554,29 @@ cmd_qtdp (char *own_buf) tpoint->cond = gdb_parse_agent_expr (&actparm); packet = actparm; } + else if (*packet == 'P') + { + ++packet; + tpoint->ptid = read_ptid (packet, &packet); + + /* Check if this tracepoint is for current process. */ + if (ptid_get_pid (current_ptid) + != ptid_get_pid (tpoint->ptid)) + { + trace_debug ("\ +Tracepoint error: tracepoint %d is not for current process", (int) num); + write_enn (own_buf); + return; + } + if (ptid_get_lwp (tpoint->ptid) == 0 + && ptid_get_tid (tpoint->ptid) == 0) + { + /* This tracepoint is OK for all the thread of current + process, set its ptid to minus_one_ptid to make its + ptid is not checked before trigger this tracepoint. */ + tpoint->ptid = minus_one_ptid; + } + } else if (*packet == '-') break; else if (*packet == '\0') @@ -4562,10 +4588,14 @@ tracepoint_was_hit (struct thread_info * target_pid_to_str (tinfo->entry.id), tpoint->number, paddress (tpoint->address)); - /* Test the condition if present, and collect if true. */ - if (!tpoint->cond - || (condition_true_at_tracepoint - ((struct tracepoint_hit_ctx *) &ctx, tpoint))) + /* Check if tpoint->ptid is same with minus_one_ptid or + tinfo->entry.id, test the condition if present, + and collect if all true. */ + if ((ptid_equal (minus_one_ptid, tpoint->ptid) + || ptid_equal (tinfo->entry.id, tpoint->ptid)) + && (!tpoint->cond + || (condition_true_at_tracepoint + ((struct tracepoint_hit_ctx *) &ctx, tpoint)))) collect_data_at_tracepoint ((struct tracepoint_hit_ctx *) &ctx, stop_pc, tpoint);