-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LLDB] lldb-mi debugger not able to take input file as an exe argument #1219
Comments
@echosys Can you pass an input file like that when using gdb to debug it? I suspect you can't since |
Nope. Looks like I'm wrong. You can add items to
The file needs to sit in your if you enable I referred to this article. |
If |
I tried your first suggestion where I use the arg parameter. But it does not work as if the debugger is still waiting for input. Launching: '/Users/wge/Github/CSE340cpp/Pj3/a.out' [program hangs here....] |
On your second remark, I assume you mean input using the console window that opens up? The program still hangs and it seems like the debugger is able to get any input. Launching: '/Users/wge/Github/CSE340cpp/Pj3/a.out' </Users/wge/Github/CSE340cpp/Pj3/testa7C1.txt |
I'm having the same problem as @echosys on a Mac. Both for If you look at @echosys post above, with |
@pieandcakes thanks for hint! With |
The same issue on MacOS HighSierra 10.13.3 (17D102) and VS code Version 1.18.1 (1.18.1). It looks like the problem is because when the program and args from launch.json are launched, they are taken in quotation marks. Let me show in on the example. My program mmatiush.filler
Different output when '<test.txt' is taken in quotation marks and when it's not.
The same happens when I try to debug a program that expects stdin input. "<test.txt" redirect doesn't work and console is stuck waiting for my input. On the last line of the screenshot you can see that av[1] is printed as <text.txt while it should be printed as (null) if < worked correctly.
With "args": [ "<", "test.txt" ] . vs "args": [ "< test.txt" ] result is the same |
Hi, Is there any progress on this issue? I am still experiencing it. It's the only problem I have with the C++ plugin, everything else works great. |
@spinicist Are you also using it on Mac? The gdb on Linux fix seems to work, but I haven't had time to investigate it yet on Mac. Edit: I see your comment above. I'll see if I can take a look at this soon. |
So I tested this with |
Thanks for testing! That's a shame. If you run
But I guess that isn't terribly helpful for launching with VS Code. |
hmm. let me see if theres more documentation available. Unfortunately, |
In Mac OS, using lldb, I solved this problem like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"osx": {
"MIMode": "lldb"
},
"setupCommands": [
{
"`": "settings set target.input-path ${workspaceFolder}/input.txt"
}
]
}
]
} |
That's a very interesting tip, I will have to try it. Thanks! |
@graykode I think there is typo inside |
This drived me insane for a couple of hours. Turned out the option is renamed from "setupCommands" to "preRunCommands", even though in oficial documentation it is still setupCommands. The only way I was able to find it out to just eyeball using fuzzy search through all the available configuration string keys which popped up with intellisense. |
I replace preRunCommands with initCommands and that works.
{
// 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": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/bin/${fileBasenameNoExtension}",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"initCommands": [
"settings set target.input-path ${workspaceFolder}/data/input.txt",
"settings set target.output-path ${workspaceFolder}/data/output.txt"
],
},
],
} |
Wow. Just wow! Why are there even more than one way to do it? :) |
I lost couple of hours too trying to figure out why the ldb server wasn't picking up the args.
Where I realized that:
how I am solving currently:
but is hacking and I don't like having that big args string, could be better if I could pass an array . |
Hi, I am trying to debug a program which takes a input file. It works in command line when I run it as ./a.out <testinput.txt and when I try to debug it I get the following output and debugger hangs as if it doesnot get any input.
Launching: '/Users/wge/Github/CSE340cpp/Pj3/a.out'
Working directory: '/Users/wge/Github/CSE340cpp/Pj3'
2 arguments:
argv[0] = '/Users/wge/Github/CSE340cpp/Pj3/a.out'
argv[1] = '<testa8t.txt'
I did try put < and testfile.txt in two arguments with no difference.
I set the external console to be true but it doesn't seem like there is a way for cpp debugger to accept a input like regular command line would?
I am using vscode 1.17 and lastest cpp extension with lldb on Mac OSX.
{
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.out",
"args": ["<testa8t.txt"],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"osx": {
"MIMode": "lldb"
}
}
]
}
The text was updated successfully, but these errors were encountered: