ppheap.pas 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. var pl : plongint;
  29. begin
  30. longint(p^):=aktfilepos.line;
  31. pl:=plongint(cardinal(p)+4);
  32. pl^:=aktfilepos.column;
  33. pl:=plongint(cardinal(p)+8);
  34. if assigned(current_module) then
  35. pl^:=current_module^.unit_index*100000+aktfilepos.fileindex
  36. else
  37. pl^:=aktfilepos.fileindex
  38. end;
  39. const
  40. pp_heap_inited : boolean = false;
  41. procedure pp_heap_init;
  42. begin
  43. if not pp_heap_inited then
  44. begin
  45. setheaptraceoutput('heap.log');
  46. {$ifndef TP}
  47. SetExtraInfo(12,@ppextra_info);
  48. {$else TP}
  49. SetExtraInfo(12,ppextra_info);
  50. {$endif TP}
  51. end;
  52. pp_heap_inited:=true;
  53. end;
  54. begin
  55. pp_heap_init;
  56. end.
  57. {
  58. $Log$
  59. Revision 1.8 1999-11-17 17:05:02 pierre
  60. * Notes/hints changes
  61. Revision 1.7 1999/06/08 15:26:49 pierre
  62. * fix to get it self compiled
  63. Revision 1.6 1999/05/17 15:09:28 pierre
  64. * heaptrc output to heap.log file
  65. Revision 1.5 1999/01/26 11:32:13 pierre
  66. * ppheap init code can be called before any getmem
  67. }