Add client_state struct.
[deliverable/binutils-gdb.git] / gdb / gdbserver / tracepoint.c
index 41727561925f62168fa8f2b84bac19b5fd1e6fcc..c203080dff078d5c0e1107f6ae1b9e9acc6a58f6 100644 (file)
@@ -973,11 +973,6 @@ struct traceframe
    fields (and no data) marks the end of trace data.  */
 #define TRACEFRAME_EOB_MARKER_SIZE offsetof (struct traceframe, data)
 
-/* The traceframe to be used as the source of data to send back to
-   GDB.  A value of -1 means to get data from the live program.  */
-
-int current_traceframe = -1;
-
 /* This flag is true if the trace buffer is circular, meaning that
    when it fills, the oldest trace frames are discarded in order to
    make room.  */
@@ -2279,10 +2274,11 @@ static struct traceframe *
 find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
                               int *tfnump)
 {
+  client_state &cs = get_client_state ();
   struct traceframe *tframe;
   CORE_ADDR tfaddr;
 
-  *tfnump = current_traceframe + 1;
+  *tfnump = cs.current_traceframe + 1;
   tframe = find_traceframe (*tfnump);
   /* The search is not supposed to wrap around.  */
   if (!tframe)
@@ -2312,9 +2308,10 @@ find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
 static struct traceframe *
 find_next_traceframe_by_tracepoint (int num, int *tfnump)
 {
+  client_state &cs = get_client_state ();
   struct traceframe *tframe;
 
-  *tfnump = current_traceframe + 1;
+  *tfnump = cs.current_traceframe + 1;
   tframe = find_traceframe (*tfnump);
   /* The search is not supposed to wrap around.  */
   if (!tframe)
@@ -2343,6 +2340,7 @@ find_next_traceframe_by_tracepoint (int num, int *tfnump)
 static void
 cmd_qtinit (char *packet)
 {
+  client_state &cs = get_client_state ();
   struct trace_state_variable *tsv, *prev, *next;
 
   /* Can't do this command without a pid attached.  */
@@ -2353,7 +2351,7 @@ cmd_qtinit (char *packet)
     }
 
   /* Make sure we don't try to read from a trace frame.  */
-  current_traceframe = -1;
+  cs.current_traceframe = -1;
 
   stop_tracing ();
 
@@ -2813,6 +2811,7 @@ cmd_qtenable_disable (char *own_buf, int enable)
 static void
 cmd_qtv (char *own_buf)
 {
+  client_state &cs = get_client_state ();
   ULONGEST num;
   LONGEST val = 0;
   int err;
@@ -2821,7 +2820,7 @@ cmd_qtv (char *own_buf)
   packet += strlen ("qTV:");
   unpack_varlen_hex (packet, &num);
 
-  if (current_traceframe >= 0)
+  if (cs.current_traceframe >= 0)
     {
       err = traceframe_read_tsv ((int) num, &val);
       if (err)
@@ -3552,6 +3551,7 @@ cmd_qtdisconnected (char *own_buf)
 static void
 cmd_qtframe (char *own_buf)
 {
+  client_state &cs = get_client_state ();
   ULONGEST frame, pc, lo, hi, num;
   int tfnum, tpnum;
   struct traceframe *tframe;
@@ -3602,7 +3602,7 @@ cmd_qtframe (char *own_buf)
       if (tfnum == -1)
        {
          trace_debug ("Want to stop looking at traceframes");
-         current_traceframe = -1;
+         cs.current_traceframe = -1;
          write_ok (own_buf);
          return;
        }
@@ -3612,7 +3612,7 @@ cmd_qtframe (char *own_buf)
 
   if (tframe)
     {
-      current_traceframe = tfnum;
+      cs.current_traceframe = tfnum;
       sprintf (own_buf, "F%xT%x", tfnum, tframe->tpnum);
     }
   else
@@ -5297,6 +5297,7 @@ traceframe_read_mem (int tfnum, CORE_ADDR addr,
 static int
 traceframe_read_tsv (int tsvnum, LONGEST *val)
 {
+  client_state &cs = get_client_state ();
   int tfnum;
   struct traceframe *tframe;
   unsigned char *database, *dataptr;
@@ -5306,7 +5307,7 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
 
   trace_debug ("traceframe_read_tsv");
 
-  tfnum = current_traceframe;
+  tfnum = cs.current_traceframe;
 
   if (tfnum < 0)
     {
This page took 0.02458 seconds and 4 git commands to generate.