Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: tests/standalone/dwarf_stack_trace_test.dart

Issue 2762313003: Dwarf tools interpret line number table pc's as start boundries instead of end boundries. (Closed)
Patch Set: test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/dwarf_stack_trace_test.dart
diff --git a/tests/standalone/dwarf_stack_trace_test.dart b/tests/standalone/dwarf_stack_trace_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c9ff78b65ecd855e19fffdf786ff34e19c78540e
--- /dev/null
+++ b/tests/standalone/dwarf_stack_trace_test.dart
@@ -0,0 +1,92 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// VMOptions=--dwarf-stack-traces
+
+import 'package:unittest/unittest.dart';
+import 'dart:io';
+
+bar() {
+ // Keep the 'throw' and its argument on separate lines.
+ throw
+ "Hello, Dwarf!";
+}
+
+foo() {
+ bar();
+}
+
+main() {
+ String rawStack;
+ try {
+ foo();
+ } catch (e, st) {
+ rawStack = st.toString();
+ }
+ print(rawStack);
+
+ if (Platform.isAndroid) {
+ // Attempts to execute 'file' etc fail with security exceptions on
+ // Android.
+ print("Skipping test on Android");
+ return;
+ }
+
+ ProcessResult result = Process.runSync("file", ["--version"]);
+ if (result.exitCode != 0) {
+ print("Skipping test because 'file' is not present");
Cutch 2017/03/22 14:04:37 you should fail here and update the status file ac
+ return;
+ }
+
+ result = Process.runSync("addr2line", ["--version"]);
+ if (result.exitCode != 0) {
+ print("Skipping test because 'addr2line' is not present");
Cutch 2017/03/22 14:04:37 you should fail here and update the status file ac
+ return;
+ }
+
+ result = Process.runSync("file", [Platform.script.toFilePath()]);
+ if (result.exitCode != 0) {
+ print(result.stdout);
+ print(result.stderr);
+ throw "'file' failed";
+ return;
+ }
+ if (!result.stdout.contains("shared object")) {
+ print("Skipping test because we are not running from a dylib");
Cutch 2017/03/22 14:04:37 you should fail here and update the status file ac
+ return;
+ }
+
+ var frameRegex = new RegExp("pc ([0-9a-z]+) ([0-9a-zA-Z/\._]+)");
+ var symbolizedStack = new StringBuffer();
+ for (var frameMatch in frameRegex.allMatches(rawStack)) {
+ var framePC = frameMatch[1];
+ var frameDSO = frameMatch[2];
+ print(framePC);
+ print(frameDSO);
+ result = Process.runSync("addr2line",
+ ["--exe", frameDSO,
+ "--functions",
+ "--inlines",
+ framePC]);
+ if (result.exitCode != 0) {
+ print(result.stdout);
+ print(result.stderr);
+ throw "'addr2line' failed";
+ }
+ print(result.stdout);
+ symbolizedStack.write(result.stdout);
+ }
+
+ print(symbolizedStack);
+ var symbolizedLines = symbolizedStack.toString().split("\n");
Cutch 2017/03/22 14:04:37 use stringContainsInOrder expect(symbolizedStack.
rmacnak 2017/03/22 17:28:15 Done.
+ expect(symbolizedLines.length, greaterThan(8));
+ expect(symbolizedLines[0], equals("bar"));
+ expect(symbolizedLines[1], endsWith("dwarf_stack_trace_test.dart:12"));
+ expect(symbolizedLines[2], equals("foo"));
+ expect(symbolizedLines[3], endsWith("dwarf_stack_trace_test.dart:17"));
+ expect(symbolizedLines[4], equals("main"));
+ expect(symbolizedLines[5], endsWith("dwarf_stack_trace_test.dart:23"));
+ expect(symbolizedLines[6], equals("main")); // dispatcher
+ expect(symbolizedLines[7], endsWith("dwarf_stack_trace_test.dart:20"));
+}
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698