@@ -787,8 +787,10 @@ internal sealed class MonoSDBHelper
787787 private DebugStore store ;
788788 private SessionId sessionId ;
789789
790- private readonly ILogger logger ;
791- private static readonly Regex regexForAsyncLocals = new ( @"\<([^)]*)\>" , RegexOptions . Singleline ) ;
790+ internal readonly ILogger logger ;
791+ private static readonly Regex regexForAsyncLocals = new ( @"\<([^)]*)\>([^)]*)([_][_])([0-9]*)" , RegexOptions . Singleline ) ; //<testCSharpScope>5__1
792+ private static readonly Regex regexForVBAsyncLocals = new ( @"\$VB\$ResumableLocal_([^)]*)\$([0-9]*)" , RegexOptions . Singleline ) ; //$VB$ResumableLocal_testVbScope$2
793+ private static readonly Regex regexForVBAsyncMethodName = new ( @"VB\$StateMachine_([0-9]*)_([^)]*)" , RegexOptions . Singleline ) ; //VB$StateMachine_2_RunVBScope
792794 private static readonly Regex regexForAsyncMethodName = new ( @"\<([^>]*)\>([d][_][_])([0-9]*)" , RegexOptions . Compiled ) ;
793795 private static readonly Regex regexForGenericArgs = new ( @"[`][0-9]+" , RegexOptions . Compiled ) ;
794796 private static readonly Regex regexForNestedLeftRightAngleBrackets = new ( "^(((?'Open'<)[^<>]*)+((?'Close-Open'>)[^<>]*)+)*(?(Open)(?!))[^<>]*" , RegexOptions . Compiled ) ;
@@ -1271,6 +1273,14 @@ public async Task<string> GetPrettyMethodName(int methodId, bool isAnonymous, Ca
12711273 if ( anonymousMethodId . LastIndexOf ( '_' ) >= 0 )
12721274 anonymousMethodId = klassName . Substring ( klassName . LastIndexOf ( '_' ) + 1 ) ;
12731275 }
1276+ else if ( klassName . StartsWith ( "VB$" ) )
1277+ {
1278+ var match = regexForVBAsyncMethodName . Match ( klassName ) ;
1279+ if ( match . Success )
1280+ ret = ret . Insert ( 0 , match . Groups [ 2 ] . Value ) ;
1281+ else
1282+ ret = ret . Insert ( 0 , klassName ) ;
1283+ }
12741284 else
12751285 {
12761286 var matchOnClassName = regexForNestedLeftRightAngleBrackets . Match ( klassName ) ;
@@ -1920,7 +1930,7 @@ private static bool IsClosureReferenceField (string fieldName)
19201930 fieldName . StartsWith ( "<>8__" , StringComparison . Ordinal ) ;
19211931 }
19221932
1923- public async Task < JArray > GetHoistedLocalVariables ( int objectId , IEnumerable < JToken > asyncLocals , CancellationToken token )
1933+ public async Task < JArray > GetHoistedLocalVariables ( MethodInfoWithDebugInformation method , int objectId , IEnumerable < JToken > asyncLocals , int offset , CancellationToken token )
19241934 {
19251935 JArray asyncLocalsFull = new JArray ( ) ;
19261936 List < int > objectsAlreadyRead = new ( ) ;
@@ -1931,7 +1941,6 @@ public async Task<JArray> GetHoistedLocalVariables(int objectId, IEnumerable<JTo
19311941 if ( fieldName . EndsWith ( "__this" , StringComparison . Ordinal ) )
19321942 {
19331943 asyncLocal [ "name" ] = "this" ;
1934- asyncLocalsFull . Add ( asyncLocal ) ;
19351944 }
19361945 else if ( IsClosureReferenceField ( fieldName ) ) //same code that has on debugger-libs
19371946 {
@@ -1941,10 +1950,11 @@ public async Task<JArray> GetHoistedLocalVariables(int objectId, IEnumerable<JTo
19411950 {
19421951 var asyncProxyMembersFromObject = await MemberObjectsExplorer . GetObjectMemberValues (
19431952 this , dotnetObjectId . Value , GetObjectCommandOptions . WithProperties , token ) ;
1944- var hoistedLocalVariable = await GetHoistedLocalVariables ( dotnetObjectId . Value , asyncProxyMembersFromObject . Flatten ( ) , token ) ;
1953+ var hoistedLocalVariable = await GetHoistedLocalVariables ( method , dotnetObjectId . Value , asyncProxyMembersFromObject . Flatten ( ) , offset , token ) ;
19451954 asyncLocalsFull = new JArray ( asyncLocalsFull . Union ( hoistedLocalVariable ) ) ;
19461955 }
19471956 }
1957+ continue ;
19481958 }
19491959 else if ( fieldName . StartsWith ( "<>" , StringComparison . Ordinal ) ) //examples: <>t__builder, <>1__state
19501960 {
@@ -1954,18 +1964,37 @@ public async Task<JArray> GetHoistedLocalVariables(int objectId, IEnumerable<JTo
19541964 {
19551965 var match = regexForAsyncLocals . Match ( fieldName ) ;
19561966 if ( match . Success )
1967+ {
1968+ if ( ! method . Info . ContainsAsyncScope ( Convert . ToInt32 ( match . Groups [ 4 ] . Value ) , offset ) )
1969+ continue ;
19571970 asyncLocal [ "name" ] = match . Groups [ 1 ] . Value ;
1958- asyncLocalsFull . Add ( asyncLocal ) ;
1971+ }
19591972 }
1960- else
1973+ //VB language
1974+ else if ( fieldName . StartsWith ( "$VB$Local_" , StringComparison . Ordinal ) )
1975+ {
1976+ asyncLocal [ "name" ] = fieldName . Remove ( 0 , 10 ) ;
1977+ }
1978+ else if ( fieldName . StartsWith ( "$VB$ResumableLocal_" , StringComparison . Ordinal ) )
1979+ {
1980+ var match = regexForVBAsyncLocals . Match ( fieldName ) ;
1981+ if ( match . Success )
1982+ {
1983+ if ( ! method . Info . ContainsAsyncScope ( Convert . ToInt32 ( match . Groups [ 2 ] . Value ) + 1 , offset ) )
1984+ continue ;
1985+ asyncLocal [ "name" ] = match . Groups [ 1 ] . Value ;
1986+ }
1987+ }
1988+ else if ( fieldName . StartsWith ( "$" ) )
19611989 {
1962- asyncLocalsFull . Add ( asyncLocal ) ;
1990+ continue ;
19631991 }
1992+ asyncLocalsFull . Add ( asyncLocal ) ;
19641993 }
19651994 return asyncLocalsFull ;
19661995 }
19671996
1968- public async Task < JArray > StackFrameGetValues ( MethodInfoWithDebugInformation method , int thread_id , int frame_id , VarInfo [ ] varIds , CancellationToken token )
1997+ public async Task < JArray > StackFrameGetValues ( MethodInfoWithDebugInformation method , int thread_id , int frame_id , VarInfo [ ] varIds , int offset , CancellationToken token )
19691998 {
19701999 using var commandParamsWriter = new MonoBinaryWriter ( ) ;
19712000 commandParamsWriter . Write ( thread_id ) ;
@@ -1982,7 +2011,7 @@ public async Task<JArray> StackFrameGetValues(MethodInfoWithDebugInformation met
19822011 retDebuggerCmdReader . ReadByte ( ) ; //ignore type
19832012 var objectId = retDebuggerCmdReader . ReadInt32 ( ) ;
19842013 GetMembersResult asyncProxyMembers = await MemberObjectsExplorer . GetObjectMemberValues ( this , objectId , GetObjectCommandOptions . WithProperties , token , includeStatic : true ) ;
1985- var asyncLocals = await GetHoistedLocalVariables ( objectId , asyncProxyMembers . Flatten ( ) , token ) ;
2014+ var asyncLocals = await GetHoistedLocalVariables ( method , objectId , asyncProxyMembers . Flatten ( ) , offset , token ) ;
19862015 return asyncLocals ;
19872016 }
19882017
0 commit comments