Mercurial > hg > xemacs-beta
comparison src/profile.h @ 4162:8f6a825eb3d3
[xemacs-hg @ 2007-09-04 21:20:18 by aidan]
Eliminate a crash when profiling; only pass the backtrace record to
profile_record_about_to_call, profile_record_just_called when it's non-nil.
author | aidan |
---|---|
date | Tue, 04 Sep 2007 21:20:26 +0000 |
parents | 390dee4913ba |
children | 308d34e9f07d |
comparison
equal
deleted
inserted
replaced
4161:08efedad2696 | 4162:8f6a825eb3d3 |
---|---|
45 | 45 |
46 /* As just mentioned, we rely on the dynamic value of profiling_active. | 46 /* As just mentioned, we rely on the dynamic value of profiling_active. |
47 This ensures correct behavior (e.g. we never modify the profiling info | 47 This ensures correct behavior (e.g. we never modify the profiling info |
48 when profiling is not active) because we seed and reap all functions | 48 when profiling is not active) because we seed and reap all functions |
49 currently on the stack when starting and stopping. See | 49 currently on the stack when starting and stopping. See |
50 `start-profiling'. */ | 50 `start-profiling'. |
51 | |
52 We check do_backtrace to make sure that the backtrace structure is | |
53 initialised. If it isn't, we can enter a function with profiling turned | |
54 off, and exit it with it turned on, with the consequence that an | |
55 unitialised backtrace structure is passed to | |
56 profile_record_just_called. Since do_backtrace is function-local (apart | |
57 from in the garbage collector) this avoids that. */ | |
51 #define PROFILE_ENTER_FUNCTION() \ | 58 #define PROFILE_ENTER_FUNCTION() \ |
52 do \ | 59 do \ |
53 { \ | 60 { \ |
54 if (profiling_active) \ | 61 if (profiling_active && do_backtrace) \ |
55 profile_record_about_to_call (&backtrace); \ | 62 profile_record_about_to_call (&backtrace); \ |
56 } \ | 63 } \ |
57 while (0) | 64 while (0) |
58 | 65 |
59 #define PROFILE_EXIT_FUNCTION() \ | 66 #define PROFILE_EXIT_FUNCTION() \ |
60 do \ | 67 do \ |
61 { \ | 68 { \ |
62 if (profiling_active) \ | 69 if (profiling_active && do_backtrace) \ |
63 profile_record_just_called (&backtrace); \ | 70 profile_record_just_called (&backtrace); \ |
64 } \ | 71 } \ |
65 while (0) | 72 while (0) |
66 | 73 |
67 /* We are entering a section that we would like to record profile information | 74 /* We are entering a section that we would like to record profile information |