* memdebug enhancements

This commit is contained in:
peter 2002-09-05 19:29:42 +00:00
parent 8b5e92cb3c
commit 20af604613
10 changed files with 188 additions and 38 deletions

View File

@ -602,13 +602,13 @@ Implementation
{$endif} {$endif}
begin begin
{$ifdef MEMDEBUG} {$ifdef MEMDEBUG}
d := tmemdebug.create('agbin'); d := tmemdebug.create(name+' - agbin');
{$endif} {$endif}
objectdata.free; objectdata.free;
objectoutput.free; objectoutput.free;
objectalloc.free; objectalloc.free;
{$ifdef MEMDEBUG} {$ifdef MEMDEBUG}
d.free; d.free;
{$endif} {$endif}
end; end;
@ -1608,7 +1608,10 @@ Implementation
end. end.
{ {
$Log$ $Log$
Revision 1.43 2002-08-20 16:55:38 peter Revision 1.44 2002-09-05 19:29:42 peter
* memdebug enhancements
Revision 1.43 2002/08/20 16:55:38 peter
* don't write (stabs)line info when inlining a procedure * don't write (stabs)line info when inlining a procedure
Revision 1.42 2002/08/12 15:08:39 carl Revision 1.42 2002/08/12 15:08:39 carl

View File

@ -36,12 +36,15 @@ interface
type type
tmemdebug = class tmemdebug = class
private private
totalmem,
startmem : integer; startmem : integer;
infostr : string[40]; infostr : string[40];
public public
constructor Create(const s:string); constructor Create(const s:string);
destructor Destroy;override; destructor Destroy;override;
procedure show; procedure show;
procedure start;
procedure stop;
end; end;
{******************************************** {********************************************
@ -293,6 +296,13 @@ implementation
constructor tmemdebug.create(const s:string); constructor tmemdebug.create(const s:string);
begin begin
infostr:=s; infostr:=s;
totalmem:=0;
Start;
end;
procedure tmemdebug.start;
begin
{$ifdef Delphi} {$ifdef Delphi}
startmem:=0; startmem:=0;
{$else} {$else}
@ -301,25 +311,31 @@ implementation
end; end;
procedure tmemdebug.stop;
begin
if startmem<>0 then
begin
inc(TotalMem,memavail-startmem);
startmem:=0;
end;
end;
destructor tmemdebug.destroy; destructor tmemdebug.destroy;
begin begin
Stop;
show; show;
end; end;
procedure tmemdebug.show; procedure tmemdebug.show;
{$ifndef Delphi}
var
l : integer;
{$endif}
begin begin
{$ifndef Delphi} {$ifndef Delphi}
write('memory [',infostr,'] '); write('memory [',infostr,'] ');
l:=memavail; if TotalMem>0 then
if l>startmem then writeln(DStr(TotalMem shr 10),' Kb released')
writeln(l-startmem,' released')
else else
writeln(startmem-l,' allocated'); writeln(DStr((-TotalMem) shr 10),' Kb allocated');
{$endif Delphi} {$endif Delphi}
end; end;
@ -1735,7 +1751,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.17 2002-08-11 13:24:11 peter Revision 1.18 2002-09-05 19:29:42 peter
* memdebug enhancements
Revision 1.17 2002/08/11 13:24:11 peter
* saving of asmsymbols in ppu supported * saving of asmsymbols in ppu supported
* asmsymbollist global is removed and moved into a new class * asmsymbollist global is removed and moved into a new class
tasmlibrarydata that will hold the info of a .a file which tasmlibrarydata that will hold the info of a .a file which

View File

@ -520,7 +520,7 @@ implementation
{$endif} {$endif}
begin begin
{$ifdef MEMDEBUG} {$ifdef MEMDEBUG}
d:=tmemdebug.create('asmlist'); d:=tmemdebug.create(current_module.modulename^+' - asmlists');
{$endif} {$endif}
exprasmlist.free; exprasmlist.free;
codesegment.free; codesegment.free;
@ -655,7 +655,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.26 2002-08-18 20:06:23 peter Revision 1.27 2002-09-05 19:29:42 peter
* memdebug enhancements
Revision 1.26 2002/08/18 20:06:23 peter
* inlining is now also allowed in interface * inlining is now also allowed in interface
* renamed write/load to ppuwrite/ppuload * renamed write/load to ppuwrite/ppuload
* tnode storing in ppu * tnode storing in ppu

View File

@ -143,10 +143,11 @@ implementation
uses uses
{$ifdef delphi} {$ifdef delphi}
dmisc dmisc,
{$else} {$else}
dos dos,
{$endif} {$endif}
cutils
; ;
{**************************************************************************** {****************************************************************************
@ -217,10 +218,10 @@ begin
{$endif Delphi} {$endif Delphi}
if (status.currentline>0) and (status.currentline mod 100=0) then if (status.currentline>0) and (status.currentline mod 100=0) then
{$ifdef FPC} {$ifdef FPC}
WriteLn(status.currentline,' ',memavail shr 10,'/',system.heapsize shr 10,' Kb Free'); WriteLn(status.currentline,' ',DStr(memavail shr 10),'/',DStr(system.heapsize shr 10),' Kb Free');
{$else} {$else}
{$ifndef Delphi} {$ifndef Delphi}
WriteLn(status.currentline,' ',memavail shr 10,' Kb Free'); WriteLn(status.currentline,' ',DStr(memavail shr 10),' Kb Free');
{$endif Delphi} {$endif Delphi}
{$endif} {$endif}
end end
@ -355,7 +356,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.19 2002-05-18 13:34:06 peter Revision 1.20 2002-09-05 19:29:42 peter
* memdebug enhancements
Revision 1.19 2002/05/18 13:34:06 peter
* readded missing revisions * readded missing revisions
Revision 1.18 2002/05/16 19:46:35 carl Revision 1.18 2002/05/16 19:46:35 carl

View File

@ -67,6 +67,7 @@ interface
function tostr(i : longint) : string; function tostr(i : longint) : string;
function int64tostr(i : int64) : string; function int64tostr(i : int64) : string;
function tostr_with_plus(i : longint) : string; function tostr_with_plus(i : longint) : string;
function DStr(l:longint):string;
procedure valint(S : string;var V : longint;var code : integer); procedure valint(S : string;var V : longint;var code : integer);
{# Returns true if the string s is a number } {# Returns true if the string s is a number }
function is_number(const s : string) : boolean; function is_number(const s : string) : boolean;
@ -374,6 +375,23 @@ uses
end; end;
function DStr(l:longint):string;
var
TmpStr : string[32];
i : longint;
begin
Str(l,TmpStr);
i:=Length(TmpStr);
while (i>3) do
begin
dec(i,3);
if TmpStr[i]<>'-' then
insert('.',TmpStr,i+1);
end;
DStr:=TmpStr;
end;
function trimbspace(const s:string):string; function trimbspace(const s:string):string;
{ {
return s with all leading spaces and tabs removed return s with all leading spaces and tabs removed
@ -803,7 +821,10 @@ initialization
end. end.
{ {
$Log$ $Log$
Revision 1.21 2002-07-26 11:16:35 jonas Revision 1.22 2002-09-05 19:29:42 peter
* memdebug enhancements
Revision 1.21 2002/07/26 11:16:35 jonas
* fixed (actual and potential) range errors * fixed (actual and potential) range errors
Revision 1.20 2002/07/07 11:13:34 carl Revision 1.20 2002/07/07 11:13:34 carl

View File

@ -455,7 +455,6 @@ uses
stringdispose(exefilename); stringdispose(exefilename);
stringdispose(outputpath); stringdispose(outputpath);
stringdispose(path); stringdispose(path);
stringdispose(modulename);
stringdispose(realmodulename); stringdispose(realmodulename);
stringdispose(mainsource); stringdispose(mainsource);
stringdispose(asmprefix); stringdispose(asmprefix);
@ -464,7 +463,7 @@ uses
localincludesearchpath.free; localincludesearchpath.free;
locallibrarysearchpath.free; locallibrarysearchpath.free;
{$ifdef MEMDEBUG} {$ifdef MEMDEBUG}
d:=tmemdebug.create('symtable'); d:=tmemdebug.create(modulename^+' - symtable');
{$endif} {$endif}
if assigned(globalsymtable) then if assigned(globalsymtable) then
globalsymtable.free; globalsymtable.free;
@ -474,12 +473,13 @@ uses
d.free; d.free;
{$endif} {$endif}
{$ifdef MEMDEBUG} {$ifdef MEMDEBUG}
d:=tmemdebug.create('librarydata'); d:=tmemdebug.create(modulename^+' - librarydata');
{$endif} {$endif}
librarydata.free; librarydata.free;
{$ifdef MEMDEBUG} {$ifdef MEMDEBUG}
d.free; d.free;
{$endif} {$endif}
stringdispose(modulename);
inherited Destroy; inherited Destroy;
end; end;
@ -603,7 +603,10 @@ uses
end. end.
{ {
$Log$ $Log$
Revision 1.27 2002-08-16 15:31:08 peter Revision 1.28 2002-09-05 19:29:42 peter
* memdebug enhancements
Revision 1.27 2002/08/16 15:31:08 peter
* fixed possible crashes with current_scanner * fixed possible crashes with current_scanner
Revision 1.26 2002/08/12 16:46:04 peter Revision 1.26 2002/08/12 16:46:04 peter

View File

@ -821,10 +821,6 @@ implementation
fillchar(localrttilab,sizeof(localrttilab),0); fillchar(localrttilab,sizeof(localrttilab),0);
end; end;
{$ifdef MEMDEBUG}
var
manglenamesize : longint;
{$endif}
constructor tstoreddef.ppuloaddef(ppufile:tcompilerppufile); constructor tstoreddef.ppuloaddef(ppufile:tcompilerppufile);
begin begin
@ -3441,17 +3437,49 @@ implementation
end; end;
aliasnames.free; aliasnames.free;
if assigned(parast) then if assigned(parast) then
parast.free; begin
{$ifdef MEMDEBUG}
memprocparast.start;
{$endif MEMDEBUG}
parast.free;
{$ifdef MEMDEBUG}
memprocparast.stop;
{$endif MEMDEBUG}
end;
if assigned(localst) and (localst.symtabletype<>staticsymtable) then if assigned(localst) and (localst.symtabletype<>staticsymtable) then
localst.free; begin
{$ifdef MEMDEBUG}
memproclocalst.start;
{$endif MEMDEBUG}
localst.free;
{$ifdef MEMDEBUG}
memproclocalst.start;
{$endif MEMDEBUG}
end;
if (proccalloption=pocall_inline) and assigned(code) then if (proccalloption=pocall_inline) and assigned(code) then
tnode(code).free; begin
{$ifdef MEMDEBUG}
memprocnodetree.start;
{$endif MEMDEBUG}
tnode(code).free;
{$ifdef MEMDEBUG}
memprocnodetree.start;
{$endif MEMDEBUG}
end;
if assigned(regvarinfo) then if assigned(regvarinfo) then
dispose(pregvarinfo(regvarinfo)); dispose(pregvarinfo(regvarinfo));
if (po_msgstr in procoptions) then if (po_msgstr in procoptions) then
strdispose(messageinf.str); strdispose(messageinf.str);
if assigned(_mangledname) then if assigned(_mangledname) then
stringdispose(_mangledname); begin
{$ifdef MEMDEBUG}
memmanglednames.start;
{$endif MEMDEBUG}
stringdispose(_mangledname);
{$ifdef MEMDEBUG}
memmanglednames.stop;
{$endif MEMDEBUG}
end;
inherited destroy; inherited destroy;
end; end;
@ -5509,7 +5537,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.91 2002-08-25 19:25:20 peter Revision 1.92 2002-09-05 19:29:42 peter
* memdebug enhancements
Revision 1.91 2002/08/25 19:25:20 peter
* sym.insert_in_data removed * sym.insert_in_data removed
* symtable.insertvardata/insertconstdata added * symtable.insertvardata/insertconstdata added
* removed insert_in_data call from symtable.insert, it needs to be * removed insert_in_data call from symtable.insert, it needs to be

View File

@ -527,11 +527,25 @@ implementation
destructor tstoredsym.destroy; destructor tstoredsym.destroy;
begin begin
if assigned(_mangledname) then if assigned(_mangledname) then
stringdispose(_mangledname); begin
{$ifdef MEMDEBUG}
memmanglednames.start;
{$endif MEMDEBUG}
stringdispose(_mangledname);
{$ifdef MEMDEBUG}
memmanglednames.stop;
{$endif MEMDEBUG}
end;
if assigned(defref) then if assigned(defref) then
begin begin
{$ifdef MEMDEBUG}
membrowser.start;
{$endif MEMDEBUG}
defref.freechain; defref.freechain;
defref.free; defref.free;
{$ifdef MEMDEBUG}
membrowser.stop;
{$endif MEMDEBUG}
end; end;
inherited destroy; inherited destroy;
end; end;
@ -2482,7 +2496,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.60 2002-09-05 14:51:42 peter Revision 1.61 2002-09-05 19:29:45 peter
* memdebug enhancements
Revision 1.60 2002/09/05 14:51:42 peter
* internalerror instead of crash in getprocdef * internalerror instead of crash in getprocdef
Revision 1.59 2002/09/03 16:26:27 daniel Revision 1.59 2002/09/03 16:26:27 daniel

View File

@ -1048,7 +1048,7 @@ implementation
else if (varalign>1) and (dataalignment<2) then else if (varalign>1) and (dataalignment<2) then
dataalignment:=2; dataalignment:=2;
end; end;
dataalignment:=max(dataalignment,aktalignment.maxCrecordalign); dataalignment:=min(dataalignment,aktalignment.maxCrecordalign);
end end
else else
varalign:=vardef.alignment; varalign:=vardef.alignment;
@ -2299,7 +2299,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.69 2002-08-25 19:25:21 peter Revision 1.70 2002-09-05 19:29:45 peter
* memdebug enhancements
Revision 1.69 2002/08/25 19:25:21 peter
* sym.insert_in_data removed * sym.insert_in_data removed
* symtable.insertvardata/insertconstdata added * symtable.insertvardata/insertconstdata added
* removed insert_in_data call from symtable.insert, it needs to be * removed insert_in_data call from symtable.insert, it needs to be

View File

@ -27,6 +27,9 @@ interface
uses uses
{ common } { common }
cutils, cutils,
{$ifdef MEMDEBUG}
cclasses,
{$endif MEMDEBUG}
{ global } { global }
globtype,globals, globtype,globals,
{ symtable } { symtable }
@ -140,6 +143,16 @@ interface
procedure resolvesym(var sym:pointer); procedure resolvesym(var sym:pointer);
procedure resolvedef(var def:pointer); procedure resolvedef(var def:pointer);
{$ifdef MEMDEBUG}
var
membrowser,
memrealnames,
memmanglednames,
memprocparast,
memproclocalst,
memprocnodetree : tmemdebug;
{$endif MEMDEBUG}
implementation implementation
@ -212,7 +225,13 @@ implementation
destructor tsym.destroy; destructor tsym.destroy;
begin begin
{$ifdef MEMDEBUG}
memrealnames.start;
{$endif MEMDEBUG}
stringdispose(_realname); stringdispose(_realname);
{$ifdef MEMDEBUG}
memrealnames.stop;
{$endif MEMDEBUG}
inherited destroy; inherited destroy;
end; end;
@ -525,10 +544,37 @@ implementation
sym:=nil; sym:=nil;
end; end;
{$ifdef MEMDEBUG}
initialization
membrowser:=TMemDebug.create('BrowserRefs');
membrowser.stop;
memrealnames:=TMemDebug.create('Realnames');
memrealnames.stop;
memmanglednames:=TMemDebug.create('Manglednames');
memmanglednames.stop;
memprocparast:=TMemDebug.create('ProcParaSt');
memprocparast.stop;
memproclocalst:=TMemDebug.create('ProcLocalSt');
memproclocalst.stop;
memprocnodetree:=TMemDebug.create('ProcNodeTree');
memprocnodetree.stop;
finalization
membrowser.free;
memrealnames.free;
memmanglednames.free;
memprocparast.free;
memproclocalst.free;
memprocnodetree.free;
{$endif MEMDEBUG}
end. end.
{ {
$Log$ $Log$
Revision 1.21 2002-08-18 20:06:28 peter Revision 1.22 2002-09-05 19:29:46 peter
* memdebug enhancements
Revision 1.21 2002/08/18 20:06:28 peter
* inlining is now also allowed in interface * inlining is now also allowed in interface
* renamed write/load to ppuwrite/ppuload * renamed write/load to ppuwrite/ppuload
* tnode storing in ppu * tnode storing in ppu