microsoft / microsoft/vscode-cpptools

Extremely long time to reach the breakpoint with VSCode,but immediately with GDB directly

Open
#13,251 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug debugger help wanted
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and version: unbuntu 22.04
  • VS Code:1.96.4
  • C/C++ extension:Latest "C/C++ for VSCode" version
  • OS and version of remote machine (if applicable):unbuntu 22.04
  • GDB / LLDB version:GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
Bug Summary and Steps to Reproduce

Bug Summary:

I am debugging a Linux kernel with version 5.15.130 using the Serial Port /dev/ttyS0. When using Visual Studio Code (VSCode) to run the code to the breakpoint, it takes an extremely long time to reach the breakpoint. However, when using GDB directly, the code reaches the breakpoint almost immediately as the breakpoint is the entry point of the code. Interestingly, once the breakpoint is hit for the first time, subsequent runs to the breakpoint are faster, but still significantly slower than using GDB directly.

Debugger Configurations
My launch.json is configured as follows:
"version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/vmlinux",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/home/xx/sudo_gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                },
            ],
       }

The script sudo_gdb is specifically designed to launch GDB with root privileges, and its content is as follows:
#!/bin/zsh
pkexec /usr/bin/gdb "$@" -ex "target remote /dev/ttyS0" -ex "set directories /home/xx/linux-5.15.130"
Debugger Logs
Debug console log is as follows and delete some eedundancy lines:

1: (125) LaunchOptions{"name":"(gdb) Launch","type":"cppdbg","request":"launch","program":"/homexx/linux-5.15.130/vmlinux","args":[],"stopAtEntry":true,"cwd":"/home/xx/linux-5.15.130","environment":[],"externalConsole":false,"MIMode":"gdb","miDebuggerPath":"/home/xx/sudo_gdb","miDebuggerServerAddress":"/dev/ttyS0","setupCommands":[{"description":"Enable pretty-printing for gdb","text":"-enable-pretty-printing","ignoreFailures":true},{"description":"Set Disassembly Flavor to Intel","text":"-gdb-set disassembly-flavor intel","ignoreFailures":true}],"logging":{"engineLogging":true},"__configurationTarget":6,"__sessionId":"bed832ab-282a-4cb1-a339-f9471ee3e7b9"}
1: (198) Starting: "/home/xx/sudo_gdb" --interpreter=mi
1: (225) DebuggerPid=2357383
1: (10520) ->=thread-group-added,id="i1"
1: (10530) ->~"GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1\n"
1: (10530) ->~"Copyright (C) 2022 Free Software Foundation, Inc.\n"
1: (10530) ->~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
1: (10531) ->~"\nType \"show copying\" and \"show warranty\" for details.\n"
1: (10531) ->~"This GDB was configured as \"x86_64-linux-gnu\".\n"
1: (10532) ->~"Type \"show configuration\" for configuration details.\n"
1: (10532) ->~"For bug reporting instructions, please see:\n"
1: (10532) ->~"<https://www.gnu.org/software/gdb/bugs/>.\n"
1: (10532) ->~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
1: (10532) ->~"\n\n"
1: (10533) ->~"For help, type \"help\".\n"
1: (10533) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (10533) ->=cmd-param-changed,param="directories",value="/home/xx/linux-5.15.130:$cdir:$cwd"
1: (10533) ->(gdb)
1: (10541) <-1001-gdb-set mi-async on
1: (10542) ->1001^done
1: (10543) ->(gdb)
1: (10547) 1001: elapsed time 8



1: (12782) ->(gdb)
1: (12782) 1008: elapsed time 2216
1: (12786) <-1009-interpreter-exec console "show architecture"
1: (12787) ->~"The target architecture is set to \"auto\" (currently \"i386:x86-64\").\n"
1: (12787) ->1009^done
1: (12787) ->(gdb)
1: (12787) 1009: elapsed time 1
1: (12790) <-1010-break-insert -f main
1: (13105) ->&"Function \"main\" not defined.\n"
1: (13106) ->1010^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="main",times="0",original-location="main"}
1: (13106) ->(gdb)
1: (13110) 1010: elapsed time 320
1: (13112) <-1011-target-select remote /dev/ttyS0
1: (13478) ->=thread-group-started,id="i1",pid="42000"
1: (13478) ->=thread-created,id="1",group-id="i1"
1: (13478) ->=thread-created,id="2",group-id="i1"
1: (13478) ->=thread-created,id="3",group-id="i1"
1: (13478) ->=thread-created,id="4",group-id="i1"
1: (13478) ->=thread-created,id="5",group-id="i1"
1: (13478) ->=thread-created,id="6",group-id="i1"
1: (13478) ->=thread-created,id="7",group-id="i1"
1: (13478) ->=thread-created,id="8",group-id="i1"
1: (13478) ->=thread-created,id="9",group-id="i1"


