CMAKE build and debug on different target

已回答

Hello!

CMake application build and debug works fine on one remote machine.

I need to build a debug cmake application on one target machine and after that start to debug it at another machine. Please tell me the correct and optimal way to achieve this.

thanks

0

Hello!

1. Is the machine for building a Docker container? Or is it a separate remote machine?

2. What OS does the local machine have?

0

1)Separate

2)both remote machines for building and debug are Linux, local machine is MacOS

0

This scenario is not fully supported at the moment. Feel free to comment or upvote a related feature request: https://youtrack.jetbrains.com/issue/CPP-22148. See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

As a workaround, you can do the following:

  1. Create a remote toolchain for the "building machine", make it the default one (move it to the top of the toolchains list).
  2. Build the project using the "CMake application" configuration so that the resulted binary appears on the "building machine".
  3. Create an external tool which will download the resulted binary to the local machine (using scp, for example). 
  4. Run this external tool manually (Tools | External Tools) to download the resulted binary to the local machine.
  5. Create the "Remote GDB Server" configuration.
  6. Select the local binary in the "Executable" field: click on the button with three dots next to the "Executable" field and select the downloaded binary.
  7. Select the remote GDB in the "GDB" field, otherwise the path mapping will fail.
  8. In the "Credentials" field specify the credentials for accessing your target machine (machine for debug).
  9. Specify the external tool (from the point 3) in the "Before launch" section, after "Build".

Now each time you launch the "Remote GDB Server" configuration, the project will be built on the "building machine" using the remote toolchain, then it will be downloaded to the local machine using the external tool, then it will be uploaded to the target machine and the debugging process will start.

Does this workaround work for you?

0

Thanks for reply

1) I created only one remote toolchain "Remote host for build"

2)I created external tool to download binary file from remote host. It works.

3)I added configuration "remote gdbserver".

if i choose in gdb filed "Bundled GDB" - after build, the local binary has been successfully uploaded to the remote debug machine, debugging starts, but breakpoints from code  are ignored..

if I choose in gdb filed "Remote host GDB (from 'Remote host for build')" - after build, the local binary has been successfully uploaded to the remote debug machine, debug does not start - 

/usr/bin/gdbserver :1234 /tmp/CLion/debug/app_client
Process /tmp/CLion/debug/app_client created; pid = 8083
Listening on port 1234
Error during pretty printers setup: Error while executing Python code.

Some features and performance optimizations will not be available.

com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException: Cannot load symbol file: /Users/name/work/Develop/apps/bin_debug/app_client: No such file or directory.

Process finished with exit code 0
^C^CGDB Server stopped, exit code 129

It looks like the build machine is using the path from the local machine

 

 

0

>if i choose in gdb filed "Bundled GDB" - after build, the local binary has been successfully uploaded to the remote debug machine, debugging starts, but breakpoints from code  are ignored

As I said earlier, that's expected - the path mapping fails in this case.

com.jetbrains.cidr.execution.debugger.backend.DebuggerCommandException: Cannot load symbol file: /Users/name/work/Develop/apps/bin_debug/app_client: No such file or directory.

This one is unclear. Please enable debugger logging as described here, reproduce the issue and send the resulting idea.log file (`Help | Show Log in ...`) to clion-support at jetbrains.com. Do not forget to disable debug logging after that. Note that logs might contain private user's information (like file paths and names). 

Also please send screenshots of your remote toolchain and the external tool along with the log.

0

Sorry, im not understand . We need run gdb from local machine or from build maschine? I added mapping paths and remote debug machine found symbol files , but then I got a message:

/usr/bin/gdbserver :1234 /tmp/CLion/debug/app_client
Process /tmp/CLion/debug/app_client created; pid = 21039
Listening on port 1234
Error during pretty printers setup: Error while executing Python code.

Some features and performance optimizations will not be available.

Remote debugging from host 192.168.1.118
readchar: Got EOF
Remote side has terminated connection. GDBserver will reopen the connection.
Listening on port 1234
com.jetbrains.cidr.execution.debugger.backend.gdb.GDBDriver$GDBCommandException: Remote 'g' packet reply is too long: 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070fdffbe0000000000fbfcb6100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Debugger disconnected

Process finished with exit code 0
^C^CGDB Server stopped, exit code 129

0
  1. What path mappings did you add? Where?
  2. What debugger do yo have in the "Remote GDB Server" configuration now?
0

You didn't answer my question - we use BUNDLED GDB from a local machine or GDB from remote building machine?

0

In all the previous times when we came across a similar scenario, we suggested to use the remote GDB (GDB from remote building machine), as I already wrote in one of my previous comments in the point 7. Because when the local bundled GDB is used, the path mapping fails and breakpoints do not work, as you already noticed.

It's unclear why this method doesn't work for you, that's why I requested the log which you didn't provide.

0

Everything is correct. But it does not work because the building machine - is a cross compile building machine and  has a different architecture (x86) and gdb on it simply cannot run the binary file intended for the arm architecture (target machine). can we run gdb on a target debug machine?

0

>can we run gdb on a target debug machine?

For now I don't see a way to do it, I'll consult with the developers.

>gdb on it simply cannot run the binary file intended for the arm architecture

Isn't is possible to install gdb-multiarch on the building machine (sudo apt install gdb-multiarch in case of Ubuntu, for example)? 

0

Very strange , in this post https://intellij-support.jetbrains.com/hc/en-us/community/posts/4408376122002-Download-symbol-file-Makefile-project-from-remote-host  all works (but there was a small binary and another project)

Yes, I could install gdb-multiarch , but available only 7.7.1 version 

0

>Very strange , in this post https://intellij-support.jetbrains.com/hc/en-us/community/posts/4408376122002-Download-symbol-file-Makefile-project-from-remote-host  all works (but there was a small binary and another project)

In that post the scenario was different: there were only two machines and compilation took place on the same machine where it was debugged.

>Yes, I could install gdb-multiarch , but available only 7.7.1 version 

Then I kindly ask you to install gdb-multiarch and give it a try by selecting it in your remote toolchain and respectively in the "Remote GDB Server" configuration. Does it work?

0

It's very hard to read logs on the forum. Please send the idea.log file to clion-support at jetbrains.com, and we will continue to investigate the issue over email.

0

请先登录再写评论。