summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2020-05-15 01:22:56 +0900
committerGitHub <noreply@github.com>2020-05-15 01:22:56 +0900
commit39365b46e250162f278cb36aa148bc2a92b1b84a (patch)
tree4eb62c6d4143dd0bd095a8f6c0cd5b89f7a59a7f /ruby.c
parent531e4a35f4c9c772aae331281cad324c6806c603 (diff)
Merge pull request #3047 from mame/suppress-backtrace
Add `--suppress-backtrace=num` option to limit the backtrace length
Notes
Notes: Merged-By: mame <mame@ruby-lang.org>
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ruby.c b/ruby.c
index 901556f..ba515bf 100644
--- a/ruby.c
+++ b/ruby.c
@@ -309,6 +309,7 @@ usage(const char *name, int help, int highlight, int columns)
M("--verbose", "", "turn on verbose mode and disable script from stdin"),
M("--version", "", "print the version number, then exit"),
M("--help", "", "show this message, -h for short message"),
+ M("--backtrace-limit=num", "", "limit the maximum length of backtrace"),
};
static const struct message dumps[] = {
M("insns", "", "instruction sequences"),
@@ -1423,6 +1424,12 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
opt->dump |= DUMP_BIT(help);
goto switch_end;
}
+ else if (is_option_with_arg("backtrace-limit", Qfalse, Qfalse)) {
+ char *e;
+ long n = strtol(s, &e, 10);
+ if (errno == ERANGE || n < 0 || *e) rb_raise(rb_eRuntimeError, "wrong limit for backtrace length");
+ rb_backtrace_length_limit = n;
+ }
else {
rb_raise(rb_eRuntimeError,
"invalid option --%s (-h will show valid options)", s);