1: (13527) <-1425-thread-info 414
1: (13527) <-1426-thread-info 415
1: (13527) <-1427-thread-info 416
1: (13527) <-1428-thread-info 417
1: (13527) <-1429-thread-info 418
1: (13527) <-1430-thread-info 419
1: (13527) <-1431-thread-info 420
1: (13527) <-1432-thread-info 421
1: (13527) <-1433-thread-info 422
1: (13527) <-1434-thread-info 423

thread-group-added,id="i1"
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="directories",value="/home/xx/linux-5.15.130:$cdir:$cwd"
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
To enable execution of this file add
	add-auto-load-safe-path /home/xx/linux-5.15.130/vmlinux-gdb.py
line to your configuration file "/root/.config/gdb/gdbinit".
To completely disable this security protection add
	set auto-load safe-path /
line to your configuration file "/root/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
	info "(gdb)Auto-loading safe path"
[Switching to Thread 4294967294]
kgdb_breakpoint () at kernel/debug/debug_core.c:1231
1231		wmb(); /* Sync point after breakpoint */


1: (15076) <-1511-thread-info
1: (15238) ->1013^done,threads=[{id="2",target-id="Thread 4294967293",details="shadowCPU1",frame={level="0",addr="0xffffffff8171bcdf",func="get_current",args=[],file="./arch/x86/include/asm/current.h",fullname="/home/xx/linux-5.15.130/arch/x86/include/asm/current.h",line="15",arch="i386:x86-64"},state="stopped"}]
1: (15239) ->(gdb)
1: (15239) 1013: elapsed time 1748
1: (15240) Send Event AD7ThreadCreateEvent
1: (15621) ->1014^done,threads=[{id="3",target-id="Thread 4294967292",details="shadowCPU2",frame={level="0",addr="0xffffffff8171bcdf",func="get_current",args=[],file="./arch/x86/include/asm/current.h",fullname="/home/xx/linux-5.15.130/arch/x86/include/asm/current.h",line="15",arch="i386:x86-64"},state="stopped"}]
1: (15621) ->(gdb)
1: (15621) 1014: elapsed time 2129
1: (15621) Send Event AD7ThreadCreateEvent
1: (16003) ->1015^done,threads=[{id="4",target-id="Thread 4294967291",details="shadowCPU3",frame={level="0",addr="0xffffffff811c9104",func="kgdb_breakpoint",args=[],file="kernel/debug/debug_core.c",fullname="/home/xx/linux-5.15.130/kernel/debug/debug_core.c",line="1231",arch="i386:x86-64"},state="stopped"}]
1: (16003) ->(gdb)
1: (16003) 1015: elapsed time 2511
1: (16003) Send Event AD7ThreadCreateEvent
1: (16383) ->1016^done,threads=[{id="5",target-id="Thread 4294967290",details="shadowCPU4",frame={level="0",addr="0xffffffff8171bcdf",func="get_current",args=[],file="./arch/x86/include/asm/current.h",fullname="/home/xx/linux-5.15.130/arch/x86/include/asm/current.h",line="15",arch="i386:x86-64"},state="stopped"}]
1: (16383) ->(gdb)
Other Extensions

No response

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the launch.json configuration and compare the Debug Console timings for target-select remote /dev/ttyS0, breakpoint setup, and thread-info against direct GDB. The kernel location mentioned is kernel/debug/debug_core.c:1231; done means identifying whether the delay is caused by the extension's MI handling or the remote target and documenting or correcting the confirmed cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux, vscode
Domain
devtools, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.