@@ -377,9 +377,30 @@ void generate_single_entry(enum event_type type, jvmtiEnv * jvmti,
377377 } else {
378378 memcpy (class_name , csig , sizeof (class_name ) - 1 );
379379 }
380- snprintf (output , noutput , "%s::%s%s" , class_name ,
381- method_name , method_signature );
382380
381+ char * source_file = NULL ;
382+ jvmtiError err =
383+ (* jvmti )-> GetSourceFileName (jvmti , class , & source_file );
384+ if (err != JVMTI_ERROR_NONE ) {
385+ source_file = NULL ;
386+ }
387+
388+ jint entry_count = 0 ;
389+ jvmtiLineNumberEntry * table = NULL ;
390+ int line_number = -1 ;
391+ err =
392+ (* jvmti )-> GetLineNumberTable (jvmti , method , & entry_count ,
393+ & table );
394+ if (err == JVMTI_ERROR_NONE && entry_count > 0 && table != NULL ) {
395+ line_number = table [0 ].line_number ;
396+ }
397+
398+ snprintf (output , noutput , "%s::%s%s[%s:%d]" , class_name ,
399+ method_name , method_signature ,
400+ source_file == NULL ? "" : source_file , line_number );
401+
402+ deallocate (jvmti , (unsigned char * )table );
403+ deallocate (jvmti , (unsigned char * )source_file );
383404 deallocate (jvmti , (unsigned char * )csig );
384405 }
385406
0 commit comments