@@ -21,6 +21,36 @@ export interface ParsedErrorFrame {
2121 } ;
2222}
2323
24+ export type SpecialHermesStackTraceFrameTypes = 'native' | 'address at' | 'empty url' ;
25+
26+ function getSpecialHermesStackTraceFrameType ( {
27+ url,
28+ } : {
29+ url : Platform . DevToolsPath . UrlString ,
30+ } ) : SpecialHermesStackTraceFrameTypes | null {
31+ // functions implemented in c++.
32+ // TODO: these might be enhanced to include the C++ loc for the frame
33+ // so that a debugger could stitch together a hybrid cross-language call stack
34+ if ( url === 'native' ) {
35+ return 'native' ;
36+ }
37+
38+ // frames with empty url
39+ // TODO: these seem to be happening due to a bug that needs to be investigated
40+ // and produce an actual script URL instead
41+ if ( url === '' ) {
42+ return 'empty url' ;
43+ }
44+
45+ // frames pointing to a bytecode locations
46+ // TODO: these could be symbolicated and link to source files with the help of
47+ // a bytecode source maps once they are available.
48+ if ( url . startsWith ?.( 'address at ' ) ) {
49+ return 'address at' ;
50+ }
51+ return null ;
52+ }
53+
2454/**
2555 * Takes a V8 Error#stack string and extracts source position information.
2656 *
@@ -79,7 +109,8 @@ export function parseSourcePositionsFromErrorStack(
79109
80110 const linkCandidate = line . substring ( left , right ) ;
81111 const splitResult = Common . ParsedURL . ParsedURL . splitLineAndColumn ( linkCandidate ) ;
82- if ( splitResult . url === '<anonymous>' || splitResult . url === 'native' ) {
112+ const specialHermesFrameType = getSpecialHermesStackTraceFrameType ( splitResult ) ;
113+ if ( splitResult . url === '<anonymous>' || specialHermesFrameType !== null ) {
83114 if ( linkInfos . length && linkInfos [ linkInfos . length - 1 ] . isCallFrame && ! linkInfos [ linkInfos . length - 1 ] . link ) {
84115 // Combine builtin frames.
85116 linkInfos [ linkInfos . length - 1 ] . line += `\n${ line } ` ;
0 commit comments