简体   繁体   English

如何解释strace输出

[英]How to interpret the strace output

When I execute the following program on the my embedded Linux nothing happens: 在嵌入式Linux上执行以下程序时,没有任何反应:

#include <boost/thread/thread.hpp>
#include <boost/lockfree/spsc_queue.hpp>
#include <iostream>

#include <boost/atomic.hpp>

void Test(void)
{
    std::cout << "Hello World" << std::endl;
}

int main(int argc, char* argv[])
{
    std::cout << "init";

    boost::thread producer_thread(Test);

    producer_thread.join();

    std::cout << "end";
}


# ./prog -> nothing happens here

The last few lines from strace output are: strace输出的最后几行是:

open("/lib/libboost_thread.so.1.55.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\240\272\0\0004\0\0\0"..., 512) = 512
lseek(3, 95536, SEEK_SET)               = 95536
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1200) = 1200
lseek(3, 95226, SEEK_SET)               = 95226
read(3, "A'\0\0\0aeabi\0\1\35\0\0\0\0055T\0\6\3\10\1\t\1\22\4\24\1\25\1"..., 40) = 40
exit_group(1)                           = ?
+++ exited with 1 +++
# 

The cross compiled libbost_thread is right installed at /lib. 交叉编译的libbost_thread已正确安装在/ lib中。

The program exit before main() being called. 程序在调用main()之前退出。 The program runs normal under my Ubuntu. 该程序在我的Ubuntu下可以正常运行。

Target: ARM with buildroot (sama5d3) 目标:具有buildroot的ARM(sama5d3)

Toolchain: arm-linux-gnueabihf- 工具链:arm-linux-gnueabihf-

Regards 问候

strace is a tool that traces system calls. strace是跟踪系统调用的工具。 In your example, this consists of calls to open() , lseek() , and read() . 在您的示例中,这包括对open()lseek()read() lseek() Specifically, the snippet that you pasted shows the OS's dynamic library loader opening the libboost_thread.so.1.55.0 file and reading its contents; 具体来说,您粘贴的代码片段显示了OS的动态库加载器,打开了libboost_thread.so.1.55.0文件并读取其内容。 nothing more. 而已。 It doesn't really demonstrate anything about your program except that it is linked against that library. 除了与该库链接之外,它实际上没有演示任何有关您程序的内容。

Maybe as a hint: 可能提示:

Have you linked against libpthread with compile and link option -pthread for your target? 您是否已使用目标的编译和链接选项-pthread与libpthread链接?

If not it can have the same effect as seen in your environment: The prog starts, try to start a new thread, have no threading enabled and call the abort() function. 如果不是,则其效果可能与您在环境中看到的效果相同:编启动,尝试启动新线程,未启用任何线程,然后调用abort()函数。 Because abort() simply leave the prog with error in exit code nothing else happens. 因为abort()只会使编步在退出代码中出错,否则不会发生其他情况。

Can you also add your compile & link commands for debugging purpose please! 您是否还可以添加用于编译目的的编译和链接命令!

In addition: 此外:

Your outputs without endl will not be printed because cout is buffered. 不带endl输出将不会被打印,因为cout已缓冲。 The buffer will be printed only if you call flush or send a endl . 仅当您调用flush或发送endl才会打印缓冲区。 Maybe you change this in your example. 也许您在示例中对此进行了更改。

Hope that helps... 希望有帮助...

I found the problem. 我发现了问题。

The boost library was compiled with arm-linux-gnueabi- (elibc) and the buildroot is compiled with uClibc. boost库是用arm-linux-gnueabi-(elibc)编译的,而buildroot是用uClibc编译的。

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

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