[RFA] tracepoint.c: tfile_trace_find, make it return -1 when num is -1

Hui Zhu teawater@gmail.com
Thu May 19 14:29:00 GMT 2011


On Thu, May 19, 2011 at 17:45, Pedro Alves <pedro@codesourcery.com> wrote:
> On Thursday 19 May 2011 08:38:36, Hui Zhu wrote:
>> Hi,
>>
>> I found that when GDB parse a tfile, tfile_trace_find will be call
>> with num is -1 when GDB call target_read_live_memory.
>> But it will not find anything.  Because -1 is mean live frame.
>>
>> So I make a patch to make it return -1 when num is -1.
>
> Set *tpp to -1 as well, see the end of the function.  Something like:
>
>  /* No use looking up for frame -1 by number, it won't exist,
>     since -1 means live target/frame.  */
>  if (type == tfind_number)
>    {
>      if (tpp)
>       *tpp = -1;
>      return -1;
>    }
>
> Okay with that change.
>
>>
>> Thanks,
>> Hui
>>
>> 2011-05-19  Hui Zhu  <teawater@gmail.com>
>>
>>       * tracepoint.c (tfile_trace_find): Return directly when num is -1.
>> ---
>>  tracepoint.c |    2 ++
>>  1 file changed, 2 insertions(+)
>>
>> --- a/tracepoint.c
>> +++ b/tracepoint.c
>> @@ -3815,6 +3815,8 @@ tfile_trace_find (enum trace_find_type t
>>       first.  */
>>    if (type != tfind_number)
>>      set_tfile_traceframe ();
>> +  else if (num == -1)
>> +    return -1;
>>
>>    lseek (trace_fd, trace_frames_offset, SEEK_SET);
>>    offset = trace_frames_offset;
>>
>
> --
> Pedro Alves
>

Thanks for your help, Pedro.

Do you think this patch is OK with 7.3?

Thanks,
Hui

Following patch checked in.

===================================================================
RCS file: /cvs/src/src/gdb/tracepoint.c,v
retrieving revision 1.223
retrieving revision 1.224
diff -u -r1.223 -r1.224
--- src/gdb/tracepoint.c	2011/05/12 12:09:16	1.223
+++ src/gdb/tracepoint.c	2011/05/19 14:06:44	1.224
@@ -3815,6 +3815,12 @@
      first.  */
   if (type != tfind_number)
     set_tfile_traceframe ();
+  else if (num == -1)
+    {
+      if (tpp)
+        *tpp = -1;
+      return -1;
+    }

   lseek (trace_fd, trace_frames_offset, SEEK_SET);
   offset = trace_frames_offset;



More information about the Gdb-patches mailing list