85 Commits

Author SHA1 Message Date
Bart Van Assche
39c447e4a9 Merge mc_replace_strmem.c, hg_intercepts.c and drd_strmem_intercepts.c
Move memcheck/mc_replace_strmem.c to shared/vg_replace_strmem.c and
add several intercepts for SSE-variants. Include that source file from
drd/drd_strmem_intercepts.c, helgrind/hg_intercepts.c and
memcheck/mc_replace_strmem.c.

Merge memcheck/tests/filter_memcpy into tests/filter_stderr_basic.
    
Update tests/check_headers_and_includes.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13719
2013-11-24 17:48:13 +00:00
Bart Van Assche
04252a5172 memcheck/mc_replace_strmem.c: Remove trailing whitespace
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13717
2013-11-23 16:41:54 +00:00
Bart Van Assche
38c8815567 memcheck: Optimize the memcpy() intercept
This change reduces the time needed to run the memcheck regression tests
with 2% on my development system.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13716
2013-11-23 15:48:12 +00:00
Julian Seward
dbf9b63605 Update copyright dates (20XY-2012 ==> 20XY-2013)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13658
2013-10-18 14:27:36 +00:00
Florian Krohm
3bd1597a41 Silence clang warnings about uninitialised and unused values in
memcheck testcases.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13599
2013-10-01 22:38:43 +00:00
Florian Krohm
6d15b5deb4 Include pub_core/tool_clreq.h instead of valgrind.h where apropriate.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13555
2013-09-16 20:56:35 +00:00
Tom Hughes
b97113218b Replace bcopy on linux as, at least in 32 bit build, glibc will
sometimes choose to use an optimised version. Fixes #311407.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13253
2013-01-21 15:17:02 +00:00
Julian Seward
9244972b6d Add an implementation of memset() that costs half as much on 64 bit
platforms.  (But why are we intercepting memset anyway?  It makes no
sense to me.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13239
2013-01-18 11:01:53 +00:00
Julian Seward
5ed1bb6a2f Add an intercept for stpncpy. Fixes #309427.
(Mark Wielaard, mjw@redhat.com)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13163
2012-12-06 17:54:33 +00:00
Julian Seward
8904839e87 Add intercepts for wcscpy, wcscmp, wcsrchr and wcschr on Linux.
Fixes #307828.  (Mark Wielaard, mjw@redhat.com)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13162
2012-12-06 17:16:00 +00:00
Florian Krohm
e7f4d4f57f Fix some casts that removed const-ness as pointed out by
GCC's -Wcast-qual.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13138
2012-11-24 19:41:54 +00:00
Florian Krohm
b87aa67392 Final patch for Char/HChar mixups.
Remove -Wno-pointer-sign from configure.in.
Fixes 273227.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13125
2012-11-18 00:36:15 +00:00
Julian Seward
95866a7d77 Intercept __GI_memmove on Linux. Fixes #306612.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12982
2012-09-17 15:44:15 +00:00
Julian Seward
ec3a16088b Implement a wrapper for wcslen on Linux, assuming that
sizeof(wchar_t) == 4, which I believe to be true on both Linux
and MacOSX.  Fixes #298281.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12893
2012-08-24 14:44:27 +00:00
Julian Seward
4a3633e266 Update copyright dates to include 2012.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12843
2012-08-05 15:46:46 +00:00
Philippe Waroquiers
ab7b338320 301265 - add x86 support to Android build
Patch by Dragos Tatulea.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12835
2012-08-05 00:08:25 +00:00
Julian Seward
ea5434e0dd Add an intercept for memrchr. Needed for amd64 Ubuntu 12.04.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12833
2012-08-04 23:08:08 +00:00
Julian Seward
7bf78edb21 Add another intercept for strncasecmp_l. Fixes #297701.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12738
2012-07-13 13:21:11 +00:00
Julian Seward
2db1d0a8a2 Reinstate intercepts for plain "memcpy" and "memmove" on OSX <= 10.6
(not on Lion).  Fixes #285662.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12423
2012-03-07 15:26:50 +00:00
Philippe Waroquiers
be97cddd7a Fixes 282230 group allocator for small fixed size, use it for MC_Chunk/SEc vbit
* new files include/pub_tool_groupalloc.h and coregrind/m_groupalloc.c
  implementing a group allocator (based on helgrind group alloc).
* include/Makefile.am coregrind/Makefile.am : added pub_tool_groupalloc.h
  and m_groupalloc.c
* helgrind/libhb_core.c : use pub_tool_groupalloc.h/m_groupalloc.c
  instead  of the local implementation.
* include/pub_tool_oset.h coregrind/m_oset.c : new function
  allowing to create an oset that will use a pool allocator.
  new function allowing to clone an oset (so as to share the pool alloc)
* memcheck/tests/unit_oset.c drd/tests/unit_bitmap.c : modified
  so that it compiles with the new m_oset.c
* memcheck/mc_main.c : use group alloc for MC_Chunk
  memcheck/mc_include.h : declare the MC_Chunk group alloc
* memcheck/mc_main.c : use group alloc for the nodes of the secVBitTable OSet
* include/pub_tool_hashtable.h coregrind/m_hashtable.c : pass the free node
  function in the VG_(HT_destruct).
  (needed as the hashtable user can allocate a node with its own alloc,
  the hash table destroy must be able to free the nodes with the user
  own free).
* coregrind/m_gdbserver/m_gdbserver.c : pass free function to VG_(HT_destruct)
* memcheck/mc_replace_strmem.c memcheck/mc_machine.c
  memcheck/mc_malloc_wrappers.c memcheck/mc_leakcheck.c
  memcheck/mc_errors.c memcheck/mc_translate.c : new include needed
  due to group alloc.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12341
2012-01-17 21:16:30 +00:00
Julian Seward
68cf6ae28d Some fixes for Android:
* initial support for Pandaboard/Linaro
* on Android/ARM, ask for non-executable stacks in the executables
* disable Memcheck's strcasestr intercept; its use of tolower()
  causes the dynamic linker to fail.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12234
2011-10-26 15:10:49 +00:00
Julian Seward
084b7cb10b Fix #284384 (clang 3.1 -Wunused-value warnings in valgrind.h,
memcheck.h) by changing a bunch of VALGRIND_DO_CLIENT_REQUEST_EXPR
into VALGRIND_DO_CLIENT_REQUEST_STMT for cases where the return value
of the former would be unused.  (Bart Van Assche, bart.vanassche@gmail.com)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12226
2011-10-24 13:21:57 +00:00
Julian Seward
c96096ab24 Update all copyright dates, from 20xy-2010 to 20xy-2011.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12206
2011-10-23 07:32:08 +00:00
Julian Seward
1fd197db11 Add a replacement for strcasestr, along with test case. Fixes #282979.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12187
2011-10-21 08:07:13 +00:00
Florian Krohm
dc608b4b58 Declare _exit as "noreturn". This will avoid a GCC warning.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12104
2011-10-05 14:36:00 +00:00
Julian Seward
ef5296e445 arm_linux_android: intercept __dl_strcmp and __dl_strlen in
/system/bin/linker, for the usual reason.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12054
2011-09-26 20:20:19 +00:00
Julian Seward
8885c4e740 Add initial support for Mac OS X 10.7 (Lion). Tracked by bug #275168.
* configure.in support

