From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10193 invoked by alias); 30 Jan 2014 05:47:02 -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 10178 invoked by uid 89); 30 Jan 2014 05:47:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Jan 2014 05:47:01 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1W8kSn-0003T0-R1 from Yao_Qi@mentor.com ; Wed, 29 Jan 2014 21:46:57 -0800 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 29 Jan 2014 21:46:57 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Wed, 29 Jan 2014 21:46:55 -0800 From: Yao Qi To: CC: Subject: [PATCH 2/2] Create inferior for ctf target. Date: Thu, 30 Jan 2014 05:47:00 -0000 Message-ID: <1391060652-10870-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1391060652-10870-1-git-send-email-yao@codesourcery.com> References: <1391060652-10870-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2014-01/txt/msg01056.txt.bz2 This patch creates inferior when GDB opens a ctf trace data, to be consistent with tfile target. A test case is added to test for live target, tfile and ctf target. gdb: 2014-01-30 Yao Qi * ctf.c: Include "inferior.h" and "gdbthread.h". (CTF_PID): A new macro. (ctf_open): Call inferior_appeared and add_thread_silent. (ctf_close): Call exit_inferior_silent and set inferior_ptid. (ctf_thread_alive): New function. (init_ctf_ops): Install ctf_thread_alive to to_thread_alive. gdb/testsuite: 2014-01-30 Yao Qi * gdb.trace/report.exp (use_collected_data): Test the output of "info threads" and "info inferiors". --- gdb/ctf.c | 24 ++++++++++++++++++++++++ gdb/testsuite/gdb.trace/report.exp | 7 ++++++- 2 files changed, 30 insertions(+), 1 deletions(-) diff --git a/gdb/ctf.c b/gdb/ctf.c index a22937f..6035c2b 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -26,6 +26,8 @@ #include #include "exec.h" #include "completer.h" +#include "inferior.h" +#include "gdbthread.h" #include @@ -76,6 +78,8 @@ #define CTF_EVENT_ID_TSV_DEF 5 #define CTF_EVENT_ID_TP_DEF 6 +#define CTF_PID (2) + /* The state kept while writing the CTF datastream file. */ struct trace_write_handler @@ -1188,6 +1192,10 @@ ctf_open (char *dirname, int from_tty) trace_dirname = xstrdup (dirname); push_target (&ctf_ops); + inferior_appeared (current_inferior (), CTF_PID); + inferior_ptid = pid_to_ptid (CTF_PID); + add_thread_silent (inferior_ptid); + merge_uploaded_trace_state_variables (&uploaded_tsvs); merge_uploaded_tracepoints (&uploaded_tps); } @@ -1198,10 +1206,16 @@ ctf_open (char *dirname, int from_tty) static void ctf_close (void) { + int pid; + ctf_destroy (); xfree (trace_dirname); trace_dirname = NULL; + pid = ptid_get_pid (inferior_ptid); + inferior_ptid = null_ptid; /* Avoid confusion from thread stuff. */ + exit_inferior_silent (pid); + trace_reset_local_state (); } @@ -1725,6 +1739,15 @@ ctf_has_registers (struct target_ops *ops) return get_traceframe_number () != -1; } +/* This is the implementation of target_ops method to_thread_alive. + CTF trace data has one thread faked by GDB. */ + +static int +ctf_thread_alive (struct target_ops *ops, ptid_t ptid) +{ + return 1; +} + /* This is the implementation of target_ops method to_traceframe_info. Iterate the events whose name is "memory", in current frame, extract memory range information, and return them in @@ -1831,6 +1854,7 @@ Specify the filename of the CTF directory."; ctf_ops.to_has_stack = ctf_has_stack; ctf_ops.to_has_registers = ctf_has_registers; ctf_ops.to_traceframe_info = ctf_traceframe_info; + ctf_ops.to_thread_alive = ctf_thread_alive; ctf_ops.to_magic = OPS_MAGIC; } diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp index 8bf1251..4d33512 100644 --- a/gdb/testsuite/gdb.trace/report.exp +++ b/gdb/testsuite/gdb.trace/report.exp @@ -197,7 +197,7 @@ proc use_collected_data { data_source } { global tdp1 tdp2 tdp3 tdp4 tdp5 tdp6 global testline1 testline2 testline3 testline4 testline5 testline6 global pcreg fpreg spreg - global srcfile srcdir subdir + global srcfile srcdir subdir binfile global arg1 arg3 global decimal hex gdb_prompt # @@ -397,6 +397,11 @@ proc use_collected_data { data_source } { } } } + + # There is always a thread of an inferior, either a live one or + # a faked one. + gdb_test "info threads" "\\* ${decimal} (process|Thread) ${decimal}\[ \t\].*" + gdb_test "info inferiors" "\\* 1 process ${decimal} \[ \t\]+${binfile}.*" } } -- 1.7.7.6