microsoft / vscode-cpptools

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

[GDB pipe DOCKER] Breakpoint hit in runtime loaded lib may not respond in UI #12637

Open zhekaso opened 2 weeks ago

zhekaso commented 2 weeks ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: My launch.json use pipe to docker container. I am try to debug program which is use munit C testing framework. Program logic is this: dlopen application-tests-lib -> munit run test from this lib -> munit internal fork -> test is running. Breakpoint is set in application-tests-lib which is loaded in rutime. Sometimes the breakpoint is hit, but sometimes VSCode has no reaction and in the log I see breakpoint hit on 'remote' side and gdb is waiting.

Debugger Configurations

{
    "version": "2.0.0",
    "configurations": [
        {
            "name": "(gdb) Pipe to docker",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/user/projects/base/sim/.rootfs/usr/bin/tests-runner",
            "args": [
                "--work-dir=/home/user/projects/base/sim/.rootfs",
                "--cores-dir=./usr/lib/cores",
                "--tests-dir=./usr/lib/tests",
                "--tests-lib-filter=(?!.*sdk)pp-manager",
                "--",
                "unit/pp-manager/l2-mac-ip/audit-all-cleared"
            ],
            "stopAtEntry": false,
            "cwd": "/home/user/projects/base/sim/",
            "environment": [],
            "externalConsole": false,
            "pipeTransport": {
                "debuggerPath": "/usr/bin/gdb",
                /* builder.sh runs docker container. */
                "pipeProgram": "${workspaceFolder}/../../builder/builder.sh",
                "pipeArgs": ["run", "-pipe"],
                "pipeCwd": "${workspaceFolder}/../../builder/",
                "quoteArgs": false
            },
            "sourceFileMap": {
                "/home/user/projects": "${workspaceFolder}/../..",
            },
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "GDB format",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Follow fork child",
                    "text": "-gdb-set follow-fork-mode child",
                    "ignoreFailures": false
                }
            ],
            "logging": {"trace": true, "engineLogging":true, "programOutput": true, "traceResponse": true, "moduleLoad": true, "exceptions": true}
        }
    ],
}

Debugger Logs

--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"Thread 2.1 \"tests-runner\" hit Breakpoint 2, init_pp_manager (params=0x0, user_data=0x561920a8a3ec) at tests/pp-manager-core/pp_manager_utils.c:100\n"},"seq":629}
Thread 2.1 "tests-runner" hit Breakpoint 2, init_pp_manager (params=0x0, user_data=0x561920a8a3ec) at tests/pp-manager-core/pp_manager_utils.c:100
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"100\t\trmkdir(buff, S_IRWXU);\n"},"seq":631}
100     rmkdir(buff, S_IRWXU);
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1506) <-1031-thread-info\n"},"seq":633}
1: (1506) <-1031-thread-info
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1506) ->1031^done,threads=[{id=\"2\",target-id=\"Thread 0x7fd9b94bdc40 (LWP 175)\",name=\"tests-runner\",frame={level=\"0\",addr=\"0x00007fd9b7c1c757\",func=\"init_pp_manager\",args=[{name=\"params\",value=\"0x0\"},{name=\"user_data\",value=\"0x561920a8a3ec\"}],file=\"tests/pp-manager-core/pp_manager_utils.c\",fullname=\"/home/user/projects/eltex-services/pp-manager/tests/pp-manager-core/pp_manager_utils.c\",line=\"100\",arch=\"i386:x86-64\"},state=\"stopped\",core=\"1\"}],current-thread-id=\"2\"\n"},"seq":635}
1: (1506) ->1031^done,threads=[{id="2",target-id="Thread 0x7fd9b94bdc40 (LWP 175)",name="tests-runner",frame={level="0",addr="0x00007fd9b7c1c757",func="init_pp_manager",args=[{name="params",value="0x0"},{name="user_data",value="0x561920a8a3ec"}],file="tests/pp-manager-core/pp_manager_utils.c",fullname="/home/user/projects/eltex-services/pp-manager/tests/pp-manager-core/pp_manager_utils.c",line="100",arch="i386:x86-64"},state="stopped",core="1"}],current-thread-id="2"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1507) ->(gdb)\n"},"seq":637}
1: (1507) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1507) 1029: elapsed time 27\n"},"seq":639}
1: (1507) 1029: elapsed time 27
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1507) Send Event AD7BreakpointBoundEvent\n"},"seq":641}
1: (1507) Send Event AD7BreakpointBoundEvent
--> E (breakpoint): {"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":4,"verified":true,"line":130,"BoundBreakpoints":[]}},"seq":643}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1507) 1030: elapsed time 3\n"},"seq":645}
1: (1507) 1030: elapsed time 3
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1508) Send Event AD7ProcessInfoUpdatedEvent\n"},"seq":647}
1: (1508) Send Event AD7ProcessInfoUpdatedEvent
--> E (process): {"type":"event","event":"process","body":{"startMethod":"launch","name":"/home/user/projects/base/sim/.rootfs/usr/bin/tests-runner","systemProcessId":0,"pointerSize":64},"seq":649}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1508) Send Event AD7ThreadCreateEvent\n"},"seq":651}
1: (1508) Send Event AD7ThreadCreateEvent
--> E (thread): {"type":"event","event":"thread","body":{"reason":"started","threadId":175},"seq":653}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (1508) 1031: elapsed time 2\n"},"seq":655}
1: (1508) 1031: elapsed time 2
<--   C (threads-12): {"command":"threads","type":"request","seq":12}
--> R (threads-12): {"type":"response","request_seq":12,"success":true,"command":"threads","body":{"threads":[{"id":175,"name":"tests-runner [175]"}]},"seq":658}

Other Extensions

No response

Additional Information

Logs when breakpoint not hit in UI: problem.log Logs when breakpoint is hit in UI: no-problem.log

zhekaso commented 2 weeks ago

Without fork problem is same. So i think main reason is pending breakpoint resolution.

github-actions[bot] commented 2 weeks ago

Thank you for reporting this issue. We’ll let you know if we need more information to investigate it. Additionally, if you're working with GDB/LLDB, please note that the code is open source at https://github.com/microsoft/MIEngine/wiki/Contributing-Code . Your contributions are always welcome and appreciated.