add the cleanup checker
[deliverable/binutils-gdb.git] / gdb / tracepoint.c
index b89ca22b4bf89786ee75460ac2dc849bf7c42f3a..26aedac4825009cf7cc3412d478d87755c0093e1 100644 (file)
@@ -55,6 +55,7 @@
 #include "probe.h"
 #include "ctf.h"
 #include "completer.h"
+#include "filestuff.h"
 
 /* readline include files */
 #include "readline/readline.h"
@@ -81,8 +82,6 @@
    large.  (400 - 31)/2 == 184 */
 #define MAX_AGENT_EXPR_LEN     184
 
-#define TFILE_PID (1)
-
 /* A hook used to notify the UI of tracepoint operations.  */
 
 void (*deprecated_trace_find_hook) (char *arg, int from_tty);
@@ -1242,7 +1241,7 @@ clear_collection_list (struct collection_list *list)
 
 /* Reduce a collection list to string form (for gdb protocol).  */
 static char **
-stringify_collection_list (struct collection_list *list, char *string)
+stringify_collection_list (struct collection_list *list)
 {
   char temp_buf[2048];
   char tmp2[40];
@@ -1365,7 +1364,6 @@ stringify_collection_list (struct collection_list *list, char *string)
 
 static void
 encode_actions_1 (struct command_line *action,
-                 struct breakpoint *t,
                  struct bp_location *tloc,
                  int frame_reg,
                  LONGEST frame_offset,
@@ -1598,7 +1596,7 @@ encode_actions_1 (struct command_line *action,
             here.  */
          gdb_assert (stepping_list);
 
-         encode_actions_1 (action->body_list[0], t, tloc, frame_reg,
+         encode_actions_1 (action->body_list[0], tloc, frame_reg,
                            frame_offset, stepping_list, NULL);
        }
       else
@@ -1609,10 +1607,9 @@ encode_actions_1 (struct command_line *action,
 /* Render all actions into gdb protocol.  */
 
 void
-encode_actions (struct breakpoint *t, struct bp_location *tloc,
-               char ***tdp_actions, char ***stepping_actions)
+encode_actions (struct bp_location *tloc, char ***tdp_actions,
+               char ***stepping_actions)
 {
-  static char tdp_buff[2048], step_buff[2048];
   char *default_collect_line = NULL;
   struct command_line *actions;
   struct command_line *default_collect_action = NULL;
@@ -1631,7 +1628,7 @@ encode_actions (struct breakpoint *t, struct bp_location *tloc,
   gdbarch_virtual_frame_pointer (tloc->gdbarch,
                                 tloc->address, &frame_reg, &frame_offset);
 
-  actions = breakpoint_commands (t);
+  actions = breakpoint_commands (tloc->owner);
 
   /* If there are default expressions to collect, make up a collect
      action and prepend to the action list to encode.  Note that since
@@ -1643,7 +1640,7 @@ encode_actions (struct breakpoint *t, struct bp_location *tloc,
       default_collect_line =  xstrprintf ("collect %s", default_collect);
       make_cleanup (xfree, default_collect_line);
 
-      validate_actionline (default_collect_line, t);
+      validate_actionline (default_collect_line, tloc->owner);
 
       default_collect_action = xmalloc (sizeof (struct command_line));
       make_cleanup (xfree, default_collect_action);
@@ -1651,16 +1648,14 @@ encode_actions (struct breakpoint *t, struct bp_location *tloc,
       default_collect_action->line = default_collect_line;
       actions = default_collect_action;
     }
-  encode_actions_1 (actions, t, tloc, frame_reg, frame_offset,
+  encode_actions_1 (actions, tloc, frame_reg, frame_offset,
                    &tracepoint_list, &stepping_list);
 
   memrange_sortmerge (&tracepoint_list);
   memrange_sortmerge (&stepping_list);
 
-  *tdp_actions = stringify_collection_list (&tracepoint_list,
-                                           tdp_buff);
-  *stepping_actions = stringify_collection_list (&stepping_list,
-                                                step_buff);
+  *tdp_actions = stringify_collection_list (&tracepoint_list);
+  *stepping_actions = stringify_collection_list (&stepping_list);
 
   do_cleanups (back_to);
 }
@@ -3000,7 +2995,7 @@ encode_source_string (int tpnum, ULONGEST addr,
           srctype, 0, (int) strlen (src));
   if (strlen (buf) + strlen (src) * 2 >= buf_size)
     error (_("Source string too long for buffer"));
-  bin2hex (src, buf + strlen (buf), 0);
+  bin2hex ((gdb_byte *) src, buf + strlen (buf), 0);
   return -1;
 }
 
@@ -3066,7 +3061,7 @@ tfile_start (struct trace_file_writer *self, const char *filename)
     = (struct tfile_trace_file_writer *) self;
 
   writer->pathname = tilde_expand (filename);
-  writer->fp = fopen (writer->pathname, "wb");
+  writer->fp = gdb_fopen_cloexec (writer->pathname, "wb");
   if (writer->fp == NULL)
     error (_("Unable to open file '%s' for saving trace data (%s)"),
           filename, safe_strerror (errno));
@@ -3190,7 +3185,7 @@ tfile_write_uploaded_tp (struct trace_file_writer *self,
     = (struct tfile_trace_file_writer *) self;
   int a;
   char *act;
-  gdb_byte buf[MAX_TRACE_UPLOAD];
+  char buf[MAX_TRACE_UPLOAD];
 
   fprintf (writer->fp, "tp T%x:%s:%c:%x:%x",
           utp->number, phex_nz (utp->addr, sizeof (utp->addr)),
@@ -3322,6 +3317,7 @@ trace_save (const char *filename, struct trace_file_writer *writer,
 
   ULONGEST offset = 0;
   gdb_byte buf[MAX_TRACE_UPLOAD];
+#define MAX_TRACE_UPLOAD 2000
   int written;
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
 
@@ -4175,7 +4171,7 @@ tfile_open (char *filename, int from_tty)
   int scratch_chan;
   char header[TRACE_HEADER_SIZE];
   char linebuf[1000]; /* Should be max remote packet size or so.  */
-  char byte;
+  gdb_byte byte;
   int bytes, i;
   struct trace_status *ts;
   struct uploaded_tp *uploaded_tps = NULL;
@@ -4197,7 +4193,7 @@ tfile_open (char *filename, int from_tty)
 
   flags = O_BINARY | O_LARGEFILE;
   flags |= O_RDONLY;
-  scratch_chan = open (filename, flags, 0);
+  scratch_chan = gdb_open_cloexec (filename, flags, 0);
   if (scratch_chan < 0)
     perror_with_name (filename);
 
@@ -4272,10 +4268,6 @@ tfile_open (char *filename, int from_tty)
       throw_exception (ex);
     }
 
-  inferior_appeared (current_inferior (), TFILE_PID);
-  inferior_ptid = pid_to_ptid (TFILE_PID);
-  add_thread_silent (inferior_ptid);
-
   if (ts->traceframe_count <= 0)
     warning (_("No traceframes present in this file."));
 
@@ -4286,8 +4278,6 @@ tfile_open (char *filename, int from_tty)
   merge_uploaded_trace_state_variables (&uploaded_tsvs);
 
   merge_uploaded_tracepoints (&uploaded_tps);
-
-  post_create_inferior (&tfile_ops, from_tty);
 }
 
 /* Interpret the given line from the definitions part of the trace
@@ -4387,7 +4377,7 @@ Status line: '%s'\n"), p, line);
          else if (p2 != p1)
            {
              ts->stop_desc = xmalloc (strlen (line));
-             end = hex2bin (p1, ts->stop_desc, (p2 - p1) / 2);
+             end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
              ts->stop_desc[end] = '\0';
            }
          else
@@ -4407,7 +4397,7 @@ Status line: '%s'\n"), p, line);
          if (p2 != p1)
            {
              ts->stop_desc = xmalloc ((p2 - p1) / 2 + 1);
-             end = hex2bin (p1, ts->stop_desc, (p2 - p1) / 2);
+             end = hex2bin (p1, (gdb_byte *) ts->stop_desc, (p2 - p1) / 2);
              ts->stop_desc[end] = '\0';
            }
          else
@@ -4461,7 +4451,7 @@ Status line: '%s'\n"), p, line);
        {
          ++p1;
          ts->user_name = xmalloc (strlen (p) / 2);
-         end = hex2bin (p1, ts->user_name, (p3 - p1)  / 2);
+         end = hex2bin (p1, (gdb_byte *) ts->user_name, (p3 - p1)  / 2);
          ts->user_name[end] = '\0';
          p = p3;
        }
@@ -4469,7 +4459,7 @@ Status line: '%s'\n"), p, line);
        {
          ++p1;
          ts->notes = xmalloc (strlen (p) / 2);
-         end = hex2bin (p1, ts->notes, (p3 - p1) / 2);
+         end = hex2bin (p1, (gdb_byte *) ts->notes, (p3 - p1) / 2);
          ts->notes[end] = '\0';
          p = p3;
        }
@@ -4660,10 +4650,6 @@ tfile_close (void)
   if (trace_fd < 0)
     return;
 
-  pid = ptid_get_pid (inferior_ptid);
-  inferior_ptid = null_ptid;   /* Avoid confusion from thread stuff.  */
-  exit_inferior_silent (pid);
-
   close (trace_fd);
   trace_fd = -1;
   xfree (trace_filename);
@@ -4865,7 +4851,7 @@ traceframe_walk_blocks (walk_blocks_callback_func callback,
       unsigned short mlen;
       char block_type;
 
-      tfile_read (&block_type, 1);
+      tfile_read ((gdb_byte *) &block_type, 1);
 
       ++pos;
 
@@ -5148,12 +5134,6 @@ tfile_has_registers (struct target_ops *ops)
   return traceframe_number != -1;
 }
 
-static int
-tfile_thread_alive (struct target_ops *ops, ptid_t ptid)
-{
-  return 1;
-}
-
 /* Callback for traceframe_walk_blocks.  Builds a traceframe_info
    object for the tfile target's current traceframe.  */
 
@@ -5234,7 +5214,6 @@ init_tfile_ops (void)
   tfile_ops.to_has_stack = tfile_has_stack;
   tfile_ops.to_has_registers = tfile_has_registers;
   tfile_ops.to_traceframe_info = tfile_traceframe_info;
-  tfile_ops.to_thread_alive = tfile_thread_alive;
   tfile_ops.to_magic = OPS_MAGIC;
 }
 
This page took 0.027327 seconds and 4 git commands to generate.