alexsei
alexsei

Reputation: 21

VSCode Debuging GCC Condition breakpoint with string

In VSCode how can I set a conditional breakpoint like v.compare("2") == 0 using the graphical interface? I use this with C/C++ IntelliSense, debugging, and code browsing but the breakpoint does not work. (It always breaks regardless of the conditional value.)

image of conditional expression breakpoint

Adding the same breakpoint directly into GDB works:

(gdb) condition 1 v.compare("2") == 0
(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x000000000000166e in tttt(std::__cxx11::basic_string<char,std::char_traits<char>, std::allocator<char> > const&, bool)
                                                   at /home/butiaev/project/experience/vecxsdeq/project/executable/vecxsdeq.cpp:53
        stop only if v.compare("2") == 0
(gdb)

Upvotes: 1

Views: 1407

Answers (1)

Criminal_Affair_At_SO
Criminal_Affair_At_SO

Reputation: 3420

Assuming you have setup gdb as a debugging back-end in VSCode:

  • you left-click left of the line number to set up a breakpoint
  • a red dot appears
  • you right-click the red dot and select Edit breakpoint and you will be able to specify an expression, select number of hits or transform the breakpoint into a tracepoint.

Upvotes: 1

Related Questions