51 Commits

Author SHA1 Message Date
Tom Hughes
390115d009 Don't truncate addresses in error reports.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3608
2005-05-03 18:16:12 +00:00
Julian Seward
5c01cb38f1 * Crank up the memcheck event-counting system, and enhance it to
name the events, rather than just number them, which makes it a
  lot easier to use

* Based on that, fill in some fast-path cases 
  {LOAD,STORE}V{4,2,1}.  The assembly code looks about the same
  length as it did before, on x86.  Fast-path cases for the
  stack have yet to be done.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3538
2005-04-21 17:34:00 +00:00
Nicholas Nethercote
8aac9bd8a7 Make the 'arg' parameter to VG_BOOL_CLO and similar macros explicit, rather
than implicit.  Also tweak some formatting of command-line arg code.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3453
2005-03-27 01:00:11 +00:00
Nicholas Nethercote
6a687109c0 De-convolute somewhat the client request usage for reporting overlap errors.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3407
2005-03-22 04:27:14 +00:00
Nicholas Nethercote
e65bcc8d43 make function names more uniform
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3406
2005-03-22 04:02:43 +00:00
Nicholas Nethercote
4d3a30c448 Reinstated Memcheck. Did the full merge from CVS, except for the
user-specified block stuff, which confused me because I wasn't sure whether
to use the code already in SVN, or the code in CVS.  Perhaps that code
doesn't need to be changed.

Unfortunately, Memcheck doesn't work entirely correctly -- I get some
spurious errors.  Nonetheless I'm checking it in as a starting point.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3353
2005-03-14 02:42:44 +00:00
Nicholas Nethercote
a551dd690a Reinstate Addrcheck. Some of the tests fail -- some of the leak ones
because the added VG_(find_root_memory)() is just a stub.  And there's a
problem with overlap checking that I haven't worked out yet.  Still it's a
start.  The commit also brings Memcheck back into the build process,
although mc_main.c is entirely commented out at the moment.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3352
2005-03-14 01:16:05 +00:00
Nicholas Nethercote
58fb32879e Make MAC_(print_malloc_stats) local by moving it and associated stuff to
mac_needs.c.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3336
2005-03-13 06:10:20 +00:00
Nicholas Nethercote
5ef4243598 Default to using --leak-check=summary.
MERGED FROM CVS HEAD



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3312
2005-03-12 20:38:13 +00:00
Nicholas Nethercote
05fe123a9e Update copyright notice for 2005 on all relevant files. Don't bother trying
to be selective about it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3303
2005-03-12 16:22:54 +00:00
Julian Seward
0356d27ca6 Merge in changes from the 2.4.0 line. This basically brings in the
overhaul of the thread support.  Many things are now probably broken,
but at least with --tool=none, simple and not-so-simple threaded and
non-thread programs work.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3265
2005-03-10 23:59:00 +00:00
Nicholas Nethercote
10b4595add Added beginnings of an AMD64 port, so lots of new files and directories.
It compiles, but aborts immediately if you try to run it.

I didn't include ldt.c;  I'm not sure how the LDT is used on AMD64.  It can be
added later if necessary.

While doing this, did some 64-bit cleanness fixes:
- Added necessary intermediate casts to ULong to avoid warnings when converting
  ThreadId to void* and vice versa, in vg_scheduler.c.
- Fixed VALGRIND_NON_SIMD_CALL[0123] to use 'long' as the return type.
- Fixed VALGRIND_PRINTF{,BACKTRACE} to use unsigned longs instead of unsigned
  ints, as needed.
- Converted some offsets in vg_symtab2.h from "Int" to "OffT".
- Made strlen, strncat, etc, use SizeT instead of 'unsigned int' for the length
  parameter.
- Couple of other minor things.

I had to insert some "#ifdef __amd64__" and "#ifndef __amd64__" guards in
places.  In particular, in vg_mylibc.c, some of our syscall wrappers aren't
appropriate for AMD64 because the syscall numbering is a bit different in
places.  This difference will have to be abstracted out somehow.

Also rewrote the sys_fcntl and sys_fcntl64 wrappers, as required for AMD64.

Also moved the ipc wrapper into x86, since it's not applicable for
AMD64.  However, it is applicable (I think) for ARM, so it would be nice
to work out a way to share syscall wrappers between some, but not all,
archs.  Hmm.  Also now using the real IPC constants rather than magic
numbers in the wrapper.

