I want to debug quickjs
qjsc
which accepts arguments from c++ argv
,
and I also hope everyone can debug quickjs based my configuration for learning javascript engine.
But I can't pass arguments to program through gdb debugger in vscode
Here are my vscode launch.json
{
// 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": "qjs-debug main.js",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/qjs-debug",
"args": [
"-I",
"${workspaceFolder}/debugger/main.js"
],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"logging": {"engineLogging": true},
"preLaunchTask": "gcc build active file",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "--args"
}
]
}
when I start debug, I saw argv only have a /
Some anwsers said args
in launch.json
will pass to gdb, you should use --args
instead.
But I have tried. Nothing works :(
How I pass args to command cli based program?
Why argv is /
from picture?
My repo is
https://github.com/iamwwc/quickjs-debugger
You can get all configuration from my github.
Problem is not in VSCode launch configuration but in the way your program read the inputs, @Marek R said in the comments.
It is recommended to use int main(int argc, char* argv[]) { body }
instead of int main(int argc, char **argv) { body }
(see here).