@@ -53,7 +53,6 @@ internal class AD7DebugSession : DebugAdapterBase, IDebugPortNotify2, IDebugEven
5353 private int m_firstStoppingEvent ;
5454 private uint m_breakCounter = 0 ;
5555 private bool m_isAttach ;
56- private bool m_isCoreDump ;
5756 private bool m_isStopped = false ;
5857 private bool m_isStepping = false ;
5958
@@ -174,7 +173,7 @@ private bool ValidateProgramPath(ref string program)
174173 return true ;
175174 }
176175
177- private void SetCommonDebugSettings ( Dictionary < string , JToken > args , out int sourceFileMappings )
176+ private void SetCommonDebugSettings ( Dictionary < string , JToken > args )
178177 {
179178 // Save the Just My Code setting. We will set it once the engine is created.
180179 m_sessionConfig . JustMyCode = args . GetValueAsBool ( "justMyCode" ) . GetValueOrDefault ( m_sessionConfig . JustMyCode ) ;
@@ -210,26 +209,26 @@ private void SetCommonDebugSettings(Dictionary<string, JToken> args, out int sou
210209 m_logger . SetLoggingConfiguration ( LoggingCategory . AdapterResponse , traceResponse . Value ) ;
211210 }
212211 }
212+ }
213+
214+ private void SetCommonMISettings ( Dictionary < string , JToken > args )
215+ {
216+ string miMode = args . GetValueAsString ( "MIMode" ) ;
213217
214- sourceFileMappings = 0 ;
215- Dictionary < string , string > sourceFileMap = null ;
218+ // If MIMode is not provided, set default to GDB.
219+ if ( string . IsNullOrEmpty ( miMode ) )
220+ {
221+ args [ "MIMode" ] = "gdb" ;
222+ }
223+ else
216224 {
217- dynamic sourceFileMapProperty = args . GetValueAsObject ( "sourceFileMap" ) ;
218- if ( sourceFileMapProperty != null )
225+ // If lldb and there is no miDebuggerPath, set it.
226+ bool hasMiDebuggerPath = args . ContainsKey ( "miDebuggerPath" ) ;
227+ if ( miMode == "lldb" && ! hasMiDebuggerPath )
219228 {
220- try
221- {
222- sourceFileMap = sourceFileMapProperty . ToObject < Dictionary < string , string > > ( ) ;
223- sourceFileMappings = sourceFileMap . Count ;
224- }
225- catch ( Exception e )
226- {
227- SendMessageEvent ( MessagePrefix . Error , "Configuration for 'sourceFileMap' has a format error and will be ignored.\n Exception: " + e . Message ) ;
228- sourceFileMap = null ;
229- }
229+ args [ "miDebuggerPath" ] = MILaunchOptions . GetLLDBMIPath ( ) ;
230230 }
231231 }
232- m_pathConverter . m_pathMapper = new PathMapper ( sourceFileMap ) ;
233232 }
234233
235234 private ProtocolException VerifyLocalProcessId ( string processId , string telemetryEventName , out int pid )
@@ -310,14 +309,11 @@ private static long FileTimeToPosix(FILETIME ft)
310309
311310 public void BeforeContinue ( )
312311 {
313- if ( ! m_isCoreDump )
314- {
315- m_isStepping = false ;
316- m_isStopped = false ;
317- m_variableManager . Reset ( ) ;
318- m_frameHandles . Reset ( ) ;
319- m_threadFrameEnumInfos . Clear ( ) ;
320- }
312+ m_isStepping = false ;
313+ m_isStopped = false ;
314+ m_variableManager . Reset ( ) ;
315+ m_frameHandles . Reset ( ) ;
316+ m_threadFrameEnumInfos . Clear ( ) ;
321317 }
322318
323319 public void Stopped ( IDebugThread2 thread )
@@ -774,8 +770,7 @@ protected override void HandleLaunchRequestAsync(IRequestResponder<LaunchArgumen
774770 }
775771 }
776772
777- int sourceFileMappings = 0 ;
778- SetCommonDebugSettings ( responder . Arguments . ConfigurationProperties , sourceFileMappings : out sourceFileMappings ) ;
773+ SetCommonDebugSettings ( responder . Arguments . ConfigurationProperties ) ;
779774
780775 bool success = false ;
781776 try
@@ -790,22 +785,7 @@ protected override void HandleLaunchRequestAsync(IRequestResponder<LaunchArgumen
790785 // Don't convert the workingDirectory string if we are a pipeTransport connection. We are assuming that the user has the correct directory separaters for their target OS
791786 string workingDirectoryString = pipeTransport != null ? workingDirectory : m_pathConverter . ConvertClientPathToDebugger ( workingDirectory ) ;
792787
793- bool debugServerUsed = false ;
794- bool isOpenOCD = false ;
795- bool stopAtEntrypoint ;
796- bool visualizerFileUsed ;
797- string launchOptions = MILaunchOptions . CreateLaunchOptions (
798- program : program ,
799- workingDirectory : workingDirectoryString ,
800- args : JsonConvert . SerializeObject ( responder . Arguments . ConfigurationProperties ) ,
801- isPipeLaunch : responder . Arguments . ConfigurationProperties . ContainsKey ( "pipeTransport" ) ,
802- stopAtEntry : out stopAtEntrypoint ,
803- isCoreDump : out m_isCoreDump ,
804- debugServerUsed : out debugServerUsed ,
805- isOpenOCD : out isOpenOCD ,
806- visualizerFileUsed : out visualizerFileUsed ) ;
807-
808- m_sessionConfig . StopAtEntrypoint = stopAtEntrypoint ;
788+ m_sessionConfig . StopAtEntrypoint = responder . Arguments . ConfigurationProperties . GetValueAsBool ( "stopAtEntry" ) . GetValueOrDefault ( false ) ;
809789
810790 m_processId = Constants . InvalidProcessId ;
811791 m_processName = program ;
@@ -816,14 +796,18 @@ protected override void HandleLaunchRequestAsync(IRequestResponder<LaunchArgumen
816796 flags = enum_LAUNCH_FLAGS . LAUNCH_NODEBUG ;
817797 }
818798
799+ SetCommonMISettings ( responder . Arguments . ConfigurationProperties ) ;
800+
801+ string launchJson = JsonConvert . SerializeObject ( responder . Arguments . ConfigurationProperties ) ;
802+
819803 // Then attach
820804 hr = m_engineLaunch . LaunchSuspended ( null ,
821805 m_port ,
822806 program ,
823807 null ,
824808 null ,
825809 null ,
826- launchOptions ,
810+ launchJson ,
827811 flags ,
828812 0 ,
829813 0 ,
@@ -869,18 +853,11 @@ protected override void HandleLaunchRequestAsync(IRequestResponder<LaunchArgumen
869853
870854 var properties = new Dictionary < string , object > ( StringComparer . Ordinal ) ;
871855
872- properties . Add ( DebuggerTelemetry . TelemetryIsCoreDump , m_isCoreDump ) ;
873- if ( debugServerUsed )
874- {
875- properties . Add ( DebuggerTelemetry . TelemetryUsesDebugServer , isOpenOCD ? "openocd" : "other" ) ;
876- }
877856 if ( flags . HasFlag ( enum_LAUNCH_FLAGS . LAUNCH_NODEBUG ) )
878857 {
879858 properties . Add ( DebuggerTelemetry . TelemetryIsNoDebug , true ) ;
880859 }
881860
882- properties . Add ( DebuggerTelemetry . TelemetryVisualizerFileUsed , visualizerFileUsed ) ;
883- properties . Add ( DebuggerTelemetry . TelemetrySourceFileMappings , sourceFileMappings ) ;
884861 properties . Add ( DebuggerTelemetry . TelemetryMIMode , mimode ) ;
885862
886863 DebuggerTelemetry . ReportTimedEvent ( telemetryEventName , DateTime . Now - launchStartTime , properties ) ;
@@ -930,8 +907,6 @@ protected override void HandleAttachRequestAsync(IRequestResponder<AttachArgumen
930907 JObject pipeTransport = responder . Arguments . ConfigurationProperties . GetValueAsObject ( "pipeTransport" ) ;
931908 bool isPipeTransport = ( pipeTransport != null ) ;
932909 bool isLocal = string . IsNullOrEmpty ( miDebuggerServerAddress ) && ! isPipeTransport ;
933- bool visualizerFileUsed = false ;
934- int sourceFileMappings = 0 ;
935910 string mimode = responder . Arguments . ConfigurationProperties . GetValueAsString ( "MIMode" ) ;
936911
937912 if ( isLocal )
@@ -968,11 +943,10 @@ protected override void HandleAttachRequestAsync(IRequestResponder<AttachArgumen
968943 return ;
969944 }
970945
971- SetCommonDebugSettings ( responder . Arguments . ConfigurationProperties , sourceFileMappings : out sourceFileMappings ) ;
946+ SetCommonDebugSettings ( responder . Arguments . ConfigurationProperties ) ;
972947
973948 string program = responder . Arguments . ConfigurationProperties . GetValueAsString ( "program" ) ;
974949 string executable = null ;
975- string launchOptions = null ;
976950 bool success = false ;
977951 try
978952 {
@@ -990,21 +964,6 @@ protected override void HandleAttachRequestAsync(IRequestResponder<AttachArgumen
990964 responder . SetError ( CreateProtocolExceptionAndLogTelemetry ( telemetryEventName , 1011 , "debuggerPath is required for attachTransport." ) ) ;
991965 return ;
992966 }
993- bool debugServerUsed = false ;
994- bool isOpenOCD = false ;
995- bool stopAtEntrypoint = false ;
996-
997- launchOptions = MILaunchOptions . CreateLaunchOptions (
998- program : program ,
999- workingDirectory : String . Empty , // No cwd for attach
1000- args : JsonConvert . SerializeObject ( responder . Arguments . ConfigurationProperties ) ,
1001- isPipeLaunch : responder . Arguments . ConfigurationProperties . ContainsKey ( "pipeTransport" ) ,
1002- stopAtEntry : out stopAtEntrypoint ,
1003- isCoreDump : out m_isCoreDump ,
1004- debugServerUsed : out debugServerUsed ,
1005- isOpenOCD : out isOpenOCD ,
1006- visualizerFileUsed : out visualizerFileUsed ) ;
1007-
1008967
1009968 if ( string . IsNullOrEmpty ( program ) )
1010969 {
@@ -1031,19 +990,6 @@ protected override void HandleAttachRequestAsync(IRequestResponder<AttachArgumen
1031990 return ;
1032991 }
1033992
1034- bool debugServerUsed = false ;
1035- bool isOpenOCD = false ;
1036- bool stopAtEntrypoint = false ;
1037- launchOptions = MILaunchOptions . CreateLaunchOptions (
1038- program : program ,
1039- workingDirectory : string . Empty ,
1040- args : JsonConvert . SerializeObject ( responder . Arguments . ConfigurationProperties ) ,
1041- isPipeLaunch : responder . Arguments . ConfigurationProperties . ContainsKey ( "pipeTransport" ) ,
1042- stopAtEntry : out stopAtEntrypoint ,
1043- isCoreDump : out m_isCoreDump ,
1044- debugServerUsed : out debugServerUsed ,
1045- isOpenOCD : out isOpenOCD ,
1046- visualizerFileUsed : out visualizerFileUsed ) ;
1047993 executable = program ;
1048994 m_isAttach = true ;
1049995 }
@@ -1054,8 +1000,12 @@ protected override void HandleAttachRequestAsync(IRequestResponder<AttachArgumen
10541000 }
10551001 m_processName = program ?? string . Empty ;
10561002
1003+ SetCommonMISettings ( responder . Arguments . ConfigurationProperties ) ;
1004+
1005+ string launchJson = JsonConvert . SerializeObject ( responder . Arguments . ConfigurationProperties ) ;
1006+
10571007 // attach
1058- int hr = m_engineLaunch . LaunchSuspended ( null , m_port , executable , null , null , null , launchOptions , 0 , 0 , 0 , 0 , this , out m_process ) ;
1008+ int hr = m_engineLaunch . LaunchSuspended ( null , m_port , executable , null , null , null , launchJson , 0 , 0 , 0 , 0 , this , out m_process ) ;
10591009
10601010 if ( hr != HRConstants . S_OK )
10611011 {
@@ -1096,8 +1046,6 @@ protected override void HandleAttachRequestAsync(IRequestResponder<AttachArgumen
10961046
10971047 var properties = new Dictionary < string , object > ( StringComparer . Ordinal ) ;
10981048 properties . Add ( DebuggerTelemetry . TelemetryMIMode , mimode ) ;
1099- properties . Add ( DebuggerTelemetry . TelemetryVisualizerFileUsed , visualizerFileUsed ) ;
1100- properties . Add ( DebuggerTelemetry . TelemetrySourceFileMappings , sourceFileMappings ) ;
11011049
11021050 DebuggerTelemetry . ReportTimedEvent ( telemetryEventName , DateTime . Now - attachStartTime , properties ) ;
11031051 success = true ;
@@ -1252,10 +1200,7 @@ protected override void HandleStepInRequestAsync(IRequestResponder<StepInArgumen
12521200 }
12531201 catch ( AD7Exception e )
12541202 {
1255- if ( m_isCoreDump )
1256- {
1257- responder . SetError ( new ProtocolException ( e . Message ) ) ;
1258- }
1203+ responder . SetError ( new ProtocolException ( e . Message ) ) ;
12591204 }
12601205 }
12611206
0 commit comments