运行valpgind for powerpc时出错

时间:2016-04-18 05:14:57

标签: linux valgrind

我已成功交叉编译valgrid用于PPC85xx架构。我有以下文件

./coregrind/valgrind
./coregrind/vgpreload_core-ppc32-linux.so
./memcheck/memcheck-ppc32-linux
./memcheck/vgpreload_memcheck-ppc32-linux.so
./default.supp

我确实将这些文件放在目标文件夹的/home/valg11文件夹中,并将库导出为

export VALGRIND_LIB=/home/valg11

我正在运行valgrind并收到此错误。

[root@85xx valg11]# ./valgrind -v /home/val
==988== Memcheck, a memory error detector
==988== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==988== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==988== Command: /home/val
==988== 
--988-- Valgrind options:
--988--    -v
--988-- Contents of /proc/version:
--988--   Linux version 2.6.32 (somya@somya-HP-Pro-3330-MT) (gcc version 4.2.2) #230 Mon Oct 12 14:02:51 IST 2015
--988-- 
--988-- Arch and hwcaps: PPC32, BigEndian, ppc32-int-flt-FX-GX
--988-- Page sizes: currently 4096, max supported 65536
--988-- Valgrind library directory: /home/valg11
--988-- Reading syms from /lib/ld-2.8.so
--988-- Reading syms from /home/val
--988-- Reading syms from /home/valg11/memcheck-ppc32-linux
--988--    object doesn't have a dynamic symbol table
--988-- Scheduler: using generic scheduler lock implementation.
--988-- Reading suppressions file: /home/valg11/default.supp
==988== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-988-by-root-on-???
==988== embedded gdbserver: writing to   /tmp/vgdb-pipe-to-vgdb-from-988-by-root-on-???
==988== embedded gdbserver: shared mem   /tmp/vgdb-pipe-shared-mem-vgdb-988-by-root-on-???
==988== 
==988== TO CONTROL THIS PROCESS USING vgdb (which you probably
==988== don't want to do, unless you know exactly what you're doing,
==988== or are doing some strange experiment):
==988==   /home/valg11/../../bin/vgdb --pid=988 ...command...
==988== 
==988== TO DEBUG THIS PROCESS USING GDB: start GDB like this
==988==   /path/to/gdb /home/val
==988== and then give GDB the following command
==988==   target remote | /home/valg11/../../bin/vgdb --pid=988
==988== --pid is optional if only one valgrind process is running
==988== 
==988== error 22 Invalid argument
==988== error VG_(am_shared_mmap_file_float_valgrind) /tmp/vgdb-pipe-shared-mem-vgdb-988-by-root-on-???

正如在某处建议的那样,我确实在没有vgdb的情况下运行valgrind但是valgrind没有检测到内存泄漏并且发出了非法指令错误。

[root@85xx valg11]# ./valgrind -v --vgdb=no /home/val
==995== Memcheck, a memory error detector
==995== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==995== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==995== Command: /home/val
==995== 
--995-- Valgrind options:
--995--    -v
--995--    --vgdb=no
--995-- Contents of /proc/version:
--995--   Linux version 2.6.32 (somya@somya-HP-Pro-3330-MT) (gcc version 4.2.2) #230 Mon Oct 12 14:02:51 IST 2015
--995-- 
--995-- Arch and hwcaps: PPC32, BigEndian, ppc32-int-flt-FX-GX
--995-- Page sizes: currently 4096, max supported 65536
--995-- Valgrind library directory: /home/valg11
--995-- Reading syms from /lib/ld-2.8.so
--995-- Reading syms from /home/val
--995-- Reading syms from /home/valg11/memcheck-ppc32-linux
--995--    object doesn't have a dynamic symbol table
--995-- Scheduler: using generic scheduler lock implementation.
--995-- Reading suppressions file: /home/valg11/default.supp
disInstr(ppc): unhandled instruction: 0x10E40301
                 primary 4(0x4), secondary 769(0x301)
==995== valgrind: Unrecognised instruction at address 0x4018ff0.
==995==    at 0x4018FF0: memcpy (in /lib/ld-2.8.so)
==995==    by 0x40021C3: _dl_start_final (in /lib/ld-2.8.so)
==995==    by 0x4015F8B: _start (in /lib/ld-2.8.so)
==995== Your program just tried to execute an instruction that Valgrind
==995== did not recognise.  There are two possible reasons for this.
==995== 1. Your program has a bug and erroneously jumped to a non-code
==995==    location.  If you are running Memcheck and you just saw a
==995==    warning about a bad jump, it's probably your program's fault.
==995== 2. The instruction is legitimate but Valgrind doesn't handle it,
==995==    i.e. it's Valgrind's fault.  If you think this is the case or
==995==    you are not sure, please let us know and we'll try to fix it.
==995== Either way, Valgrind will now raise a SIGILL signal which will
==995== probably kill your program.
==995== 
==995== Process terminating with default action of signal 4 (SIGILL)
==995==  Illegal opcode at address 0x4018FF0
==995==    at 0x4018FF0: memcpy (in /lib/ld-2.8.so)
==995==    by 0x40021C3: _dl_start_final (in /lib/ld-2.8.so)
==995==    by 0x4015F8B: _start (in /lib/ld-2.8.so)
==995== 
==995== HEAP SUMMARY:
==995==     in use at exit: 0 bytes in 0 blocks
==995==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==995== 
==995== All heap blocks were freed -- no leaks are possible
==995== 
==995== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 2)
--995-- 
--995-- used_suppression:      4 dl-hack1 /home/valg11/default.supp:1205
==995== 
==995== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 2)
Illegal instruction

我不知道问题是什么,有人在powerpc架构上运行valgrind吗?我应该遵循什么程序?

2 个答案:

答案 0 :(得分:1)

最有可能是它记录的第二个原因:

  

该指令是合法的,但Valgrind并没有处理它,   即它是Valgrind的错。如果您认为是这种情况或   你不确定,请告诉我们,我们会尝试解决它。​​

您的可执行文件似乎可能是使用目标指令集编译的,而您正在使用的valgrind版本并不完全支持该指令集。假设您已经从最新的源代码构建了valgrind,对您的问题最简单的解决方法可能是使用更严格(通常更旧)的目标ISA版本重新编译可执行文件。如果您提供完整的编译器版本和命令行信息,我们可能会帮助您弄清楚如何执行此操作。

答案 1 :(得分:0)

你的主机系统可能在memcpy / memmove中有CPU检测,以决定运行哪个版本的函数 - 而valgrind不能很好地处理这个问题。尝试将自己的memcpy和朋友版本制作成动态库,并将其强制加载到您的应用程序中。

(我必须在我的ARM系统上执行此操作)

libmemcmp来源:

#include <unistd.h>

int
memcmp(
    const void *s1,                     /* First string. */
    const void *s2,                     /* Second string. */
    size_t      n)                      /* Length to compare. */
{
    unsigned char u1, u2;

    for ( ; n-- ; s1++, s2++) {
        u1 = * (unsigned char *) s1;
        u2 = * (unsigned char *) s2;
        if ( u1 != u2) {
            return (u1-u2);
        }
    }
    return 0;
}

void *memcpy(void *v_dst, const void *v_src, size_t c)
{
        const char *src = v_src;
        char *dst = v_dst;

        /* Simple, byte oriented memcpy. */
        while (c--)
                *dst++ = *src++;

        return v_dst;
}

LD_PRELOAD = / home / pi / libmemcmp.so valgrind --leak-check = full ./myapp