Skip to content

Windows pause_execution on a launched C/C++ program anchors get_stack_trace on the injected break-in thread (all internal), not the program thread in main #898

Closed

Description

@debugmcpdev

Summary

On Windows, pause_execution on a launched C/C++ program lands on the thread Windows injects for the break-in, and get_stack_trace anchors there — a stack with no program frame at all — while the program's own thread sits in main one list_threads away.

Measured (Windows 11, main + #894, CodeLLDB 1.11.8, MSYS2 g++ 15.2.0, dev server)

create_debug_session cpp → start_debugging examples/cpp/pause_test.cpp → pause_execution → get_stack_trace:

stopReason: pause (rawReason exception, "Exception 0x80000003 encountered at address 0x7ff958103ab0")
threadId 28180 ("5: tid=28180")
stackFrames: [DbgBreakPoint @DbgBreakPoint]          <- 1 shown
hiddenFrames: 3  (DbgUiRemoteBreakin, BaseThreadInitThunk, RtlUserThreadStart)
note: "All 4 frames are internal/runtime frames; showing the top internal frame ..."

list_threads → five threads; get_stack_trace { threadId: 24604 } ("1: tid=24604") → std::this_thread::sleep_for<...> (this_thread_sleep.h:82), main (pause_test.cpp:20), hiddenFrames: 10.

Before #894 the break-in stack showed all four native frames (nothing hidden); after it the #346 guarantee keeps DbgBreakPoint and says every frame is internal. Either way the agent has to know to go looking for the other thread.

Expected

The attach path already handles this shape: on a Windows attach CodeLLDB reports the stop on the break-in thread and the attach controller moves the current thread to the first thread whose stack reaches user code (attach-controller.ts reachesSource, issues #761/#817, pinned by session-manager-attach-modes.test.ts "moves off a reported stop thread whose stack never reaches user code"). A pause_execution stop on Windows should get the same treatment: when the stopped thread's stack is entirely internal (allFramesInternal) and a sibling's stack reaches user code, anchor on the sibling and disclose the switch in note — the resolver's existing sibling adoption (frame-anchor-resolver.ts ~436) does this for a frameless stopped thread; extending it to an all-internal one covers this case.

Found while measuring #824.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions