daveleroy / SublimeDebugger

Graphical Debugger for Sublime Text for debuggers that support the debug adapter protocol
MIT License
374 stars 44 forks source link

LLDB adapter not starting debug target #271

Open uuc110 opened 1 month ago

uuc110 commented 1 month ago

So the thing is I wanna do Competitive programming in C++ on Sublime-text. I use 2 column Editor layout and use Input1.in and output1.out for my input and output. for compiling it works fine, but debuggign is something I'm having issue with. I using this Debugger, since this well known and suggested by Everyone

this is my debugger_configuration and LSP-ClangD for clang and build

Gist link -> https://gist.github.com/uuc110/72c8b29df9450fdf3636df2beb427488

I wanna do with LLDB, but i tried GDB and reached some progress and got this error

Warning: 'set target-async', an alias for the command 'set mi-async', is deprecated.

Use 'set mi-async'.

‌​​​No source file named C:\Users\USERID\AppData\Roaming\Sublime Text\Packages\User\file.cpp.

‌​​​​​​Running executable

[New Thread 7608.0x58fc]

[New Thread 7608.0x2680]

[New Thread 7608.0x3964]

and this callback keepgoing and no varible shown or anything.
https://i.imgur.com/BAZa9WE.png and https://i.imgur.com/a/IyyIAPK

image

image

let me know if you need other info to need more context

NOTE: I have done in Clion, VSCode, but wanna try sublime this time. so its not I don't like. I just wanna try and work with this.

daveleroy commented 1 month ago

I have never personally used gdb so I can't help that much here but you might want to look at the issues for the adapter.

https://github.com/WebFreak001/code-debug/issues/

If its not stopping at breakpoints I would guess that ‌​​​No source file named C:\Users\USERID\AppData\Roaming\Sublime Text\Packages\User\file.cpp is probably related

I would try using -ggdb instead of -g when compiling (https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html) to force gdb debug info

daveleroy commented 1 month ago

What issue were you running into with lldb?

uuc110 commented 1 month ago

What issue were you running into with lldb?

it's shows nothing I just run, and all the tab are empty, Console, terminal dn debug all three are empty when I run LLDB and debug

captain0xff commented 1 month ago

I was also trying out the lldb adapter yesterday because the gdb adapter doesn't support logpoints and faced the same issue. The issue is that the adapter just launches the debugger but doesn't run the program. If you go to the console tab and type the run command then the program will launch in the debugger and you can debug normally. Though this workaround works, I think it's still a bug. I am on debian sid, the code is compiled in cmake debug mode with gcc 14 and the debugger is lldb v19.

uuc110 commented 1 month ago

I was also trying out the lldb adapter yesterday because the gdb adapter doesn't support logpoints and faced the same issue. The issue is that the adapter just launches the debugger but doesn't run the program. If you go to the console tab and type the run command then the program will launch in the debugger and you can debug normally. Though this workaround works, I think it's still a bug. I am on debian sid, the code is compiled in cmake debug mode with gcc 14 and the debugger is lldb v19.

can you share me your build, and debugger sublime configs.

uuc110 commented 1 month ago

@captain0xff can you send me a video of you did that? would be great man! since I didn't any video on YT regrarding this

captain0xff commented 1 month ago

I am on linux so my configs won't work for you. If you still want them then I can share them later when I am on pc.

uuc110 commented 1 month ago

@captain0xff sure that work. I just want rough idea of work around

captain0xff commented 1 month ago
    "debugger_configurations":
    [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Launch",
            "program": "${folder}/build/main",
            "args": [],
            "cwd": "${folder}/build"
        },
        {
            "type": "gdb",
            "request": "launch",
            "name": "Launch Program",
            "target": "${project_path}/build/main",
            "cwd": "${project_path}/build",
            "valuesFormatting": "parseText"
        },
    ],

Here is my config. I use cmake and executable stays in the build directory and for this particular project it's named main. The gdb config works perfectly and for the lldb one you need to manually type the command run in the console tab (which should work out of the box imo).

morew4rd commented 3 weeks ago

I have the same issue on macos with lldb. can't even try gdb because mac.

edit: @captain0xff workaround works in my case as well. it was just tricky to get to type "run" in the console

daveleroy commented 3 weeks ago

I can't reproduce this issue.

Does the same thing happen using https://github.com/vadimcn/codelldb in vscode? This sounds like an issue with the debug adapter unless there is some configuration option that codelldb is adding by default.

You guys could probably use one of the lldb configuration options to automatically run the target https://github.com/vadimcn/codelldb/blob/master/MANUAL.md since the adapter (or lldb) appears to not be starting it for some reason

Maybe try adding "postRunCommands": ["run"]

captain0xff commented 2 weeks ago

Maybe try adding "postRunCommands": ["run"]

Sadly this doesn't help. And I am able to reproduce this even on my windows machine with the example projects. In the example projects the debugger seems to be stuck in the compile task i.e the pre debug task. I think the same is happening with my local project. I tried hard to get any logs but even with verboseLogging none of the consoles/terminals produce anything. Also, sorry for the late reply.

captain0xff commented 2 weeks ago

Haha, found it! Left the debugger running for some time by mistake and here is what is yeilded

Failed to redirect stdio to a terminal. (Terminal agent did not respond within the allotted time.)
Debuggee output will appear here.

Here is the link to the line emitting that error https://github.com/vadimcn/codelldb/blob/fe108b53a0f276c10f02d57d85b93991bbb6e30b/adapter/codelldb/src/debug_session/launch.rs#L367 And here is an upstream issue probably related to it https://github.com/vadimcn/codelldb/issues/400

captain0xff commented 2 weeks ago

Setting "terminal": "console" fixes the issue as expected. Maybe consider mentioning this in the README.