mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 09:38:12 +02:00

+ Added callstack object and dialog + Added checks to see if debugger = nil + Added dbgutils git-svn-id: trunk@1654 -
113 lines
2.6 KiB
ObjectPascal
113 lines
2.6 KiB
ObjectPascal
{ $Id$ }
|
|
{ -------------------------------------------
|
|
dbgutils.pp - Debugger utility routines
|
|
-------------------------------------------
|
|
|
|
@created(Sun Apr 28st WET 2002)
|
|
@lastmod($Date$)
|
|
@author(Marc Weustink <marc@@dommelstein.net>)
|
|
|
|
This unit contains a collection of debugger support routines.
|
|
|
|
/***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
***************************************************************************/
|
|
}
|
|
unit DBGUtils;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
function GetLine(var ABuffer: String): String;
|
|
function StripLN(const ALine: String): String;
|
|
function GetPart(const ASkipTo, AnEnd: String; var ASource: String): String;
|
|
|
|
const
|
|
{$IFDEF WIN32}
|
|
LINE_END = #13#10;
|
|
{$ELSE}
|
|
LINE_END = #10;
|
|
{$ENDIF}
|
|
|
|
implementation
|
|
|
|
function GetLine(var ABuffer: String): String;
|
|
var
|
|
idx: Integer;
|
|
begin
|
|
idx := Pos(#10, ABuffer);
|
|
if idx = 0
|
|
then Result := ''
|
|
else begin
|
|
Result := Copy(ABuffer, 1, idx);
|
|
Delete(ABuffer, 1, idx);
|
|
end;
|
|
end;
|
|
|
|
function StripLN(const ALine: String): String;
|
|
var
|
|
idx: Integer;
|
|
begin
|
|
idx := Pos(#10, ALine);
|
|
if idx = 0
|
|
then begin
|
|
idx := Pos(#13, ALine);
|
|
if idx = 0
|
|
then begin
|
|
Result := ALine;
|
|
Exit;
|
|
end;
|
|
end
|
|
else begin
|
|
if (idx > 1)
|
|
and (ALine[idx - 1] = #13)
|
|
then Dec(idx);
|
|
end;
|
|
Result := Copy(ALine, 1, idx - 1);
|
|
end;
|
|
|
|
function GetPart(const ASkipTo, AnEnd: String; var ASource: String): String;
|
|
var
|
|
idx: Integer;
|
|
begin
|
|
if ASkipTo <> ''
|
|
then begin
|
|
idx := Pos(ASkipTo, ASource);
|
|
if idx = 0
|
|
then begin
|
|
Result := '';
|
|
Exit;
|
|
end;
|
|
Delete(ASource, 1, idx + Length(ASkipTo) - 1);
|
|
end;
|
|
if AnEnd = ''
|
|
then idx := 0
|
|
else idx := Pos(AnEnd, ASource);
|
|
if idx = 0
|
|
then begin
|
|
Result := ASource;
|
|
ASource := '';
|
|
end
|
|
else begin
|
|
Result := Copy(ASource, 1, idx - 1);
|
|
Delete(ASource, 1, idx - 1);
|
|
end;
|
|
end;
|
|
|
|
|
|
end.
|
|
{ =============================================================================
|
|
$Log$
|
|
Revision 1.1 2002/04/30 15:57:39 lazarus
|
|
MWE:
|
|
+ Added callstack object and dialog
|
|
+ Added checks to see if debugger = nil
|
|
+ Added dbgutils
|
|
|
|
} |