2010-10-20 Hui Zhu <teawater@gmail.com>
authorHui Zhu <teawater@gmail.com>
Wed, 20 Oct 2010 14:03:17 +0000 (14:03 +0000)
committerHui Zhu <teawater@gmail.com>
Wed, 20 Oct 2010 14:03:17 +0000 (14:03 +0000)
* tracepoint.c (tfile_get_traceframe_address): Call
extract_signed_integer.
(tfile_trace_find): Call extract_signed_integer and
extract_unsigned_integer.  Change data_size to unsigned int.
(tfile_fetch_registers): Call extract_unsigned_integer.
(tfile_xfer_partial): Ditto.
(tfile_get_trace_state_variable_value): Call
extract_signed_integer and extract_unsigned_integer.

gdb/ChangeLog
gdb/tracepoint.c

index 02e42dad44894b20ba0889c6a929dc032564b59d..66cea089dca7ba78444efaade5e3b916860aa380 100644 (file)
@@ -1,3 +1,14 @@
+2010-10-20  Hui Zhu  <teawater@gmail.com>
+
+       * tracepoint.c (tfile_get_traceframe_address): Call
+       extract_signed_integer.
+       (tfile_trace_find): Call extract_signed_integer and
+       extract_unsigned_integer.  Change data_size to unsigned int.
+       (tfile_fetch_registers): Call extract_unsigned_integer.
+       (tfile_xfer_partial): Ditto.
+       (tfile_get_trace_state_variable_value): Call
+       extract_signed_integer and extract_unsigned_integer.
+
 2010-10-20  Vladimir Prus  <vladimir@codesourcery.com>
 
        * remote.c (remote_get_threadlist): If we got empty
index b441bd49ffd4edc29e5a292b3f1e0107e159f1e5..93fb5dbe2c72347bcce078e4576d869ed21586bc 100644 (file)
@@ -3665,6 +3665,9 @@ tfile_get_traceframe_address (off_t tframe_offset)
     perror_with_name (trace_filename);
   else if (gotten < 2)
     error (_("Premature end of file while reading trace file"));
+  tpnum = (short) extract_signed_integer ((gdb_byte *) &tpnum, 2,
+                                         gdbarch_byte_order
+                                             (target_gdbarch));
 
   tp = get_tracepoint_by_number_on_target (tpnum);
   /* FIXME this is a poor heuristic if multiple locations */
@@ -3688,7 +3691,7 @@ tfile_trace_find (enum trace_find_type type, int num,
 {
   short tpnum;
   int tfnum = 0, found = 0, gotten;
-  int data_size;
+  unsigned int data_size;
   struct breakpoint *tp;
   off_t offset, tframe_offset;
   ULONGEST tfaddr;
@@ -3703,6 +3706,9 @@ tfile_trace_find (enum trace_find_type type, int num,
        perror_with_name (trace_filename);
       else if (gotten < 2)
        error (_("Premature end of file while reading trace file"));
+      tpnum = (short) extract_signed_integer ((gdb_byte *) &tpnum, 2,
+                                             gdbarch_byte_order
+                                                 (target_gdbarch));
       offset += 2;
       if (tpnum == 0)
        break;
@@ -3711,6 +3717,9 @@ tfile_trace_find (enum trace_find_type type, int num,
        perror_with_name (trace_filename);
       else if (gotten < 4)
        error (_("Premature end of file while reading trace file"));
+      data_size = (unsigned int) extract_unsigned_integer
+                                     ((gdb_byte *) &data_size, 4,
+                                     gdbarch_byte_order (target_gdbarch));
       offset += 4;
       switch (type)
        {
@@ -3832,6 +3841,10 @@ tfile_fetch_registers (struct target_ops *ops,
            perror_with_name (trace_filename);
          else if (gotten < 2)
            error (_("Premature end of file while reading trace file"));
+          mlen = (unsigned short)
+                extract_unsigned_integer ((gdb_byte *) &mlen, 2,
+                                          gdbarch_byte_order
+                                              (target_gdbarch));
          lseek (trace_fd, mlen, SEEK_CUR);
          pos += (8 + 2 + mlen);
          break;
@@ -3924,12 +3937,18 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
            perror_with_name (trace_filename);
          else if (gotten < 8)
            error (_("Premature end of file while reading trace file"));
-
+          maddr = extract_unsigned_integer ((gdb_byte *) &maddr, 8,
+                                           gdbarch_byte_order
+                                               (target_gdbarch));
          gotten = read (trace_fd, &mlen, 2);
          if (gotten < 0)
            perror_with_name (trace_filename);
          else if (gotten < 2)
            error (_("Premature end of file while reading trace file"));
+          mlen = (unsigned short)
+                extract_unsigned_integer ((gdb_byte *) &mlen, 2,
+                                          gdbarch_byte_order
+                                              (target_gdbarch));
          /* If the block includes the first part of the desired
             range, return as much it has; GDB will re-request the
             remainder, which might be in a different block of this
@@ -4032,6 +4051,10 @@ tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val)
            perror_with_name (trace_filename);
          else if (gotten < 2)
            error (_("Premature end of file while reading trace file"));
+          mlen = (unsigned short)
+                extract_unsigned_integer ((gdb_byte *) &mlen, 2,
+                                          gdbarch_byte_order
+                                              (target_gdbarch));
          lseek (trace_fd, mlen, SEEK_CUR);
          pos += (8 + 2 + mlen);
          break;
@@ -4041,6 +4064,9 @@ tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val)
            perror_with_name (trace_filename);
          else if (gotten < 4)
            error (_("Premature end of file while reading trace file"));
+          vnum = (int) extract_signed_integer ((gdb_byte *) &vnum, 4,
+                                              gdbarch_byte_order
+                                                  (target_gdbarch));
          if (tsvnum == vnum)
            {
              gotten = read (trace_fd, val, 8);
@@ -4048,6 +4074,9 @@ tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val)
                perror_with_name (trace_filename);
              else if (gotten < 8)
                error (_("Premature end of file while reading trace file"));
+              *val = extract_signed_integer ((gdb_byte *)val, 8,
+                                            gdbarch_byte_order
+                                                (target_gdbarch));
              return 1;
            }
          lseek (trace_fd, 8, SEEK_CUR);