@@ -509,46 +509,50 @@ private StackTraceLine[] ToStackFrames(System.Exception exception, IntPtr[] nati
509
509
var address = ( UInt64 ) nativeAddresses [ i ] . ToInt64 ( ) ;
510
510
var image = loadedImages . FindImageAtAddress ( address ) ;
511
511
512
- var trace = new StackTraceLine ( ) ;
513
- trace . FrameAddress = string . Format ( "0x{0:X}" , address ) ;
514
- trace . Method = method . ToString ( ) ;
512
+ var frame = new StackTraceLine ( ) ;
513
+ frame . FrameAddress = string . Format ( "0x{0:X}" , address ) ;
514
+ frame . Method = method . ToString ( ) ;
515
+ frame . Type = "cocoa" ;
515
516
if ( image != null )
516
517
{
517
518
if ( address < image . LoadAddress )
518
519
{
519
520
// It's a relative address
520
- trace . FrameAddress = string . Format ( "0x{0:X}" , address + image . LoadAddress ) ;
521
+ frame . FrameAddress = string . Format ( "0x{0:X}" , address + image . LoadAddress ) ;
521
522
}
522
- trace . MachoFile = image . FileName ;
523
- trace . MachoLoadAddress = string . Format ( "0x{0:X}" , image . LoadAddress ) ;
524
- trace . MachoUuid = image . Uuid ;
525
- trace . InProject = image . IsMainImage ;
523
+ frame . MachoFile = image . FileName ;
524
+ frame . MachoLoadAddress = string . Format ( "0x{0:X}" , image . LoadAddress ) ;
525
+ frame . MachoUuid = FormatImageUuid ( image . Uuid ) ;
526
+ frame . InProject = image . IsMainImage ;
526
527
}
527
528
else
528
529
{
529
- trace . MachoFile = safeMainImageFileName ;
530
- trace . MachoLoadAddress = "0x0" ;
531
- trace . MachoUuid = mainImageFormattedUuid ;
532
- trace . InProject = true ;
530
+ frame . MachoFile = safeMainImageFileName ;
531
+ frame . MachoLoadAddress = "0x0" ;
532
+ frame . MachoUuid = mainImageFormattedUuid ;
533
+ frame . InProject = true ;
533
534
}
534
- stackFrames [ i ] = trace ;
535
+ stackFrames [ i ] = frame ;
535
536
}
536
537
return stackFrames ;
537
538
}
538
539
539
- private string FormatImageUuid ( string imageUuid )
540
+ private static string FormatImageUuid ( string uuid )
540
541
{
541
- if ( imageUuid == null || imageUuid . Length != 32 )
542
- {
543
- return null ;
544
- }
542
+ if ( string . IsNullOrEmpty ( uuid ) ) return uuid ;
545
543
546
- byte [ ] mainImageUuidBytes = new byte [ 16 ] ;
547
- for ( int i = 0 ; i < 16 ; i ++ )
544
+ string hex = uuid . Replace ( "-" , "" ) . Trim ( ) ;
545
+ if ( hex . Length != 32 ) return uuid ; // leave unexpected formats alone
546
+
547
+ for ( int i = 0 ; i < 32 ; i ++ )
548
548
{
549
- mainImageUuidBytes [ i ] = Convert . ToByte ( imageUuid . Substring ( i * 2 , 2 ) , 16 ) ;
549
+ char c = hex [ i ] ;
550
+ bool ok = ( c >= '0' && c <= '9' ) || ( c | 0x20 ) >= 'a' && ( c | 0x20 ) <= 'f' ;
551
+ if ( ! ok ) return uuid ;
550
552
}
551
- return new Guid ( mainImageUuidBytes ) . ToString ( ) ;
553
+
554
+ hex = hex . ToUpperInvariant ( ) ;
555
+ return $ "{ hex . Substring ( 0 , 8 ) } -{ hex . Substring ( 8 , 4 ) } -{ hex . Substring ( 12 , 4 ) } -{ hex . Substring ( 16 , 4 ) } -{ hex . Substring ( 20 ) } ";
552
556
}
553
557
554
558
public StackTraceLine [ ] ToStackFrames ( System . Exception exception )
0 commit comments