dbgjasm.pas 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. {
  2. Copyright (c) 2003-2006 by Peter Vreman, Florian Klaempfl, and Jonas Maebe
  3. This units contains support for Jasmin debug info generation
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit dbgjasm;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,globtype,
  22. aasmbase,aasmtai,aasmdata,
  23. symbase,symconst,symtype,symdef,symsym,
  24. finput,
  25. DbgBase;
  26. type
  27. { TDebugInfoJasmin }
  28. TDebugInfoJasmin=class(TDebugInfo)
  29. protected
  30. fcurrprocstart,
  31. fcurrprocend: tasmsymbol;
  32. procedure appendsym_localsym(list: TAsmList; sym: tabstractnormalvarsym);
  33. procedure appendsym_paravar(list:TAsmList;sym:tparavarsym);override;
  34. procedure appendsym_localvar(list:TAsmList;sym:tlocalvarsym);override;
  35. procedure beforeappenddef(list:TAsmList;def:tdef);override;
  36. procedure appendprocdef(list:TAsmList;def:tprocdef);override;
  37. public
  38. procedure inserttypeinfo;override;
  39. procedure insertlineinfo(list:TAsmList);override;
  40. end;
  41. implementation
  42. uses
  43. sysutils,cutils,cfileutl,constexp,
  44. version,globals,verbose,systems,
  45. cpubase,cpuinfo,cgbase,paramgr,
  46. fmodule,
  47. defutil,symtable,ppu
  48. ;
  49. {****************************************************************************
  50. TDebugInfoJasmin
  51. ****************************************************************************}
  52. procedure TDebugInfoJasmin.appendsym_localsym(list: TAsmList; sym: tabstractnormalvarsym);
  53. var
  54. jvar: tai_jvar;
  55. proc: tprocdef;
  56. begin
  57. if tdef(sym.owner.defowner).typ<>procdef then
  58. exit;
  59. if not(sym.localloc.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  60. exit;
  61. proc:=tprocdef(sym.owner.defowner);
  62. jvar:=tai_jvar.create(sym.localloc.reference.offset,sym.jvmmangledbasename,fcurrprocstart,fcurrprocend);
  63. proc.exprasmlist.InsertAfter(jvar,proc.procstarttai);
  64. end;
  65. procedure TDebugInfoJasmin.appendsym_paravar(list: TAsmList; sym: tparavarsym);
  66. begin
  67. appendsym_localsym(list,sym);
  68. end;
  69. procedure TDebugInfoJasmin.appendsym_localvar(list: TAsmList; sym: tlocalvarsym);
  70. begin
  71. appendsym_localsym(list,sym);
  72. end;
  73. procedure TDebugInfoJasmin.beforeappenddef(list: TAsmList; def: tdef);
  74. begin
  75. end;
  76. procedure TDebugInfoJasmin.appendprocdef(list: TAsmList; def: tprocdef);
  77. var
  78. procstartlabel,
  79. procendlabel : tasmlabel;
  80. begin
  81. { insert debug information for local variables and parameters, but only
  82. for routines implemented in the Pascal code }
  83. if not assigned(def.procstarttai) then
  84. exit;
  85. current_asmdata.getlabel(procstartlabel,alt_dbgtype);
  86. current_asmdata.getlabel(procendlabel,alt_dbgtype);
  87. def.exprasmlist.insertafter(tai_label.create(procstartlabel),def.procstarttai);
  88. def.exprasmlist.insertbefore(tai_label.create(procendlabel),def.procendtai);
  89. fcurrprocstart:=procstartlabel;
  90. fcurrprocend:=procendlabel;
  91. write_symtable_parasyms(list,def.paras);
  92. write_symtable_syms(list,def.localst);
  93. end;
  94. procedure TDebugInfoJasmin.inserttypeinfo;
  95. begin
  96. { write all procedures and methods }
  97. if assigned(current_module.globalsymtable) then
  98. write_symtable_procdefs(nil,current_module.globalsymtable);
  99. if assigned(current_module.localsymtable) then
  100. write_symtable_procdefs(nil,current_module.localsymtable);
  101. end;
  102. procedure TDebugInfoJasmin.insertlineinfo(list: TAsmList);
  103. begin
  104. end;
  105. {****************************************************************************
  106. ****************************************************************************}
  107. const
  108. dbg_jasmin_info : tdbginfo =
  109. (
  110. id : dbg_jasmin;
  111. idtxt : 'JASMIN';
  112. );
  113. initialization
  114. RegisterDebugInfo(dbg_jasmin_info,TDebugInfoJasmin);
  115. end.