Debug configurationNow it is time to connect local CLion to the remote machine. Navigate to Run→Edit Configurations, click on + and select GDB Remote Debug. Configure it like this:Start the debugging and observe that the execution stops at the breakpoints and we can observe the values of the variables. Compiling on several architecturesRecall that we used target_remote folder for remote build files from Ubuntu. If we now execute the standard Rust build command from CLion, by e.g. Then SSH/Mosh into the remote machine and run: cd /home/ubuntu/Repos/actixCargo build - package actix - example ping - target-dir. target_remote/debug/examples/pingCLion does not automatically synchronize new files, it only does it with the changed files, so we need to manually download target_remote to the local machine. Navigate to Tools→Deployment→Browse Remote Host, which will open a window with the remote file system view. So go to Excluded Paths tab and add /Users//Repos/actix/target local path.We also recommend going to Preferences→Build, Execution, Deployment→Deployment→Options and switching Upload changed files automatically to the default server to Always which will allow CLion to automatically copy locally modified source files to the remote machine. Building on the remote machineBefore we can build the source on the remote machine, we need to copy it. Select the root folder in the Project tree (you might need to open it with View→Tool Windows→Project), in our case it is actix. Source code from the local machine to the remote machine Debug symbols from the remote machine to the local machine.In CLion open Preferences→Build, Execution, Deployment→Deployment. Click on + to add the new deployment configuration and fill it in:Since we are using the standard AWS Ubuntu image, the default username is ubuntu. You would also need to go to the Mappings tab and add local to remote mappings of the project files, e.g.:Deployment path: /home/ubuntu/Repos/actix.If you already have more than one deployment configuration in CLion, you might want to right-click on the newly created configuration and select Set As Default.Since we want to compile and run on two different architectures, we would need two folders for the build files. We will be using /Users//Repos/actix/target for the Mac OS build files, and /Users//Repos/actix/target_remote for the Linux build files. CLION REMOTE DEBUGGING INSTALL THE RUST.To /Users//Repos/actix, if you are on Mac OS. Open this project in CLion, but note that IDE might need time to update its indices and cache.CLion deployment feature allows us to keep in sync the files on the local and the remote machines. Interactively debug in local IDE the code running on the remote machine We will be using an AWS instance running an Ubuntu image as a remote machine.It can also be used for a large number of other special cases used mostly for the web servers which we are going to omit in this post. The following ports would need to be allowed: TCP 22 for ssh and TCP 2345 for gdbserver. Clion Remote Debugging Install The RustOur team also likes using mosh because it tolerates interrupted connections and allows moving between WiFi hotspots, which needs UDP 60000–61000 ports.After launching an AWS instance and connecting to it through ssh or mosh, run the following commands on it: apt-get update & apt-get install -y curl gdb g++-multilib lib32stdc++6 libssl-dev libncurses5-devCurl -sSf | sh -s -y - default-toolchain nightly Local machine setupIf you do not have Rust, run the following command to install it: curl -sSf | sh -s -y - default-toolchain nightlyYou can download CLion from here, and upon its launch, you would also need to install the Rust plugin which can be found in Preferences→Plugins. CLion and other JetBrains products have great support of the remote development and debugging. However, unfortunately, Rust is not a primary language of CLion which makes configuration tricky. In CLion, place breakpoint in your code, then start a debug session for the newly created Remote Debug configuration.In this post we walk through the configuration of CLion for remote Rust development and debugging, our goal is to be able to:Run and debug your projects in CLion easily. CLion’s debugger will connect to the running remote process. The terminal will show the Remote debugging from host. Message, and you can also check the debugger console for the Debugger connected to. Message.In CLion, there are various ways to do remote development but for debugging purposes, it boils down to either connecting to the GDB server on the remote.Rust, being a relatively new language, is still on its path to gaining wide support by IDEs. Most in our team use CLion for Rust development which is especially great for local debugging, alas it is not free.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |