microsoft / microsoft/vscode-cpptools
cannot debug C program reading large file from stdin on macOS 12.6 Monterey
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
Environment
- OS and version: macOS 12.6 Monterey
- VS Code: 1.72.2
- C/C++ extension: unsure, but downloaded approx. Oct. 28 2022
- OS and version of remote machine (if applicable):n/a
- GDB / LLDB version: lldb-1400.0.30.3
Bug Summary and Steps to Reproduce
Bug Summary:
I have been unable to find a way to connect large datasets to the stdin of a C code program being debugged by vscode -- it seems possible only to use the launch.json "externalConsole": true setting to input small amounts of manually entered input via an opened terminal window. (Such manual input is entirely unsuited to debugging a program with very large multi-column numerical input datasets.) This problem occurs on both Intel and Apple M1 macOS 12.6 systems.
I have seen recommendations in various places to use a launch.json args setting for this, e.g., "args": ["<", "/tmp/somefile"] , but this simply does not work (other than to corrupt the program's main() argv[] array by appending spurious < and /tmp/somefile arguments, which should obviously not be visible to any program actually reading stdin ). Here is the launch.json entry I tried unsuccessfully to use:
{
"name": "vscstdio-stdin-test",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/vscstdio",
"args": ["<", "/etc/group"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
(Note that specifying "externalConsole": true in that configuration only improved the situation to the extent of allowing manually typed input to be sent to stdin , which is not sufficient for my purposes.)
Here is a small sample program which demonstrates the problem. It simply prints out the contents of the main() argv[] array, including the spurious < and /etc/group arguments, and then echoes to stdout whatever is read from stdin :
#include <stdio.h>
#include <stdlib.h>
char buf[512];
int main(int argc, char **argv) {
int i;
for (i= 0; i < argc; i++)
(void) fprintf(stderr, "%1d: %s\n", i, argv[i]);
(void) fflush(stderr);
for (i= 0; fgets(buf, (int) 512, stdin) != (char *) 0; i++)
(void) fprintf(stdout, "[%3d] _%s", i, buf);
(void) fprintf(stdout, "At EOF\n");
exit(0);
}
When run with the above launch.json configuration it hangs indefinitely on the first call to fgets() instead of properly reading the redirected /etc/group through stdin .
I truly hope you can either fix this problem or tell me what I am doing wrong, otherwise vscode is not usable to me for debugging a lot of my project's software which makes heavy use of stdio. Thanks!
Debugger Configurations
See launch.json above.
tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/clang",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Debugger Logs
None.
Other Extensions
No response
Additional Information
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la configurazione cppdbg di launch.json e il programma C di esempio; confronta le impostazioni externalConsole e args mentre riproduci il blocco usando /etc/group come stdin. Controlla come l’estensione avvia LLDB su macOS 12.6. Il lavoro è completato quando l’input del file raggiunge stdin senza aggiungere token di redirezione a argv né bloccarsi in fgets().
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, macos, vscode
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100