dbgbase.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. {
  2. Copyright (c) 2003-2004 by Peter Vreman and Florian Klaempfl
  3. This units contains support for 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 dbgbase;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. systems,
  22. aasmtai;
  23. type
  24. TDebugInfo=class
  25. constructor Create;virtual;
  26. procedure insertmodulestart(list:taasmoutput);virtual;
  27. procedure insertmoduleend(list:taasmoutput);virtual;
  28. procedure insertlineinfo(list:taasmoutput);virtual;
  29. end;
  30. TDebugInfoClass=class of TDebugInfo;
  31. var
  32. CDebugInfo : array[tdbg] of TDebugInfoClass;
  33. DebugInfo : TDebugInfo;
  34. procedure InitDebugInfo;
  35. procedure DoneDebugInfo;
  36. procedure RegisterDebugInfo(const r:tdbginfo;c:TDebugInfoClass);
  37. implementation
  38. uses
  39. verbose;
  40. constructor tdebuginfo.Create;
  41. begin
  42. end;
  43. procedure tdebuginfo.insertmodulestart(list:taasmoutput);
  44. begin
  45. end;
  46. procedure tdebuginfo.insertmoduleend(list:taasmoutput);
  47. begin
  48. end;
  49. procedure tdebuginfo.insertlineinfo(list:taasmoutput);
  50. begin
  51. end;
  52. procedure InitDebugInfo;
  53. begin
  54. if not assigned(CDebugInfo[target_dbg.id]) then
  55. begin
  56. Comment(V_Fatal,'cg_f_debuginfo_output_not_supported');
  57. exit;
  58. end;
  59. DebugInfo:=CDebugInfo[target_dbg.id].Create;
  60. end;
  61. procedure DoneDebugInfo;
  62. begin
  63. if assigned(DebugInfo) then
  64. begin
  65. DebugInfo.Free;
  66. DebugInfo:=nil;
  67. end;
  68. end;
  69. procedure RegisterDebugInfo(const r:tdbginfo;c:TDebugInfoClass);
  70. var
  71. t : tdbg;
  72. begin
  73. t:=r.id;
  74. if assigned(dbginfos[t]) then
  75. writeln('Warning: DebugInfo is already registered!')
  76. else
  77. Getmem(dbginfos[t],sizeof(tdbginfo));
  78. dbginfos[t]^:=r;
  79. CDebugInfo[t]:=c;
  80. end;
  81. const
  82. dbg_none_info : tdbginfo =
  83. (
  84. id : dbg_none;
  85. idtxt : 'NONE';
  86. );
  87. initialization
  88. RegisterDebugInfo(dbg_none_info,tdebuginfo);
  89. end.