]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Create inferior for ctf target.
authorYao Qi <yao@codesourcery.com>
Thu, 30 Jan 2014 02:09:11 +0000 (10:09 +0800)
committerYao Qi <yao@codesourcery.com>
Wed, 5 Feb 2014 11:37:25 +0000 (19:37 +0800)
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-02-05  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-02-05  Yao Qi  <yao@codesourcery.com>

* gdb.trace/report.exp (use_collected_data): Test the output
of "info threads" and "info inferiors".

gdb/ChangeLog
gdb/ctf.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.trace/report.exp

index 04f4cea88b04c620d7ed47c42ba272617ca4341e..73e87749d7c4bd29542c9050cc9e93f0a254b3e7 100644 (file)
@@ -1,3 +1,12 @@
+2014-02-05  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.
+
 2014-02-05  Yao Qi  <yao@codesourcery.com>
 
        Revert this patch:
index a22937f09658a8fc3b25edb548300464ebd3e61c..6035c2bc122caa8b61a855a171b0995e013f4b8a 100644 (file)
--- 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;
 }
 
index 74fc0f7ab39f2bd2cd0af2d9d70f2375a43e4c17..480732a7df75aff71f73ff52babd174425698cae 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-05  Yao Qi  <yao@codesourcery.com>
+
+       * gdb.trace/report.exp (use_collected_data): Test the output
+       of "info threads" and "info inferiors".
+
 2014-02-05  Yao Qi  <yao@codesourcery.com>
 
        Revert this patch:
index 8bf12510da985fb543dff7f7a0cd3352c117f6c5..4d335125fa2c6bae2a79176c8242a7d135375a0b 100644 (file)
@@ -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}.*"
     }
 }