Other non-AMD64-related fixes:
- ARM: fixed syscall table by accounting for the fact that syscall
  numbers don't start at 0, but rather at 0x900000.
- Converted a few places to use ThreadId instead of 'int' or 'Int' for
  thread IDs.
- Added both AMD64 and ARM (which I'd forgotten) entries to valgrind.spec.in.
- Tweaked comments in various places.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3136
2004-11-29 13:54:10 +00:00
Julian Seward
3558db91b1 Get rid of baseBlock. Now, when generated code is running, the guest
state pointer points directly at the ThreadState.arch.vex field, thus
updating it in place and avoiding a lot of code (and time-wasting)
which copies stuff back and forth to baseBlock.

Fix zillions of other places in the system where the current thread id
is needed.  It is now passed to all needed places.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3090
2004-11-24 10:44:19 +00:00
Nicholas Nethercote
400cfc0311 Remove useless parameters to TL_(pre_syscall)() and TL_(post_syscall)().
Also remove Memcheck's and Addrcheck's use of syscall_wrappers,
since they didn't do anything useful.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3064
2004-11-22 19:57:39 +00:00
Nicholas Nethercote
454ab569fe Converted the SK_ prefix to TL_ everywhere.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3060
2004-11-22 18:33:15 +00:00
Nicholas Nethercote
3093a1768b Renamed VG_(skin_panic) as VG_(tool_panic).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3057
2004-11-22 18:02:32 +00:00
Nicholas Nethercote
213ef621b7 Renamed functions with 'Skin' in them: SK_(pp_SkinError),
SK_(eq_SkinError), MAC_(pp_shared_SkinError)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3056
2004-11-22 17:57:07 +00:00
Nicholas Nethercote
cf9cf2a220 Renamed sk_assert() as tl_assert().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3055
2004-11-22 17:18:48 +00:00
Nicholas Nethercote
b55751404f Improved Memcheck's error checking messages in two significant ways:
- All memory-related errors are now clear whether they are caused by
  unaddressable or uninitialised memory.  (Previously, writes were
  clearly addressability errors, but reads could be either.)  Mostly
  done by replacing the 'isWrite' field in MAC_Error with 'isUnaddr'.
  Also, mc_check_readable() now indicates not just if an error occurred,
  but what kind of error (ie. addressability or definedness).

- Put machinery into place in the core to inform tools when registers
  are being read by the core -- ie. a 'pre_reg_read' event.  Most
  notably, this facilitates syscall scalar arg definedness checking for
  Memcheck.  Currently this is only working for read(), write(), exit()
  and exit_group(), but it will be extended as the syscalls are
  overhauled as part of the arch-abstraction work.

  A consequence of this is that the ParamErr messages have changed.  This:

    Syscall param write(buf) contains uninitialised byte(s)

  now means that the pointer 'buf' is partially undefined.  If the memory
  pointed to by 'buf' is partially undefined or unaddressable, it says one of:

    Syscall param write(buf) points to uninitialised byte(s)
    Syscall param write(buf) points to unaddressable byte(s)

  The docs have been updated accordingly.

  I also added a couple of regression tests.

These two change sare notable for being the first improvements to
Memcheck's checking/errors in a long time.

I also folded mc_clientreqs.c into mc_main.c, which saves exporting a
whole bunch of things that are not used anywhere else.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2949
2004-11-08 19:20:09 +00:00
Nicholas Nethercote
cc936a9c7c 64-bit cleanness: convert client requests to receive and return UWords.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2921
2004-11-04 18:22:28 +00:00
Nicholas Nethercote
6451cc22a2 64-bit cleanness: lots more replacing of UInt with UWord as necessary.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2920
2004-11-04 18:03:06 +00:00
Nicholas Nethercote
d8fc746ba4 64-bit cleanness: Yet more UInt-->SizeT changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2910
2004-11-03 18:10:37 +00:00
Nicholas Nethercote
854d2ec10e Fix for bug #78048.
Problem was that the malloc-replacing tools (memcheck, addrcheck, massif,
helgrind) would assert if a too-big malloc was attempted.  Now they return 0 to
the client.  I also cleaned up the code handling heap-block-metadata in Massif
and Addrcheck/Memcheck a little.

This exposed a nasty bug in VG_(client_alloc)() which wasn't checking if
find_map_space() was succeeding before attempting an mmap().  Before I added
the check, very big mallocs (eg 2GB) for Addrcheck were overwriting the client
space at address 0 and causing crashes.

Added a regtest to all the affected skins for this.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2462
2004-07-10 14:56:28 +00:00
Tom Hughes
414846a941 Removed all uses of nested functions as they only work with gcc and
cause the stack to be marked as executable in order for them to work.

All assembler files have also had a declaration added so that the
object they generate will be marked as not needing an executable stack.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2446
2004-06-27 17:37:21 +00:00
Robert Walsh
79b252dfdf Memory pool support.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2428
2004-06-19 18:12:36 +00:00
Nicholas Nethercote
55cb3cd764 Introduced 4 macros to minimise boilerplate command line processing code.
Nicely cuts around 130 lines of code, spread over the core and several tools.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2422
2004-06-16 21:26:32 +00:00
Nicholas Nethercote
874fc865a4 Fix for bug #80942.
Addrcheck wasn't doing overlap checking as it should.  This is because
mac_replace_strmem.o was being linked with vgskin_addrcheck.so instead of
vgpreload_addrcheck.so.  I fixed the Makefile, and also moved
_VG_USERREQ__MEMCHECK_GET_RECORD_OVERLAP so Addrcheck could see it.  And I
added the 'overlap' test (from memcheck/tests/) to Addrcheck's regression
suite.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2394
2004-05-05 10:46:22 +00:00
Nicholas Nethercote
979860ca67 Suppressions of jump errors were broken, because the size was zero and
so caused an assertion failure.  So set size == 1 -- it's only used for
suppressions.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2359
2004-04-13 08:47:35 +00:00
Nicholas Nethercote
6a0aeb3716 Changed error message from:
Address 0x%x is not stack'd, malloc'd or free'd

to

  Address 0x%x is not stack'd, malloc'd or (recently) free'd

This makes things clearer in some circumstances, particularly when bogusly
accessing heap memory that has been freed, but Memcheck is no longer tracking.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2358
2004-04-13 08:36:35 +00:00
Julian Seward
cafeef8e48 Support for FXSAVE/FXRSTOR (Tom Hughes). Fixes #71180.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2183
2004-01-04 23:30:55 +00:00
Nicholas Nethercote
07b8e3438b Updated copyright dates for 2004. Also added a couple of missing headers and
footers to some new files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2177
2004-01-04 16:43:23 +00:00
Nicholas Nethercote
fb2d543ee8 Started to rescind the name "skin", replacing it with "tool". Did this in all
the places that normal users will see:

  - command line: --tool=foo (although --skin=foo still works)
  - docs: removed all traces (included renaming coregrind_skins.html to
    coregrind_tools.html)
  - in the usage messages
  - in error messages

Also did in in some places that I judged were unlikely to cause clashes with
existing workspaces:

  - in the header comments of many files (eg. "This file is part of Memcheck, a
    Valgrind tool for...")
  - in the regtests script
  - in the .supp files
  - in AUTHORS
  - in README_MISSING_SYSCALL_OR_IOCTL

Also update the AUTHORS file to mention Jeremy.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2027
2003-11-14 17:47:54 +00:00
Nicholas Nethercote
e9a3bff869 Changed error messages: subsidiary explanations within an error message are now
indented one space;  previously it was mixed, but Memcheck/Addrcheck indented
"Address" lines 3, which made them hard to see in the stack trace.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2021
2003-11-13 17:53:43 +00:00
Nicholas Nethercote
4877ebb17e Moved the MALLOCLIKE and FREELIKE client requests out of memcheck.h, and into
valgrind.h.  Although these requests are not implemented by the core, they can
be implemented by skins that track heap blocks, eg. Memcheck, Annelid, Massif.
This is in preparation for committing Massif to the repository.

I think I managed to make the change in a binary-compatible way.  The only
inconvenience for users is that if they have a client program compiled with the
old requests in, Valgrind will abort with an explanatory message that tells
them to recompile.  Once they've done that (no changes to their program are
required), it works again.

I even updated the docs.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1881
2003-10-02 13:44:04 +00:00
Nicholas Nethercote
f8762eb55d Remove two pieces of identical code used by Memcheck and Addrcheck, and put
them in a shared place.  (They used to be different, when Addrcheck didn't
distinguish between reads and writes, but now they're the same.)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1837
2003-09-26 14:55:31 +00:00
Nicholas Nethercote
d9309149c8 Addrcheck was broken, because it wasn't recognising "Overlap" suppressions.
Fixed now.

MERGE TO STABLE (assuming that Addrcheck does overlap checking in STABLE, which
I think it does)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1828
2003-09-19 08:10:07 +00:00
Nicholas Nethercote
f1bde14402 Fixed overlap errors so the hacky strdup'ing of strings isn't necessary;
now passing in the relevant parameters via an 'extra' struct, as is proper.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1809
2003-09-04 20:50:47 +00:00
Julian Seward
ffbedad97e Fix the strdup-of-OverlapErr-string problem better. Move the
strdup to MAC_(record_overlap_error), wherein we know that
s is a string.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1786
2003-07-24 23:50:17 +00:00
Nicholas Nethercote
0f871c249c A big commit size-wise, but small concept-wise: removed the ThreadState type
from skin's view, replacing all instances with ThreadId.  Much cleaner.  Had to
change the way VG_(get_ExeContext)() worked a little.  Changed the core/skin
major interface because this breaks the old version.  Also fixed a few minor
related things here and there.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1782
2003-07-24 08:45:32 +00:00
Nicholas Nethercote
aca466757f Changed behaviour of VALGRIND_COUNT_LEAKS slightly. Previously, the numbers it
returned (bytes leaked, dubious, etc) were incremented for every leak check
performed.  So if you called VALGRIND_DO_LEAK_CHECK twice in a row, the totals
would be updated twice by the same amount.  This was a bit silly.  So now
COUNT_LEAKS just returns the numbers of bytes leaked found from the previous
leak check.  I even updated the docs, and changed the regression test so old
version fail but the new version passes (by doing two DO_LEAK_CHECKS in a row).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1778
2003-07-22 22:03:58 +00:00
Nicholas Nethercote
ca84f991d3 Added overlap checking to Addrcheck, mostly just moving things around. In
particular, renamed mc_replace_strmem.c as mac_replace_strmem.c;  the 'mac'
prefix indicates it's shared between Memcheck and Addrcheck.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1774
2003-07-22 09:12:33 +00:00
Julian Seward
96c3057550 Add patch from Nick to get proper backtraces in
MC_(get_or_set_vbits_for_client).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1719
2003-07-06 00:54:47 +00:00
Nicholas Nethercote
36bbb35307 Added support for Value16 and Addr16 error suppressions.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1677
2003-06-12 09:58:41 +00:00
Nicholas Nethercote
40571c6f66 Added VALGRIND_MALLOCLIKE_BLOCK and VALGRIND_FREELIKE_BLOCK which allow you to
use a custom-allocator and detect almost as many errors as you could detect if
you used malloc/new/new[].  (eg. leaks detected, free errors, free mismatch,
etc).

Had to fiddle with mac_malloc_wrappers.c a bit to factor out the appropriate
code to be called from the client request handling code.  Also had to add a
new element `MAC_AllocCustom' to the MAC_AllocKind type.

Also added a little documentation, and a regression test.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1643
2003-05-20 16:38:24 +00:00
Julian Seward
07258f73de gcc-3.3 as supplied with SuSE 8.2 ("gcc version 3.3 20030226
(prerelease) (SuSE Linux)") seems to complain about signed-vs-unsigned
comparisons, when -Wall is on.  This commit fixes (most of) those
complaints.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1638
2003-05-18 10:05:38 +00:00
Nicholas Nethercote
8c22ec62d9 Made memcpy()-et-al-overlap errors fully fledged errors, suppressible,
recordable, etc.  Thanks to Tom Hughes <thh@cyberscience.com> for the patch.

Also fixed a minor bug in the reporting -- the src/dst pointers given for
strncat(), strcpy(), strcat().

And I updated the relevent regression test.

And I even added relevant documentation.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1582
2003-05-02 17:24:29 +00:00
Nicholas Nethercote
1b48c55fc5 Added two client requests: VALGRIND_COUNT_ERRORS and VALGRIND_COUNT_LEAKS.
The first returns the number of errors found so far, and is a core request.
The second returns the number of bytes found
reachable/dubious/leaked/suppressed by all leak checks so far, for Memcheck and
Addrcheck.

Both are useful for using Valgrind in regression test suites where multiple
tests are present in a single file -- one can run Valgrind with no output
(using --logfile-fd=-1) and use the requests after each test to determine if
any errors happened.

Had to rename and make public vg_n_errs_found --> VG_(n_errs_found) to do so.
Nb: leak errors are not counted as errors for the purposes of
VALGRIND_COUNT_ERRORS.  This was decided as the best thing to do after
discussion with Olly Betts, who original suggested these changes.

Pulled out common client request code shared between Memcheck and Addrcheck.

Added a regression test for this.

Added some documentation too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1533
2003-04-21 13:24:40 +00:00
Nicholas Nethercote
ac7027c441 Updated copyright notices for 2003. Only 4 months late.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1526
2003-04-15 14:58:06 +00:00
Nicholas Nethercote
7a03be02b3 Namespace police
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1525
2003-04-15 14:09:58 +00:00
Nicholas Nethercote
982fa6481a -----------------------------------------------------------------------------
overview
-----------------------------------------------------------------------------
Previously Valgrind had its own versions of malloc() et al that replaced
glibc's.  This is necessary for various reasons for Memcheck, but isn't needed,
and was actually detrimental, to some other skins.  I never managed to treat
this satisfactorily w.r.t the core/skin split.

Now I have.  If a skin needs to know about malloc() et al, it must provide its
own replacements.  But because this is not uncommon, the core provides a module
vg_replace_malloc.c which a skin can link with, which provides skeleton
definitions, to reduce the amount of work a skin must do.  The skeletons handle
the transfer of control from the simd CPU to the real CPU, and also the
--alignment, --sloppy-malloc and --trace-malloc options.  These skeleton
definitions subsequently call functions SK_(malloc), SK_(free), etc, which the
skin must define;  in these functions the skin can do the things it needs to do
about tracking heap blocks.

For skins that track extra info about malloc'd blocks -- previously done with
ShadowChunks -- there is a new file vg_hashtable.c that implements a
generic-ish hash table (using dodgy C-style inheritance using struct overlays)
which allows skins to continue doing this fairly easily.

Skins can also replace other functions too, eg. Memcheck has its own versions
of strcpy(), memcpy(), etc.

Overall, it's slightly more work now for skins that need to replace malloc(),
but other skins don't have to use Valgrind's malloc(), so they're getting a
"purer" program run, which is good, and most of the remaining rough edges from
the core/skin split have been removed.

-----------------------------------------------------------------------------
details
-----------------------------------------------------------------------------
Moved malloc() et al intercepts from vg_clientfuncs.c into vg_replace_malloc.c.
Skins can link to it if they want to replace malloc() and friends;  it does
some stuff then passes control to SK_(malloc)() et al which the skin must
define.  They can call VG_(cli_malloc)() and VG_(cli_free)() to do the actual
allocation/deallocation.  Redzone size for the client (the CLIENT arena) is
specified by the static variable VG_(vg_malloc_redzone_szB).
vg_replace_malloc.c thus represents a kind of "mantle" level service.

To get automake to build vg_replace_malloc.o, had to resort to a similar trick
as used for the demangler -- ask for a "no install" library (which is never
used) to be built from it.

Note that all malloc, calloc, realloc, builtin_new, builtin_vec_new, memalign
are now aware of --alignment, when running on simd CPU or real CPU.

This means the new_mem_heap, die_mem_heap, copy_mem_heap and ban_mem_heap
events no longer exist, since the core doesn't control malloc() any more, and
skins can watch for these events themselves.

This required moving all the ShadowChunk stuff out of the core, which meant
the sizeof_shadow_block ``need'' could be removed, yay -- it was a horrible
hack.  Now ShadowChunks are done with a generic HashTable type, in
vg_hashtable.c, which skins can "inherit from" (in a dodgy C-only fashion by
using structs with similar layouts).  Also, the free_list stuff was all moved
as a part of this.  Also, VgAllocKind was moved out of core into
Memcheck/Addrcheck and renamed MAC_AllocKind.

Moved these options out of core into vg_replace_malloc.c:
    --trace-malloc
    --sloppy-malloc
    --alignment

The alternative_free ``need'' could go, too, since Memcheck is now in complete
control of free(), yay -- another horribility.

The bad_free and free_mismatch events could go too, since they're now not
detected by core, yay -- yet another horribility.

Moved malloc() et al wrappers for Memcheck out of vg_clientmalloc.c into
mac_malloc_wrappers.c.  Helgrind has its own wrappers now too.

Introduced VG_USERREQ__CLIENT_CALL[123] client requests.  When a skin function
is operating on the simd CPU, this will call a given function and run it on the
real CPU.  The macros VG_NON_SIMD_CALL[123] in valgrind.h present a cleaner
interface to actually use.  Also introduce analogues of these that pass 'tst'
from the scheduler as the first arg to the called function -- needed for
MC_(client_malloc)() et al.

Fiddled with USERREQ_{MALLOC,FREE} etc. in vg_scheduler.c; they call
SK_({malloc,free})() which by default call VG_(cli_malloc)() -- can't call
glibc's malloc() here.  All the other default SK_(calloc)() etc. instantly
panic; there's a lock variable to ensure that the default SK_({malloc,free})()
are only called from the scheduler, which prevents a skin from forgetting to
override SK_({malloc,free})().  Got rid of the unused USERREQ_CALLOC,
USERREQ_BUILTIN_NEW, etc.

Moved special versions of strcpy/strlen, etc, memcpy() and memchr() into
mac_replace_strmem.c -- they are only necessary for memcheck, because the
hyper-optimised normal glibc versions confuse it, and for memcpy() etc. overlap
checking.

Also added dst/src overlap checks to strcpy(), memcpy(), strcat().  They are
reported not as proper errors, but just with single line warnings, as for silly
args to malloc() et al;  this is mainly because they're on the simulated CPU
and proper error handling would be a pain;  hopefully they're rare enough to
not be a problem.  The strcpy check is done after the copy, because it would
require counting the length of the string beforehand.  Also added strncpy() and
strncat(), which have overlap checks too.  Note that addrcheck doesn't do
overlap checking.

Put USERREQ__LOGMESSAGE in vg_skin.h to do the overlap check error messages.

After removing malloc() et al and strcpy() et al out of vg_clientfuncs.c, moved
the remaining three things (sigsuspend, VG_(__libc_freeres_wrapper),
__errno_location) into vg_intercept.c, since it contains things that run on the
simulated CPU too.  Removed vg_clientfuncs.c altogether.

Moved regression test "malloc3" out of corecheck into memcheck, since corecheck
no longer looks for silly (eg. negative) args to malloc().

Removed the m_eip, m_esp, m_ebp fields from the `Error' type.  They were being
set up, and then read immediately only once, only if GDB attachment was done.
So now they're just being held in local variables.  This saves 12 bytes per
Error.

Made replacement calloc() check for --sloppy-malloc;  previously it didn't.

Added "silly" negative size arg check to realloc(), it didn't have one.

Changed VG_(read_selfprocmaps)() so it can parse the file directly, or from a
previously read buffer.  Buffer can be filled with the new
VG_(read_selfprocmaps_contents)().  Using this at start-up to snapshot
/proc/self/maps before the skins do anything, and then parsing it once they
have done their setup stuff.  Skins can now safely call VG_(malloc)() in
SK_({pre,post}_clo_init)() without the mmap'd superblock erroneously being
identified as client memory.

Changed the --help usage message slightly, now divided into four sections: core
normal, skin normal, core debugging, skin debugging.  Changed the interface for
the command_line_options need slightly -- now two functions, VG_(print_usage)()
and VG_(print_debug_usage)(), and they do the printing themselves, instead of
just returning a string -- that's more flexible.

Removed DEBUG_CLIENTMALLOC code, it wasn't being used and was a pain.

Added a regression test testing leak suppressions (nanoleak_supp), and another
testing strcpy/memcpy/etc overlap warnings (overlap).

Also changed Addrcheck to link with the files shared with Memcheck, rather than
#including the .c files directly.

Commoned up a little more shared Addrcheck/Memcheck code, for the usage
message, and initialisation/finalisation.

Added a Bool param to VG_(unique_error)() dictating whether it should allow
GDB to be attached; for leak checks, because we don't want to attach GDB on
leak errors (causes seg faults).  A bit hacky, but it will do.

Had to change lots of the expected outputs from regression files now that
malloc() et al are in vg_replace_malloc.c rather than vg_clientfuncs.c.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1524
2003-04-15 13:03:23 +00:00