This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/5] Look for the last matched 'V' block in trace frame


On 03/13/2013 01:48 AM, Tom Tromey wrote:
> Yao> -  return 1;
> Yao> +  return !found;
> 
> I think the logic change here is fine, but it invalidates the
> trace_debug just before the return.
> 
> I think this needs to be:
> 
> if (!found)
>    trace_debug (...);
> 

Oh, you are right.

> 
> The patch is ok with that fix.

Patch below is what I committed.

-- 
Yao (éå)

gdb/gdbserver:

2013-03-13  Yao Qi  <yao@codesourcery.com>

	* tracepoint.c (traceframe_read_tsv): Look for the last matched
	'V' block in trace frame.

gdb:

2013-03-13  Yao Qi  <yao@codesourcery.com>

	* tracepoint.c (tfile_get_trace_state_variable_value): Look for
	the last matched 'V' blcok in trace frame.
---
 gdb/gdbserver/tracepoint.c |   13 ++++++++-----
 gdb/tracepoint.c           |   10 +++++++---
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index dcc2e78..bea6202 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -5257,6 +5257,7 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
   unsigned char *database, *dataptr;
   unsigned int datasize;
   int vnum;
+  int found = 0;
 
   trace_debug ("traceframe_read_tsv");
 
@@ -5279,7 +5280,8 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
   datasize = tframe->data_size;
   database = dataptr = &tframe->data[0];
 
-  /* Iterate through a traceframe's blocks, looking for the tsv.  */
+  /* Iterate through a traceframe's blocks, looking for the last
+     matched tsv.  */
   while ((dataptr = traceframe_find_block_type (dataptr,
 						datasize
 						- (dataptr - database),
@@ -5294,16 +5296,17 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
       if (tsvnum == vnum)
 	{
 	  memcpy (val, dataptr, sizeof (*val));
-	  return 0;
+	  found = 1;
 	}
 
       /* Skip over this block.  */
       dataptr += sizeof (LONGEST);
     }
 
-  trace_debug ("traceframe %d has no data for variable %d",
-	       tfnum, tsvnum);
-  return 1;
+  if (!found)
+    trace_debug ("traceframe %d has no data for variable %d",
+		 tfnum, tsvnum);
+  return !found;
 }
 
 /* Read a requested block of static tracepoint data from a trace
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 32b29f2..e7dde74 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -5040,7 +5040,12 @@ static int
 tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val)
 {
   int pos;
+  int found = 0;
 
+  /* Iterate over blocks in current frame and find the last 'V'
+     block in which tsv number is TSVNUM.  In one trace frame, there
+     may be multiple 'V' blocks created for a given trace variable,
+     and the last matched 'V' block contains the updated value.  */
   pos = 0;
   while ((pos = traceframe_find_block_type ('V', pos)) >= 0)
     {
@@ -5056,13 +5061,12 @@ tfile_get_trace_state_variable_value (int tsvnum, LONGEST *val)
 	  *val = extract_signed_integer ((gdb_byte *) val, 8,
 					 gdbarch_byte_order
 					 (target_gdbarch ()));
-	  return 1;
+	  found = 1;
 	}
       pos += (4 + 8);
     }
 
-  /* Didn't find anything.  */
-  return 0;
+  return found;
 }
 
 static int
-- 
1.7.7.6



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]