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 import 'package:path/path.dart' as path; | 5 import 'package:path/path.dart' as path; |
6 | 6 |
7 import 'trace.dart'; | 7 import 'trace.dart'; |
8 import 'unparsed_frame.dart'; | 8 import 'unparsed_frame.dart'; |
9 | 9 |
10 // #1 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21) | 10 // #1 Foo._bar (file:///home/nweiz/code/stuff.dart:42:21) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 r'@' | 45 r'@' |
46 r')?' | 46 r')?' |
47 r'(.*?)' // The frame's URL. | 47 r'(.*?)' // The frame's URL. |
48 r':' | 48 r':' |
49 r'(\d*)' // The line number. Empty in Safari if it's unknown. | 49 r'(\d*)' // The line number. Empty in Safari if it's unknown. |
50 r'(?::(\d*))?' // The column number. Not present in older browsers and | 50 r'(?::(\d*))?' // The column number. Not present in older browsers and |
51 // empty in Safari if it's unknown. | 51 // empty in Safari if it's unknown. |
52 r'$'); | 52 r'$'); |
53 | 53 |
54 // foo/bar.dart 10:11 Foo._bar | 54 // foo/bar.dart 10:11 Foo._bar |
55 // foo/bar.dart 10:11 (anonymous function).dart.fn | |
55 // http://dartlang.org/foo/bar.dart Foo._bar | 56 // http://dartlang.org/foo/bar.dart Foo._bar |
57 // data:... 10:11 Foo._bar | |
56 final _friendlyFrame = new RegExp( | 58 final _friendlyFrame = new RegExp( |
57 r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d]\S*)$'); | 59 r'^(\S+)(?: (\d+)(?::(\d+))?)?\s+([^\d].*)$'); |
58 | 60 |
59 /// A regular expression that matches asynchronous member names generated by the | 61 /// A regular expression that matches asynchronous member names generated by the |
60 /// VM. | 62 /// VM. |
61 final _asyncBody = new RegExp(r'<(<anonymous closure>|[^>]+)_async_body>'); | 63 final _asyncBody = new RegExp(r'<(<anonymous closure>|[^>]+)_async_body>'); |
62 | 64 |
63 final _initialDot = new RegExp(r"^\."); | 65 final _initialDot = new RegExp(r"^\."); |
64 | 66 |
65 /// A single stack frame. Each frame points to a precise location in Dart code. | 67 /// A single stack frame. Each frame points to a precise location in Dart code. |
66 class Frame { | 68 class Frame { |
67 /// The URI of the file in which the code is located. | 69 /// The URI of the file in which the code is located. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 /// Parses a string representation of a Safari stack frame. | 244 /// Parses a string representation of a Safari stack frame. |
243 factory Frame.parseSafari(String frame) => new Frame.parseFirefox(frame); | 245 factory Frame.parseSafari(String frame) => new Frame.parseFirefox(frame); |
244 | 246 |
245 /// Parses this package's string representation of a stack frame. | 247 /// Parses this package's string representation of a stack frame. |
246 factory Frame.parseFriendly(String frame) => _catchFormatException(frame, () { | 248 factory Frame.parseFriendly(String frame) => _catchFormatException(frame, () { |
247 var match = _friendlyFrame.firstMatch(frame); | 249 var match = _friendlyFrame.firstMatch(frame); |
248 if (match == null) { | 250 if (match == null) { |
249 throw new FormatException( | 251 throw new FormatException( |
250 "Couldn't parse package:stack_trace stack trace line '$frame'."); | 252 "Couldn't parse package:stack_trace stack trace line '$frame'."); |
251 } | 253 } |
252 | 254 // Fake truncated data urls generated by the friendly stack trace format |
253 var uri = Uri.parse(match[1]); | 255 // cause Uri.parse to throw an exception so we have to special case them. |
256 var uri = match[1] == 'data:...' | |
257 ? new Uri.dataFromString('...') | |
nweiz
2017/03/07 21:27:28
Maybe just pass this an empty string. I think that
Jacob
2017/03/07 23:27:20
Done.
| |
258 : Uri.parse(match[1]); | |
254 // If there's no scheme, this is a relative URI. We should interpret it as | 259 // If there's no scheme, this is a relative URI. We should interpret it as |
255 // relative to the current working directory. | 260 // relative to the current working directory. |
256 if (uri.scheme == '') { | 261 if (uri.scheme == '') { |
257 uri = path.toUri(path.absolute(path.fromUri(uri))); | 262 uri = path.toUri(path.absolute(path.fromUri(uri))); |
258 } | 263 } |
259 | 264 |
260 var line = match[2] == null ? null : int.parse(match[2]); | 265 var line = match[2] == null ? null : int.parse(match[2]); |
261 var column = match[3] == null ? null : int.parse(match[3]); | 266 var column = match[3] == null ? null : int.parse(match[3]); |
262 return new Frame(uri, line, column, match[4]); | 267 return new Frame(uri, line, column, match[4]); |
263 }); | 268 }); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 return body(); | 300 return body(); |
296 } on FormatException catch (_) { | 301 } on FormatException catch (_) { |
297 return new UnparsedFrame(text); | 302 return new UnparsedFrame(text); |
298 } | 303 } |
299 } | 304 } |
300 | 305 |
301 Frame(this.uri, this.line, this.column, this.member); | 306 Frame(this.uri, this.line, this.column, this.member); |
302 | 307 |
303 String toString() => '$location in $member'; | 308 String toString() => '$location in $member'; |
304 } | 309 } |
OLD | NEW |