From 5b2c24bed381aa6eb7a8bfe3d9bcae9c51b7f132 Mon Sep 17 00:00:00 2001 From: theraven Date: Thu, 26 May 2011 22:08:27 +0000 Subject: [PATCH] If LIBOBJC_DUMP_GC_STATUS_ON_SIGNAL is set, dump the GC state in response to kill -$(LIBOBJC_DUMP_GC_STATUS_ON_SIGNAL) {pid}. --- gc_boehm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gc_boehm.c b/gc_boehm.c index de4b9eb..343b383 100644 --- a/gc_boehm.c +++ b/gc_boehm.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "gc_ops.h" #define I_HIDE_POINTERS #include @@ -454,11 +455,17 @@ void* objc_gc_reallocate_collectable(void *ptr, size_t size, BOOL isScanned) static void init(void) { GC_INIT(); + char *sigNumber; // Dump GC stats on exit - uncomment when debugging. if (getenv("LIBOBJC_DUMP_GC_STATUS_ON_EXIT")) { atexit(GC_dump); } + if ((sigNumber = getenv("LIBOBJC_DUMP_GC_STATUS_ON_SIGNAL"))) + { + int s = sigNumber[0] ? (int)strtol(sigNumber, NULL, 10) : SIGUSR2; + signal(s, (void(*)(int))GC_dump); + } refcounts = refcount_create(4096); GC_clear_roots(); finalize = sel_registerName("finalize");