@@ -198,6 +198,41 @@ private void RaiseOutputReceivedEvent(string category, string data)
198198 OutputReceived ? . Invoke ( this , new DebugeeOutputEventArgs ( category , data ) ) ;
199199 }
200200
201+ private string ApplyRemoteWorkspaceString ( string path )
202+ {
203+ var clientPath = path ;
204+
205+ if ( ! string . IsNullOrWhiteSpace ( HostWorkspace ) && ! string . IsNullOrWhiteSpace ( RemoteWorkspace ) )
206+ {
207+
208+ var hostWorkspace = HostWorkspace ;
209+ var remoteWorkspace = RemoteWorkspace ;
210+
211+ string normalizedClientPath = clientPath . Replace ( '/' , '\\ ' ) . Trim ( ) ;
212+ string normalizedHostWorkspace = hostWorkspace . Replace ( '/' , '\\ ' ) . Trim ( ) ;
213+
214+ if ( ! normalizedHostWorkspace . EndsWith ( "\\ " ) )
215+ normalizedHostWorkspace += "\\ " ;
216+
217+ if ( normalizedClientPath . StartsWith ( normalizedHostWorkspace , StringComparison . OrdinalIgnoreCase ) )
218+ {
219+
220+ string relativePath = normalizedClientPath . Substring ( normalizedHostWorkspace . Length ) ;
221+
222+ string normalizedRemote = remoteWorkspace . Trim ( ) . Replace ( '\\ ' , '/' ) ;
223+ normalizedRemote = normalizedRemote . TrimEnd ( '/' ) ;
224+
225+ clientPath = string . IsNullOrEmpty ( relativePath )
226+ ? normalizedRemote
227+ : normalizedRemote + "/" + relativePath . Replace ( '\\ ' , '/' ) ;
228+
229+ }
230+ }
231+
232+ return clientPath ;
233+
234+ }
235+
201236 private void Terminate ( )
202237 {
203238 if ( ! _terminated )
@@ -273,7 +308,14 @@ public void SetExceptionsBreakpoints((string Id, string Condition)[] filters)
273308
274309 public Breakpoint [ ] SetBreakpoints ( IEnumerable < Breakpoint > breakpoints )
275310 {
276- var confirmedBreaks = _debugger . SetMachineBreakpoints ( breakpoints . ToArray ( ) ) ;
311+ var breakpointsArray = breakpoints . ToArray ( ) ;
312+
313+ for ( int i = 0 ; i < breakpointsArray . Length ; i ++ )
314+ {
315+ breakpointsArray [ i ] . Source = ApplyRemoteWorkspaceString ( breakpointsArray [ i ] . Source ) ;
316+ }
317+
318+ var confirmedBreaks = _debugger . SetMachineBreakpoints ( breakpointsArray ) ;
277319
278320 return confirmedBreaks ;
279321 }
@@ -297,6 +339,7 @@ public StackFrame[] GetStackTrace(int threadId, int firstFrameIdx, int limit)
297339 for ( int i = firstFrameIdx ; i < limit && i < allFrames . Length ; i ++ )
298340 {
299341 allFrames [ i ] . ThreadId = threadId ;
342+ allFrames [ i ] . Source = ApplyRemoteWorkspaceString ( allFrames [ i ] . Source ) ;
300343 result . Add ( allFrames [ i ] ) ;
301344 }
302345
0 commit comments