Skip to content

Clarify --walk usage #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion bin/stackprof
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parser = OptionParser.new(ARGV) do |o|
o.on('--sort-total', "Sort --text or --files output on total samples\n\n"){ options[:sort] = true }
o.on('--method [grep]', 'Zoom into specified method'){ |f| options[:format] = :method; options[:filter] = f }
o.on('--file [grep]', "Show annotated code for specified file"){ |f| options[:format] = :file; options[:filter] = f }
o.on('--walk', "Walk the stacktrace interactively\n\n"){ |f| options[:walk] = true }
o.on('--walk', "Walk the stacktrace interactively (needs --method flag)\n\n"){ |f| options[:walk] = true }
o.on('--callgrind', 'Callgrind output (use with kcachegrind, stackprof-gprof2dot.py)'){ options[:format] = :callgrind }
o.on('--graphviz', "Graphviz output (use with dot)"){ options[:format] = :graphviz }
o.on('--node-fraction [frac]', OptionParser::DecimalNumeric, 'Drop nodes representing less than [frac] fraction of samples'){ |n| options[:node_fraction] = n }
Expand Down Expand Up @@ -63,6 +63,11 @@ end
options = default_options.merge(options)
options.delete(:limit) if options[:limit] == 0

if options[:walk] && !options[:method]
STDERR.puts "Missing --method option."
exit 1
end

case options[:format]
when :text
report.print_text(options[:sort], options[:limit], options[:select_files], options[:reject_files], options[:select_names], options[:reject_names])
Expand Down
4 changes: 3 additions & 1 deletion lib/stackprof/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,9 @@ def walk_method(name)

# Pick selection
STDOUT.printf "> "
selection = STDIN.gets.chomp.to_i - 1
selection = STDIN.gets
break unless selection # EOF
selection = selection.chomp.to_i - 1
STDOUT.puts "\n\n\n"

# Determine if it was a valid choice
Expand Down