Closed noam-sol closed 1 year ago
I see the point, async (uri, token) => ...
is part of argument and should be parsed as part of method call, but not stand alone method body inside another method.
This should be carefully investigated first (in order to detect argument-related part), since we have a lot of breakpoint resolve related cases that must care about.
I have found that this patch resolves this, but it drops support from what the comment says here-
This is wrong "fix" for sure, since it broke another case.
Proper solution?
SymbolReader.cs
operate with debug info, that could provide "source code line" to "IL offset/method token" mapping. Debug info don't provide any info about code execution "hierarchy". The real fix should use metadata, that is part of debuggee process IMO (debugger should find out, is this method part of argument or not). We don't have such logic now, this should be investigated and implemented.
(debugger should find out, is this method part of argument or not)
it sounds a bit heuristic, isn't it? I can try implementing this if you guys think it's the right approach, but I'd like to suggest some other idea-
To check whether both functinos are on the same line, and in that case break on the outer one.
does that sound ok? I'm thinking whether it should already work in this clause - https://github.com/Samsung/netcoredbg/blob/294177eb3b7c0822c5b3db25bdae2f54b2c3e03b/src/metadata/modules_sources.cpp#L156
However, I'm getting some bad (?) debug info - nested_p.StartLine
is one line below current_p.StartLine
although they are on the same source line.
it sounds a bit heuristic, isn't it? I can try implementing this if you guys think it's the right approach
Unfortunately, I don't really sure in what way we should do this, not even sure my suggestion is correct.
To check whether both functinos are on the same line, and in that case break on the outer one.
I think, you can't implement proper fix from this point, since you don't have all info you need.
Probably, we may fix this case by implement all parent
method sequence points check, I believe this should looks like this:
void f()
{ <--- parent.StartLine (parent sequence point1 start, parent sequence point1 end)
await Parallel.ForEachAsync( async (uri, token) => <--- (parent sequence point2 start)
{ <--- nested.StartLine
await new HttpClient().GetAsync("https://google.com");
} <--- nested.endLine
); <--- (parent sequence point2 end)
} <--- parent.endLine (parent sequence point2 start, parent sequence point2 end)
void f()
{ <--- parent.StartLine (parent sequence point1 start, parent sequence point1 end)
void ForEach( async (uri, token)
{ <--- nested.StartLine
return;
}; <--- nested.endLine
} <--- parent.endLine (parent sequence point3 start, parent sequence point3 end)
breakpoint resolve should care about all methods data in case line have code, but, should skip nested
method that is part of some parent
method sequence point in case breakpoint set at line without code and should be "corrected" to first line with code. But at this moment debugger's breakpoint-related structures don't store info we need for this check and managed part don't have related code.
Unfortunately, I can't tell you idea you could implement, this should be investigated carefully first, but I don't have time now.
and managed part don't have related code.
@viewizard I think it does? https://github.com/Samsung/netcoredbg/blob/8d9744a6bdee044fd2cc73dd142bf6eba1ad34a1/src/managed/SymbolReader.cs#L795
and on that clause the nested breakpoint is actually added, maybe I can check for sequence point parent-child relations around here?
I think it does?
I believe, implementation should start from https://github.com/Samsung/netcoredbg/blob/8d9744a6bdee044fd2cc73dd142bf6eba1ad34a1/src/metadata/modules_sources.cpp#L709, since in case breakpoint set to line without code, at fast look, logic should not provide as closestNestedToken
method tokens that is part of "arguments".
This should be fixed in latest release. Feel free to reopen if you see any more related issues.
Steps to reproduce
Add a breakpoint on line 6:
await Parallel.ForEachAsync(userHandlers, parallelOptions, async (uri, token) =>
return 0;
below.Mitigation
I have found that this patch resolves this, but it drops support from what the comment says here-
Proper solution?
Maybe on managed part? on
SymbolReader.cs
there's this condition - https://github.com/Samsung/netcoredbg/blob/db69338cf1606d8d327de0eaaf1694d8463af135/src/managed/SymbolReader.cs#L795I added some prints -
and they are -
I'm not sure if the condition needs to be changed, or it's given some bad input. That's because the nested function is not really between
10:5
to10:6
, and actaully contains multiple lines. So I'm not sure how to really solve this properly.