分段故障而嵌入式系统上运行的Qt的Helloworld

分段故障而嵌入式系统上运行的Qt的Helloworld

本文介绍了分段故障而嵌入式系统上运行的Qt的Helloworld的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我交叉编译对于 ARM 的Helloworld 可执行文件。它的工作以及我的朋友的开发板,但有一个分段错误我的船上失败。两块板是在硬件和软件两者稍有不同。

我的问题是,我怎么能在我的板子调试?它是比较容易调试这样一个简单的程序?这是否表明,没有什么错的可执行文件和问题最可能出在我局的文件系统?

下面是code:

 的#include<&的QApplication GT;
#包括LT&; QPushButton>INT主(INT ARGC,CHAR *的argv [])
{
QApplication的应用程序(ARGC,ARGV);QPushButton你好(世界,你好);
hello.resize(100,30);hello.show();
返回app.exec();
}

和由下列命令生成的可执行文件:

  qmake的-project
qmake的
使


解决方案

最有可能是GDB移植到被ARM的目标,但如果缺少了或调试方便,你应该使用gdb的远程调试运行。

GDBSERVER是应用程序应该在目标上运行。以下是演示如何使用它们了。 (维基百科复制)

目标设置:

 远程$ gdbserver的:2345参考hello world
流程参考hello world创建的; PID = 2509
侦听端口2345

主机设置:

 本地$ GDB -q参考hello world
阅读从/home/user/hello_world...done符号。
(GDB)的目标远程192.168.0.11:2345
使用192.168.0.11:2345远程调试
0x002f3850在?? ()从/lib/ld-linux.so.2
(GDB)继续
继续。计划接收信号SIGSEGV,分割过错。
0x08048414在main()在hello_world.c:10
10的printf(X [%d个=%G \\ N,I,X [I]);
(GDB)

I cross-compiled a Helloworld executable for ARM. It worked well on my friend's development board, but failed with a " segmentation fault " on my board. The two boards are slightly different in both hardware and software.

My question is, how can I debug in my board? Is it relatively easy to debug such a simple program? Does it indicate that there's nothing wrong with the executable and the problem most probably lies in the filesystem of my board?

Below is the code:

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QPushButton hello("Hello world");
hello.resize(100, 30);

hello.show();
return app.exec();
}

And the executable is generated by the following commands:

qmake -project
qmake
make
解决方案

most probably gdb is ported to be run on ARM target but in case lack of that or for easy debugging, you should use gdb remote debugging.http://sourceware.org/gdb/onlinedocs/gdb/Remote-Debugging.html#Remote-Debugging

Gdbserver is the application should be run on target. the following is demonstration howto use it. (copied from wikipedia)

Target settings:

remote$ gdbserver :2345 hello_world
Process hello_world created; pid = 2509
Listening on port 2345

Host settings:

local$ gdb -q hello_world
Reading symbols from /home/user/hello_world...done.
(gdb) target remote 192.168.0.11:2345
Remote debugging using 192.168.0.11:2345
0x002f3850 in ?? () from /lib/ld-linux.so.2
(gdb) continue
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x08048414 in main () at hello_world.c:10
10              printf("x[%d] = %g\n", i, x[i]);
(gdb)

这篇关于分段故障而嵌入式系统上运行的Qt的Helloworld的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 03:17