lib/gdbdump/cli.rb in gdbdump-0.9.3 vs lib/gdbdump/cli.rb in gdbdump-0.9.4

- old
+ new

@@ -17,10 +17,11 @@ opts = { debug: false, gdbinit: nil, gdb: nil, ruby: nil, + pid_or_core: nil, } op.on('-d', '--[no-]debug', "print debug log (default: #{opts[:debug]})") {|v| opts[:debug] = v } @@ -28,31 +29,31 @@ opts[:gdbinit] = v } op.on('--gdb PATH', "path to gdb command (default: gdb)") {|v| opts[:gdb] = v } - op.on('--ruby PATH', "path to ruby which the attached process uses (default: get from /proc/[PID]/exe)") {|v| - opts[:ruby] = v - } - op.banner += ' pid' + op.banner += ' [ pid | /path/to/ruby pid | /path/to/ruby core ]' begin args = op.parse(argv) rescue OptionParser::InvalidOption => e usage e.message end if args.size == 1 - @pid = args.first + opts[:pid_or_core] = args[0] + elsif args.size == 2 + opts[:ruby] = args[0] + opts[:pid_or_core] = args[1] else - usage 'number of arguments must be 1' + usage 'number of arguments must be 1 or 2' end @opts = opts end def run parse_options - GDB.new(pid: @pid, **(@opts)).print_backtrace + GDB.new(@opts).print_backtrace end end end