Conversation
|
Done. template <typename T>
int foo(T t)
{
return 0;
} |
| var response = new GotoTargetsResponse(); | ||
|
|
||
| var source = responder.Arguments.Source; | ||
| // TODO: handle this for disassembly debugging |
There was a problem hiding this comment.
// TODO: handle this for disassembly debugging [](start = 12, length = 46)
I feel like the right want to handle disassembly is to add a gotoInstruction request which would take a instructionReference and offset (like "InstructionBreakpoint")
| /// <summary> | ||
| /// Jumps to a specified target location | ||
| /// </summary> | ||
| abstract public Task ExecJump(string filename, int line); |
There was a problem hiding this comment.
abstract public Task ExecJump(string filename, int line); [](start = 8, length = 57)
Same
WardenGnaw
left a comment
There was a problem hiding this comment.
Made some fixes in 9696770
We get some weirdness since GoToRequest assumes the process is always stopped but the way GDB handles -exec-jump, it causes it to resume the process, so a temporary breakpoint is used.
However, in between the GoTo Request and before we get stopped at the temporary breakpoint, we get a StackTraceRequest. But since we are not stopped, we return no frames.
Thoughts on how to address this issue and my other comment about freezing other threads in a comment below?
| private async Task JumpInternal(string target) | ||
| { | ||
| // temporary breakpoint + jump | ||
| await _debugger.CmdAsync("-break-insert -t " + target, ResultClass.done); |
There was a problem hiding this comment.
With this temporary breakpoint not registered, when we get a stopping event it will be unknown and returned as an exception.
I think we need to treat this as an async break.
There was a problem hiding this comment.
What do you mean by not registered?
There was a problem hiding this comment.
On stopping and when it is a breakpoint, we go through a list of breakpoints:
If if there are none, we assume it is an entrypoint breakpoint, embedded, we hit a bp pending deletion, or it is an exception.
There was a problem hiding this comment.
Indeed. It does receive a breakpoint-modified event and disp is "del" fwiw.
<-1067-break-insert -t *0x5555555573B1
->1067^done,bkpt={number="3",type="breakpoint",disp="del",enabled="y",addr="0x00005555555573b1",func="main(int, "...
<-1068-exec-jump *0x5555555573B1
->1068^running
->*running,thread-id="all"
->=breakpoint-modified,bkpt={number="3",type="breakpoint",disp="del",enabled="y",addr="0x00005555555573b1",func="main(int, "...
->*stopped,reason="breakpoint-hit",disp="del",bkptno="3",frame={addr="0x00005555555573b1",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdb68"}],file="../test.cpp",fullname="/tmp/test.cpp",line="28",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="6"
->=breakpoint-deleted,id="3"
| } | ||
| targets.Add(new GotoTarget(m_gotoCodeContexts.Create(codeContext), contextName, line)); | ||
|
|
||
| int codeContextId = m_nextContextId++; |
There was a problem hiding this comment.
Wouldn't this need to be atomic if multiple simultaneous requests are expected?
| public async Task Jump(string filename, int line) | ||
| { | ||
| await MICommandFactory.ExecJump(filename, line); | ||
| } |
There was a problem hiding this comment.
I think we want to remove all the overloads that use filename and line number since we always seem to use the overload that take the address.
| } | ||
| BeforeContinue(); | ||
| builder.CheckHR(thread.SetNextStatement(null, gotoTarget)); | ||
| } |
There was a problem hiding this comment.
} [](start = 16, length = 1)
We need to throw if this if is false.
|
We are looking into splitting GoToTargets and the GoTo Request. |
|
@WardenGnaw Squashed and also removed the obsolete resource string. I also added a test commit using Other than that gdb's jump cmd is equal to |
| _engineCallback.OnError(EngineUtils.GetExceptionDescription(e)); | ||
| return Constants.E_ABORT; | ||
| } | ||
| DebuggedProcess.ThreadCache.MarkDirty(); |
There was a problem hiding this comment.
This was needed to update the current line in the UI. Is it the right place?
| } | ||
| BeforeContinue(); | ||
| //BeforeContinue(); | ||
| builder.CheckHR(thread.SetNextStatement(null, gotoTarget)); |
There was a problem hiding this comment.
You probably want BeforeContinue. The other debug adapter that the VS debugger team owns currently doesn't clear our handle collections on SetNextStatement, but you are probably correct that it should. But we should check VS Code and make sure it is happy.
There was a problem hiding this comment.
Yeah idk technically it doesn't run the program but on the other hand the current line of code needs to be updated. The thread cache invalidation worked in VSCode.
|
|
||
| public override Task ExecJump(ulong address) | ||
| { | ||
| return _debugger.ConsoleCmdAsync("set $pc = " + string.Format(CultureInfo.InvariantCulture, "0x{0:X}", address), false); |
There was a problem hiding this comment.
The question is if some kind of error handling is needed.
There was a problem hiding this comment.
Ideally yes, but since this is a non-MI command, there aren't wonderful options for knowing it is succeeded. I am not sure if GDB supports assigning to $pc through MI commands instead (-var-assign?)
There was a problem hiding this comment.
Looks like it but requires a variable object incl. creation/deletion (possibly just once): https://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI-Variable-Objects.html
|
If I may ask, what is the state of this pull request? Is there additional things to discuss? |
|
See all the comments after my last commit. |
|
Eclipse GDB debugger has two commands around -exec-jump: Move to Line, and Resume at Line. In the Move to Line, it does insert a breakpoint and then jumps: In the Resume at Line, it just does the jump: Visual Studio Set Next Statement behavior is the same as Eclipse's Move to Line. In other words, it does not continue the program execution. |
That |
|
The Context Management talks about the ‘--thread’ parameter:
https://sourceware.org/gdb/current/onlinedocs/gdb/Context-management.html#Context-management |
|
Interesting. But it doesn't make a difference here as it still runs all threads: So it could still theoretically break in another thread first. |
Interesting observation indeed. I had to turn on non-stop mode in order to behave as expected: |
|
And there's also scheduler-locking mode, very convoluted. |
|
Hello, |
|
See all the open discussions. There were some points without final resolution. |
fixes microsoft/vscode-cpptools#1025