View Issue Details

IDProjectCategoryView StatusLast Update
0016155LazarusDebuggerpublic2010-04-07 07:33
ReporterFlávio Etrusco Assigned ToMarc Weustink  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.29 (SVN) 
Fixed in Version0.9.29 (SVN) 
Summary0016155: [Patch] Error in TCmdLineDebugger.ReadLine trimming of LineBreaks
DescriptionThe detection of LineEnd type/length is bogus (but wasn't causing problems in Linux, because there's only one LineEnd registered).
Also, changes the function to strip the LineEnd chars.
TagsNo tags attached.
Fixed in Revision24479 24481
LazTarget-
Widgetset
Attached Files

Activities

2010-03-30 18:38

 

dbg_output_trim_lf (1,187 bytes)   
# HG changeset patch
# Parent 202159f34df1415985f8b946a71787f93f2c0428
# User etrusco <flavio.etrusco@gmail.com>
[mq]: package_case_fix

diff --git a/debugger/cmdlinedebugger.pp b/debugger/cmdlinedebugger.pp
--- a/debugger/cmdlinedebugger.pp
+++ b/debugger/cmdlinedebugger.pp
@@ -335,15 +335,17 @@ begin
       MinIdx := MaxInt;
       for n := 0 to FLineEnds.Count - 1 do
       begin
-        LineEndMatch := FLineEnds[n];
-        Idx := Pos(LineEndMatch, FOutputBuf);
-        if (idx > 0) and (idx < MinIdx) 
-        then MinIdx := idx;
+        Idx := Pos(FLineEnds[n], FOutputBuf);
+        if (idx > 0) and (idx < MinIdx) then
+        begin
+          MinIdx := idx;
+          LineEndMatch := FLineEnds[n];
+        end;
       end;
     
       if MinIdx < MaxInt 
       then begin
-        n := MinIdx + Length(LineEndMatch) - 1;
+        n := MinIdx - 1;
         Result := Copy(FOutputBuf, 1, n);
         if APeek 
         then begin
@@ -354,7 +356,7 @@ begin
             Continue;
           end;
         end
-        else Delete(FOutputBuf, 1, n);
+        else Delete(FOutputBuf, 1, n + Length(LineEndMatch));
       
         DoDbgOutput(Result);
         Break;
dbg_output_trim_lf (1,187 bytes)   

Marc Weustink

2010-04-03 17:57

administrator   ~0036422

I reread/debugged my implementation and I fail to see where it should go wrong.
You have the original implementation somewhat rewritten, but it essentially does the same. ReadLine is supposed to return the full line (so including line end). To strip the lineend, use the StripLN utility function.

Flávio Etrusco

2010-04-05 04:44

developer   ~0036446

Last edited: 2010-04-05 05:31

LineEndMatch is always assigned, not only when pos is smaller then MinIdx, so it can/will use wrong FLineEnds[i].
I know about StripLN and I see it everywhere in the debugger code. I just don't see the reason to return the LineEnd char in the string, and force a new copy of the string just to strip it...
I realize one might want to keep the original LineEnds for more faithful/reliable of transcription of gdb output. But may I suggest then that a parameter be added, and LineEnd be trimmed by default? All calls for it in GDBMIDebugger wrap it in a call to StripLN...

Marc Weustink

2010-04-06 23:49

administrator   ~0036504

I now see the problem. It is not a matter of linux, on windows this works too. It only fails if more than one lineend is defined, which isn't the case.
Cmdlinedebuger is meant as generic class, so no I won't strip crlf.

Flávio Etrusco

2010-04-07 00:09

developer   ~0036505

Marc, please, what's good about keeping the crlf?

Issue History

Date Modified Username Field Change
2010-03-30 18:38 Flávio Etrusco New Issue
2010-03-30 18:38 Flávio Etrusco Status new => assigned
2010-03-30 18:38 Flávio Etrusco Assigned To => Marc Weustink
2010-03-30 18:38 Flávio Etrusco File Added: dbg_output_trim_lf
2010-03-30 18:38 Flávio Etrusco LazTarget => -
2010-03-30 18:38 Flávio Etrusco Widgetset => GTK, GTK 2, Win32/Win64, WinCE, Carbon, QT, fpGUI
2010-04-03 17:57 Marc Weustink Note Added: 0036422
2010-04-03 17:57 Marc Weustink Status assigned => feedback
2010-04-05 04:44 Flávio Etrusco Note Added: 0036446
2010-04-05 05:31 Flávio Etrusco Note Edited: 0036446
2010-04-06 09:17 Flávio Etrusco Status feedback => assigned
2010-04-06 23:49 Marc Weustink Note Added: 0036504
2010-04-07 00:09 Flávio Etrusco Note Added: 0036505
2010-04-07 01:27 Marc Weustink Fixed in Revision => 24479 24481
2010-04-07 01:27 Marc Weustink Widgetset GTK, GTK 2, Win32/Win64, WinCE, Carbon, QT, fpGUI =>
2010-04-07 01:27 Marc Weustink Status assigned => resolved
2010-04-07 01:27 Marc Weustink Fixed in Version => 0.9.29 (SVN)
2010-04-07 01:27 Marc Weustink Resolution open => fixed
2010-04-07 07:33 Flávio Etrusco Status resolved => closed