From afec5b915f91a233f37047c29de9531be001778a Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Mon, 22 Feb 2010 15:33:08 -0800 Subject: [PATCH] Minor bug fix/enhancement for OProfile post-processing tools. 1) Display samples collected in the code cache into dalvik-jit-code-cache. 2) Tolerate phantom event on counter 3 when it is not configured. --- daemon/opd_events.c | 11 +++++++++++ opcontrol/opcontrol.cpp | 3 ++- opimport_pull | 21 ++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/daemon/opd_events.c b/daemon/opd_events.c index b544fb3..fa017e4 100644 --- a/daemon/opd_events.c +++ b/daemon/opd_events.c @@ -142,8 +142,19 @@ struct opd_event * find_counter_event(unsigned long counter) } fprintf(stderr, "Unknown event for counter %lu\n", counter); + /* + * ANDROID FIXME - from time to time there seems to be 1 phantom event + * reported from counter 3 when only counter 0 is enabled. Instead of + * crashing the daemon and losing tons of useful samples, we just + * charge the erroneous single count to the first event. + */ +#ifdef ANDROID + return &opd_events[0]; +#else abort(); return NULL; + +#endif } diff --git a/opcontrol/opcontrol.cpp b/opcontrol/opcontrol.cpp index 2558760..5dffe24 100644 --- a/opcontrol/opcontrol.cpp +++ b/opcontrol/opcontrol.cpp @@ -45,7 +45,7 @@ int min_count[MAX_EVENTS] = {150000, 200000, 250000}; #else #define MAX_EVENTS 5 -int min_count[MAX_EVENTS] = {150000, 200000, 250000, 300000, 350000}; +int min_count[MAX_EVENTS] = {150000, 20000, 25000, 30000, 35000}; #endif int list_events; @@ -665,6 +665,7 @@ int main(int argc, char * const argv[]) } if (stop) { + echo_dev("1", 0, "dump", -1); echo_dev("0", 0, "enable", -1); } } diff --git a/opimport_pull b/opimport_pull index e61d3e5..ed820f0 100755 --- a/opimport_pull +++ b/opimport_pull @@ -71,7 +71,24 @@ if result != 0: # enter the destination directory os.chdir(output_dir) -stream = os.popen("find raw_samples -type f -name \*all") + +# We need to replace the " (deleted)" part in the directory names if +# the region is allocated through ashmem. The post-processing tool doesn't like +# space and parentheses. +# Rename each individual directory from the longest first +# For example, first rename +# raw_samples/current/{root}/dev/ashmem/dalvik-jit-code-cache (deleted)/{dep}/{root}/dev/ashmem/dalvik-jit-code-cache (deleted) +# to +# raw_samples/current/{root}/dev/ashmem/dalvik-jit-code-cache (deleted)/{dep}/{root}/dev/ashmem/dalvik-jit-code-cache +# then to +# raw_samples/current/{root}/dev/ashmem/dalvik-jit-code-cache/{dep}/{root}/dev/ashmem/dalvik-jit-code-cache +deleted_pattern = re.compile(" \(deleted\)$"); +stream = os.popen("find raw_samples -type d -name \*\ \(deleted\)\* | sort -r") +for line in stream: + line = line.rstrip() + new_dir = deleted_pattern.sub("", line) + cmd = "mv " + "\"" + line + "\" \"" + new_dir + "\"" + os.system(cmd) # now all the sample files are on the host, we need to invoke opimport one at a # time to convert the content from the ARM abi to x86 ABI @@ -81,6 +98,8 @@ stream = os.popen("find raw_samples -type f -name \*all") # 2: intermediate dirs: "/blah/blah/blah" # 3: filename: e.g. "CPU_CYCLES.150000.0.all.all.all" pattern = re.compile("(^raw_samples)(.*)/(.*)$") + +stream = os.popen("find raw_samples -type f -name \*all") for line in stream: match = pattern.search(line) leading_dir = match.group(1)