
C++ Just My Code Stepping in Visual Studio - jjuhl
https://blogs.msdn.microsoft.com/vcblog/2018/06/29/announcing-jmc-stepping-in-visual-studio/
======
waynecochran
Great. Now if they can actually fix the debugger to lock onto a single thread
when stepping thru multithreaded code. Currently when you set a breakpoint and
step, you’ll be jarringly switched back to the breakpoint when another thread
hits it. The solutions now are tedious :
[https://visualstudio.uservoice.com/forums/121579-visual-
stud...](https://visualstudio.uservoice.com/forums/121579-visual-studio-
ide/suggestions/8543248-make-the-debugger-stick-to-the-current-thread-inst)

~~~
1_player
The problem is that the normal implementation of a breakpoint/step is replace
a single byte with a 0xCC opcode (INT 3), which will be hit by every thread.
Making it lock onto a single thread would require a conditional breakpoint,
checking the thread ID every time that code path is executed, which might
potentially use a lot of CPU. I'm not sure that kind of conditional breakpoint
has hardware support.

It's definitely possible to implement, but not as easy as using a regular INT
3 instruction.

~~~
legulere
Should be doable with help from the operating system to have thread-local
storage for the code segment when debugging.

~~~
1_player
That sounds like a pretty good idea, would be nice to see gdb implement
something like that.

------
melling
Someone had a useful gdb trick in a previous post:

[https://news.ycombinator.com/item?id=17427001](https://news.ycombinator.com/item?id=17427001)

“”” with gdb 7.12 or later, you can exclude files matching a glob with "skip
-gfile", e.g. "skip -gfile /usr/*" “””

------
ubadair
Using libClang and gdb:
[http://jefftrull.github.io/c++/gdb/python/libclang/llvm/2018...](http://jefftrull.github.io/c++/gdb/python/libclang/llvm/2018/04/30/stepping-
with-libclang.html)

------
a-dub
It would be pretty funny if they extended it to "just my uncommitted changes."
ie: I want to step through every line I have written, but skip everything
else...

------
scraft
It is funny how long this has been an issue and how I and so many people have
given up stepping in and instead jump to the actual user function, set break
point, and then step over at the source location, then unset the breakpoint
and continue. A bunch of crazy steps which you end up doing again and again.

Needless to say, this improvement is much welcomed!

~~~
Dinux
Visual Studio even created the "Jump to here" option to do just this, but I
agree this is how we all did it for a long time.

------
Dinux
As a developer spending hours a day in Visual Studio with C++ as primary
language this is a major improvement in terms of development time. Debugging
is a a time consuming task in any language, but library headers from STD and
Boost slow down the process tremendously.

~~~
johnboyer
Although it does help, I would say its only a bit faster than actually just
setting a breakpoint of where you want the code to stop, and running till
then, unlike Microsoft's example which shows 85 step intos, as if people
actually do that.

~~~
hhmc
It depends on the purpose of your debugging. If you know exactly where you
want to go then, as you say, this has diminished value. but debugging can
often be exploratory, in which case this feature could be a real timesaver.

------
spoiler
I love this idea. I wonder if something similar could be ported/achieved for
JavaScript!

~~~
maddyboo
Not exactly the same, but you can use blackboxing [1] in the Chrome DevTools
to isolate code you’ve written from library/framework code in the debugger.

[1]:
[https://developer.chrome.com/devtools/docs/blackboxing](https://developer.chrome.com/devtools/docs/blackboxing)

~~~
spoiler
Thanks for this! I didn't realise this feature existed.

------
chris_wot
I would love to know the best Linux/OS X GUI debugger... and can it do this?

~~~
neverfone
I don't know if there are any good Linux GUI debuggers, but gdb is a
comprehensive debugger and can do something similar with the skip command.

Any gui debugger for Linux is probably a frontend to gdb, so as long as it
lets you passthrough commands to gdb it can do this.

------
TylerGlaiel
Why does this require a special compiler switch? Can't the IDE just auto-step
until it gets back to your own file of code?

------
w_t_payne
Why has it taken this long for something so obvious to be implemented?

~~~
merinowool
So that people with VS2015 would have to buy new version...

~~~
rootlocus
I know you're sarcastic, but this was common practice at my previous shop.

------
anilgulecha
Just a clarifying note : this is the closed Visual Studio, and not free
software - VS Code - which usually does the rounds on HN.

I'm far more excited about the LSP protocol for C++ which would bring like
this to all IDEs.

~~~
Rusky
I don't think the LSP includes any debugging support?

~~~
anilgulecha
I meant the sister/offshoot of LSP:

[https://github.com/Microsoft/vscode-debugadapter-
node/tree/m...](https://github.com/Microsoft/vscode-debugadapter-
node/tree/master/protocol)

[https://code.visualstudio.com/docs/extensionAPI/api-
debuggin...](https://code.visualstudio.com/docs/extensionAPI/api-debugging)

