@@ -1364,16 +1364,13 @@ internal static bool IsGeneratedType (Type tm)
1364
1364
1365
1365
ValueReference GetHoistedThisReference ( CorEvaluationContext cx )
1366
1366
{
1367
- try {
1367
+ return CorDebugUtil . CallHandlingComExceptions ( ( ) => {
1368
1368
CorValRef vref = new CorValRef ( delegate {
1369
1369
return cx . Frame . GetArgument ( 0 ) ;
1370
1370
} ) ;
1371
1371
var type = ( CorType ) GetValueType ( cx , vref ) ;
1372
1372
return GetHoistedThisReference ( cx , type , vref ) ;
1373
- } catch ( COMException e ) {
1374
- DebuggerLoggingService . LogMessage ( "Exception in GetHoistedThisReference(): {0}" , e . Message ) ;
1375
- }
1376
- return null ;
1373
+ } , "GetHoistedThisReference()" ) ;
1377
1374
}
1378
1375
1379
1376
ValueReference GetHoistedThisReference ( CorEvaluationContext cx , CorType type , object val )
@@ -1451,7 +1448,7 @@ ValueReference GetThisReference (CorEvaluationContext ctx)
1451
1448
if ( mi == null || mi . IsStatic )
1452
1449
return null ;
1453
1450
1454
- try {
1451
+ return CorDebugUtil . CallHandlingComExceptions ( ( ) => {
1455
1452
CorValRef vref = new CorValRef ( delegate {
1456
1453
var result = ctx . Frame . GetArgument ( 0 ) ;
1457
1454
if ( result . Type == CorElementType . ELEMENT_TYPE_BYREF )
@@ -1460,12 +1457,18 @@ ValueReference GetThisReference (CorEvaluationContext ctx)
1460
1457
} ) ;
1461
1458
1462
1459
return new VariableReference ( ctx , vref , "this" , ObjectValueFlags . Variable | ObjectValueFlags . ReadOnly ) ;
1463
- } catch ( COMException e ) {
1464
- DebuggerLoggingService . LogMessage ( "Exception in GetThisReference(): {0}" , e . Message ) ;
1465
- return null ;
1466
- }
1460
+ } , "GetThisReference()" ) ;
1461
+ }
1462
+
1463
+ static VariableReference CreateParameterReference ( CorEvaluationContext ctx , int paramIndex , string paramName , ObjectValueFlags flags = ObjectValueFlags . Parameter )
1464
+ {
1465
+ CorValRef vref = new CorValRef ( delegate {
1466
+ return ctx . Frame . GetArgument ( paramIndex ) ;
1467
+ } ) ;
1468
+ return new VariableReference ( ctx , vref , paramName , flags ) ;
1467
1469
}
1468
1470
1471
+
1469
1472
protected override IEnumerable < ValueReference > OnGetParameters ( EvaluationContext gctx )
1470
1473
{
1471
1474
CorEvaluationContext ctx = ( CorEvaluationContext ) gctx ;
@@ -1476,28 +1479,19 @@ protected override IEnumerable<ValueReference> OnGetParameters (EvaluationContex
1476
1479
int pos = pi . Position ;
1477
1480
if ( met . IsStatic )
1478
1481
pos -- ;
1479
- CorValRef vref = null ;
1480
- try {
1481
- vref = new CorValRef ( delegate {
1482
- return ctx . Frame . GetArgument ( pos ) ;
1483
- } ) ;
1484
- }
1485
- catch ( Exception /*ex*/ ) {
1486
- }
1487
- if ( vref != null )
1488
- yield return new VariableReference ( ctx , vref , pi . Name , ObjectValueFlags . Parameter ) ;
1482
+
1483
+ yield return CorDebugUtil . CallHandlingComExceptions ( ( ) => CreateParameterReference ( ctx , pos , pi . Name ) ,
1484
+ string . Format ( "Get parameter {0} of {1}" , pi . Name , met . Name ) ) ;
1489
1485
}
1490
1486
yield break ;
1491
1487
}
1492
1488
}
1493
1489
1494
- int count = ctx . Frame . GetArgumentCount ( ) ;
1490
+ int count = CorDebugUtil . CallHandlingComExceptions ( ( ) => ctx . Frame . GetArgumentCount ( ) , "GetArgumentCount()" , 0 ) ;
1495
1491
for ( int n = 0 ; n < count ; n ++ ) {
1496
1492
int locn = n ;
1497
- var vref = new CorValRef ( delegate {
1498
- return ctx . Frame . GetArgument ( locn ) ;
1499
- } ) ;
1500
- yield return new VariableReference ( ctx , vref , "arg_" + ( n + 1 ) , ObjectValueFlags . Parameter ) ;
1493
+ yield return CorDebugUtil . CallHandlingComExceptions ( ( ) => CreateParameterReference ( ctx , locn , "arg_" + ( locn + 1 ) ) ,
1494
+ string . Format ( "Get parameter {0}" , n ) ) ;
1501
1495
}
1502
1496
}
1503
1497
@@ -1568,42 +1562,39 @@ IEnumerable<ValueReference> GetLocalVariables (CorEvaluationContext cx)
1568
1562
{
1569
1563
uint offset ;
1570
1564
CorDebugMappingResult mr ;
1571
- try {
1565
+ return CorDebugUtil . CallHandlingComExceptions ( ( ) => {
1572
1566
cx . Frame . GetIP ( out offset , out mr ) ;
1573
1567
return GetLocals ( cx , null , ( int ) offset , false ) ;
1574
- } catch ( Exception e ) {
1575
- cx . WriteDebuggerError ( e ) ;
1576
- return null ;
1577
- }
1568
+ } , "GetLocalVariables()" , new ValueReference [ 0 ] ) ;
1578
1569
}
1579
1570
1580
1571
public override ValueReference GetCurrentException ( EvaluationContext ctx )
1581
1572
{
1582
1573
CorEvaluationContext wctx = ( CorEvaluationContext ) ctx ;
1583
1574
CorValue exception = wctx . Thread . CurrentException ;
1584
1575
1585
- try {
1586
- if ( exception != null )
1587
- {
1588
- CorHandleValue exceptionHandle = wctx . Session . GetHandle ( exception ) ;
1589
-
1590
- CorValRef vref = new CorValRef ( delegate {
1591
- return exceptionHandle ;
1592
- } ) ;
1593
-
1594
- return new VariableReference ( ctx , vref , ctx . Options . CurrentExceptionTag , ObjectValueFlags . Variable ) ;
1595
- }
1596
- return base . GetCurrentException ( ctx ) ;
1597
- } catch ( Exception e ) {
1598
- ctx . WriteDebuggerError ( e ) ;
1576
+ if ( exception == null )
1599
1577
return null ;
1600
- }
1578
+ return CorDebugUtil . CallHandlingComExceptions ( ( ) => {
1579
+ CorValRef vref = new CorValRef ( delegate {
1580
+ return wctx . Session . GetHandle ( exception ) ;
1581
+ } ) ;
1582
+ return new VariableReference ( ctx , vref , ctx . Options . CurrentExceptionTag , ObjectValueFlags . Variable ) ;
1583
+ } , "Get current exception" ) ;
1584
+ }
1585
+
1586
+ static VariableReference CreateLocalVariableReference ( CorEvaluationContext ctx , int varIndex , string varName , ObjectValueFlags flags = ObjectValueFlags . Variable )
1587
+ {
1588
+ CorValRef vref = new CorValRef ( delegate {
1589
+ return ctx . Frame . GetLocalVariable ( varIndex ) ;
1590
+ } ) ;
1591
+ return new VariableReference ( ctx , vref , varName , flags ) ;
1601
1592
}
1602
1593
1603
1594
IEnumerable < ValueReference > GetLocals ( CorEvaluationContext ctx , ISymbolScope scope , int offset , bool showHidden )
1604
1595
{
1605
- if ( ctx . Frame . FrameType != CorFrameType . ILFrame )
1606
- yield break ;
1596
+ if ( ctx . Frame . FrameType != CorFrameType . ILFrame )
1597
+ yield break ;
1607
1598
1608
1599
if ( scope == null ) {
1609
1600
ISymbolMethod met = ctx . Frame . Function . GetSymbolMethod ( ctx . Session ) ;
@@ -1613,10 +1604,8 @@ IEnumerable<ValueReference> GetLocals (CorEvaluationContext ctx, ISymbolScope sc
1613
1604
int count = ctx . Frame . GetLocalVariablesCount ( ) ;
1614
1605
for ( int n = 0 ; n < count ; n ++ ) {
1615
1606
int locn = n ;
1616
- CorValRef vref = new CorValRef ( delegate {
1617
- return ctx . Frame . GetLocalVariable ( locn ) ;
1618
- } ) ;
1619
- yield return new VariableReference ( ctx , vref , "local_" + ( n + 1 ) , ObjectValueFlags . Variable ) ;
1607
+ yield return CorDebugUtil . CallHandlingComExceptions ( ( ) => CreateLocalVariableReference ( ctx , locn , "local_" + ( locn + 1 ) ) ,
1608
+ string . Format ( "Get local variable {0}" , locn ) ) ;
1620
1609
}
1621
1610
yield break ;
1622
1611
}
@@ -1626,20 +1615,23 @@ IEnumerable<ValueReference> GetLocals (CorEvaluationContext ctx, ISymbolScope sc
1626
1615
if ( var . Name == "$site" )
1627
1616
continue ;
1628
1617
if ( IsClosureReferenceLocal ( var ) ) {
1629
- int addr = var . AddressField1 ;
1630
- var vref = new CorValRef ( delegate {
1631
- return ctx . Frame . GetLocalVariable ( addr ) ;
1632
- } ) ;
1633
-
1634
- foreach ( var gv in GetHoistedLocalVariables ( ctx , new VariableReference ( ctx , vref , var . Name , ObjectValueFlags . Variable ) ) ) {
1635
- yield return gv ;
1618
+ var variableReference = CorDebugUtil . CallHandlingComExceptions ( ( ) => {
1619
+ int addr = var . AddressField1 ;
1620
+ return CreateLocalVariableReference ( ctx , addr , var . Name ) ;
1621
+ } , string . Format ( "Get local variable {0}" , var . Name ) ) ;
1622
+
1623
+ if ( variableReference != null ) {
1624
+ foreach ( var gv in GetHoistedLocalVariables ( ctx , variableReference ) ) {
1625
+ yield return gv ;
1626
+ }
1636
1627
}
1637
1628
} else if ( ! IsGeneratedTemporaryLocal ( var ) || showHidden ) {
1638
- int addr = var . AddressField1 ;
1639
- var vref = new CorValRef ( delegate {
1640
- return ctx . Frame . GetLocalVariable ( addr ) ;
1641
- } ) ;
1642
- yield return new VariableReference ( ctx , vref , var . Name , ObjectValueFlags . Variable ) ;
1629
+ var variableReference = CorDebugUtil . CallHandlingComExceptions ( ( ) => {
1630
+ int addr = var . AddressField1 ;
1631
+ return CreateLocalVariableReference ( ctx , addr , var . Name ) ;
1632
+ } , string . Format ( "Get local variable {0}" , var . Name ) ) ;
1633
+ if ( variableReference != null )
1634
+ yield return variableReference ;
1643
1635
}
1644
1636
}
1645
1637
0 commit comments