Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 'chain.dart'; | 10 import 'chain.dart'; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 // IE and Safari, where the stack trace is just an empty string (issue | 119 // IE and Safari, where the stack trace is just an empty string (issue |
| 120 // 11257). | 120 // 11257). |
| 121 return new Trace.parseVM(trace); | 121 return new Trace.parseVM(trace); |
| 122 } on FormatException catch (error) { | 122 } on FormatException catch (error) { |
| 123 throw new FormatException('${error.message}\nStack trace:\n$trace'); | 123 throw new FormatException('${error.message}\nStack trace:\n$trace'); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 /// Parses a string representation of a Dart VM stack trace. | 127 /// Parses a string representation of a Dart VM stack trace. |
| 128 Trace.parseVM(String trace) | 128 Trace.parseVM(String trace) |
| 129 : this(trace.trim().split("\n").map((line) => new Frame.parseVM(line))); | 129 : this(trace.trim().split("\n"). |
| 130 // TODO(nweiz): remove this when issue 15920 is fixed. | |
| 131 where((line) => line.isNotEmpty). | |
|
Bob Nystrom
2014/01/06 21:42:49
Should you trim the line first in case it contains
nweiz
2014/01/06 23:59:27
I'm pretty sure that in practice the blank lines p
| |
| 132 map((line) => new Frame.parseVM(line))); | |
| 130 | 133 |
| 131 /// Parses a string representation of a Chrome/V8 stack trace. | 134 /// Parses a string representation of a Chrome/V8 stack trace. |
| 132 Trace.parseV8(String trace) | 135 Trace.parseV8(String trace) |
| 133 : this(trace.split("\n").skip(1) | 136 : this(trace.split("\n").skip(1) |
| 134 // It's possible that an Exception's description contains a line that | 137 // It's possible that an Exception's description contains a line that |
| 135 // looks like a V8 trace line, which will screw this up. | 138 // looks like a V8 trace line, which will screw this up. |
| 136 // Unfortunately, that's impossible to detect. | 139 // Unfortunately, that's impossible to detect. |
| 137 .skipWhile((line) => !line.startsWith(_v8TraceLine)) | 140 .skipWhile((line) => !line.startsWith(_v8TraceLine)) |
| 138 .map((line) => new Frame.parseV8(line))); | 141 .map((line) => new Frame.parseV8(line))); |
| 139 | 142 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 // Figure out the longest path so we know how much to pad. | 240 // Figure out the longest path so we know how much to pad. |
| 238 var longest = frames.map((frame) => frame.location.length) | 241 var longest = frames.map((frame) => frame.location.length) |
| 239 .fold(0, math.max); | 242 .fold(0, math.max); |
| 240 | 243 |
| 241 // Print out the stack trace nicely formatted. | 244 // Print out the stack trace nicely formatted. |
| 242 return frames.map((frame) { | 245 return frames.map((frame) { |
| 243 return '${padRight(frame.location, longest)} ${frame.member}\n'; | 246 return '${padRight(frame.location, longest)} ${frame.member}\n'; |
| 244 }).join(); | 247 }).join(); |
| 245 } | 248 } |
| 246 } | 249 } |
| OLD | NEW |