* new supp file darwin11.supp

* comment out many intercepts in mc_replace_strmem.c and
  vg_replace_malloc.c that are apparently unnecessary for Darwin

* add minimal handling for the following new syscalls and mach traps:
    mach_port_set_context
    task_get_exception_ports
    getaudit_addr
    psynch_mutexwait
    psynch_mutexdrop
    psynch_cvbroad
    psynch_cvsignal
    psynch_cvwait
    psynch_rw_rdlock
    psynch_rw_wrlock
    psynch_rw_unlock
    psynch_cvclrprepost

* wqthread_hijack on amd64-darwin: deal with
  tst->os_state.pthread having an apparently different offset,
  which caused an assertion failure

* m_debuginfo: for 32 bit processes on Lion, use the DebugInfoFSM
  cleanup added in r12041/12042 to handle apparently new dyld
  behaviour, which is to map text areas r-- first and only
  vm_protect them later to r-x.



The following cleanups remain to be done

* remove apparently pointless, commented out wrapper macro
  invokations in mc_replace_strmem.c, eg

  //MEMMOVE(VG_Z_DYLD,        memmove)

  (or determine that they are still necessary, and uncomment)


* ditto in vg_replace_malloc.c, plus general VGO_darwin cleanups
  there


* write proper syscall wrappers for
    mach_port_set_context
    task_get_exception_ports
    getaudit_addr
    psynch_mutexwait
    psynch_mutexdrop
    psynch_cvbroad
    psynch_cvsignal
    psynch_cvwait
    psynch_rw_rdlock
    psynch_rw_wrlock
    psynch_rw_unlock
    psynch_cvclrprepost
  These are currently just no-ops and may be causing Memcheck to
  report false undef-value errors


