microsoft / microsoft/vscode-cpptools
gdb executes expression from hovering over a define (expression) without brackets
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Environment
- OS and version: Win11 22H2
- VS Code: 1.92.2
- C/C++ extension: ms-vscode.cpptools
- OS and version of remote machine (if applicable):
- GDB / LLDB version: GNU gdb (Arm GNU Toolchain 13.3.Rel1 (Build arm-13.24)) 14.2.90.20240526-git
Bug Summary and Steps to Reproduce
Bug Summary:
I'm not sure if this is the correct extension for the bug.
It is from an old c-project.
Hovering over a define with an expression, will lead the gdb to execute the expression.
#define LED_ON led = 100
#define LED_OFF led = 0
uint8_t led = 0;
LED_ON;
dely(100);
LED_OFF;
The extension tries to get the value of the define.
But the gdb executes the expression of the define and sets the this value to the memory of the halted microcontroller.
197-var-create --thread 4 --frame 0 hover_41cfaa7f209f0751459adf07e2163093f0baf6914b74b82363bf47de05986d92 @ "LED_ON"
-> =memory-changed,thread-group="i1",addr="0x20010f92",len="0x1"
So i can switch on or off the LED only with hovering over the define.
It is the same with a normal variable.
Debugger Configurations
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug cortex-debug jlink",
"request": "launch",
"type": "cortex-debug",
"servertype": "jlink",
"cwd": "${workspaceFolder}",
"executable": "${command:cmake.launchTargetPath}",
"serverpath": "JLinkGDBServerCL.exe",
"toolchainPrefix": "arm-none-eabi",
"device": "STM32F205VG",
"interface": "swd",
"runToEntryPoint": "main",
"svdPath": "${workspaceFolder}/Tools/Debug/STM32F215.svd",
"rtos": "FreeRTOS",
"showDevDebugOutput": "both",
"liveWatch": {
"enabled": true,
"samplesPerSecond": 4
},
"swoConfig": {
"enabled": true,
"source": "socket",
"swoFrequency": 4000000,
// "swoFrequency": 6000000, // Only J-Link Ultra
"cpuFrequency": 120000000,
"decoders": [
// {
// "label": "Port 0",
// "type": "console",
// "port": 0,
// "showOnStartup": true,
// // "logfile": "",
// "timestamp": false,
// "encoding": "ascii",
// },
// ... copy and change port and label
]
}
}
Debugger Logs
197-var-create --thread 4 --frame 0 hover_41cfaa7f209f0751459adf07e2163093f0baf6914b74b82363bf47de05986d92 @ "TEST_0"
-> =memory-changed,thread-group="i1",addr="0x20010f92",len="0x1"
GDB -> App: {"output":"","outOfBandRecord":[{"isStream":false,"type":"notify","asyncClass":"memory-changed","output":[["thread-group","i1"],["addr","0x20010f92"],["len","0x1"]]}]}
-> 197^done,name="hover_41cfaa7f209f0751459adf07e2163093f0baf6914b74b82363bf47de05986d92",numchild="0",value="0x0",type="uint8_t",has_more="0"
GDB -> App: {"output":"","token":197,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[["name","hover_41cfaa7f209f0751459adf07e2163093f0baf6914b74b82363bf47de05986d92"],["numchild","0"],["value","0x0"],["type","uint8_t"],["has_more","0"]]}}
Other Extensions
marus25.cortex-debug
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by tracing the hover path that issues the GDB/MI var-create request, then reproduce with the LED_ON and LED_OFF macros on the stated Cortex-M setup. Done means hovering over an expression-valued define or variable no longer changes target memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, typescript
- Domain
- devtools, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100