Skip to content

Commit 1f0fcc5

Browse files
Фикс HasExited и получения PathsMapper из json
1 parent 00a373d commit 1f0fcc5

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

src/VSCode.DebugAdapter/DebugeeProcess.cs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,20 @@ public DebugeeProcess(PathHandlingStrategy pathHandling)
4242
_strategy = pathHandling;
4343
}
4444

45-
public bool HasExited => _process?.HasExited ?? true;
45+
public bool HasExited
46+
{
47+
get
48+
{
49+
if (_process != null)
50+
return _process.HasExited;
51+
52+
if (_attachMode && _debugger != null)
53+
return false;
54+
55+
return true;
56+
}
57+
}
58+
4659
public int ExitCode => _process?.ExitCode ?? 0;
4760

4861
public int DebugPort { get; set; }
@@ -112,16 +125,28 @@ public void Init(JObject args)
112125

113126
public void InitPathsMapper(JObject args)
114127
{
128+
if (args == null)
129+
{
130+
PathsMapper = null;
131+
return;
132+
}
115133

116134
try
117135
{
118-
PathsMapper = args.ToObject<WorkspaceMapper>();
136+
var mappingToken = args["pathsMapping"];
137+
if (mappingToken == null || mappingToken.Type == JTokenType.Null)
138+
{
139+
PathsMapper = null;
140+
return;
141+
}
142+
143+
PathsMapper = mappingToken.ToObject<WorkspaceMapper>();
119144
}
120-
catch
145+
catch (Exception ex)
121146
{
122-
PathsMapper = new WorkspaceMapper("", "");
147+
Log.Warning(ex, "Failed to initialize paths mapper; path mapping will be disabled");
148+
PathsMapper = null;
123149
}
124-
125150
}
126151

127152
protected abstract Process CreateProcess();
@@ -290,7 +315,8 @@ public Breakpoint[] SetBreakpoints(IEnumerable<Breakpoint> breakpoints)
290315
{
291316
var breakpointsArray = breakpoints.ToArray();
292317

293-
if (PathsMapper != null) {
318+
if (PathsMapper != null)
319+
{
294320
for (int i = 0; i < breakpointsArray.Length; i++)
295321
{
296322
breakpointsArray[i].Source = PathsMapper.LocalToRemote(breakpointsArray[i].Source);
@@ -324,7 +350,8 @@ public StackFrame[] GetStackTrace(int threadId, int firstFrameIdx, int limit)
324350

325351
allFrames[i].ThreadId = threadId;
326352

327-
if (pathsMapperInit) {
353+
if (pathsMapperInit)
354+
{
328355
allFrames[i].Source = PathsMapper.RemoteToLocal(allFrames[i].Source);
329356
}
330357

0 commit comments

Comments
 (0)