https://github.com/jetbrains/clion-debugger-plugin-stub
Minimalistic plugin with custom debugger stub
https://github.com/jetbrains/clion-debugger-plugin-stub
clion clion-ide debugger debugging-tool jetbrains jetbrains-plugin
Last synced: 4 months ago
JSON representation
Minimalistic plugin with custom debugger stub
- Host: GitHub
- URL: https://github.com/jetbrains/clion-debugger-plugin-stub
- Owner: JetBrains
- License: apache-2.0
- Created: 2020-05-21T09:24:59.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-08T16:24:10.000Z (6 months ago)
- Last Synced: 2025-01-30T02:03:33.904Z (4 months ago)
- Topics: clion, clion-ide, debugger, debugging-tool, jetbrains, jetbrains-plugin
- Language: Java
- Homepage:
- Size: 139 KB
- Stars: 6
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Minimalistic plugin with custom debugger stub
===[](https://github.com/JetBrains#jetbrains-on-github)
Compatibility Disclaimer
---
This is an educational example, compatible with CLion 2024.2. Neither the example author nor JetBrains guarantees
compatibility with upcoming versions.HOW2USE
---
- Download and install CLion.
- Follow the steps described at [Develop plugins for CLion](https://www.jetbrains.com/help/clion/develop-plugins-for-clion.html).
- Open the project and click *Debug Plugin*. This will start CLion with the plugin installed.
- In CLion:
- Create a project of type *C++ Executable*.
- Configure the toolchain as described [here](https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-windows.html).
- Create a Run Configuration of type *Debugger-Stub*
Functionality Testing
---
- Start the debugger: Click the *Debug* button
- Pausing the debugger and disassembly: Click *Pause Program* button
The execution is interrupted, and fake disassembly is shown
- Execution stepping: Click *Step Over* button several times
- Variables access: Evaluate *foo* expression. A string value *bar* is shown
- Resume execution: Click *Resume program* button
- Stop the debugger: Click the *Stop* buttonImplementation details
---
There are two approaches to adding new debugger integrations in CLion.### Using the IntelliJ API
The official way for all IntelliJ-based IDEs is to:
- implement `com.intellij.xdebugger.XDebugProcess` together with the necessary `com.intellij.execution.runners.ProgramRunner`
for the "Debug" action to pick up your debugger,
- register a new `com.intellij.xdebugger.breakpoints.XLineBreakpointType`
so that users can put breakpoints in the desired file types,
- implement `com.intellij.xdebugger.attach.XAttachDebuggerProvider` for attaching to already running processes, and
- make lots of other small customizations along the way.The benefit is that you control each and every little detail, and use the official and stable platform API, which is also
[open-source](https://github.com/JetBrains/intellij-community/tree/201/platform/xdebugger-api/src/com/intellij/xdebugger).
Of course, the downside is that it's a huge amount of work with little to no relation to the real task - making a new native
debugger work in CLion.
Also, the whole new debugger stack should be integrated with the existing CLion C/C++ file types and run configurations,
which is a whole other task on its own.### Using the CIDR / CLion API
This is the approach demonstrated in this example plugin. Instead of re-implementing the high-level code responsible
for integration with the IntelliJ Platform, here we implement a `com.jetbrains.cidr.execution.debugger.backend.DebuggerDriver`
subclass, which is a lower-level API responsible for communication with the actual debugger process.The pros and cons of this approach are the opposite: you only implement the relevant business logic, but in order to do
that, you have to use the "unofficial" API, which is subject to change, as already stated before.Further development steps
---
Major functionality:
* Implement all the **//todo**s in `com.jetbrains.clion.bugeater.debugger.BugEaterDriver` classMinor things:
* Update *resources/META-INF/plugin.xml* with an actual name, description, etc.
* Update *resources/META-INF/pluginIcon.svg*.
* Update *resources/icons/bugEaterRunConfig.svg*. Please keep the size unchanged (16x16 px).