mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-04 11:58:30 +02:00
* fixes for locals in inlined procedures
fix for bug797 + stabs generation for inlined paras and locals
This commit is contained in:
parent
35d59eeb52
commit
16638c8b65
@ -20,6 +20,9 @@
|
||||
|
||||
****************************************************************************
|
||||
}
|
||||
{$ifdef FPC}
|
||||
{$goto on}
|
||||
{$endif FPC}
|
||||
unit cg386cal;
|
||||
interface
|
||||
|
||||
@ -41,7 +44,7 @@ implementation
|
||||
cobjects,verbose,globals,
|
||||
symconst,aasm,types,
|
||||
{$ifdef GDB}
|
||||
gdb,
|
||||
strings,gdb,
|
||||
{$endif GDB}
|
||||
hcodegen,temp_gen,pass_2,
|
||||
cpubase,cpuasm,
|
||||
@ -1285,6 +1288,11 @@ implementation
|
||||
proc_names : tstringcontainer;
|
||||
inlineentrycode,inlineexitcode : paasmoutput;
|
||||
oldexitlabel,oldexit2label,oldquickexitlabel:Pasmlabel;
|
||||
{$ifdef GDB}
|
||||
startlabel,endlabel : pasmlabel;
|
||||
pp : pchar;
|
||||
mangled_length : longint;
|
||||
{$endif GDB}
|
||||
begin
|
||||
oldinlining_procedure:=inlining_procedure;
|
||||
oldexitlabel:=aktexitlabel;
|
||||
@ -1293,11 +1301,11 @@ implementation
|
||||
getlabel(aktexitlabel);
|
||||
getlabel(aktexit2label);
|
||||
oldprocsym:=aktprocsym;
|
||||
{ we're inlining a procedure }
|
||||
inlining_procedure:=true;
|
||||
{ save old procinfo }
|
||||
getmem(oldprocinfo,sizeof(tprocinfo));
|
||||
move(procinfo^,oldprocinfo^,sizeof(tprocinfo));
|
||||
{ we're inlining a procedure }
|
||||
inlining_procedure:=true;
|
||||
{ set the return value }
|
||||
aktprocsym:=p^.inlineprocsym;
|
||||
procinfo^.returntype:=aktprocsym^.definition^.rettype;
|
||||
@ -1309,16 +1317,44 @@ implementation
|
||||
st^.symtablelevel:=oldprocsym^.definition^.localst^.symtablelevel;
|
||||
if st^.datasize>0 then
|
||||
begin
|
||||
st^.address_fixup:=gettempofsizepersistant(st^.datasize);
|
||||
st^.address_fixup:=gettempofsizepersistant(st^.datasize)+st^.datasize;
|
||||
{$ifdef extdebug}
|
||||
Comment(V_debug,'local symtable is at offset '+tostr(st^.address_fixup));
|
||||
exprasmlist^.concat(new(pai_asm_comment,init(strpnew(
|
||||
'local symtable is at offset '+tostr(st^.address_fixup)))));
|
||||
{$endif extdebug}
|
||||
end;
|
||||
exprasmlist^.concat(new(Pai_Marker, Init(InlineStart)));
|
||||
{$ifdef extdebug}
|
||||
exprasmlist^.concat(new(pai_asm_comment,init(strpnew('Start of inlined proc'))));
|
||||
{$endif extdebug}
|
||||
{$ifdef GDB}
|
||||
if (cs_debuginfo in aktmoduleswitches) then
|
||||
begin
|
||||
getlabel(startlabel);
|
||||
getlabel(endlabel);
|
||||
emitlab(startlabel);
|
||||
p^.inlineprocsym^.definition^.localst^.symtabletype:=inlinelocalsymtable;
|
||||
p^.inlineprocsym^.definition^.parast^.symtabletype:=inlineparasymtable;
|
||||
|
||||
{ Here we must include the para and local symtable info }
|
||||
p^.inlineprocsym^.concatstabto(withdebuglist);
|
||||
|
||||
{ set it back for savety }
|
||||
p^.inlineprocsym^.definition^.localst^.symtabletype:=localsymtable;
|
||||
p^.inlineprocsym^.definition^.parast^.symtabletype:=parasymtable;
|
||||
|
||||
mangled_length:=length(oldprocsym^.definition^.mangledname);
|
||||
getmem(pp,mangled_length+50);
|
||||
strpcopy(pp,'192,0,0,'+startlabel^.name);
|
||||
if (target_os.use_function_relative_addresses) then
|
||||
begin
|
||||
strpcopy(strend(pp),'-');
|
||||
strpcopy(strend(pp),oldprocsym^.definition^.mangledname);
|
||||
end;
|
||||
withdebuglist^.concat(new(pai_stabn,init(strnew(pp))));
|
||||
end;
|
||||
{$endif GDB}
|
||||
{ takes care of local data initialization }
|
||||
inlineentrycode:=new(paasmoutput,init);
|
||||
inlineexitcode:=new(paasmoutput,init);
|
||||
@ -1333,15 +1369,31 @@ implementation
|
||||
{$ifdef extdebug}
|
||||
exprasmlist^.concat(new(pai_asm_comment,init(strpnew('End of inlined proc'))));
|
||||
{$endif extdebug}
|
||||
exprasmlist^.concat(new(Pai_Marker, Init(InlineEnd)));
|
||||
|
||||
{we can free the local data now, reset also the fixup address }
|
||||
if st^.datasize>0 then
|
||||
begin
|
||||
ungetpersistanttemp(st^.address_fixup);
|
||||
ungetpersistanttemp(st^.address_fixup-st^.datasize);
|
||||
st^.address_fixup:=0;
|
||||
end;
|
||||
{ restore procinfo }
|
||||
move(oldprocinfo^,procinfo^,sizeof(tprocinfo));
|
||||
freemem(oldprocinfo,sizeof(tprocinfo));
|
||||
{$ifdef GDB}
|
||||
if (cs_debuginfo in aktmoduleswitches) then
|
||||
begin
|
||||
emitlab(endlabel);
|
||||
strpcopy(pp,'224,0,0,'+endlabel^.name);
|
||||
if (target_os.use_function_relative_addresses) then
|
||||
begin
|
||||
strpcopy(strend(pp),'-');
|
||||
strpcopy(strend(pp),oldprocsym^.definition^.mangledname);
|
||||
end;
|
||||
withdebuglist^.concat(new(pai_stabn,init(strnew(pp))));
|
||||
freemem(pp,mangled_length+50);
|
||||
end;
|
||||
{$endif GDB}
|
||||
{ restore }
|
||||
aktprocsym:=oldprocsym;
|
||||
aktexitlabel:=oldexitlabel;
|
||||
@ -1355,7 +1407,12 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.126 2000-02-09 18:08:33 jonas
|
||||
Revision 1.127 2000-03-01 00:03:11 pierre
|
||||
* fixes for locals in inlined procedures
|
||||
fix for bug797
|
||||
+ stabs generation for inlined paras and locals
|
||||
|
||||
Revision 1.126 2000/02/09 18:08:33 jonas
|
||||
* added regallocs for esi
|
||||
|
||||
Revision 1.125 2000/02/09 13:22:45 peter
|
||||
@ -1443,4 +1500,4 @@ end.
|
||||
needs some corections regarding register saving
|
||||
* gettempansistring is again a procedure
|
||||
|
||||
}
|
||||
}
|
@ -166,7 +166,11 @@ implementation
|
||||
inlineparasymtable,localsymtable]) then
|
||||
begin
|
||||
p^.location.reference.base:=procinfo^.framepointer;
|
||||
p^.location.reference.offset:=pvarsym(p^.symtableentry)^.address+p^.symtable^.address_fixup;
|
||||
if (symtabletype in [inlinelocalsymtable,
|
||||
localsymtable]) then
|
||||
p^.location.reference.offset:=pvarsym(p^.symtableentry)^.address-p^.symtable^.address_fixup
|
||||
else
|
||||
p^.location.reference.offset:=pvarsym(p^.symtableentry)^.address+p^.symtable^.address_fixup;
|
||||
|
||||
if (symtabletype in [localsymtable,inlinelocalsymtable]) then
|
||||
begin
|
||||
@ -961,7 +965,7 @@ implementation
|
||||
end
|
||||
else
|
||||
emit_push_loc(hp^.left^.location);
|
||||
inc(pushedparasize);
|
||||
inc(pushedparasize);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -1005,7 +1009,12 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.100 2000-02-09 18:08:33 jonas
|
||||
Revision 1.101 2000-03-01 00:03:11 pierre
|
||||
* fixes for locals in inlined procedures
|
||||
fix for bug797
|
||||
+ stabs generation for inlined paras and locals
|
||||
|
||||
Revision 1.100 2000/02/09 18:08:33 jonas
|
||||
* added regallocs for esi
|
||||
|
||||
Revision 1.99 2000/02/09 13:22:47 peter
|
||||
@ -1093,4 +1102,3 @@ end.
|
||||
* resources are working again
|
||||
|
||||
}
|
||||
|
||||
|
@ -2729,10 +2729,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
|
||||
begin
|
||||
procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
|
||||
reset_reference(hr);
|
||||
if psym(p)^.owner^.symtabletype=localsymtable then
|
||||
if psym(p)^.owner^.symtabletype in [localsymtable,inlinelocalsymtable] then
|
||||
begin
|
||||
hr.base:=procinfo^.framepointer;
|
||||
hr.offset:=-pvarsym(p)^.address;
|
||||
hr.offset:=-pvarsym(p)^.address+pvarsym(p)^.owner^.address_fixup;
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -2794,12 +2794,12 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
|
||||
procinfo^.flags:=procinfo^.flags or pi_needs_implicit_finally;
|
||||
reset_reference(hr);
|
||||
case psym(p)^.owner^.symtabletype of
|
||||
localsymtable:
|
||||
localsymtable,inlinelocalsymtable:
|
||||
begin
|
||||
hr.base:=procinfo^.framepointer;
|
||||
hr.offset:=-pvarsym(p)^.address;
|
||||
hr.offset:=-pvarsym(p)^.address+pvarsym(p)^.owner^.address_fixup;
|
||||
end;
|
||||
parasymtable:
|
||||
parasymtable,inlineparasymtable:
|
||||
begin
|
||||
hr.base:=procinfo^.framepointer;
|
||||
hr.offset:=pvarsym(p)^.address+procinfo^.para_offset;
|
||||
@ -2972,7 +2972,7 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
|
||||
href1.offset:=pvarsym(p)^.address+procinfo^.para_offset;
|
||||
reset_reference(href2);
|
||||
href2.base:=procinfo^.framepointer;
|
||||
href2.offset:=-pvarsym(p)^.localvarsym^.address;
|
||||
href2.offset:=-pvarsym(p)^.localvarsym^.address+pvarsym(p)^.localvarsym^.owner^.address_fixup;
|
||||
copyshortstring(href2,href1,pstringdef(pvarsym(p)^.vartype.def)^.len,true);
|
||||
end
|
||||
else
|
||||
@ -2982,7 +2982,7 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
|
||||
href1.offset:=pvarsym(p)^.address+procinfo^.para_offset;
|
||||
reset_reference(href2);
|
||||
href2.base:=procinfo^.framepointer;
|
||||
href2.offset:=-pvarsym(p)^.localvarsym^.address;
|
||||
href2.offset:=-pvarsym(p)^.localvarsym^.address+pvarsym(p)^.localvarsym^.owner^.address_fixup;
|
||||
concatcopy(href1,href2,pvarsym(p)^.vartype.def^.size,true,true);
|
||||
end;
|
||||
end;
|
||||
@ -3781,7 +3781,12 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.83 2000-02-18 21:25:48 florian
|
||||
Revision 1.84 2000-03-01 00:03:12 pierre
|
||||
* fixes for locals in inlined procedures
|
||||
fix for bug797
|
||||
+ stabs generation for inlined paras and locals
|
||||
|
||||
Revision 1.83 2000/02/18 21:25:48 florian
|
||||
* fixed a bug in int64/qword handling was a quite ugly one
|
||||
|
||||
Revision 1.82 2000/02/18 20:53:14 pierre
|
||||
|
@ -1403,7 +1403,7 @@
|
||||
+vartype.def^.numberstring+'",'+
|
||||
tostr(N_LCSYM)+',0,'+tostr(fileinfo.line)+','+mangledname);
|
||||
end
|
||||
else if (owner^.symtabletype=parasymtable) then
|
||||
else if (owner^.symtabletype in [parasymtable,inlineparasymtable]) then
|
||||
begin
|
||||
case varspez of
|
||||
vs_var : st := 'v'+st;
|
||||
@ -1420,7 +1420,7 @@
|
||||
{offset to ebp => will not work if the framepointer is esp
|
||||
so some optimizing will make things harder to debug }
|
||||
end
|
||||
else if (owner^.symtabletype=localsymtable) then
|
||||
else if (owner^.symtabletype in [localsymtable,inlinelocalsymtable]) then
|
||||
{$ifdef i386}
|
||||
if reg<>R_NO then
|
||||
begin
|
||||
@ -1441,7 +1441,7 @@
|
||||
else
|
||||
stabstring := strpnew('"'+name+':'+st
|
||||
+vartype.def^.numberstring+'",'+
|
||||
tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',-'+tostr(address))
|
||||
tostr(N_LSYM)+',0,'+tostr(fileinfo.line)+',-'+tostr(address-owner^.address_fixup))
|
||||
else
|
||||
stabstring := inherited stabstring;
|
||||
end;
|
||||
@ -2125,7 +2125,12 @@
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.139 2000-02-11 13:53:49 pierre
|
||||
Revision 1.140 2000-03-01 00:03:10 pierre
|
||||
* fixes for locals in inlined procedures
|
||||
fix for bug797
|
||||
+ stabs generation for inlined paras and locals
|
||||
|
||||
Revision 1.139 2000/02/11 13:53:49 pierre
|
||||
* avoid stack overflow in tref.done (bug 846)
|
||||
|
||||
Revision 1.138 2000/02/09 13:23:05 peter
|
||||
|
@ -1185,6 +1185,12 @@ implementation
|
||||
psym(p)^.concatstabto(asmoutput);
|
||||
end;
|
||||
|
||||
procedure resetstab(p : pnamedindexobject);
|
||||
begin
|
||||
if psym(p)^.typ <> procsym then
|
||||
psym(p)^.isstabwritten:=false;
|
||||
end;
|
||||
|
||||
procedure concattypestab(p : pnamedindexobject);
|
||||
begin
|
||||
if psym(p)^.typ = typesym then
|
||||
@ -2123,6 +2129,9 @@ implementation
|
||||
procedure tsymtable.concatstabto(asmlist : paasmoutput);
|
||||
begin
|
||||
asmoutput:=asmlist;
|
||||
if symtabletype in [inlineparasymtable,inlinelocalsymtable] then
|
||||
foreach({$ifndef TP}@{$endif}resetstab);
|
||||
|
||||
foreach({$ifndef TP}@{$endif}concatstab);
|
||||
end;
|
||||
{$endif}
|
||||
@ -2784,7 +2793,12 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.78 2000-02-20 20:49:45 florian
|
||||
Revision 1.79 2000-03-01 00:03:10 pierre
|
||||
* fixes for locals in inlined procedures
|
||||
fix for bug797
|
||||
+ stabs generation for inlined paras and locals
|
||||
|
||||
Revision 1.78 2000/02/20 20:49:45 florian
|
||||
* newcg is compiling
|
||||
* fixed the dup id problem reported by Paul Y.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user