Add [-q] [-t TYPEREGEXP] [NAMEREGEXP] args to info [args|functions|locals|variables]
[deliverable/binutils-gdb.git] / gdb / ctf.c
index cae5d221cb1c3f4a8143df60ea12b0df75101ccd..ca5266fbd7c588c07fec662ec6c199931a3d8c6d 100644 (file)
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -31,6 +31,7 @@
 #include "tracefile.h"
 #include <ctype.h>
 #include <algorithm>
+#include "common/filestuff.h"
 
 /* The CTF target.  */
 
@@ -354,7 +355,8 @@ ctf_start (struct trace_file_writer *self, const char *dirname)
 
   std::string file_name = string_printf ("%s/%s", dirname, CTF_METADATA_NAME);
 
-  writer->tcs.metadata_fd = fopen (file_name.c_str (), "w");
+  writer->tcs.metadata_fd
+    = gdb_fopen_cloexec (file_name.c_str (), "w").release ();
   if (writer->tcs.metadata_fd == NULL)
     error (_("Unable to open file '%s' for saving trace data (%s)"),
           file_name.c_str (), safe_strerror (errno));
@@ -362,7 +364,8 @@ ctf_start (struct trace_file_writer *self, const char *dirname)
   ctf_save_metadata_header (&writer->tcs);
 
   file_name = string_printf ("%s/%s", dirname, CTF_DATASTREAM_NAME);
-  writer->tcs.datastream_fd = fopen (file_name.c_str (), "w");
+  writer->tcs.datastream_fd
+    = gdb_fopen_cloexec (file_name.c_str (), "w").release ();
   if (writer->tcs.datastream_fd == NULL)
     error (_("Unable to open file '%s' for saving trace data (%s)"),
           file_name.c_str (), safe_strerror (errno));
@@ -1008,14 +1011,14 @@ ctf_read_tsv (struct uploaded_tsv **uploaded_tsvs)
 #define SET_ARRAY_FIELD(EVENT, SCOPE, VAR, NUM, ARRAY) \
   do                                                   \
     {                                                  \
-      uint32_t u32, i;                                         \
+      uint32_t lu32, i;                                                \
       const struct bt_definition *def;                         \
                                                                \
-      u32 = (uint32_t) bt_ctf_get_uint64 (bt_ctf_get_field ((EVENT),   \
-                                                           (SCOPE),    \
-                                                           #NUM));     \
+      lu32 = (uint32_t) bt_ctf_get_uint64 (bt_ctf_get_field ((EVENT),  \
+                                                            (SCOPE),   \
+                                                            #NUM));    \
       def = bt_ctf_get_field ((EVENT), (SCOPE), #ARRAY);               \
-      for (i = 0; i < u32; i++)                                        \
+      for (i = 0; i < lu32; i++)                                       \
        {                                                               \
          const struct bt_definition *element                           \
            = bt_ctf_get_index ((EVENT), def, i);                       \
@@ -1160,7 +1163,7 @@ ctf_target_open (const char *dirname, int from_tty)
   push_target (&ctf_ops);
 
   inferior_appeared (current_inferior (), CTF_PID);
-  inferior_ptid = pid_to_ptid (CTF_PID);
+  inferior_ptid = ptid_t (CTF_PID);
   add_thread_silent (inferior_ptid);
 
   merge_uploaded_trace_state_variables (&uploaded_tsvs);
@@ -1175,15 +1178,12 @@ ctf_target_open (const char *dirname, int from_tty)
 void
 ctf_target::close ()
 {
-  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);
+  exit_inferior_silent (current_inferior ());
 
   trace_reset_local_state ();
 }
@@ -1262,16 +1262,16 @@ ctf_target::fetch_registers (struct regcache *regcache, int regno)
          /* Make sure we stay within block bounds.  */
          if (offset + regsize >= trace_regblock_size)
            break;
-         if (regcache_register_status (regcache, regn) == REG_UNKNOWN)
+         if (regcache->get_register_status (regn) == REG_UNKNOWN)
            {
              if (regno == regn)
                {
-                 regcache_raw_supply (regcache, regno, regs + offset);
+                 regcache->raw_supply (regno, regs + offset);
                  break;
                }
              else if (regno == -1)
                {
-                 regcache_raw_supply (regcache, regn, regs + offset);
+                 regcache->raw_supply (regn, regs + offset);
                }
            }
          offset += regsize;
This page took 0.025123 seconds and 4 git commands to generate.