From 78a8cdfbe86545a1ed5c22da1ea32590e8c19d72 Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Tue, 16 Jun 2009 12:08:59 +0000 Subject: [PATCH] Added utility scripts for running oprofile in tools/oprofile. To profile running the JavaScript file test.js using the V8 release mode shell (assuming it is build passing prof=oprofile to the SCons build). The following commands can be used: $ tools/oprofile/start $ tools/oprofile/run test.js $ tools/oprofile/report | less $ tools/oprofile/annotate | less $ tools/oprofile/shutdown Here is a summary of the commands. For all the commands taking an executable the executable is expected to be a binary using V8. If no executable is specified the release mode V8 shell is assumed. By default the --session-dir=/tmp/oprofv8 is passed to all oprofile commands. This walue can be changed by setting environment variable OPROFILE_SESSION_DIR. When using the defaulf executable (V8 shell in release mode) it is assumed to be located in ../.. relative from the oprofile utility scripts. This default location can be overridden using the V8_SHELL_DIR environment variable. start ----- Start the oprofiling daemon. run [executable] [parameters] ----------------------------- Profile a V8 executable. Running this will reset oprofile samples, run the command and do an oprofile dump to flush samples and write ELF binaries for the generated code. The parameters are passed to the executable together with the --oprofile option. report [executable] [parameters] -------------------------------- Print the report for a profile run. The parameters are passed to opreport. E.g report --callgraph. annotate [executable] [parameters] ---------------------------------- Print annotated assembly for a profile run. The parameters are passed to opannotate. E.g annotate -threshold 1. reset ----- Reset oprofile samples. dump ---- Flush oprofile samples and write ELF binaries for the generated code. shutdown -------- Shutdown oprofile daemon. Added a warning which is printed if option --oprofile is passed to a V8 which has not been compiled with oprofile support. Review URL: http://codereview.chromium.org/125181 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2186 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/oprofile-agent.cc | 4 ++++ tools/oprofile/annotate | 7 +++++++ tools/oprofile/common | 19 +++++++++++++++++++ tools/oprofile/dump | 7 +++++++ tools/oprofile/report | 7 +++++++ tools/oprofile/reset | 7 +++++++ tools/oprofile/run | 14 ++++++++++++++ tools/oprofile/shutdown | 7 +++++++ tools/oprofile/start | 7 +++++++ 9 files changed, 79 insertions(+) create mode 100755 tools/oprofile/annotate create mode 100755 tools/oprofile/common create mode 100755 tools/oprofile/dump create mode 100755 tools/oprofile/report create mode 100755 tools/oprofile/reset create mode 100755 tools/oprofile/run create mode 100755 tools/oprofile/shutdown create mode 100755 tools/oprofile/start diff --git a/src/oprofile-agent.cc b/src/oprofile-agent.cc index c4595b4..8aa3937 100644 --- a/src/oprofile-agent.cc +++ b/src/oprofile-agent.cc @@ -52,6 +52,10 @@ bool OProfileAgent::Initialize() { return true; } #else + if (FLAG_oprofile) { + OS::Print("Warning: --oprofile specified but binary compiled without " + "oprofile support.\n"); + } return true; #endif } diff --git a/tools/oprofile/annotate b/tools/oprofile/annotate new file mode 100755 index 0000000..a6a8545 --- /dev/null +++ b/tools/oprofile/annotate @@ -0,0 +1,7 @@ +#!/bin/sh + +# Source common stuff. +. `cd $(dirname "$0");pwd`/common + +opannotate --assembly --session-dir="$OPROFILE_SESSION_DIR" "$shell_exec" "$@" + diff --git a/tools/oprofile/common b/tools/oprofile/common new file mode 100755 index 0000000..fd00207 --- /dev/null +++ b/tools/oprofile/common @@ -0,0 +1,19 @@ +#!/bin/sh + +# Determine the session directory to use for oprofile. +[ "$OPROFILE_SESSION_DIR" ] || OPROFILE_SESSION_DIR=/tmp/oprofv8 + +# If no executable passed as the first parameter assume V8 release mode shell. +if [[ -x $1 ]] +then + shell_exec=`readlink -f "$1"` + # Any additional parameters are for the oprofile command. + shift +else + oprofile_tools_path=`cd $(dirname "$0");pwd` + [ "$V8_SHELL_DIR" ] || V8_SHELL_DIR=$oprofile_tools_path/../.. + shell_exec=$V8_SHELL_DIR/shell +fi + +alias sudo_opcontrol='sudo opcontrol --session-dir="$OPROFILE_SESSION_DIR"' + diff --git a/tools/oprofile/dump b/tools/oprofile/dump new file mode 100755 index 0000000..17bb0a1 --- /dev/null +++ b/tools/oprofile/dump @@ -0,0 +1,7 @@ +#!/bin/sh + +# Source common stuff. +. `cd $(dirname "$0");pwd`/common + +sudo_opcontrol --dump "@$" + diff --git a/tools/oprofile/report b/tools/oprofile/report new file mode 100755 index 0000000..b7f28b9 --- /dev/null +++ b/tools/oprofile/report @@ -0,0 +1,7 @@ +#!/bin/sh + +# Source common stuff. +. `cd $(dirname "$0");pwd`/common + +opreport --symbols --session-dir="$OPROFILE_SESSION_DIR" "$shell_exec" "$@" + diff --git a/tools/oprofile/reset b/tools/oprofile/reset new file mode 100755 index 0000000..edb7071 --- /dev/null +++ b/tools/oprofile/reset @@ -0,0 +1,7 @@ +#!/bin/sh + +# Source common stuff. +. `cd $(dirname "$0");pwd`/common + +sudo_opcontrol --reset "$@" + diff --git a/tools/oprofile/run b/tools/oprofile/run new file mode 100755 index 0000000..0a92470 --- /dev/null +++ b/tools/oprofile/run @@ -0,0 +1,14 @@ +#!/bin/sh + +# Source common stuff. +. `cd $(dirname "$0");pwd`/common + +# Reset oprofile samples. +sudo_opcontrol --reset + +# Run the executable to profile with the correct arguments. +"$shell_exec" --oprofile "$@" + +# Flush oprofile data including the generated code into ELF binaries. +sudo_opcontrol --dump + diff --git a/tools/oprofile/shutdown b/tools/oprofile/shutdown new file mode 100755 index 0000000..8ebb72f --- /dev/null +++ b/tools/oprofile/shutdown @@ -0,0 +1,7 @@ +#!/bin/sh + +# Source common stuff. +. `cd $(dirname "$0");pwd`/common + +sudo_opcontrol --shutdown "$@" + diff --git a/tools/oprofile/start b/tools/oprofile/start new file mode 100755 index 0000000..059e4b8 --- /dev/null +++ b/tools/oprofile/start @@ -0,0 +1,7 @@ +#!/bin/sh + +# Source common stuff. +. `cd $(dirname "$0");pwd`/common + +sudo_opcontrol --start --no-vmlinux "$@" + -- 2.7.4