|
From: Myoungkyu S. <mks...@gm...> - 2014-09-26 17:14:02
|
Please see the followings. After posting my question at that moment, I realized that I should specify the shared library name, because it's in libc as you said. However, it didn't work using VG_Z_LIBC_SONAME. Best regards, Myoungkyu ==================================================================== mksong@mksong:testwrap$ valgrind --trace-redir=yes -v ./w_main ==5111== Memcheck, a memory error detector ==5111== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==5111== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info ==5111== Command: ./w_main ==5111== --5111-- Valgrind options: --5111-- --trace-redir=yes --5111-- -v --5111-- Contents of /proc/version: --5111-- Linux version 3.13.0-35-generic (buildd@roseapple) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #62-Ubuntu SMP Fri Aug 15 01:58:01 UTC 2014 --5111-- Arch and hwcaps: X86, LittleEndian, x86-mmxext-sse1-sse2 --5111-- Page sizes: currently 4096, max supported 4096 --5111-- Valgrind library directory: /usr/local/lib/valgrind --5111-- << --5111-- ------ REDIR STATE after VG_(redir_initialise) ------ --5111-- TOPSPECS of soname (hardwired) --5111-- ld-linux.so.2 strlen R-> (0000.0) 0x380696b2 --5111-- ld-linux.so.2 index R-> (0000.0) 0x3806968d --5111-- ------ ACTIVE ------ --5111-- >> --5111-- Reading syms from /lib/i386-linux-gnu/ld-2.19.so --5111-- svma 0x0000000860, avma 0x0004000860 --5111-- Considering /lib/i386-linux-gnu/ld-2.19.so .. --5111-- .. CRC mismatch (computed 19686c0d wanted 131a893d) --5111-- Considering /usr/lib/debug/lib/i386-linux-gnu/ld-2.19.so .. --5111-- .. CRC is valid --5111-- << --5111-- ------ REDIR STATE after VG_(redir_notify_new_DebugInfo) ------ --5111-- TOPSPECS of soname ld-linux.so.2 filename /lib/i386-linux-gnu/ ld-2.19.so --5111-- TOPSPECS of soname (hardwired) --5111-- ld-linux.so.2 strlen R-> (0000.0) 0x380696b2 --5111-- ld-linux.so.2 index R-> (0000.0) 0x3806968d --5111-- ------ ACTIVE ------ --5111-- 0x04017ce0 (index ) R-> (0000.0) 0x3806968d ??? --5111-- 0x04017ed0 (strlen ) R-> (0000.0) 0x380696b2 ??? --5111-- >> --5111-- Reading syms from /home/mksong/workspace/.../valgrind_ubuntu14.04/valgrind-3.10.0/testwrap/w_main --5111-- svma 0x00080483a0, avma 0x00080483a0 valgrind: m_demangle/demangle.c:231 (vgPlain_maybe_Z_demangle): the 'impossible' happened. valgrind: symbol with a 'VG_Z_' prefix: _vgw00000ZU_VG_Z_LIBC_SONAME_strcpy. see pub_tool_redir.h for an explanation. host stacktrace: ==5111== at 0x3804E604: ??? (in /usr/local/lib/valgrind/memcheck-x86-linux) sched status: running_tid=0 Note: see also the FAQ in the source distribution. It contains workarounds to several common problems. In particular, if Valgrind aborted or crashed after identifying problems in your program, there's a good chance that fixing those problems will prevent Valgrind aborting or crashing, especially if it happened in m_mallocfree.c. If that doesn't help, please report this bug to: www.valgrind.org In the bug report, send all the above text, the valgrind version, and what OS and version you are using. Thanks. ==================================================================== On Fri, Sep 26, 2014 at 11:22 AM, Julian Seward <js...@ac...> wrote: > On 09/23/2014 03:31 AM, Myoungkyu Song wrote: > > I have a question, which maybe was discussed. I would like to implement > a > > wrapper function for standard API such as "strcpy". However, I failed to > > do. When I tested a user-defined function like "hello(char *, char *)" > > below, I successfully wrapped it, accessing to arguments and a return > > value. > > The problem is here > > > char* I_WRAP_SONAME_FNNAME_ZU(NONE,strcpy) ( char *dest, const char *src > ) > > By using "(NONE,strcpy)" you are requesting to wrap the function strcpy in > the main executable (that's what "NONE") means. But strcpy lives in > libc.so. Really you need to use VG_Z_LIBC_SONAME (with a suitable > definition for VG_Z_LIBC_SONAME) to make it work. Unfortunately the > definition of VG_Z_LIBC_SONAME is system-dependent. > > You should be able to find all the examples you need in > shared/vg_replace_strmem.c > > Note also, using -v is very helpful for debugging wrapping/intercept > problems. If you need complete details, also try --trace-redir=yes. > > J > > > > |