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

Side by Side Diff: pkg/stack_trace/lib/src/trace.dart

Issue 23133004: Support "..." VM frames in pkg/stack_trace. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « pkg/stack_trace/lib/src/frame.dart ('k') | pkg/stack_trace/test/frame_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library trace; 5 library trace;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'frame.dart'; 10 import 'frame.dart';
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 factory Trace.from(StackTrace trace) { 65 factory Trace.from(StackTrace trace) {
66 if (trace is Trace) return trace; 66 if (trace is Trace) return trace;
67 return new LazyTrace(() => new Trace.parse(trace.toString())); 67 return new LazyTrace(() => new Trace.parse(trace.toString()));
68 } 68 }
69 69
70 /// Parses a string representation of a stack trace. 70 /// Parses a string representation of a stack trace.
71 /// 71 ///
72 /// [trace] should be formatted in the same way as a Dart VM or browser stack 72 /// [trace] should be formatted in the same way as a Dart VM or browser stack
73 /// trace. 73 /// trace.
74 factory Trace.parse(String trace) { 74 factory Trace.parse(String trace) {
75 if (trace.isEmpty) return new Trace(<Frame>[]); 75 try {
76 if (trace.startsWith("Error\n")) return new Trace.parseV8(trace); 76 if (trace.isEmpty) return new Trace(<Frame>[]);
77 if (trace.contains(_firefoxTrace)) return new Trace.parseFirefox(trace); 77 if (trace.startsWith("Error\n")) return new Trace.parseV8(trace);
78 if (trace.contains(_friendlyTrace)) return new Trace.parseFriendly(trace); 78 if (trace.contains(_firefoxTrace)) return new Trace.parseFirefox(trace);
79 if (trace.contains(_friendlyTrace)) return new Trace.parseFriendly(trace);
79 80
80 // Default to parsing the stack trace as a VM trace. This is also hit on IE 81 // Default to parsing the stack trace as a VM trace. This is also hit on
81 // and Safari, where the stack trace is just an empty string (issue 11257). 82 // IE and Safari, where the stack trace is just an empty string (issue
82 return new Trace.parseVM(trace); 83 // 11257).
84 return new Trace.parseVM(trace);
85 } on FormatException catch (error) {
86 throw new FormatException('${error.message}\nStack trace:\n$trace');
87 }
83 } 88 }
84 89
85 /// Parses a string representation of a Dart VM stack trace. 90 /// Parses a string representation of a Dart VM stack trace.
86 Trace.parseVM(String trace) 91 Trace.parseVM(String trace)
87 : this(trace.trim().split("\n").map((line) => new Frame.parseVM(line))); 92 : this(trace.trim().split("\n").map((line) => new Frame.parseVM(line)));
88 93
89 /// Parses a string representation of a Chrome/V8 stack trace. 94 /// Parses a string representation of a Chrome/V8 stack trace.
90 Trace.parseV8(String trace) 95 Trace.parseV8(String trace)
91 : this(trace.split("\n").skip(1).map((line) => new Frame.parseV8(line))); 96 : this(trace.split("\n").skip(1).map((line) => new Frame.parseV8(line)));
92 97
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Figure out the longest path so we know how much to pad. 155 // Figure out the longest path so we know how much to pad.
151 var longest = frames.map((frame) => frame.location.length) 156 var longest = frames.map((frame) => frame.location.length)
152 .fold(0, math.max); 157 .fold(0, math.max);
153 158
154 // Print out the stack trace nicely formatted. 159 // Print out the stack trace nicely formatted.
155 return frames.map((frame) { 160 return frames.map((frame) {
156 return '${padRight(frame.location, longest)} ${frame.member}\n'; 161 return '${padRight(frame.location, longest)} ${frame.member}\n';
157 }).join(); 162 }).join();
158 } 163 }
159 } 164 }
OLDNEW
« no previous file with comments | « pkg/stack_trace/lib/src/frame.dart ('k') | pkg/stack_trace/test/frame_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698