1
0

heap_scan_stack.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Generic stack scanning function
  3. *
  4. * This currently only scans the last 32 levels of the current stack.
  5. */
  6. #ifdef __GNUC__
  7. #include "private.h"
  8. #include "node.h"
  9. /*--------------------------------------------------------- */
  10. void
  11. lub_heap_scan_stack(void)
  12. {
  13. char *start,*end;
  14. #define FRAME_ADDRESS(n) \
  15. { \
  16. char *fn = __builtin_return_address(n); \
  17. if(!fn || (fn > lub_heap_data_start)) \
  18. { \
  19. break; \
  20. } \
  21. end = __builtin_frame_address(n); \
  22. } \
  23. start = end = __builtin_frame_address(0);
  24. do {
  25. FRAME_ADDRESS(0);
  26. FRAME_ADDRESS(1);
  27. FRAME_ADDRESS(2);
  28. FRAME_ADDRESS(3);
  29. FRAME_ADDRESS(4);
  30. FRAME_ADDRESS(5);
  31. FRAME_ADDRESS(6);
  32. FRAME_ADDRESS(7);
  33. FRAME_ADDRESS(8);
  34. FRAME_ADDRESS(9);
  35. FRAME_ADDRESS(10);
  36. FRAME_ADDRESS(11);
  37. FRAME_ADDRESS(12);
  38. FRAME_ADDRESS(13);
  39. FRAME_ADDRESS(14);
  40. FRAME_ADDRESS(15);
  41. FRAME_ADDRESS(16);
  42. FRAME_ADDRESS(17);
  43. FRAME_ADDRESS(18);
  44. FRAME_ADDRESS(19);
  45. FRAME_ADDRESS(20);
  46. FRAME_ADDRESS(21);
  47. FRAME_ADDRESS(22);
  48. FRAME_ADDRESS(23);
  49. FRAME_ADDRESS(24);
  50. FRAME_ADDRESS(25);
  51. FRAME_ADDRESS(26);
  52. FRAME_ADDRESS(27);
  53. FRAME_ADDRESS(28);
  54. FRAME_ADDRESS(29);
  55. FRAME_ADDRESS(30);
  56. FRAME_ADDRESS(31);
  57. } while(0);
  58. /* now scan the memory */
  59. lub_heap_scan_memory(start,end-start);
  60. }
  61. /*--------------------------------------------------------- */
  62. #else /* not __GNUC__ */
  63. #warning "Generic stack scanning not implemented for non-GCC compiler..."
  64. #endif /* not __GNUC__*/