diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-16 08:39:39 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-16 08:39:39 +0000 |
commit | 955a38da08b64a1c4092f6f8cc3527ce50598092 (patch) | |
tree | 3c7fa39dce7e512385098ac98ef363e5fc63322e /error.c | |
parent | c6b599e1b60c6cd99f0276290c53d95731a26238 (diff) | |
download | ruby-955a38da08b64a1c4092f6f8cc3527ce50598092.tar.gz |
* error.c, internal.h (rb_bug_reporter_add): add a new C-API.
rb_bug_reporter_add() allows to register a function which
is called at rb_bug() called.
* ext/-test-/bug_reporter/bug_reporter.c: add a test for this C-API.
* ext/-test-/bug_reporter/extconf.rb: ditto.
* test/-ext-/bug_reporter/test_bug_reporter.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -264,6 +264,29 @@ rb_warn_m(int argc, VALUE *argv, VALUE exc) return Qnil; } +#define MAX_BUG_REPORTERS 0x100 + +static struct bug_reporters { + void (*func)(FILE *out, void *data); + void *data; +} bug_reporters[MAX_BUG_REPORTERS]; + +static int bug_reporters_size; + +int +rb_bug_reporter_add(void (*func)(FILE *, void *), void *data) +{ + struct bug_reporters *reporter; + if (bug_reporters_size >= MAX_BUG_REPORTERS) { + rb_bug("rb_bug_reporter_add: overflow"); + } + reporter = &bug_reporters[bug_reporters_size++]; + reporter->func = func; + reporter->data = data; + + return bug_reporters_size; +} + static void report_bug(const char *file, int line, const char *fmt, va_list args) { @@ -281,9 +304,16 @@ report_bug(const char *file, int line, const char *fmt, va_list args) snprintf(buf, 256, "\n%s\n\n", ruby_description); fputs(buf, out); - rb_vm_bugreport(); + /* call additional bug reporters */ + { + int i; + for (i=0; i<bug_reporters_size; i++) { + struct bug_reporters *reporter = &bug_reporters[i]; + (*reporter->func)(out, reporter->data); + } + } fprintf(out, REPORTBUG_MSG); } } |