Browse Source

+ Correct indent/deindent of method enter/exit

git-svn-id: trunk@1331 -
michael 20 years ago
parent
commit
66bb1e0a95
2 changed files with 13 additions and 10 deletions
  1. 10 10
      fcl/inc/dbugintf.pp
  2. 3 0
      fcl/tests/debugtest.pp

+ 10 - 10
fcl/inc/dbugintf.pp

@@ -28,7 +28,6 @@ procedure SendInteger(const Identifier: string; const Value: Integer; HexNotatio
 procedure SendPointer(const Identifier: string; const Value: Pointer);
 procedure SendDebugEx(const Msg: string; MType: TDebugLevel);
 procedure SendDebug(const Msg: string);
-procedure SendInteger(const Identifier: string; const Value: Integer);
 procedure SendMethodEnter(const MethodName: string);
 procedure SendMethodExit(const MethodName: string);
 procedure SendSeparator;
@@ -60,12 +59,13 @@ Const
   DmtError       = lctError;
   ErrorLevel     : Array[TDebugLevel] of integer
                  = (dmtInformation,dmtWarning,dmtError);
-
+  IndentChars    = 2;
+  
 var
   DebugClient : TSimpleIPCClient = nil;
   MsgBuffer : TMemoryStream = Nil;
   ServerID : Integer;
-
+  Indent : Integer = 0;
   
 Procedure WriteMessage(Const Msg : TDebugMessage);
 
@@ -76,12 +76,14 @@ begin
 end;
 
 
-procedure SendDebugMessage(Const Msg : TDebugMessage);
+procedure SendDebugMessage(Var Msg : TDebugMessage);
 
 begin
   try
     If (DebugClient=Nil) then
       InitDebugClient;
+    if (Indent>0) then
+      Msg.Msg:=StringOfChar(' ',Indent)+Msg.Msg;
     WriteMessage(Msg);
   except
     On E : Exception do
@@ -142,21 +144,19 @@ begin
   SendDebugMessage(Mesg);
 end;
 
-procedure SendInteger(const Identifier: string; const Value: Integer);
-
-begin
-  SendDebugFmt('%s = %d',[identifier,Value]);
-end;
-
 procedure SendMethodEnter(const MethodName: string);
 
 begin
   SendDebug(SEntering+MethodName);
+  inc(Indent,IndentChars);
 end;
 
 procedure SendMethodExit(const MethodName: string);
 
 begin
+  Dec(Indent,IndentChars);
+  If (Indent<0) then
+    Indent:=0;
   SendDebug(SExiting+MethodName);
 end;
 

+ 3 - 0
fcl/tests/debugtest.pp

@@ -20,6 +20,7 @@ Var
  S : String;
 
 begin
+  SendMethodEnter('Program');
   Repeat
     Writeln('Enter message to send to debug server (STOP exits): ');
     Write('> ');
@@ -28,4 +29,6 @@ begin
     If (SendError<>'') then
       Writeln('Error : ',SendError);
   Until (S='STOP');
+  SendMethodExit('Program');
+  SendDebug('Ending');
 end.