简体   繁体   English

如何为ARM交叉编译并在NetBeans的另一台计算机上调试?

[英]How do I cross-compile for ARM and debug on another machine in NetBeans?

I am trying to set up a NetBeans x86_64 environment where I can write code and add breakpoints in the IDE, cross-compile for ARM, then run the binary on a raspberry pi (for now) running gdbserver. 我试图建立一个NetBeans x86_64环境,可以在其中编写代码并在IDE中添加断点,为ARM进行交叉编译,然后在运行gdbserver的raspberry pi上运行二进制文件。

A common option is to use a remote build host to build, run, and debug the binary, but I will eventually be working on an embedded device that will not have room for a development toolchain. 一个常见的选择是使用远程构建主机来构建,运行和调试二进制文件,但是我最终将在没有足够开发工具链空间的嵌入式设备上工作。 I am using a pi right now to learn how I will compile and debug once the embedded machines arrive. 我现在正在使用pi来学习一旦嵌入式计算机到货后如何进行编译和调试。 Please do not suggest using a remote build host. 请不要建议使用远程构建主机。

Right now, my best guess has been to replace the run command with ./run.sh "${OUTPUT_PATH}" , where run.sh is a small bash script that transfers the newly compiled binary to the pi, then runs gdbserver --debug localhost:6000 ~/app . 现在,我最好的猜测是用./run.sh "${OUTPUT_PATH}"替换run命令,其中run.sh是一个小型bash脚本,它将新编译的二进制文件传输到pi,然后运行gdbserver --debug localhost:6000 ~/app There is a gdbserver plugin for NetBeans that I have been able to attach to, after NetBeans has transferred the binary and run gdbserver, but all that gives me is the stdout of gdb (which makes sense). 在NetBeans传输二进制文件并运行gdbserver之后,有一个我可以连接到NetBeans的gdbserver插件 ,但是给我的只是gdb的标准输出(这很有意义)。 What I want is setting and stepping through breakpoints using the IDE and watching variables change, but I can't seem to get that to work using this setup. 我想要的是使用IDE设置并逐步执行断点,并观察变量的变化,但是我似乎无法使用此设置来使它起作用。

What is the right way to do this? 什么是正确的方法?

gdbserver --debug localhost:6000 ~/app gdbserver-调试localhost:6000〜/ app

This doesn't match the invocation syntax documented for versions of gdbserver I'm familiar with, but even without knowing the form, the argument seems mistaken. 这与我所熟悉的gdbserver版本记录的调用语法不匹配,但是即使不知道其形式,该参数似乎还是错误的。

"localhost" always refers to the same computer, never another. “本地主机”始终是指同一台计算机,而不是另一台计算机。 So specifying "localhost" would imply you were going to run gdbserver and gdb on the same machine, which negates the whole point of using gdbserver . 因此,指定“ localhost”将意味着您将在同一台计算机上运行gdbservergdb ,这使使用gdbserver的整个过程变得gdbserver

It's unclear what your command causes gdbserver to do, but neither possibility is good. 目前尚不清楚您的命令会导致gdbserver做什么,但是两种可能性都不是。

  • if it causes gdbserver to listen on the loopback interface rather than INADDR_ANY, then only programs running on the target itself will be able to contact the gdbserver process, which rules out the remote gdb. 如果它导致gdbserver 侦听回送接口而不是INADDR_ANY,则只有在目标本身上运行的程序才可以联系gdbserver进程,从而排除了远程gdb。

  • if it causes gdbserver to attempt to connect to an already running remote gdb , then that won't work either, as it will be attempting to connect to a non-existent local one. 如果它导致gdbserver尝试连接到已经运行的远程gdb ,那么它也不起作用,因为它将尝试连接到不存在的本地 gdb

Likely what you want to do is something like 您可能想做的是

target> gdbserver :6000 ~/app

devmachine>gdb build/app
gdb> target remote target_machine_ip:6000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM