microsoft / microsoft/vscode-cpptools

setupCommands run before gdb is ready

Open
#7,489 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug type: Debugger
Launching for an embedded target is not working as the setupCommands that are needed are being passed before gdb has actually started. setupCommands snippet below followed by the trace output. You'll see the gdb setupCommands emitted in the trace before the output from gdb itself and the show architecture request I believe comes from the extension that comes at the end of the trace.

I have repro code that can be shared but it is a bit of setup.

"setupCommands": [
                {
                    "text": "set target-async off"    
                },
                {
                    "text": "set pagination off",
                },
                {
                    "text": "target extended-remote localhost:3333",
                    "ignoreFailures": false
                },
                {
                    "text": "-file-exec-and-symbols C:/source/embedded/examples/blinky/AZ3166/build/mxchip_blinky.elf",
                    "ignoreFailures": false
                },
                {
                    "text": "monitor reset halt",
                    "ignoreFailures": false
                },
                {
                    "text": "monitor reset init",
                    "ignoreFailures": false
                },
                {
                    "text": "-target-download",
                    "ignoreFailures": false
                },
                {
                    "text": "load",
                    "ignoreFailures": false
                }
GDB Logs
1: (98) LaunchOptions{"name":"Launch no tasks","type":"cppdbg","request":"launch","cwd":"C:\\source\\embedded\\examples\\blinky\\AZ3166","program":"C:\\source\\embedded\\examples\\blinky\\AZ3166/build/mxchip_blinky.elf","MIMode":"gdb","miDebuggerPath":"arm-none-eabi-gdb","miDebuggerServerAddress":"localhost:3333","debugServerPath":"openocd","debugServerArgs":"-f board/stm32f4discovery.cfg","serverStarted":"Listening on port 3333 for gdb connections","serverLaunchTimeout":10000,"filterStderr":true,"stopAtEntry":true,"externalConsole":false,"setupCommands":[{"text":"set target-async off"},{"text":"set pagination off"},{"text":"target extended-remote localhost:3333","ignoreFailures":false},{"text":"-file-exec-and-symbols C:/source/embedded/examples/blinky/AZ3166/build/mxchip_blinky.elf","ignoreFailures":false},{"text":"monitor reset halt","ignoreFailures":false},{"text":"monitor reset init","ignoreFailures":false},{"text":"-target-download","ignoreFailures":false},{"text":"load","ignoreFailures":false}],"launchCompleteCommand":"exec-continue","logging":{"moduleLoad":true,"trace":true,"engineLogging":true,"programOutput":true,"exceptions":true},"__configurationTarget":5,"__sessionId":"749aa19b-7f23-4fa5-826a-69ab2ab9a4f4"}
1: (167) Starting: "openocd" -f board/stm32f4discovery.cfg
1: (559) Starting: "C:\armgcc\10-2020-q4-major\bin\arm-none-eabi-gdb.exe" --interpreter=mi
1: (563) DebuggerPid=9104
1: (619) ->=thread-group-added,id="i1"
1: (619) ->~"GNU gdb (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.1.90.20201028-git\n"
1: (619) ->~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
1: (619) ->~"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: (619) ->~"\nType \"show copying\" and \"show warranty\" for details.\n"
1: (619) ->~"This GDB was configured as \"--host=i686-w64-mingw32 --target=arm-none-eabi\".\n"
1: (619) ->~"Type \"show configuration\" for configuration details.\n"
1: (619) ->~"For bug reporting instructions, please see:\n"
1: (619) ->~"<https://www.gnu.org/software/gdb/bugs/>.\n"
1: (619) ->~"Find the GDB manual and other documentation resources online at:\n    <http://www.gnu.org/software/gdb/documentation/>."
1: (619) ->~"\n\n"
1: (619) ->~"For help, type \"help\".\n"
1: (619) ->~"Type \"apropos word\" to search for commands related to \"word\".\n"
1: (619) ->(gdb)
1: (626) <-1001-gdb-set target-async on
1: (631) ->1001^done
1: (631) ->(gdb)
1: (631) ->&"\n"
1: (631) ->^done
1: (631) ->(gdb)
1: (632) 1001: elapsed time 5
1: (645) <-1002-interpreter-exec console "set target-async off"
1: (650) ->=cmd-param-changed,param="mi-async",value="off"
1: (650) ->1002^done
1: (650) ->(gdb)
1: (650) ->&"\n"
1: (651) ->^done
1: (651) ->(gdb)
1: (650) 1002: elapsed time 5
1: (651) <-1003-interpreter-exec console "set pagination off"
1: (665) ->=cmd-param-changed,param="pagination",value="off"
1: (665) ->1003^done
1: (665) ->(gdb)
1: (665) ->&"\n"
1: (665) ->^done
1: (665) ->(gdb)
1: (665) 1003: elapsed time 13
1: (665) <-1004-interpreter-exec console "target extended-remote localhost:3333"
1: (2727) ->~"Remote debugging using localhost:3333\n"
1: (2732) ->=thread-group-started,id="i1",pid="42000"
1: (2732) ->&"warning: No executable has been specified and target does not support\ndetermining executable automatically.  Try using the \"file\" command."
1: (2732) ->&"\n"
1: (2732) ->=thread-created,id="1",group-id="i1"
1: (2732) ->~"0x08000e0c in ?? ()\n"
1: (2732) ->*stopped,frame={addr="0x08000e0c",func="??",args=[],arch="arm"},thread-id="1",stopped-threads="all"
1: (2732) ->1004^done
1: (2732) ->(gdb)
1: (2732) ->&"\n"
1: (2732) ->^done
1: (2741) ->(gdb)
1: (2744) 1004: elapsed time 2078
1: (2744) <-1005-thread-info 1
1: (2744) <-1006-file-exec-and-symbols C:/source/embedded/examples/blinky/AZ3166/build/mxchip_blinky.elf
1: (2760) ->1005^done,threads=[{id="1",target-id="Remote target",frame={level="0",addr="0x08000e0c",func="??",args=[],arch="arm"},state="stopped"}]
1: (2760) ->(gdb)
1: (2760) ->&"\n"
1: (2760) ->^done
1: (2760) ->(gdb)
1: (2762) 1005: elapsed time 18
1: (2766) ->1006^done
1: (2766) ->(gdb)
1: (2766) 1006: elapsed time 22
1: (2766) ->&"\n"
1: (2766) ->^done
1: (2766) ->(gdb)
1: (2766) <-1007-interpreter-exec console "monitor reset halt"
1: (2788) ->@"Unable to match requested speed 2000 kHz, using 1800 kHz\n"
1: (2788) ->@"Unable to match requested speed 2000 kHz, using 1800 kHz\n"
1: (3009) ->@"target halted due to debug-request, current mode: Thread \n"
1: (3009) ->@"xPSR: 0x01000000 pc: 0x08000e0c msp: 0x2001fffc\n"
1: (3009) ->1007^done
1: (3009) ->(gdb)
1: (3009) 1007: elapsed time 243
1: (3009) <-1008-interpreter-exec console "monitor reset init"
1: (3023) ->&"\n"
1: (3023) ->^done
1: (3023) ->(gdb)
1: (3024) ->@"Unable to match requested speed 2000 kHz, using 1800 kHz\n"
1: (3024) ->@"Unable to match requested speed 2000 kHz, using 1800 kHz\n"
1: (3219) ->@"target halted due to debug-request, current mode: Thread \n"
1: (3219) ->@"xPSR: 0x01000000 pc: 0x08000e0c msp: 0x2001fffc\n"
1: (3247) ->@"Unable to match requested speed 8000 kHz, using 4000 kHz\n"
1: (3247) ->@"Unable to match requested speed 8000 kHz, using 4000 kHz\n"
1: (3247) ->1008^done
1: (3247) ->(gdb)
1: (3247) 1008: elapsed time 238
1: (3247) <-1009-target-download
1: (3247) ->&"\n"
1: (3247) ->^done
1: (3247) ->(gdb)
1: (3849) ->1009+download,{section=".isr_vector",section-size="452",total-size="989915"}
1: (3849) ->1009+download,{section=".isr_vector",section-sent="452",section-size="452",total-sent="452",total-size="989915"}
1: (3849) ->1009+download,{section=".text",section-size="3464",total-size="989915"}
1: (3849) ->1009+download,{section=".rodata",section-size="8",total-size="989915"}
1: (3860) ->1009+download,{section=".init_array",section-size="4",total-size="989915"}
1: (3860) ->1009+download,{section=".fini_array",section-size="4",total-size="989915"}
1: (3861) ->1009+download,{section=".data",section-size="8",total-size="989915"}
1: (4181) ->1009^done,address="0x08000e0c",load-size="3940",transfer-rate="33776",write-rate="656"
1: (4181) ->(gdb)
1: (4181) 1009: elapsed time 933
1: (4181) <-1010-interpreter-exec console "load"
1: (4181) ->&"\n"
1: (4181) ->^done
1: (4181) ->(gdb)
1: (4751) ->~"Loading section .isr_vector, size 0x1c4 lma 0x8000000\n"
1: (4751) ->1010+download,{section=".isr_vector",section-size="452",total-size="989915"}
1: (4751) ->1010+download,{section=".isr_vector",section-sent="452",section-size="452",total-sent="452",total-size="989915"}
1: (4758) ->~"Loading section .text, size 0xd88 lma 0x80001c4\n"
1: (4758) ->1010+download,{section=".text",section-size="3464",total-size="989915"}
1: (4758) ->~"Loading section .rodata, size 0x8 lma 0x8000f4c\n"
1: (4759) ->1010+download,{section=".rodata",section-size="8",total-size="989915"}
1: (4759) ->~"Loading section .init_array, size 0x4 lma 0x8000f54\n"
1: (4759) ->1010+download,{section=".init_array",section-size="4",total-size="989915"}
1: (4759) ->~"Loading section .fini_array, size 0x4 lma 0x8000f58\n"
1: (4759) ->1010+download,{section=".fini_array",section-size="4",total-size="989915"}
1: (4759) ->~"Loading section .data, size 0x8 lma 0x8000f5c\n"
1: (4760) ->1010+download,{section=".data",section-size="8",total-size="989915"}
1: (5085) ->~"Start address 0x08000e0c, load size 3940\n"
1: (5085) ->~"Transfer rate: 4 KB/sec, 656 bytes/write.\n"
1: (5085) ->1010^done
1: (5085) ->(gdb)
1: (5085) 1010: elapsed time 903
1: (5085) ->&"\n"
1: (5085) ->^done
1: (5085) ->(gdb)
1: (5085) <-1011-interpreter-exec console "set pagination off"
1: (5110) ->1011^done
1: (5110) ->(gdb)
1: (5110) 1011: elapsed time 25
1: (5110) <-1012-gdb-set auto-solib-add on
1: (5110) ->&"\n"
1: (5110) ->^done
1: (5110) ->(gdb)
1: (5114) ->1012^done
1: (5114) ->(gdb)
1: (5114) 1012: elapsed time 3
1: (5115) <-1013-gdb-set solib-search-path C:\\source\\embedded\\examples\\blinky\\AZ3166/build;
1: (5115) ->&"\n"
1: (5115) ->^done
1: (5116) ->(gdb)
1: (5118) ->1013^done
1: (5119) ->(gdb)
1: (5119) 1013: elapsed time 4
1: (5119) <-1014-environment-cd C:/source/embedded/examples/blinky/AZ3166
1: (5119) ->&"\n"
1: (5119) ->^done
1: (5120) ->(gdb)
1: (5120) ->1014^done
1: (5121) ->(gdb)
1: (5121) 1014: elapsed time 1
1: (5121) <-1015-interpreter-exec console "show configuration"
1: (5121) ->&"\n"
1: (5122) ->^done
1: (5122) ->(gdb)
1: (5152) ->~"This GDB was configured as follows:\n   configure --host="
1: (5152) ->~"i686-w64-mingw32 --target=arm-none-eabi\n"
1: (5152) ->~"             --with-auto-load-dir=$debugdir:$datadir/auto-load\n             --with-auto-load-safe-path="
1: (5152) ->~"$debugdir:$datadir/auto-load\n"
1: (5152) ->~"             --with-expat\n"
1: (5152) ->~"             --with-gdb-datadir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/arm-none-eabi/share/gdb (relocatable)\n"
1: (5152) ->~"             --with-jit-reader-dir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/lib/gdb (relocatable)\n"
1: (5152) ->~"             --without-libunwind-ia64\n"
1: (5152) ->~"             --without-lzma\n"
1: (5152) ->~"             --without-babeltrace\n"
1: (5152) ->~"             --without-intel-pt\n"
1: (5152) ->~"             --without-mpfr\n"
1: (5152) ->~"             --without-xxhash\n"
1: (5152) ->~"             --without-python\n"
1: (5152) ->~"             --without-python-libdir\n"
1: (5152) ->~"             --without-debuginfod\n"
1: (5152) ->~"             --without-guile\n"
1: (5152) ->~"             --disable-source-highlight\n"
1: (5152) ->~"             --with-separate-debug-dir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/lib/debug (relocatable)\n"
1: (5152) ->~"             --with-system-gdbinit=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-mingw/i686-w64-mingw32/arm-none-eabi/lib/gdbinit (relocatable)\n"
1: (5152) ->~"\n(\"Relocatable\" means the directory can be moved with the GDB installation\ntree, and GDB will still find it.)\n"
1: (5152) ->1015^done
1: (5152) ->(gdb)
1: (5152) ->&"\n"
1: (5152) ->^done
1: (5152) ->(gdb)
1: (5152) 1015: elapsed time 31
1: (5152) <-1016-file-exec-and-symbols C:/source/embedded/examples/blinky/AZ3166/build/mxchip_blinky.elf
1: (5178) ->1016^done
1: (5178) ->(gdb)
1: (5178) 1016: elapsed time 25
1: (5178) <-1017-interpreter-exec console "show architecture"
1: (5178) ->&"\n"
1: (5179) ->^done
1: (5179) ->(gdb)
1: (5180) ->~"The target architecture is set to \"auto\" (currently \"armv7e-m\").\n"
1: (5180) ->1017^done
1: (5180) ->(gdb)
1: (5180) 1017: elapsed time 1
1: (5180) ->&"\n"
1: (5180) ->^done
1: (5180) ->(gdb)
1: (5181) <-1018-exec-arguments 2>CON 1>CON <CON
1: (5200) ->1018^done
1: (5200) ->(gdb)
1: (5200) 1018: elapsed time 19
1: (5200) <-1019-break-insert -f main
1: (5200) ->&"\n"
1: (5200) ->^done
1: (5200) ->(gdb)
1: (5225) ->~"Note: automatically using hardware breakpoints for read-only addresses.\n"
1: (5225) ->1019^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x08000e66",func="main",file="../main.c",fullname="C:\\source\\embedded\\examples\\blinky\\AZ3166\\main.c",line="7",thread-groups=["i1"],times="0",original-location="main"}
1: (5225) ->(gdb)
1: (5225) ->&"\n"
1: (5225) ->^done
1: (5225) ->(gdb)
1: (5225) 1019: elapsed time 24
1: (5225) <-1020-target-select remote localhost:3333
1: (5253) ->=thread-exited,id="1",group-id="i1"
1: (5253) ->=thread-group-exited,id="i1"
1: (5272) <-logout
1: (5273) <-logout
1: (5285) Send Event AD7MessageEvent
1: (5285) Send Event AD7ProgramDestroyEvent
The program 'C:\source\embedded\examples\blinky\AZ3166/build/mxchip_blinky.elf' has exited with code 0 (0x00000000).
1: (5297) <--gdb-exit

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

The issue provides no repository file, test, or entry point; begin by reproducing the embedded-target launch with the supplied setupCommands and comparing the GDB trace order. Done means setupCommands are issued only after GDB is ready, while the existing launch sequence still completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
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.