From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Cc: <marc.khouzam@ericsson.com>
Subject: [PATCH 2/2] Create inferior for ctf target.
Date: Thu, 30 Jan 2014 05:47:00 -0000 [thread overview]
Message-ID: <1391060652-10870-3-git-send-email-yao@codesourcery.com> (raw)
In-Reply-To: <1391060652-10870-1-git-send-email-yao@codesourcery.com>
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 <yao@codesourcery.com>
* 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 <yao@codesourcery.com>
* 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 <sys/stat.h>
#include "exec.h"
#include "completer.h"
+#include "inferior.h"
+#include "gdbthread.h"
#include <ctype.h>
@@ -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
next prev parent reply other threads:[~2014-01-30 5:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-30 5:46 [PATCH 0/2] Create inferior fro trace file target Yao Qi
2014-01-30 5:46 ` [PATCH 1/2] Create inferior for tfile target Yao Qi
2014-01-30 5:47 ` Yao Qi [this message]
2014-01-30 19:21 ` [PATCH 0/2] Create inferior fro trace file target Marc Khouzam
2014-02-05 12:54 ` Yao Qi
2014-02-04 20:57 ` Pedro Alves
2014-02-04 21:08 ` Marc Khouzam
2014-02-04 21:17 ` Pedro Alves
2014-02-05 2:05 ` Joel Brobecker
2014-02-05 12:17 ` Yao Qi
2014-02-05 12:24 ` Joel Brobecker
2014-02-05 12:31 ` Pedro Alves
2014-02-05 12:42 ` Mark Kettenis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1391060652-10870-3-git-send-email-yao@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=marc.khouzam@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox