From 9bd07601d619fcf4957d3489ece6d8ba2737ae1e Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Thu, 26 Jun 2008 00:23:57 +0000 Subject: 2008-06-25 Michael Snyder * gdbfreeplay-back.c (frame_find_request): Rewrite loop to avoid fencepost error on last frame. --- gdb/gdbserver/gdbfreeplay-back.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gdb/gdbserver/gdbfreeplay-back.c') diff --git a/gdb/gdbserver/gdbfreeplay-back.c b/gdb/gdbserver/gdbfreeplay-back.c index bcfe49bfc17..7d7cf415beb 100644 --- a/gdb/gdbserver/gdbfreeplay-back.c +++ b/gdb/gdbserver/gdbfreeplay-back.c @@ -326,11 +326,12 @@ frame_find_request (FILE *logfile, char *request) curpos = stopframe[cur_frame].eventpos; fseek (logfile, curpos, SEEK_SET); /* Now search for a matching request. */ - while (curpos < stopframe[cur_frame + 1].eventpos) + while ((line = fgets (inbuf, sizeof (inbuf), logfile)) != NULL) { - line = fgets (inbuf, sizeof (inbuf), logfile); - /* End of input? */ - if (line == NULL) + /* End of current frame? + If we're the last frame, just read till the end of file. */ + if (cur_frame < last_cached_frame && + curpos >= stopframe[cur_frame + 1].eventpos) break; curpos = ftell (logfile); if (strstr (line, request) != NULL) -- cgit v1.2.1