summaryrefslogtreecommitdiffstats
path: root/tools/traceline
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 14:58:14 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 14:58:14 +0000
commitd1d12f3e73ab60a2bea0ad380cc227dbd165c3a6 (patch)
tree624f8fdf965cf0b25b2cbcbdbf28b610db34b897 /tools/traceline
parent101f7fa7fa30edd654c53268d000d53364d680bd (diff)
downloadchromium_src-d1d12f3e73ab60a2bea0ad380cc227dbd165c3a6.zip
chromium_src-d1d12f3e73ab60a2bea0ad380cc227dbd165c3a6.tar.gz
chromium_src-d1d12f3e73ab60a2bea0ad380cc227dbd165c3a6.tar.bz2
Some improvements and bug fixes to traceline.
SVG UI: - Fix some TODOs about clipping SVG objects to the scene. This fixes bugs where a rectangle is too large and not displayed at all. - Fix the calculation of the thread endms done time. This fixes the thread gray background not being drawn for the full length of the thread. Traceline tracer: - Enable PatchCreateThread on XP. This fixes not having the thread creation information output in the JSON files on XP. Still doesn't work on Vista. - Print the manual-quit message to stderr, so it doesn't end up in the JSON. - Cast a symbol API callback to compile with both older and newer SDKs. - Add two small scripts for breaking apart large JSON files into smaller pieces, so that the Python tools can handle processing the smaller files. Review URL: http://codereview.chromium.org/118377 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/traceline')
-rw-r--r--tools/traceline/svgui/traceline.js23
-rw-r--r--tools/traceline/traceline/main.cc7
-rw-r--r--tools/traceline/traceline/scripts/filter_split.sh15
-rwxr-xr-xtools/traceline/traceline/scripts/split.py25
-rw-r--r--tools/traceline/traceline/sym_resolver.h6
5 files changed, 65 insertions, 11 deletions
diff --git a/tools/traceline/svgui/traceline.js b/tools/traceline/svgui/traceline.js
index c804f1f..5461040 100644
--- a/tools/traceline/svgui/traceline.js
+++ b/tools/traceline/svgui/traceline.js
@@ -76,6 +76,7 @@ function TLEvent(e) {
this.thread = toHex(e['thread']);
this.cpu = toHex(e['cpu']);
this.ms = e['ms'];
+ this.done = e['done'];
this.e = e;
}
@@ -240,7 +241,8 @@ function(json_data) {
// If this is the first event ever seen on this thread, create a new
// thread object and add it to our lists of threads.
if (!(e.thread in this.threads_by_id)) {
- var new_thread = new TLThread(e.thread, e.ms, e.ms);
+ var end_ms = e.done ? e.done : e.ms;
+ var new_thread = new TLThread(e.thread, e.ms, end_ms);
this.threads_by_id[new_thread.id] = this.threads.length;
this.threads.push(new_thread);
}
@@ -249,8 +251,9 @@ function(json_data) {
thread.AddEvent(e);
// Keep trace of the time of the last event seen.
- if (e.ms > this.endms) this.endms = e.ms;
- if (e.ms > thread.endms) thread.endms = e.ms;
+ var end_ms = e.done ? e.done : e.ms;
+ if (end_ms > this.endms) this.endms = end_ms;
+ if (end_ms > thread.endms) thread.endms = end_ms;
switch(e.eventtype) {
case 'EVENT_TYPE_THREADNAME':
@@ -640,8 +643,17 @@ function(dom, scene, startms, curzoom) {
var dur = this.kTimelineWidthPx / curzoom;
+ function min(a, b) {
+ return a < b ? a : b;
+ }
+
+ function max(a, b) {
+ return a > b ? a : b;
+ }
+
function timeToPixel(x) {
- var x = Math.floor(x*curzoom);
+ // TODO(deanm): This clip is a bit shady.
+ var x = min(max(Math.floor(x*curzoom), -100), 2000);
return (x == 0 ? 1 : x);
}
@@ -654,10 +666,8 @@ function(dom, scene, startms, curzoom) {
if (thing.type == SVGSceneRect) {
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
rect.setAttributeNS(null, 'class', thing.klass)
- // TODO timeToPixel could be negative, clamp it at 0
rect.setAttributeNS(null, 'x', timeToPixel(thing.x - startms));
rect.setAttributeNS(null, 'y', thing.y);
- // TODO thing.width can be larger than our current view, clamp it.
rect.setAttributeNS(null, 'width', timeToPixel(thing.width));
rect.setAttributeNS(null, 'height', thing.height);
rect.msg = thing.msg;
@@ -665,7 +675,6 @@ function(dom, scene, startms, curzoom) {
} else if (thing.type == SVGSceneLine) {
var line = document.createElementNS('http://www.w3.org/2000/svg', 'line');
line.setAttributeNS(null, 'class', thing.klass)
- // TODO timeToPixel could be negative, clamp it at 0
line.setAttributeNS(null, 'x1', timeToPixel(thing.x1 - startms));
line.setAttributeNS(null, 'y1', thing.y1);
line.setAttributeNS(null, 'x2', timeToPixel(thing.x2 - startms));
diff --git a/tools/traceline/traceline/main.cc b/tools/traceline/traceline/main.cc
index 997a428..97085eb 100644
--- a/tools/traceline/traceline/main.cc
+++ b/tools/traceline/traceline/main.cc
@@ -990,11 +990,11 @@ class Playground {
void Patch() {
- //PatchCreateThread();
-
if (options_.vista()) {
+ // TODO(deanm): Make PatchCreateThread work on Vista.
PatchThreadBeginVista();
} else {
+ PatchCreateThread();
PatchThreadBegin();
}
@@ -1309,7 +1309,8 @@ int main(int argc, char** argv) {
// Wait until we have been notified that it's exiting.
if (manual_quit) {
- printf("Press enter when you want to collect.\n");
+ fprintf(stderr, "Press enter when you want stop tracing and collect.\n");
+ fflush(stderr);
getchar();
} else {
HANDLE whs[] = {exiting, info.hProcess};
diff --git a/tools/traceline/traceline/scripts/filter_split.sh b/tools/traceline/traceline/scripts/filter_split.sh
new file mode 100644
index 0000000..19a2891
--- /dev/null
+++ b/tools/traceline/traceline/scripts/filter_split.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Runs filter_short on the individual splits of a json file, and puts
+# everything back together into a single output json. This is useful when you
+# want to filter a large json file that would otherwise OOM Python.
+
+echo "parseEvents([" > totalsplit
+for f in split.*; do
+ python scripts/filter_short.py "$f" | tail -n +2 | head -n -1 >> totalsplit
+done
+echo "]);" >> totalsplit
diff --git a/tools/traceline/traceline/scripts/split.py b/tools/traceline/traceline/scripts/split.py
new file mode 100755
index 0000000..9e9f7dd
--- /dev/null
+++ b/tools/traceline/traceline/scripts/split.py
@@ -0,0 +1,25 @@
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Splits a single json file (read from stdin) into separate files of 40k
+# records, named split.X.
+
+import sys
+
+filecount = 0;
+count = 0;
+
+f = open('split.0', 'wb');
+
+for l in sys.stdin:
+ if l == "},\r\n":
+ count += 1
+ if count == 40000:
+ f.write("}]);\r\n")
+ count = 0;
+ filecount += 1
+ f = open('split.%d' % filecount, 'wb');
+ f.write("parseEvents([\r\n")
+ continue
+ f.write(l)
diff --git a/tools/traceline/traceline/sym_resolver.h b/tools/traceline/traceline/sym_resolver.h
index c3d93c2..eb7e06c 100644
--- a/tools/traceline/traceline/sym_resolver.h
+++ b/tools/traceline/traceline/sym_resolver.h
@@ -61,7 +61,11 @@ class SymResolver {
// The name returned from SymEnumerateModules64 doesn't include the ext,
// so we can't differentiate between a dll and exe of the same name. So
// collect all of the base addresses and query for more info.
- if (SymEnumerateModules64(proc_, &SymEnumer, &bases) != TRUE) {
+ // The prototype changed from PSTR to PCSTR, so in order to support older
+ // SDKs we have to cast SymEnumer.
+ PSYM_ENUMMODULES_CALLBACK64 enumer =
+ reinterpret_cast<PSYM_ENUMMODULES_CALLBACK64>(&SymEnumer);
+ if (SymEnumerateModules64(proc_, enumer, &bases) != TRUE) {
NOTREACHED("SymEnumerateModules64 failed: %d\n", GetLastError());
}
for (size_t i = 0; i < bases.size(); ++i) {