* figure out why it doesn't work properly unless built with gcc-4.2 on
  Lion.

  gcc-4.2 is the "normal" gcc (i686-apple-darwin11-gcc-4.2.1).  Plain
  gcc is the hybrid gcc-front-end clang-back-end thing
  (i686-apple-darwin11-llvm-gcc-4.2).  Whereas on Snow Leopard, plain
  gcc is the normal gcc.

  The symptoms of the failure are that wqthread_hijack in
  syswrap-amd64-linux.c hits this /*NOTREACHED*/ vg_assert(0); right
  at the end (you need a pretty complex threaded app to trigger this),
  which makes me think that either ML_(wqthread_continue_NORETURN) or
  call_on_new_stack_0_1 do return, which they are not expected to.


* figure out if some of the uninitialised value errors reported in
  system libraries on are caused by Memcheck being confused by LLVM
  generated code, as per bug #242137



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12043
2011-09-21 08:43:08 +00:00
Julian Seward
0e8736e529 * whitespace changes
* move MEMCPY(NONE, ZuintelZufastZumemcpy) to the correct ifdef;
  it got put in the wrong place by r12009 a couple of hours ago.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12010
2011-09-05 22:18:13 +00:00
Julian Seward
4bc0e6e01e For intercepts in libc and the dynamic linker (ld.so or dyld), split
the Linux and Darwin definitions so they are in completely separate
ifdefs -- iow, remove any definitions that are common to both.  This
gives some duplication, but the upside is that it is now possible to
edit the Darwin intercepts without fear of breaking the Linux ones.
This will be important when it comes to supporting OSX 10.7.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12009
2011-09-05 20:39:57 +00:00
Julian Seward
a9fc7fe5c3 x86-linux: don't add redirections for strchr/index in ld.so since they
are already hardwiredly-redirected at startup, and so these are
redundant.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11992
2011-08-18 13:49:48 +00:00
Julian Seward
e1567da7c5 Extend the behavioural-equivalence-class mechanism for redirection
functions to include the ability to give a priority to each function,
as well as a tag indicating its behavioural class.  Add logic in
m_redir.c to resolve conflicting redirections with the same eclass but
different priorities by preferring the redirection with the higher
priority.  Use all of the above in mc_replace_strmem.c, to cause a
conflict between redirections for "memcpy" and "memcpy@GLIBC_2.2.5" to
be resolved in favour of the latter (the non-overlap-checking
version).

This is all related to the massive swamp that is #275284.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11991
2011-08-18 13:09:55 +00:00
Tom Hughes
3cc26a2ef6 Don't compare src and dst to work out which direction to iterate
in for a memcpy/memmove if the length is zero. Fixes #268563.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11990
2011-08-18 08:10:20 +00:00
Julian Seward
1f13aa82f1 Redirect memcpy@@GLIBC_2.14 differently from memcpy@GLIBC_2.2.5, so as
to retain overlap checks for the former whilst skipping them for the
latter.  Pertains to #275284.  (Tom Hughes, tom@compton.nu)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11988
2011-08-17 21:25:50 +00:00
Julian Seward
6c61d1be73 Fix for #275284 (initial fix, at least). Will break OSX; fix
to follow.

* add behavioural eclass tags for most functions in
  mc_replace_strmem.c and vg_replace_malloc.c.

* add a wrapper for strspn()  (see bug 270925)

* coregrind/m_redir.c: add logic to use eclass tags for
  resolving conflicting redirections.  Improve debug
  printing in that situation.

* mc_replace_strmem.c: add a wrapper for "__GI___strcasecmp_l".
  Gark.  Is this correct?  Does __GI___strcasecmp_l behave the
  same as __GI_strcasecmp_l and strcasecmp_l ?



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11985
2011-08-16 21:45:28 +00:00
Julian Seward
8941601fef Un-break the build on most platforms following r11888. Oops.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11889
2011-07-12 13:50:59 +00:00
Julian Seward
5eabf446b4 Fix up preload code so that on Android it doesn't try to call anything
else -- that seems to give a runtime link failure.  In particular,
avoid calling _exit, getpagesize or __libc_freeres.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11887
2011-07-12 13:33:00 +00:00
Julian Seward
ad7de5b336 Delete the AIX5 port. The last release this worked for is 3.4.1,
and then only on AIX 5.2 and 5.3.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11842
2011-06-28 07:25:29 +00:00
Bart Van Assche
9a36fe677e Get rid of the remaining "set but not used" warnings reported by gcc 4.6 by
swapping the roles of the VALGRIND_DO_CLIENT_REQUEST() and
VALGRIND_DO_CLIENT_REQUEST_EXPR() macros. Also, many __attribute__((unused))
declarations on variables have been eliminated. Closes #269778.

