@@ -425,24 +425,31 @@ private int writeFileTable(DebugContext context, ClassEntry classEntry, byte[] b
425425
426426 private int writeLineNumberTable (DebugContext context , ClassEntry classEntry , byte [] buffer , int p ) {
427427 int pos = p ;
428- FileEntry fileEntry = classEntry . getFileEntry ();
429- if (fileEntry == null ) {
428+ // if the class has no associated file then don't generate line info
429+ if (classEntry . getFileEntry () == null ) {
430430 return pos ;
431431 }
432432 /*
433- * The primary file entry should always be first in the local files list.
433+ * The class file entry should always be first in the local files list.
434434 */
435435 assert classEntry .localFilesIdx () == 1 ;
436436 String primaryClassName = classEntry .getTypeName ();
437437 String primaryFileName = classEntry .getFileName ();
438- String file = primaryFileName ;
439- int fileIdx = 1 ;
440438 log (context , " [0x%08x] primary class %s" , pos , primaryClassName );
441- log (context , " [0x%08x] primary file %s" , pos , primaryFileName );
439+ log (context , " [0x%08x] primary class file %s" , pos , primaryFileName );
442440 for (PrimaryEntry primaryEntry : classEntry .getPrimaryEntries ()) {
443441 Range primaryRange = primaryEntry .getPrimary ();
442+ // the primary method might be a substitution and not in the primary class file
443+ FileEntry fileEntry = primaryRange .getFileEntry ();
444+ if (fileEntry == null ) {
445+ log (context , " [0x%08x] primary range [0x%08x, 0x%08x] skipped (no file) %s" , pos , debugTextBase + primaryRange .getLo (), debugTextBase + primaryRange .getHi (),
446+ primaryRange .getFullMethodNameWithParams ());
447+ continue ;
448+ }
449+ String file = fileEntry .getFileName ();
450+ int fileIdx = classEntry .localFilesIdx (fileEntry );
444451 /*
445- * Each primary represents a method i.e. a contiguous sequence of subranges. we assume
452+ * Each primary represents a method i.e. a contiguous sequence of subranges. we write
446453 * the default state at the start of each sequence because we always post an
447454 * end_sequence when we finish all the subranges in the method.
448455 */
@@ -458,8 +465,9 @@ private int writeLineNumberTable(DebugContext context, ClassEntry classEntry, by
458465 /*
459466 * Set state for primary.
460467 */
461- log (context , " [0x%08x] primary range [0x%08x, 0x%08x] %s:%d" , pos , debugTextBase + primaryRange .getLo (), debugTextBase + primaryRange .getHi (), primaryRange .getFullMethodNameWithParams (),
462- primaryRange .getLine ());
468+ log (context , " [0x%08x] primary range [0x%08x, 0x%08x] %s %s:%d" , pos , debugTextBase + primaryRange .getLo (), debugTextBase + primaryRange .getHi (),
469+ primaryRange .getFullMethodNameWithParams (),
470+ file , primaryRange .getLine ());
463471
464472 /*
465473 * Initialize and write a row for the start of the primary method.
@@ -520,7 +528,8 @@ private int writeLineNumberTable(DebugContext context, ClassEntry classEntry, by
520528 long subLine = subrange .getLine ();
521529 long subAddressLo = subrange .getLo ();
522530 long subAddressHi = subrange .getHi ();
523- log (context , " [0x%08x] sub range [0x%08x, 0x%08x] %s:%d" , pos , debugTextBase + subAddressLo , debugTextBase + subAddressHi , subrange .getFullMethodNameWithParams (), subLine );
531+ log (context , " [0x%08x] sub range [0x%08x, 0x%08x] %s %s:%d" , pos , debugTextBase + subAddressLo , debugTextBase + subAddressHi , subrange .getFullMethodNameWithParams (), subfile ,
532+ subLine );
524533 if (subLine < 0 ) {
525534 /*
526535 * No line info so stay at previous file:line.
@@ -629,7 +638,7 @@ private int writeLineNumberTable(DebugContext context, ClassEntry classEntry, by
629638 }
630639 pos = writeEndSequenceOp (context , buffer , pos );
631640 }
632- log (context , " [0x%08x] primary file processed %s" , pos , primaryFileName );
641+ log (context , " [0x%08x] primary class processed %s" , pos , primaryClassName );
633642
634643 return pos ;
635644 }
0 commit comments