-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement Jump to Line #1042
base: main
Are you sure you want to change the base?
implement Jump to Line #1042
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract public Task ExecJump(string filename, int line); [](start = 8, length = 57)
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this temporary breakpoint not registered, when we get a stopping event it will be unknown and returned as an exception.
_callback.OnException(thread, "Unknown breakpoint", "", 0); |
I think we need to treat this as an async break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by not registered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On stopping and when it is a breakpoint, we go through a list of breakpoints:
AD7BoundBreakpoint[] bkpt = _breakpointManager.FindHitBreakpoints(bkptno, addr, frame, out fContinue); |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"
src/OpenDebugAD7/AD7DebugSession.cs
Outdated
} | ||
targets.Add(new GotoTarget(m_gotoCodeContexts.Create(codeContext), contextName, line)); | ||
|
||
int codeContextId = m_nextContextId++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} [](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 |
@@ -216,6 +216,7 @@ public int Jump(ulong address) | |||
_engineCallback.OnError(EngineUtils.GetExceptionDescription(e)); | |||
return Constants.E_ABORT; | |||
} | |||
DebuggedProcess.ThreadCache.MarkDirty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed to update the current line in the UI. Is it the right place?
@@ -1344,7 +1344,7 @@ protected override void HandleGotoRequestAsync(IRequestResponder<GotoArguments> | |||
if (!m_threads.TryGetValue(responder.Arguments.ThreadId, out thread)) | |||
throw new AD7Exception("Unknown thread id: " + responder.Arguments.ThreadId.ToString(CultureInfo.InvariantCulture)); | |||
} | |||
BeforeContinue(); | |||
//BeforeContinue(); | |||
builder.CheckHR(thread.SetNextStatement(null, gotoTarget)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -201,6 +201,8 @@ public override Task ExecJump(string filename, int line) | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is if some kind of error handling is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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