From 1c382ef13676cd3b4f47b23a8f294a97d0c53312 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 15 Apr 2013 10:55:41 -0700 Subject: [PATCH] replay: Fix --loop to work when --singlethread is in effect The original implementation of --loop was made only to the code implementing multi-threaded replay, (the RelayRunner class and friends), so that when --singlethread is in effect, the --loop option has no effect. This commit fixes the bug by copying the --loop logic to the single-threaded case as well. Thanks to Peter Lohrmann for reporting the bug. --- retrace/retrace_main.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp index 0c358e1..fd45e78 100644 --- a/retrace/retrace_main.cpp +++ b/retrace/retrace_main.cpp @@ -517,10 +517,42 @@ mainLoop() { if (singleThread) { trace::Call *call; - while ((call = parser.parse_call())) { + + call = parser.parse_call(); + + /* If the user wants to loop we need to get a bookmark target. We + * usually get this after replaying a call that ends a frame, but + * for a trace that has only one frame we need to get it at the + * beginning. */ + if (loopOnFinish) { + parser.getBookmark(lastFrameStart); + } + + do { + bool callEndsFrame = false; + static trace::ParseBookmark frameStart; + + if (loopOnFinish && call->flags & trace::CALL_FLAG_END_FRAME) { + callEndsFrame = true; + parser.getBookmark(frameStart); + } + retraceCall(call); delete call; - }; + call = parser.parse_call(); + + /* Restart last frame if looping is requested. */ + if (loopOnFinish) { + if (!call) { + parser.setBookmark(lastFrameStart); + call = parser.parse_call(); + } else if (callEndsFrame) { + lastFrameStart = frameStart; + } + } + + } while (call); + flushRendering(); } else { RelayRace race; -- 2.43.0