From 39365b46e250162f278cb36aa148bc2a92b1b84a Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 15 May 2020 01:22:56 +0900 Subject: Merge pull request #3047 from mame/suppress-backtrace Add `--suppress-backtrace=num` option to limit the backtrace length --- ruby.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index 901556fb86..ba515bf277 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); -- cgit v1.2.3