Difference between 'gdb --args a.out \~foo' and 'gdbgui --args a.out \~foo'
- Dominant language
- TypeScript
- Stars
- 10.4k
- Forks
- 521
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When using the `--args` to specify parameters given to the debugged program, there is a difference between `gdb --args` and `gdbgui --args`. To avoid that the shell interprets special characters like `~`, `gdb` requires to escape it using a `\`. For `gdbgui` it requires at least 2 levels of escape.
**To Reproduce**
* Write a file `a.c` containing:
```
#include
int main(int argc, char ** argv) {
if(argc > 1) puts(argv[1]);
}
```
* Compile it using the command `gcc -ggdb a.c`
* Debug it using the command `gdbgui --args a.out \~foo`
* Run the program using `r` command in the gdb prompt
The program will print the following result:
```
zsh:1: no such user or named directory: foo
```
**Expected behavior**
Using the command `gdb -q --ex 'r' --ex 'q' --args a.out \~foo`, the result is:
```
Reading symbols from a.out...
Starting program: /tmp/a.out \~foo
~foo
[Inferior 1 (process 325725) exited normally]
```
As expected, the program print `~foo`.
**Please complete the following information:**
* OS: Ubuntu 20.04 (Linux 5.11.0-40-generic)
* gdbgui version (`gdbgui -v`): 0.15.0.1
* gdb version (`gdb -v`): 9.2
* browser [e.g. chrome, safari]: chromium
* python packages (`pip freeze`):
Contributor guide
Research direction
Reproduce the issue with the a.c program using gcc, then compare `gdb --args a.out \~foo` with `gdbgui --args a.out \~foo` and the `r` command. Trace how gdbgui passes command-line arguments through its CLI and debugger entry point. Done means escaped `~foo` reaches the program unchanged, matching gdb.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux, zsh
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100