mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:59:10 +02:00
codetools: dbgs(array of const)
git-svn-id: trunk@32186 -
This commit is contained in:
parent
2451ea26ea
commit
3123ce42c2
@ -753,17 +753,21 @@ var
|
|||||||
Node: TAVLTreeNode;
|
Node: TAVLTreeNode;
|
||||||
h: String;
|
h: String;
|
||||||
begin
|
begin
|
||||||
|
if GetStringRefCount(s)<=0 then exit;
|
||||||
Node:=FindNode(s);
|
Node:=FindNode(s);
|
||||||
if Node=nil then begin
|
if Node=nil then begin
|
||||||
// increase refcount
|
// increase refcount
|
||||||
h:=s;
|
h:=s;
|
||||||
Tree.Add(Pointer(h));
|
Tree.Add(Pointer(h));
|
||||||
Pointer(h):=nil; // keep refcount
|
Pointer(h):=nil; // keep refcount
|
||||||
|
//debugln(['TStringTree.ReplaceString new string: refcount=',GetStringRefCount(s)]);
|
||||||
//debugln(['TStringTree.ReplaceString NewString="',dbgstr(s),'"']);
|
//debugln(['TStringTree.ReplaceString NewString="',dbgstr(s),'"']);
|
||||||
end else begin
|
end else begin
|
||||||
s:=AnsiString(Node.Data);
|
s:=AnsiString(Node.Data);
|
||||||
|
//debugln(['TStringTree.ReplaceString old string: refcount=',GetStringRefCount(s)]);
|
||||||
//debugln(['TStringTree.ReplaceString OldString="',dbgstr(s),'"']);
|
//debugln(['TStringTree.ReplaceString OldString="',dbgstr(s),'"']);
|
||||||
end;
|
end;
|
||||||
|
//debugln(['TStringTree.ReplaceString ',GetStringRefCount(s),' ',Node<>nil]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TStringTree.CalcMemSize: PtrUInt;
|
function TStringTree.CalcMemSize: PtrUInt;
|
||||||
|
@ -365,6 +365,7 @@ procedure DbgOut(const s1,s2,s3,s4: string);
|
|||||||
procedure DbgOut(const s1,s2,s3,s4,s5: string);
|
procedure DbgOut(const s1,s2,s3,s4,s5: string);
|
||||||
procedure DbgOut(const s1,s2,s3,s4,s5,s6: string);
|
procedure DbgOut(const s1,s2,s3,s4,s5,s6: string);
|
||||||
|
|
||||||
|
function DbgS(Args: array of const): string; overload;
|
||||||
function DbgS(const c: char): string; overload;
|
function DbgS(const c: char): string; overload;
|
||||||
function DbgS(const c: cardinal): string; overload;
|
function DbgS(const c: cardinal): string; overload;
|
||||||
function DbgS(const i: integer): string; overload;
|
function DbgS(const i: integer): string; overload;
|
||||||
@ -410,6 +411,7 @@ function CompareCTMemStat(Stat1, Stat2: TCTMemStat): integer;
|
|||||||
function CompareNameWithCTMemStat(KeyAnsiString: Pointer; Stat: TCTMemStat): integer;
|
function CompareNameWithCTMemStat(KeyAnsiString: Pointer; Stat: TCTMemStat): integer;
|
||||||
function MemSizeString(const s: string): PtrUInt;
|
function MemSizeString(const s: string): PtrUInt;
|
||||||
function MemSizeFPList(const List: TFPList): PtrUInt;
|
function MemSizeFPList(const List: TFPList): PtrUInt;
|
||||||
|
function GetStringRefCount(const s: string): PtrInt;
|
||||||
|
|
||||||
function GetTicks: int64;
|
function GetTicks: int64;
|
||||||
|
|
||||||
@ -2751,41 +2753,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DbgOut(Args: array of const);
|
procedure DbgOut(Args: array of const);
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
for i:=Low(Args) to High(Args) do begin
|
dbgout(dbgs(Args));
|
||||||
case Args[i].VType of
|
|
||||||
vtInteger: DbgOut(dbgs(Args[i].vinteger));
|
|
||||||
vtInt64: DbgOut(dbgs(Args[i].VInt64^));
|
|
||||||
vtQWord: DbgOut(dbgs(Args[i].VQWord^));
|
|
||||||
vtBoolean: DbgOut(dbgs(Args[i].vboolean));
|
|
||||||
vtExtended: DbgOut(dbgs(Args[i].VExtended^));
|
|
||||||
{$ifdef FPC_CURRENCY_IS_INT64}
|
|
||||||
// MWE:
|
|
||||||
// fpc 2.x has troubles in choosing the right dbgs()
|
|
||||||
// so we convert here
|
|
||||||
vtCurrency: DbgOut(dbgs(int64(Args[i].vCurrency^)/10000 , 4));
|
|
||||||
{$else}
|
|
||||||
vtCurrency: DbgOut(dbgs(Args[i].vCurrency^));
|
|
||||||
{$endif}
|
|
||||||
vtString: DbgOut(Args[i].VString^);
|
|
||||||
vtAnsiString: DbgOut(AnsiString(Args[i].VAnsiString));
|
|
||||||
vtChar: DbgOut(Args[i].VChar);
|
|
||||||
vtPChar: DbgOut(Args[i].VPChar);
|
|
||||||
vtPWideChar: DbgOut(Args[i].VPWideChar);
|
|
||||||
vtWideChar: DbgOut(Args[i].VWideChar);
|
|
||||||
vtWidestring: DbgOut(WideString(Args[i].VWideString));
|
|
||||||
vtObject: DbgOut(DbgSName(Args[i].VObject));
|
|
||||||
vtClass: DbgOut(DbgSName(Args[i].VClass));
|
|
||||||
vtPointer: DbgOut(Dbgs(Args[i].VPointer));
|
|
||||||
else
|
|
||||||
DbgOut('?unknown variant?');
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DBGOut(const s: string);
|
procedure DbgOut(const s: string);
|
||||||
begin
|
begin
|
||||||
if Assigned(CTDbgOutEvent) then
|
if Assigned(CTDbgOutEvent) then
|
||||||
CTDbgOutEvent(s)
|
CTDbgOutEvent(s)
|
||||||
@ -2793,7 +2765,7 @@ begin
|
|||||||
write(s);
|
write(s);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure DBGOut(const s1, s2: string);
|
procedure DbgOut(const s1, s2: string);
|
||||||
begin
|
begin
|
||||||
DbgOut(s1+s2);
|
DbgOut(s1+s2);
|
||||||
end;
|
end;
|
||||||
@ -2818,6 +2790,42 @@ begin
|
|||||||
DbgOut(s1+s2+s3+s4+s5+s6);
|
DbgOut(s1+s2+s3+s4+s5+s6);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function DbgS(Args: array of const): string;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result:='';
|
||||||
|
for i:=Low(Args) to High(Args) do begin
|
||||||
|
case Args[i].VType of
|
||||||
|
vtInteger: Result:=Result+dbgs(Args[i].vinteger);
|
||||||
|
vtInt64: Result:=Result+dbgs(Args[i].VInt64^);
|
||||||
|
vtQWord: Result:=Result+dbgs(Args[i].VQWord^);
|
||||||
|
vtBoolean: Result:=Result+dbgs(Args[i].vboolean);
|
||||||
|
vtExtended: Result:=Result+dbgs(Args[i].VExtended^);
|
||||||
|
{$ifdef FPC_CURRENCY_IS_INT64}
|
||||||
|
// MWE:
|
||||||
|
// fpc 2.x has troubles in choosing the right dbgs()
|
||||||
|
// so we convert here
|
||||||
|
vtCurrency: Result:=Result+dbgs(int64(Args[i].vCurrency^)/10000 , 4));
|
||||||
|
{$else}
|
||||||
|
vtCurrency: Result:=Result+dbgs(Args[i].vCurrency^);
|
||||||
|
{$endif}
|
||||||
|
vtString: Result:=Result+Args[i].VString^;
|
||||||
|
vtAnsiString: Result:=Result+AnsiString(Args[i].VAnsiString);
|
||||||
|
vtChar: Result:=Result+Args[i].VChar;
|
||||||
|
vtPChar: Result:=Result+Args[i].VPChar;
|
||||||
|
vtPWideChar: Result:=Result+Args[i].VPWideChar;
|
||||||
|
vtWideChar: Result:=Result+Args[i].VWideChar;
|
||||||
|
vtWidestring: Result:=Result+WideString(Args[i].VWideString);
|
||||||
|
vtObject: Result:=Result+DbgSName(Args[i].VObject);
|
||||||
|
vtClass: Result:=Result+DbgSName(Args[i].VClass);
|
||||||
|
vtPointer: Result:=Result+Dbgs(Args[i].VPointer);
|
||||||
|
else
|
||||||
|
Result:=Result+'?unknown variant?';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function DbgS(const c: char): string;
|
function DbgS(const c: char): string;
|
||||||
begin
|
begin
|
||||||
case c of
|
case c of
|
||||||
@ -2981,6 +2989,14 @@ begin
|
|||||||
+PtrUInt(List.Capacity)*SizeOf(Pointer);
|
+PtrUInt(List.Capacity)*SizeOf(Pointer);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetStringRefCount(const s: string): PtrInt;
|
||||||
|
begin
|
||||||
|
if s='' then
|
||||||
|
Result:=-1
|
||||||
|
else
|
||||||
|
Result:=PPtrInt(s)[-2];
|
||||||
|
end;
|
||||||
|
|
||||||
function GetTicks: int64;
|
function GetTicks: int64;
|
||||||
var
|
var
|
||||||
CurTick: Int64;
|
CurTick: Int64;
|
||||||
|
Loading…
Reference in New Issue
Block a user