* workaround for debug info for interface method wrappers: give them the

line number information of the method declaration if it's in the current
    unit, and otherwise the first line of the current unit (mantis #14399)

git-svn-id: trunk@37961 -
This commit is contained in:
Jonas Maebe 2018-01-13 16:54:22 +00:00
parent 393b74380c
commit d35377fdee
2 changed files with 49 additions and 9 deletions

View File

@ -118,7 +118,7 @@ implementation
wpobase,
cgbase,parabase,paramgr,
{$ifndef cpuhighleveltarget}
hlcgobj,hlcgcpu,
hlcgobj,hlcgcpu,dbgbase,
{$endif not cpuhighleveltarget}
ncgrtti;
@ -1272,6 +1272,9 @@ implementation
{$ifdef cpuhighleveltarget}
wrapperpd: tprocdef;
wrapperinfo: pskpara_interface_wrapper;
{$else}
tmplist: tasmlist;
oldfileposinfo: tfileposinfo;
{$endif cpuhighleveltarget}
begin
for i:=0 to _class.ImplementedInterfaces.count-1 do
@ -1301,12 +1304,31 @@ implementation
wrapperpd:=create_procdef_alias(pd,tmps,tmps,
current_module.localsymtable,_class,
tsk_interface_wrapper,wrapperinfo);
include(wrapperpd.procoptions,po_noreturn);
{$else cpuhighleveltarget}
oldfileposinfo:=current_filepos;
if pd.owner.iscurrentunit then
current_filepos:=pd.fileinfo
else
begin
current_filepos.moduleindex:=1;
current_filepos.fileindex:=1;
current_filepos.line:=1;
current_filepos.column:=1;
end;
{ create wrapper code }
new_section(list,sec_code,tmps,target_info.alignment.procalign);
tmplist:=tasmlist.create;
new_section(tmplist,sec_code,tmps,target_info.alignment.procalign);
tmplist.Concat(tai_function_name.create(pd.procsym.RealName));
hlcg.init_register_allocators;
hlcg.g_intf_wrapper(list,pd,tmps,ImplIntf.ioffset);
hlcg.g_intf_wrapper(tmplist,pd,tmps,ImplIntf.ioffset);
hlcg.done_register_allocators;
if (cs_debuginfo in current_settings.moduleswitches) or
(cs_use_lineinfo in current_settings.globalswitches) then
current_debuginfo.insertlineinfo(tmplist);
list.concatlist(tmplist);
tmplist.Free;
current_filepos:=oldfileposinfo;
{$endif cpuhighleveltarget}
end;
end;
@ -1347,7 +1369,7 @@ implementation
include(def.defstates,ds_vmt_written);
end;
if is_class(def) then
gen_intf_wrapper(current_asmdata.asmlists[al_globals],tobjectdef(def));
gen_intf_wrapper(current_asmdata.asmlists[al_procedures],tobjectdef(def));
end;
procdef :
begin

View File

@ -63,7 +63,7 @@ interface
* save the scanner state before calling this routine, and restore when done.
* the code *must* be written in objfpc style
}
function str_parse_method_impl(str: ansistring; usefwpd: tprocdef; is_classdef: boolean):boolean;
function str_parse_method_impl(const str: ansistring; usefwpd: tprocdef; is_classdef: boolean):boolean;
{ parses a typed constant assignment to ssym
@ -232,7 +232,7 @@ implementation
end;
function str_parse_method_impl(str: ansistring; usefwpd: tprocdef; is_classdef: boolean):boolean;
function str_parse_method_impl_with_fileinfo(str: ansistring; usefwpd: tprocdef; fileno, lineno: longint; is_classdef: boolean):boolean;
var
oldparse_only: boolean;
tmpstr: ansistring;
@ -253,9 +253,10 @@ implementation
oldparse_only:=parse_only;
parse_only:=false;
result:=false;
{ inject the string in the scanner }
{ "const" starts a new kind of block and hence makes the scanner return }
str:=str+'const;';
current_scanner.substitutemacro('meth_impl_macro',@str[1],length(str),current_scanner.line_no,current_scanner.inputfile.ref_index);
{ inject the string in the scanner }
current_scanner.substitutemacro('meth_impl_macro',@str[1],length(str),lineno,fileno);
current_scanner.readtoken(false);
{ and parse it... }
read_proc(is_classdef,usefwpd,false);
@ -268,6 +269,12 @@ implementation
end;
function str_parse_method_impl(const str: ansistring; usefwpd: tprocdef; is_classdef: boolean):boolean;
begin
result:=str_parse_method_impl_with_fileinfo(str, usefwpd, current_scanner.inputfile.ref_index, current_scanner.line_no, is_classdef);
end;
procedure str_parse_typedconst(list: TAsmList; str: ansistring; ssym: tstaticvarsym);
var
old_block_type: tblock_type;
@ -968,6 +975,7 @@ implementation
wrapperinfo: pskpara_interface_wrapper;
callthroughpd: tprocdef;
str: ansistring;
fileinfo: tfileposinfo;
begin
wrapperinfo:=pskpara_interface_wrapper(pd.skpara);
if not assigned(wrapperinfo) then
@ -983,7 +991,17 @@ implementation
str:=str+callthroughpd.procsym.realname+'(';
addvisibibleparameters(str,callthroughpd);
str:=str+') end;';
str_parse_method_impl(str,pd,false);
{ add dummy file info so we can step in/through it }
if pd.owner.iscurrentunit then
fileinfo:=pd.fileinfo
else
begin
fileinfo.moduleindex:=current_module.moduleid;
fileinfo.fileindex:=1;
fileinfo.line:=1;
fileinfo.column:=1;
end;
str_parse_method_impl_with_fileinfo(str,pd,fileinfo.fileindex,fileinfo.line,false);
dispose(wrapperinfo);
pd.skpara:=nil;
end;