diff options
Diffstat (limited to 'src/cmd/prof')
-rw-r--r-- | src/cmd/prof/Makefile | 24 | ||||
-rwxr-xr-x | src/cmd/prof/gopprof | 41 | ||||
-rw-r--r-- | src/cmd/prof/main.c | 37 |
3 files changed, 58 insertions, 44 deletions
diff --git a/src/cmd/prof/Makefile b/src/cmd/prof/Makefile index 602c07da6..e643f267c 100644 --- a/src/cmd/prof/Makefile +++ b/src/cmd/prof/Makefile @@ -2,7 +2,8 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -include ../../Make.conf +include ../../Make.inc +O:=$(HOST_O) # The directory is prof because the source is portable and general. # We call the binary 6prof to avoid confusion and because this binary @@ -12,19 +13,22 @@ TARG=6prof OFILES=\ main.$O\ -#HFILES=\ -# defs.h\ -# fns.h\ +LIB=\ + ../../../lib/libmach.a\ -$(TARG): $(OFILES) - $(LD) -o $(TARG) -L"$(GOROOT)"/lib $(OFILES) -lmach -lbio -l9 +NOINSTALL=1 +include ../../Make.ccmd -clean: - rm -f *.$O $(TARG) +ifeq ($(GOOS),windows) +NAME=windows +else +NAME=$(shell uname | tr A-Z a-z) +endif -install: install-$(shell uname | tr A-Z a-z) install-pprof +install: install-$(NAME) install-pprof install-linux: install-default install-freebsd: install-default +install-windows: install-default # on Darwin, have to install and setgid; see $GOROOT/src/sudo.bash install-darwin: $(TARG) @@ -33,7 +37,5 @@ install-darwin: $(TARG) install-default: $(TARG) cp $(TARG) "$(GOBIN)"/$(TARG) -$(OFILES): $(HFILES) - install-pprof: gopprof cp gopprof "$(GOBIN)"/gopprof diff --git a/src/cmd/prof/gopprof b/src/cmd/prof/gopprof index dffeeffa1..4bcfa5800 100755 --- a/src/cmd/prof/gopprof +++ b/src/cmd/prof/gopprof @@ -2736,6 +2736,7 @@ sub IsSymbolizedProfileFile { sub CheckSymbolPage { my $url = SymbolPageURL(); +print STDERR "Read $url\n"; open(SYMBOL, "$CURL -s '$url' |"); my $line = <SYMBOL>; $line =~ s/\r//g; # turn windows-looking lines into unix-looking lines @@ -2816,7 +2817,7 @@ sub ResolveRedirectionForCurl { # $main::prog to have the correct program name. sub ReadSymbols { my $in = shift; - my $map = {}; + my $map = shift; while (<$in>) { s/\r//g; # turn windows-looking lines into unix-looking lines # Removes all the leading zeroes from the symbols, see comment below. @@ -2858,20 +2859,30 @@ sub FetchSymbols { my @pcs = grep { !$seen{$_}++ } keys(%$pcset); # uniq if (!defined($symbol_map)) { - my $post_data = join("+", sort((map {"0x" . "$_"} @pcs))); - - open(POSTFILE, ">$main::tmpfile_sym"); - print POSTFILE $post_data; - close(POSTFILE); - - my $url = SymbolPageURL(); - $url = ResolveRedirectionForCurl($url); - my $command_line = "$CURL -sd '\@$main::tmpfile_sym' '$url'"; - # We use c++filt in case $SYMBOL_PAGE gives us mangled symbols. - my $cppfilt = $obj_tool_map{"c++filt"}; - open(SYMBOL, "$command_line | $cppfilt |") or error($command_line); - $symbol_map = ReadSymbols(*SYMBOL{IO}); - close(SYMBOL); + $symbol_map = {}; + my @toask = @pcs; + while (@toask > 0) { + my $n = @toask; + if ($n > 49) { $n = 49; } + my @thisround = @toask[0..$n]; +my $t = @toask; +print STDERR "$n $t\n"; + @toask = @toask[($n+1)..(@toask-1)]; + my $post_data = join("+", sort((map {"0x" . "$_"} @thisround))); + open(POSTFILE, ">$main::tmpfile_sym"); + print POSTFILE $post_data; + close(POSTFILE); + +print STDERR "SYMBL!\n"; + my $url = SymbolPageURL(); + $url = ResolveRedirectionForCurl($url); + my $command_line = "$CURL -sd '\@$main::tmpfile_sym' '$url'"; + # We use c++filt in case $SYMBOL_PAGE gives us mangled symbols. + my $cppfilt = $obj_tool_map{"c++filt"}; + open(SYMBOL, "$command_line | $cppfilt |") or error($command_line); + ReadSymbols(*SYMBOL{IO}, $symbol_map); + close(SYMBOL); + } } my $symbols = {}; diff --git a/src/cmd/prof/main.c b/src/cmd/prof/main.c index 2bb67f596..f36759cd3 100644 --- a/src/cmd/prof/main.c +++ b/src/cmd/prof/main.c @@ -53,9 +53,10 @@ Map *map[32]; // thread maps void Usage(void) { - fprint(2, "Usage: prof -p pid [-t total_secs] [-d delta_msec] [6.out args ...]\n"); + fprint(2, "Usage: prof -p pid [-t total_secs] [-d delta_msec]\n"); + fprint(2, " prof [-t total_secs] [-d delta_msec] 6.out args ...\n"); fprint(2, "\tformats (default -h):\n"); - fprint(2, "\t\t-c file.prof: write [c]pprof output to file.prof\n"); + fprint(2, "\t\t-P file.prof: write [c]pprof output to file.prof\n"); fprint(2, "\t\t-h: histograms\n"); fprint(2, "\t\t-f: dynamic functions\n"); fprint(2, "\t\t-l: dynamic file and line numbers\n"); @@ -192,22 +193,22 @@ amd64_ppword(uvlong w) void x86_regprint(void) { - fprint(2, "ax\t0x%llux\n", ureg_x86.ax); - fprint(2, "bx\t0x%llux\n", ureg_x86.bx); - fprint(2, "cx\t0x%llux\n", ureg_x86.cx); - fprint(2, "dx\t0x%llux\n", ureg_x86.dx); - fprint(2, "si\t0x%llux\n", ureg_x86.si); - fprint(2, "di\t0x%llux\n", ureg_x86.di); - fprint(2, "bp\t0x%llux\n", ureg_x86.bp); - fprint(2, "ds\t0x%llux\n", ureg_x86.ds); - fprint(2, "es\t0x%llux\n", ureg_x86.es); - fprint(2, "fs\t0x%llux\n", ureg_x86.fs); - fprint(2, "gs\t0x%llux\n", ureg_x86.gs); - fprint(2, "cs\t0x%llux\n", ureg_x86.cs); - fprint(2, "flags\t0x%llux\n", ureg_x86.flags); - fprint(2, "pc\t0x%llux\n", ureg_x86.pc); - fprint(2, "sp\t0x%llux\n", ureg_x86.sp); - fprint(2, "ss\t0x%llux\n", ureg_x86.ss); + fprint(2, "ax\t0x%ux\n", ureg_x86.ax); + fprint(2, "bx\t0x%ux\n", ureg_x86.bx); + fprint(2, "cx\t0x%ux\n", ureg_x86.cx); + fprint(2, "dx\t0x%ux\n", ureg_x86.dx); + fprint(2, "si\t0x%ux\n", ureg_x86.si); + fprint(2, "di\t0x%ux\n", ureg_x86.di); + fprint(2, "bp\t0x%ux\n", ureg_x86.bp); + fprint(2, "ds\t0x%ux\n", ureg_x86.ds); + fprint(2, "es\t0x%ux\n", ureg_x86.es); + fprint(2, "fs\t0x%ux\n", ureg_x86.fs); + fprint(2, "gs\t0x%ux\n", ureg_x86.gs); + fprint(2, "cs\t0x%ux\n", ureg_x86.cs); + fprint(2, "flags\t0x%ux\n", ureg_x86.flags); + fprint(2, "pc\t0x%ux\n", ureg_x86.pc); + fprint(2, "sp\t0x%ux\n", ureg_x86.sp); + fprint(2, "ss\t0x%ux\n", ureg_x86.ss); } int |