【问题标题】:Valgrind cross compile for arm 32 bit board - orange pi用于 arm 32 位板的 Valgrind 交叉编译 - 橙色 pi
【发布时间】:2021-05-06 07:13:00
【问题描述】:

问。如何在 x86 ubuntu 机器上为 ARM 交叉编译 valgrind?

【问题讨论】:

    标签: arm cross-compiling valgrind orange-pi


    【解决方案1】:

    这是一个独立的过程,假设您在 x86_64 Ubuntu Linux 机器上构建。如果不是这种情况,只需为您的 Linux 发行版提供的 arm-none-linux-gnueabihf 目标安装交叉编译器,确保它在您的路径中,然后相应地修改 configure 命令。

    PC端:

    # downloading/installing toolchain
    wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz?revision=d0b90559-3960-4e4b-9297-7ddbc3e52783&la=en&hash=985078B758BC782BC338DB947347107FBCF8EF6B
    
    sudo mkdir -p /opt/arm/10
    sudo tar Jxf gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz -C /opt/arm/10
    
    # downloading/extracting valgrind
    wget https://sourceware.org/pub/valgrind/valgrind-3.16.1.tar.bz2
    tar jxf valgrind-3.16.1.tar.bz2
    
    # building
    export PATH=/opt/arm/10/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin:$PATH
    mdkir valgrind
    cd valgrind
    
    ../valgrind-3.16.1/configure --host=arm-none-linux-gnueabihf --prefix=$(pwd)/valgrind-3.16.1-arm-none-linux-gnueabihf
    make all install
    

    在橙皮上:

    valgrind-3.16.1-arm-none-linux-gnueabihf目录及其子目录的内容从你的PC复制到你的Orangepi的/usr/local目录中。

    安装 libc6-dbg(假设您在 Orangepi 上运行 Ubuntu 或 Debian):apt-get install libc6-dbg

    使用提供here的程序进行测试:

    wget http://cs.ecs.baylor.edu/~donahoo/tools/valgrind/test.c
    gcc -o test -g test.c
    
    valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./test
        ==2034== Memcheck, a memory error detector
        ==2034== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
        ==2034== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
        ==2034== Command: ./test
        ==2034==
        ==2034==
        ==2034== FILE DESCRIPTORS: 3 open at exit.
        ==2034== Open file descriptor 2: /dev/ttyS0
        ==2034==    <inherited from parent>
        ==2034==
        ==2034== Open file descriptor 1: /dev/ttyS0
        ==2034==    <inherited from parent>
        ==2034==
        ==2034== Open file descriptor 0: /dev/ttyS0
        ==2034==    <inherited from parent>
        ==2034==
        ==2034==
        ==2034== HEAP SUMMARY:
        ==2034==     in use at exit: 35 bytes in 2 blocks
        ==2034==   total heap usage: 3 allocs, 1 frees, 47 bytes allocated
        ==2034==
        ==2034== 16 bytes in 1 blocks are definitely lost in loss record 1 of 2
        ==2034==    at 0x484A4B0: malloc (vg_replace_malloc.c:307)
        ==2034==    by 0x1087DB: main (test.c:15)
        ==2034==
        ==2034== 19 bytes in 1 blocks are definitely lost in loss record 2 of 2
        ==2034==    at 0x484A4B0: malloc (vg_replace_malloc.c:307)
        ==2034==    by 0x1087BB: main (test.c:8)
        ==2034==
        ==2034== LEAK SUMMARY:
        ==2034==    definitely lost: 35 bytes in 2 blocks
        ==2034==    indirectly lost: 0 bytes in 0 blocks
        ==2034==      possibly lost: 0 bytes in 0 blocks
        ==2034==    still reachable: 0 bytes in 0 blocks
    

    【讨论】:

    • @Shrikant Suresh Lahase:如果这个或任何答案解决了您的问题,请点击复选标记考虑accepting it。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。当然没有义务这样做。
    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 2016-03-25
    • 2019-11-23
    • 2012-07-19
    • 1970-01-01
    • 2014-03-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多