Vscode-cpptools: Support "set-next-statement"

Created on 11 Sep 2017  Â·  17Comments  Â·  Source: microsoft/vscode-cpptools

The ability to modify the instruction pointer to point a different location without running any code is an extremely useful debugging feature in C/C++. I'd like to request this feature in the toolset.

Visual Studio has an implementation of this, referred to as "Set Next Statement" in the UI. It is normally done by either dragging the yellow arrow indicating the currently executing line of code, or by right clicking a line and choosing "Set Next Statement".
https://msdn.microsoft.com/en-us/library/y740d9d3.aspx#Anchor_4

It appears the protocol for this is already implemented in VS Code.
https://github.com/Microsoft/vscode-debugadapter-node/issues/28
https://github.com/Microsoft/vscode-debugadapter-node/pull/45

Related: https://github.com/Microsoft/vscode/issues/12514

Feature Request debugger

All 17 comments

@akbyrd AFAIK gdb/lldb does not support anything like this today.

@pieandcakes I've not used them personally, but after a few searches it appears this capability exists in GDB and LLDB.

In GDB it's enabled by the jump command:
https://sourceware.org/gdb/current/onlinedocs/gdb/Jumping.html#Jumping

jump _location_
Resume execution at _location_.
The most common occasion to use the jump command is to back up—perhaps with more breakpoints set—over a portion of a program that has already executed, in order to examine its execution in more detail.

Thread where support for this was implemented in another IDE (also contains a link to a patch for another IDE with implementation)
http://forums.codeblocks.org/index.php?topic=10064.0

The LLDB manual explicitly gives an equivalent to the GDB jump command:
https://lldb.llvm.org/lldb-gdb.html

Skip 8 bytes ahead of the current program counter (instruction pointer). Note that we use backticks to evaluate an expression and insert the scalar result in LLDB.
(gdb) jump *$pc+8 | (lldb) register write pc $pc+8

And the repo actually has a script extension to make it look more like GDB jump:
https://github.com/llvm-mirror/lldb/blob/master/examples/python/jump.py

Provided I haven't misunderstood the purpose of the above command it would appear "set next statement" type behavior is well supported and fairly well used considering the amount of search hits.

@akbyrd Thank you for the information. We need to use gdb's MI mode to drive the debugger and I was able to find this:

The -exec-jump Command

Synopsis

 -exec-jump location


Resumes execution of the inferior program at the location specified by parameter. See Specify Location, for a description of the different forms of location. 

GDB Command

The corresponding GDB command is ‘jump’. 

Example

-exec-jump foo.c:10
*running,thread-id="all"
^running

i understand it cold be kinda off-topic but any idea about similar feature in c# debugger? should i reference some other group?

the feature by itself is one of they key tools while developing complex apis what require setting up a complex context for each call. As result ability to "re-walk" over and over again same code instance while modifying internal variables from the console becomes a huge time saver.

@kostyamy I would assume creating an issue in the C# repo and referencing this issue and the protocol implementation issue would be the best course of action.

@akbyrd it makes total sense but i bit confused what C# repo is?
is that https://github.com/OmniSharp/omnisharp-vscode or there is something like https://github.com/Microsoft/vscode-csharp ???

It looks like the OmniSharp repo is the official one

@akbyrd i just made a post there and referenced this issue. so thank you. hopefully they move fast enough

Any update on this? This is the one feature missing from moving exclusively to VScode.

I'd love to see this implemented. I need to use this occasionally and then always return to regular Visual Studio in frustration.

I agree with others here. This is one of the most powerful debuging features that I use in VS, and it really needs to be added to VSCode if at all possible..

I wonder if this feature has been added or is in development.

@BeBopping @TanWei @stephanreiter

Install the vsc extension of the link below.

https://marketplace.visualstudio.com/items?itemName=ntoskrnl7.cxx-set-next-statement-extension

It works well in cppvsdbg (vscode-cpptools -OpenDebugAD7).
However, GDB requires the following VSC extension(Debug Adapter) to be installed.
https://github.com/ntoskrnl7/code-debug/tree/support_gdb_goto_request

enjoy :)

Lol, gdb and lldb already support it

gdb

jump 10

10 is a code line

Plz, add support for native gcc and lldb. Also add ability to write commandline commands together with UI

@akbyrd AFAIK gdb/lldb does not support anything like this today.

this is completely false, both gdb and lldb support this

Hello,
We also need this feature in order to be able to properly debug on Visual Studio Code as we do on Visual Studio.
I understand that there is no "set next statement" method yet in the UI, but I tried to manually issue the -exec-jump foo.c:10 command in the Visual Studio Code debug console and it failed, is it expected?

@pieandcakes, from your previous reply, can you please confirm if the command -exec-jump foo.c:10 issued in the Visual Studio Code debug console (GDB) is expected to fail?

Was this page helpful?
0 / 5 - 0 ratings