Fix stack trace parsers

This commit is contained in:
Yuta Saito 2024-02-25 17:53:07 +09:00
parent 4dfca3fc45
commit a905cb1f14
3 changed files with 15 additions and 15 deletions

View File

@ -15,19 +15,19 @@
// Created by Jed Fox on 12/6/20.
//
private let webpackRegex = #/"at (.+) \\(webpack:///(.+?)\\)/#
private let wasmRegex = #/at (.+) \\(<anonymous>:(.+?)\\)/#
private let webpackRegex = #/at (.+) \(webpack:///(.+?)\)/#
private let wasmRegex = #/at (.+) \(<anonymous>:(.+?)\)/#
extension StringProtocol {
var chromeStackTrace: [StackTraceItem] {
split(separator: "\n").dropFirst().compactMap {
if let webpackMatch = try? webpackRegex.firstMatch(in: String($0)) {
let symbol = String(webpackMatch.output.0)
let location = String(webpackMatch.output.3)
if let webpackMatch = try? webpackRegex.firstMatch(in: String($0)) {
let symbol = String(webpackMatch.output.1)
let location = String(webpackMatch.output.2)
return StackTraceItem(symbol: symbol, location: location, kind: .javaScript)
} else if let wasmMatch = try? wasmRegex.firstMatch(in: String($0)) {
let symbol = String(wasmMatch.output.0)
let location = String(wasmMatch.output.3)
let symbol = String(wasmMatch.output.1)
let location = String(wasmMatch.output.2)
return StackTraceItem(
symbol: demangle(symbol),
location: location,

View File

@ -22,11 +22,11 @@ extension StringProtocol {
var firefoxStackTrace: [StackTraceItem] {
split(separator: "\n").compactMap {
if let webpackMatch = try? webpackRegex.firstMatch(in: String($0)) {
let symbol = String(webpackMatch.output.0)
let symbol = String(webpackMatch.output.1)
let location = String(webpackMatch.output.2)
return StackTraceItem(symbol: symbol, location: location, kind: .javaScript)
} else if let wasmMatch = try? wasmRegex.firstMatch(in: String($0)) {
let symbol = String(wasmMatch.output.0)
let symbol = String(wasmMatch.output.1)
let location = String(wasmMatch.output.2)
return StackTraceItem(
symbol: demangle(symbol),

View File

@ -15,24 +15,24 @@
// Created by Jed Fox on 12/6/20.
//
private let jsRegex = #/(.+?)(?:@(?:\\[(?:native|wasm) code\\]|(.+)))?$/#
private let wasmRegex = #/"<\\?>\\.wasm-function\\[(.+)\\]@\\[wasm code\\]/#
private let jsRegex = #/(.+?)(?:@(?:\[(?:native|wasm) code\]|(.+)))?$/#
private let wasmRegex = #/<\?>\.wasm-function\[(.+)\]@\[wasm code\]/#
extension StringProtocol {
var safariStackTrace: [StackTraceItem] {
split(separator: "\n").compactMap {
if let wasmMatch = try? wasmRegex.firstMatch(in: String($0)) {
let symbol = String(wasmMatch.output)
let symbol = String(wasmMatch.output.1)
return StackTraceItem(
symbol: demangle(symbol),
location: nil,
kind: .webAssembly
)
} else if let jsMatch = try? jsRegex.firstMatch(in: String($0)) {
let symbol = String(jsMatch.output.0)
let symbol = String(jsMatch.output.1)
let loc: String?
if jsMatch.output.2 == nil && !jsMatch.output.1.isEmpty {
loc = String(jsMatch.1)
if let foundLoc = jsMatch.output.2, !foundLoc.isEmpty {
loc = String(foundLoc)
} else {
loc = nil
}