microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.5k stars 1.55k forks source link

debugging inside a lambda that captures this shows the 'lambda' this instead of the 'this' 'this' #12229

Open bradphelan opened 5 months ago

bradphelan commented 5 months ago

Type: Bug

I admit that the context for the debugger is kind of ambiguous. Lambdas are generated as anonymous structs and the lambda itself is a method on this anonymous struct. However

struct Foo {

void do(){
    auto l = [this]{
        foo = 10; // <- stop debugger here
    };
    l();
}

int foo  0;

}

when you look at the debugger a this in the locals shown but it's actually the lambda rather than the Foo class. Also it is not possible to inspect member foo from the point where the debugger is stopped

image

Extension version: 1.20.1 VS Code version: Code 1.88.1 (e170252f762678dec6ca2cc69aba1570769a5d39, 2024-04-10T17:41:02.734Z) OS version: Windows_NT x64 10.0.22631 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 9 5900X 12-Core Processor (24 x 3700)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|63.93GB (35.99GB free)| |Process Argv|--crash-reporter-id 8e0f3da2-bd7f-4547-b593-29b86ad0a63e| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp2r3:30993541 dsvsc020:30976470 pythonait:31006305 jchc7451:30973076 gee8j676:31009558 dsvsc021:30996838 9c06g630:31013171 ```
bradphelan commented 1 month ago

Any hints on where this problem might live?

sean-mcmanus commented 1 month ago

@bradphelan Are you using vsdbg or cppdbg? (debugger task type)