ppheap.pas 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. SetExtraInfo(12,ppextra_info);
  42. pp_heap_inited:=true;
  43. end;
  44. begin
  45. pp_heap_init;
  46. end.
  47. {
  48. $Log$
  49. Revision 1.5 1999-01-26 11:32:13 pierre
  50. * ppheap init code can be called before any getmem
  51. }