ppheap.pas 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by FPC development team
  4. Simple unit to add source line and column to each
  5. memory allocation made with heaptrc unit
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************}
  18. unit ppheap;
  19. interface
  20. uses heaptrc;
  21. { call this function before any memory allocation
  22. in a unit initialization code (PM) }
  23. procedure pp_heap_init;
  24. implementation
  25. uses
  26. globtype,globals,files;
  27. procedure ppextra_info(p : pointer);
  28. begin
  29. longint(p^):=aktfilepos.line;
  30. plongint(cardinal(p)+4)^:=aktfilepos.column;
  31. if assigned(current_module) then
  32. plongint(cardinal(p)+8)^:=current_module^.unit_index*100000+aktfilepos.fileindex
  33. else
  34. plongint(cardinal(p)+8)^:=aktfilepos.fileindex
  35. end;
  36. const
  37. pp_heap_inited : boolean = false;
  38. procedure pp_heap_init;
  39. begin
  40. if not pp_heap_inited then
  41. begin
  42. setheaptraceoutput('heap.log');
  43. {$ifndef TP}
  44. SetExtraInfo(12,@ppextra_info);
  45. {$else TP}
  46. SetExtraInfo(12,ppextra_info);
  47. {$endif TP}
  48. end;
  49. pp_heap_inited:=true;
  50. end;
  51. begin
  52. pp_heap_init;
  53. end.
  54. {
  55. $Log$
  56. Revision 1.7 1999-06-08 15:26:49 pierre
  57. * fix to get it self compiled
  58. Revision 1.6 1999/05/17 15:09:28 pierre
  59. * heaptrc output to heap.log file
  60. Revision 1.5 1999/01/26 11:32:13 pierre
  61. * ppheap init code can be called before any getmem
  62. }