@@ -163,6 +163,7 @@ async function tryGetCallLocation(
163163 if ( token ?. isCancellationRequested ) {
164164 throw new Error ( 'cancelled' ) ;
165165 }
166+ logDebug ( `tryGetCallLocation frame ${ frame . id } : file=${ file . path } , line=${ frame . line } , func=${ frame . name } ` ) ;
166167 const zeroIndexedLine = frame . line - 1 ;
167168 const noFunctionLookupSize = 3 ;
168169 let symbolLocation : Range | undefined ;
@@ -186,6 +187,10 @@ async function tryGetCallLocation(
186187
187188 const language = getLanguageForFileCached ( file , cache ) ;
188189
190+ logDebug (
191+ `tryGetCallLocation frame ${ frame . id } : file=${ file . path } , line=${ frame . line } , func=${ frame . name } , language=${ language } , symbolLine=${ symbolLocation ?. start . line } , symbolEndLine=${ symbolLocation ?. end . line } , codeLen=${ code ?. length ?? 0 } ` ,
192+ ) ;
193+
189194 return < CallLocation > {
190195 code,
191196 file : file . path ,
@@ -204,12 +209,17 @@ async function tryGetCallLocation(
204209}
205210
206211function stubCallLocation ( frame : DebugProtocol . StackFrame ) : CallLocation {
212+ const path = frame . source ?. path ;
213+ const name = frame . source ?. name ;
214+ logDebug (
215+ `stubCallLocation frame ${ frame . id } : path=${ path ?? '<unknown>' } , name=${ name ?? '<unknown>' } , line=${ frame . line } , func=${ frame . name } ` ,
216+ ) ;
207217 return {
208218 code : '<source not found>' ,
209- file : frame . source ?. path ?? '<unknown>' ,
219+ file : path ?? '<unknown>' ,
210220 frameId : frame . id ,
211221 language : 'plaintext' ,
212- fileLocationOffset : { startLine : 0 , startCharacter : 0 } ,
222+ fileLocationOffset : { startLine : frame . line , startCharacter : 0 } ,
213223 locationInCode : { startLine : 0 , startCharacter : 0 } ,
214224 } ;
215225}
@@ -230,6 +240,7 @@ async function getCallLocation(
230240 logDebug ( `getCallLocation frame ${ frame . id } : trying primary path ${ frame . source . path } ` ) ;
231241 const location = await tryGetCallLocation ( file , frame , token , fileCache ) ;
232242 if ( location ) {
243+ logDebug ( `getCallLocation frame ${ frame . id } : primary path succeeded (${ frame . source . path } )` ) ;
233244 return location ;
234245 }
235246 } catch ( e ) {
@@ -242,6 +253,7 @@ async function getCallLocation(
242253 const file = Uri . from ( { scheme : 'file' , path : frame . source . path } ) ;
243254 const location = await tryGetCallLocation ( file , frame , token , fileCache ) ;
244255 if ( location ) {
256+ logDebug ( `getCallLocation frame ${ frame . id } : alternative path succeeded` ) ;
245257 return location ;
246258 }
247259 } catch ( e ) {
@@ -256,11 +268,19 @@ async function getCallLocation(
256268 ( file ) => frame . source ?. name && file . fsPath . endsWith ( frame . source ?. name ) ,
257269 ) ;
258270 logDebug ( `getCallLocation frame ${ frame . id } : found ${ filesWithSameName . length } matching files in workspace` ) ;
271+ for ( const f of filesWithSameName ) {
272+ logDebug ( `getCallLocation frame ${ frame . id } : candidate: ${ f . fsPath } ` ) ;
273+ }
259274 if ( filesWithSameName . length === 1 ) {
260275 const location = await tryGetCallLocation ( filesWithSameName [ 0 ] , frame , token , fileCache ) ;
261276 if ( location ) {
277+ logDebug (
278+ `getCallLocation frame ${ frame . id } : workspace file search succeeded: ${ filesWithSameName [ 0 ] . fsPath } ` ,
279+ ) ;
262280 return location ;
263281 }
282+ } else if ( filesWithSameName . length > 1 ) {
283+ logDebug ( `getCallLocation frame ${ frame . id } : multiple candidates, skipping automatic resolution` ) ;
264284 }
265285 } catch ( e ) {
266286 logWarn ( `getCallLocation frame ${ frame . id } : workspace search failed` , e ) ;
@@ -285,6 +305,13 @@ export async function getStacktraceInfo(token?: CancellationToken): Promise<Stac
285305 } ) ;
286306 logDebug ( `getStacktraceInfo: got ${ stackFrames . stackFrames . length } frames in ${ Date . now ( ) - fetchStart } ms` ) ;
287307
308+ // Log raw frame info for debugging
309+ for ( const f of stackFrames . stackFrames ) {
310+ logDebug (
311+ `raw frame ${ f . id } : name=${ f . name } , line=${ f . line } , column=${ f . column } , sourcePath=${ f . source ?. path ?? '<none>' } , sourceName=${ f . source ?. name ?? '<none>' } ` ,
312+ ) ;
313+ }
314+
288315 // Process frames with concurrency limiting and timeout
289316 const processStart = Date . now ( ) ;
290317 const fileCache = new Map < string , FileCacheEntry > ( ) ;
@@ -307,5 +334,13 @@ export async function getStacktraceInfo(token?: CancellationToken): Promise<Stac
307334 ) ;
308335 logDebug ( `getStacktraceInfo: processed ${ callLocations . length } frames in ${ Date . now ( ) - processStart } ms` ) ;
309336
337+ // Log callpath summary for all frames
338+ for ( const loc of callLocations ) {
339+ const status = loc . code === '<source not found>' ? '❌ NOT_FOUND' : '✓ OK' ;
340+ logDebug (
341+ `callpath frame ${ loc . frameId } : ${ status } file=${ loc . file } , line=${ loc . fileLocationOffset . startLine } , func=<from debug>, language=${ loc . language } ` ,
342+ ) ;
343+ }
344+
310345 return callLocations ;
311346}
0 commit comments