From d1acd1bea9bc2735b53ac68fa98891cab8c71d02 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Fri, 29 Jan 2016 19:59:06 -0800 Subject: [PATCH] Pass retain and exclude parameters to /pprof/symbol. Pass the retain and exclude parameters to the /pprof/symbol pprof server endpoint so that the server has the opportunity to optimize which symbols it looks up and/or returns mappings for. --- bin/jeprof.in | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bin/jeprof.in b/bin/jeprof.in index dfd9195e..42087fce 100644 --- a/bin/jeprof.in +++ b/bin/jeprof.in @@ -3385,6 +3385,27 @@ sub ReadSymbols { return $map; } +sub URLEncode { + my $str = shift; + $str =~ s/([^A-Za-z0-9\-_.!~*'()])/ sprintf "%%%02x", ord $1 /eg; + return $str; +} + +sub AppendSymbolFilterParams { + my $url = shift; + my @params = (); + if ($main::opt_retain ne '') { + push(@params, sprintf("retain=%s", URLEncode($main::opt_retain))); + } + if ($main::opt_exclude ne '') { + push(@params, sprintf("exclude=%s", URLEncode($main::opt_exclude))); + } + if (scalar @params > 0) { + $url = sprintf("%s?%s", $url, join("&", @params)); + } + return $url; +} + # Fetches and processes symbols to prepare them for use in the profile output # code. If the optional 'symbol_map' arg is not given, fetches symbols from # $SYMBOL_PAGE for all PC values found in profile. Otherwise, the raw symbols @@ -3409,9 +3430,11 @@ sub FetchSymbols { my $command_line; if (join(" ", @URL_FETCHER) =~ m/\bcurl -s/) { $url = ResolveRedirectionForCurl($url); + $url = AppendSymbolFilterParams($url); $command_line = ShellEscape(@URL_FETCHER, "-d", "\@$main::tmpfile_sym", $url); } else { + $url = AppendSymbolFilterParams($url); $command_line = (ShellEscape(@URL_FETCHER, "--post", $url) . " < " . ShellEscape($main::tmpfile_sym)); }