Note: so far this patch has been tested on x86/Linux, amd64/Linux and
ppc64/Linux but not yet on any other supported CPU/OS combination.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11755
2011-05-15 07:04:03 +00:00
Julian Seward
9c6d0dc9c9 Fix up most but not all warnings generated by gcc-4.6 about
dead assignments ("[-Wunused-but-set-variable]").



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11673
2011-03-28 16:26:42 +00:00
Tom Hughes
d0687af4c6 Rework the strcasecmp stuff a little, based on Jakub Jelinek's patch
on bug #256600 because the original version turned out to somewhat
fragile across different glibc versions.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11479
2010-11-12 10:40:20 +00:00
Tom Hughes
8051104c57 Add replacements for strcasecmp and related functions which have
hyper-optimised versions which defeat valgrind in recent versions
of glibc.

Fixes #256600 based on patch from Dmitry Djachenko.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11478
2010-11-12 10:03:13 +00:00
Julian Seward
d866af8d34 Change the replacement for memcpy to a vectorised version that does
word copies whenever possible.  This drastically reduces the number of
memory references Memcheck has to process and speeds up a test program
that does repeated memcpys of large blocks by a factor of 4 or more.
Also add a vectorised version of memset.

The memcpy version is also constructed with a view to be used in
exp-ptrcheck, so it can copy areas of memory without losing
pointer-identity shadow data, as happens when doing all copies at a
byte granularity.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11288
2010-08-24 09:05:52 +00:00
Julian Seward
b2113a567d Add in comments a (validated) strspn replacement, should it become
necessary.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11270
2010-08-20 18:24:16 +00:00
Julian Seward
9a8dd3161a Add intercepts for strstr, strpbrk, strcspn. These are needed for
glibc-2.11 when running on SSE4-enabled (virtual) CPUs, for the usual
reason: to avoid ultra-optimised routines using the SSE 4.2 PCMPxSTRx
instructions.  I would not be surprised if it turned out that strspn
was required, but I haven't seen a need for it so far.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11268
2010-08-19 13:22:34 +00:00
Julian Seward
9b0574dff8 Update copyright dates to 2010.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11121
2010-05-03 21:37:12 +00:00
Tom Hughes
00d987f91a Add support for ELF indirect functions. These are symbols of
type STT_GNU_IFUNC which, instead of pointing directly at the
function, point at a routine which will return the address of
the real function. Redirection of indirect functions is handled
by valgrind as follows:

  - When a redirection specification matches an indirect
    function symbol an active redirection is added in the
    normal way, but with the isIFunc flag set.

  - When a call is made to an address which matches an
    active redirection with the isIFunc flag set the call
    is redirected, but not to the target address of the
    redirection - instead it is sent to a small wrapper
    routine that is preloaded into the client.

  - The wrapper routine calls the original client routine
    and collects the result, which it reports to valgrind
    using a client request, and then returns the result to
    the caller.

  - When valgrind gets the client request it looks up the
    active redirection for the indirect function and then
    adds a new active redirection which redirects from the
    address returned by the indirection function to the
    redirection target. This new redirection does not have
    the isIFunc flag set so behaves as a normal redirection.

In addition to the above we also add a few new redirections to
memcheck to capture internal calls made by glibc to things like
strlen, as these internal calls do not go through the indirect
function and instead go direct to the chosen implementation.

Based on a patch from Dodji Seketeli and comments from Jakub
Jelinek, this commit closes bug 206013.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10920
2009-10-29 09:27:11 +00:00
Nicholas Nethercote
5dfe01a847 With the recent VG_(message) change,
VALGRIND_{PRINTF,PRINTF_BACKTRACE,INTERNAL_PRINTF} were no longer appending
newlines.  This meant that --trace-malloc=yes spewed everything onto a
single line, among other things.

Rather than adding the newline back in, I chose to offically change their
behaviour to not add the newlines, as this is more flexible (and the reason
for the underlying VG_(message) change).  I updated all the relevant places
I could find.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10694
2009-08-03 01:38:56 +00:00
Nicholas Nethercote
07045477ca Merge the DARWIN branch onto the trunk.
I tried using 'svn merge' to do the merge but it did a terrible job and
there were bazillions of conflicts.  So instead I just took the diff between
the branch and trunk  at r10155, applied the diff to the trunk, 'svn add'ed
the added files (no files needed to be 'svn remove'd) and committed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10156
2009-05-28 01:53:07 +00:00
Nicholas Nethercote
57a42692d9 Don't compile Linux-only redirects on non-Linux platforms.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9745
2009-05-04 04:20:02 +00:00
Nicholas Nethercote
2001629c3f Updated copyright years.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9344
2009-03-10 22:02:09 +00:00