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

Side by Side 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: . 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 /// VMOptions=--dwarf-stack-traces
6
7 import 'package:unittest/unittest.dart';
8 import 'dart:io';
9
10 bar() {
11 // Keep the 'throw' and its argument on separate lines.
12 throw
13 "Hello, Dwarf!";
14 }
15
16 foo() {
17 bar();
18 }
19
20 main() {
21 String rawStack;
22 try {
23 foo();
24 } catch (e, st) {
25 rawStack = st.toString();
26 }
27 print(rawStack);
28
29 if (Platform.isAndroid) {
30 // Attempts to execute 'file' etc fail with security exceptions on
31 // Android.
32 print("Skipping test on Android");
33 return;
34 }
35
36 if (Platform.isMacOS) {
37 // addr2line is not part of the XCode command line tools.
38 print("Skipping test on MacOS");
39 return;
40 }
41
42 if (Platform.isWindows) {
43 // Lacks 'file' and 'addr2line'.
44 print("Skipping test on Windows");
45 return;
46 }
47
48 ProcessResult result = Process.runSync("file", ["--version"]);
49 if (result.exitCode != 0) {
50 print(result.stdout);
51 print(result.stderr);
52 throw "'file' is not present";
53 }
54
55 result = Process.runSync("addr2line", ["--version"]);
56 if (result.exitCode != 0) {
57 print(result.stdout);
58 print(result.stderr);
59 throw "'addr2line' is not present";
60 }
61
62 result = Process.runSync("file", [Platform.script.toFilePath()]);
63 if (result.exitCode != 0) {
64 print(result.stdout);
65 print(result.stderr);
66 throw "'file' failed";
67 return;
68 }
69 if (!result.stdout.contains("shared object")) {
70 print("Skipping test because we are not running from a dylib");
71 return;
72 }
73
74 var frameRegex = new RegExp("pc ([0-9a-z]+) ([0-9a-zA-Z/\._]+)");
75 var symbolizedStack = new StringBuffer();
76 for (var frameMatch in frameRegex.allMatches(rawStack)) {
77 var framePC = frameMatch[1];
78 var frameDSO = frameMatch[2];
79 print(framePC);
80 print(frameDSO);
81 result = Process.runSync("addr2line",
82 ["--exe", frameDSO,
83 "--functions",
84 "--inlines",
85 framePC]);
86 if (result.exitCode != 0) {
87 print(result.stdout);
88 print(result.stderr);
89 throw "'addr2line' failed";
90 }
91 print(result.stdout);
92 symbolizedStack.write(result.stdout);
93 }
94
95 print(symbolizedStack);
96 var symbolizedLines = symbolizedStack.toString().split("\n");
97 expect(symbolizedLines.length, greaterThan(8));
98 expect(symbolizedStack.toString(),
99 stringContainsInOrder(["bar",
100 "dwarf_stack_trace_test.dart:12",
101 "foo",
102 "dwarf_stack_trace_test.dart:17",
103 "main",
104 "dwarf_stack_trace_test.dart:23",
105 "main", // dispatcher
106 "dwarf_stack_trace_test.dart:20"]));
107 }
OLDNEW
« 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