From a563a7620470af7fbb079f3d05a12ece141ff86f Mon Sep 17 00:00:00 2001 From: Richard Kistruck Date: Wed, 12 Nov 2008 15:07:04 +0000 Subject: Mps br/timing: mps_alert_collection_set() -- client sets a callback function; MPS calls it synchronously on collection start/stop (immediately after posting start/stop message). The callback receives two ints: alertcode (start|stop; see mps.h), and whycode (trace->why). Note: callback is also called for heap walk start/stop. amcss.c: show start/stop alerts. Copied from Perforce Change: 166703 ServerID: perforce.ravenbrook.com --- mps/code/amcss.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'mps/code/amcss.c') diff --git a/mps/code/amcss.c b/mps/code/amcss.c index 647d0525fc4..8b88dd38bec 100644 --- a/mps/code/amcss.c +++ b/mps/code/amcss.c @@ -47,7 +47,27 @@ static mps_addr_t exactRoots[exactRootsCOUNT]; static mps_addr_t ambigRoots[ambigRootsCOUNT]; -/* report - report statistics from any messages */ +/* alert -- synchronous alert of collection start/stop */ + +static void alertfn(int alertcode, int whycode) +{ + switch(alertcode) { + case MPS_ALERT_COLLECTION_START: { + printf("\n^^^^^^ START (why: %d) ^^^^^^\n", whycode); + break; + } + case MPS_ALERT_COLLECTION_STOP: { + printf("vvvvvv STOP (why: %d) vvvvvv\n", whycode); + break; + } + default: { + cdie(0, "unknown alertcode"); + break; + } + } +} + +/* report -- report statistics from any messages */ static void report(mps_arena_t arena) { @@ -313,6 +333,7 @@ int main(int argc, char **argv) "arena_create"); mps_message_type_enable(arena, mps_message_type_gc()); mps_message_type_enable(arena, mps_message_type_gc_start()); + mps_alert_collection_set(arena, &alertfn); die(mps_arena_commit_limit_set(arena, testArenaSIZE), "set limit"); die(mps_thread_reg(&thread, arena), "thread_reg"); mps_tramp(&r, test, arena, 0); -- cgit v1.2.1