Implement debugger #535

Open
matklad opened this Issue Jul 18, 2016 · 23 comments

Projects

None yet
@matklad
Member
matklad commented Jul 18, 2016 edited

The work has started: https://github.com/intellij-rust/intellij-rust/tree/fc2cfb8e0fc76984495a34ae6a83cbb37188c699/debugger

Currently for technical reasons (commit message) debugger is implemented as a separate plugin.

The current build can be download from TeamCity: Download. It may work with CLion 2016.3.2 and intellij-rust 0.1.0.1611.

Note that this is super unstable, debugger can invoke any kind of undefined behavior, including, but not limited to, summoning of nasal daemons. Most importantly, rust debugger may (though in theory it should not) break C++ debugging.

Nonetheless, step into and local variables view more or less work :)

debugger

As you can see on the screenshot, at the moment you unfortunately have to create a separate Cargo debug run configuration type (as opposed to the usual Run cargo command). Also, you only can debug binaries now :(

@matklad matklad referenced this issue Jul 18, 2016
Open

Roadmap #424

@laktak
laktak commented Jul 18, 2016

Getting a good debugger for Rust would be a great help, especially as the current options are rather limited.

@mfarrugi
Contributor

How would the rust debugger be implemented? Is the CLion C/++ debugger more than a wrapper of GDB?

@matklad
Member
matklad commented Jul 18, 2016

How would the rust debugger be implemented?

We don't know yet, but the most straightforward way seems to be to reuse CLion infrastructure for LLDB/GDB.

@laktak
laktak commented Jul 18, 2016

I'm currently using Sublime with SublimeGDB. While it's nice it doesn't always work (crashes, doesn't keep breakpoints, etc.). So I have to fight the debugger as well...

I don't know CLion but whatever solution you come up with, please make sure it's really stable.

@sherry-ummen

Sorry a newbie here. How do people debug rust code then? Or they don't ?

@HybridEidolon
Contributor

You can use gdb or lldb directly. Recent versions of gdb support rust directly.

@sherry-ummen

Thanks. Do you have an example on how to do it? And can it be used with IntelliJ rust?

@laktak
laktak commented Aug 3, 2016

@sherry-ummen if you are using sublime you can debug in your editor with SublimeGDB. It's not perfect but the best option at the moment.

@johnthagen
Contributor
johnthagen commented Aug 24, 2016 edited

Just FYI, RustDT, an Eclipse based Rust IDE, appears to wrap GDB. Might at least be a useful reference.

Also, it's been linked before but just want to add a reference to the pretty print version of gdb/lldb :

In fact, every Rust installation comes with one or both of rust-gdb and rust-lldb (depending on platform support). These are wrappers over gdb and lldb with Rust pretty-printing enabled.

Edit: Another source of inspiration/reference, a browser based debugger: https://github.com/oli-obk/priroda

@mkaput mkaput referenced this issue in intellij-rust/intellij-rust.github.io Dec 5, 2016
Closed

Add debugger GUI #36

@hgallagher1993

For anyone thinking of using sherry-ummen's link, RustyCode appears to be abandoned there's been no updates in many months. This is a fork that fixes some bugs though. I haven't used the original in months and haven't even downloaded the fork so I don't how either works at the minute.

@chriskrycho
Contributor

I can confirm the fork works fairly well, and is (at least presently) fairly actively maintained. (I understand the limitations facing everyone involved hereβ€”I look forward to when IntelliJ Rust gets debugger support, but it's also a ton of work.)

@danielbodart

I managed to get partial debug working using Remote GDB debug support in CLion and gdbserver. I can then see the stack traces but can't see the variables for what ever reason. Anyone got any suggestions?

@Nimamoh
Nimamoh commented Jan 20, 2017

Would love some debug capabilities for intellij-rust.

@windoze
windoze commented Jan 20, 2017

I guess we can reuse CLion debugger module, or migrate this plugin to CLion.
I can see many plugins are available on both IDEA and CLion, so I guess these 2 products should have shared a large part of code base.

@matklad
Member
matklad commented Jan 20, 2017

@windoze the plugin totally works with CLion, you don't need to migrate anything.

I'm planing to start the work on the debugger soon :)

@csotiriou
csotiriou commented Feb 4, 2017 edited

@matklad In CLion 2016.3.2 I installed the plugin, but the "New Project" dialog does not present the "Rust" option as it does in IntelliJ IDEA. The run config allow me to select the "Cargo Command", however.

@matklad
Member
matklad commented Feb 5, 2017

@csotiriou yep, the project management in CLion is not very convenient, because at the moment CLion does not support non-CMake project, and Rust obviously does not use CMake. The option is to use "import project from source" action.

@csotiriou

@matklad Thank you for this answer.

I eagerly await for the debugger implementation. It's the only thing that is not straightforward to use, even when using the command line.

Thank you for this plugin.

@danielbodart

Has anyone managed to get variables to show while debugging in CLion?

@matklad matklad referenced this issue Feb 8, 2017
@matklad matklad DBG: first scratches
The hardest thing about debugger is how to actually get to the infrastructure
from CLion. There isn't a good way to do this yet, so currently debugger is
segregated into completely separate plugin in `/debugger`. It is not build
during the usual CI, because building is tricky an works only on Linux:

```
cd debugger
./download_deps.sh
../gradlew :runIdea
```

Nevertheless, you can install this plugin in CLion and get step into and local
variables working. Needless to say, this is **very** unstable yet, so installing
debugger in theory can harm your C++ debugging experience.
d464a1d
@matklad
Member
matklad commented Feb 8, 2017

Has anyone managed to get variables to show while debugging in CLion?

I did :) See the top comment for the current status: #535 (comment)

@johnthagen
Contributor

@matklad I'm curious how the final Rust debugger will interact, if at all, with the need for a CLion license. Will it be possible to debug Rust code on PyCharm Community, IntelliJ Community, or Android Studio using just the intellij-rust plugin?

I'd completely understand if JetBrains wanted to require that this part of CLion be licensed, since it pays good developers to work on CLion and needs to raise revenue.

@matklad
Member
matklad commented Feb 9, 2017

@johnthagen this is something we have not figured out yet, both at the technical and the licensing side of things.

It is certain that for the nearest future the debugger will be available in CLion, AppCode and maaaybe in RubyMine just because only these IDEs include com.intellij.modules.cidr.debugger module which we use. This is of course a shame, because it leaves out IDEA, PyCharm and other IDEs, and because Rust experience in CLion is not the best due to the interaction with CMake infrastructure. But of course this is just the beginning and we intend to fix these shortcomings :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment