51 Commits

Author SHA1 Message Date
Nicholas Nethercote
798fba1991 Remove remaining profiling gunk from Memcheck.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5387
2005-12-19 22:48:06 +00:00
Nicholas Nethercote
c2e79c35e4 Remove the old profiling stuff from Memcheck.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5385
2005-12-19 22:23:35 +00:00
Tom Hughes
0e57349a13 We can print native word sized values sensibly now...
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4915
2005-10-13 15:29:39 +00:00
Tom Hughes
daf507dee2 Fix realloc wrappers to handle the out of memory case properly - if
the call to VG_(cli_malloc) returns NULL then don't try and copy the
data or register a new block and just leave the old block in place
instead, but still return NULL to the caller.

Fixes bug 109487 and it's duplicates.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4875
2005-10-06 09:00:17 +00:00
Nicholas Nethercote
85545d1a1c Changed some overflow-prone counters from UInt to ULong.
Changed some printf specifiers accordingly, plus some more that were
incorrect.

Also put commas in various output numbers, eg. the leak check stats.  
This makes them much easier to read when they get big.  One
exception is in XML number-only fields such as <leakedbytes>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4874
2005-10-06 03:32:42 +00:00
Nicholas Nethercote
8232209275 Make "silly arg" message 64-bit clean.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4476
2005-08-23 16:10:36 +00:00
Nicholas Nethercote
d5f110a674 wibbles
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4433
2005-08-16 03:34:56 +00:00
Nicholas Nethercote
d5738fd68d lots of little wibbles
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4432
2005-08-16 03:29:50 +00:00
Nicholas Nethercote
fcdc60441e Something I realised recently: in C, iterators are much better than
higher-order functions for traversing data structures.  The higher-order
approach is too clumsy due to the lack of polymorphism and closures;  you
have to use void* too much and it is more verbose than it should be.

Hence, I replaced all the uses of HT_first_match() and
HT_apply_to_all_nodes() with equivalent uses of the hashtable iterator.
Also replaced higher-order traversal functions for Memcheck's freed-list
and the thread stacks with iterators.  That last change changes the
core/tool interface, so I've increased the version number.







git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4415
2005-08-15 01:52:02 +00:00
Nicholas Nethercote
7062ca6bc7 Remove more now-unnecessary casts, thanks to the recent VgHashTable changes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4409
2005-08-14 18:32:16 +00:00
Nicholas Nethercote
5d07a9ad26 Changed many, but not all, of the VgHashNode* parameters and return
types in m_hashtable.c to void*.  This requires no changes to code
already using VgHashTables, but it allows some previously-required casts
to be removed.  I also changed Memcheck and Massif by removing some of
these now-unnecessary casts.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4404
2005-08-14 06:24:20 +00:00
Nicholas Nethercote
d892f660ec Streamline handling of realloc() in Memcheck and Massif by using
the newly added VgHashTable functions.  Also some other minor changes.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4380
2005-08-11 02:09:25 +00:00
Nicholas Nethercote
8515143ce8 Get rid of some stupidity:
- Added some useful hash table functions (vanilla lookup() and remove()).
  [Actually, I accidentally added them with my previous commit]
  
  Replaced various simple uses of VG_(HT_get_node) with these new functions. 

- Passing record_freemismatch_error() the MAC_Chunk of the freed heap block.
  So now we don't need to call describe_addr() to re-find that block, which
  means that we can remove the MAC_Chunk from the malloc_list earlier, rather
  than having to do a lookup and then later remove it with the stupid removal
  handle returned by VG_(HT_get_node)().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4379
2005-08-11 00:47:10 +00:00
Nicholas Nethercote
7f8c275c59 Give variable a better name.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4378
2005-08-11 00:06:36 +00:00
Nicholas Nethercote
a6f1874fd2 Use memcpy() instead of a loop.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4377
2005-08-10 21:25:36 +00:00
Nicholas Nethercote
e67b65d0eb Changed m_hashtable.c to allow the size of the hash table to be specified
when it is created.  Fortunately this didn't affect code outside this
module except for the calls to VG_(HT_construct)().

As a result, we save some memory because not all tables have to be as big
as the ones needed for malloc/free tracking.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4100
2005-07-03 17:53:11 +00:00
Nicholas Nethercote
7a954963d7 Try to make toobig-allocs work on 64-bit platforms.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4061
2005-06-30 02:34:32 +00:00
Nicholas Nethercote
f174930b23 Final commit for the initial modularisation pass:
- Broke part of m_scheduler off into a new module m_threadstate.  It
  contains ThreadState, VG_(threads)[] and some basic operations on the
  thread table.  All simple stuff, the complex stuff stays in m_scheduler.
  This avoids lots of circular dependencies between m_scheduler and other
  modules.

- Managed to finally remove core.h and tool.h, double hurrah!

- Introduced pub_tool_basics.h and pub_core_basics.h, one of which is
  include by every single C file.

- Lots of little cleanups and changes related to the above.

- I even did a small amount of documentation updating.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3944
2005-06-19 01:24:32 +00:00
Nicholas Nethercote
eb2d0a7d06 Modularised assertions and panics in m_libcassert.
As part of this, killed the VG_STRINGIFY macro, which was used to expand
out names like "VG_(foo)" and "vgPlain_foo" in assertion failure
messages.  This is good since we actually want the "VG_(foo)" form used
in these messages.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3842
2005-06-04 19:16:06 +00:00
Nicholas Nethercote
dbc8c6d99c Modularise printing functions in m_libcprint.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3840
2005-06-03 03:08:39 +00:00
Nicholas Nethercote
09980587a9 Started modularising vg_mylibc. Put all the standalone stuff -- ie. not
relying on any other modules -- in m_libcbase.

Also converted the 'size' parameters to functions like VG_(memcpy) and
VG_(strncpy) from Int to SizeT, as they should be.

Also removed VG_(atoll16) and VG_(toupper), which weren't being used.

Also made VG_(atoll36) less flexible -- it now only does base-36 numbers
instead of any base in the range 2..36, since base-36 is the only one we
need.  As part of that, I fixed a horrible bug in it which caused it to
return incorrect answers for any number containing the digits 'A'..'I'!
(Eg. for "A; it would return 17 instead of 10!)

Had to disable the assertions in VG_(string_match), since this module can't
see vg_assert, which wasn't ideal but also isn't a disaster.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3838
2005-06-02 03:39:33 +00:00
Julian Seward
161cfde150 First pass at adding ability for Memcheck to print all output in XML
form.  The relevant flag is --xml=yes.  Currently this only works with
Memcheck.

Specifying this flag fixes various other options relating to verbosity
and behaviour of the leak checker, so that the resulting output is in
a relatively fixed form suitable for parsing by GUIs.

Still to do:

* Add mechanism to show error counts
* Add regression test
* Document the resulting format



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3773
2005-05-19 00:25:45 +00:00
Nicholas Nethercote
a08662c48c Big clean-up: changed the core/tool interface to be mediated entirely
through the VG_(tdict) function dictionary, rather than using TL_(foo)
functions.

This facilitated the following changes:

- Removed the "TL_" prefix, which is no longer needed.

- Removed the auto-generated files vg_toolint.[ch], which were no longer
  needed, which simplifies the build a great deal.  Their (greatly
  streamlined) contents went into core.h and vg_needs.h (and will soon
  go into a new module defining the core/tool interface).  
  
  This also meant that tool.h.base reverted to tool.h (so no more
  accidentally editing tool.h and not having the changes go into the
  repo, hooray!)  And gen_toolint.pl was removed.  And toolfuncs.def was
  removed.

- Removed VG_(missing_tool_func)(), no longer used.

- Bumped the core/tool interface major version number to 8.  And I
  killed the minor version number, which was never used.  The layout
  of the ToolInfo struct is such that this should not cause problems.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3644
2005-05-09 01:02:08 +00:00
Nicholas Nethercote
f1f707c7b2 This change reduces the number of calls to dlsym() when loading tools from a
lot to one.  This required two basic changes.

1. Tools are responsible for telling the tool about any functions they
provide that the tool may call.  This includes basic functions like
TL_(instrument)(), functions that assist core services such as
TL_(pp_Error)(), and malloc-replacement-related functions like
TL_(malloc)().  

2. Tools that replace malloc now specify the size of the heap block redzones
through an arg to the VG_(malloc_funcs)() function, rather than with a
variable VG_(vg_malloc_redzone_szB).

One consequence of these changes is that VG_(tool_init_dlsym)() no longer
needs to be generated by gen_toolint.pl.

There are a number of further improvements that could follow on from this one.
- Avoid the confusingly different definitions of the TL_() macro in the
  core vs. for tools.  Indeed, the functions provided by the tools now don't
  need to use the TL_() macro at all, as they can have arbitrary names.
- Remove a lot of the auto-generated stuff in vg_toolint.c and vg_toolint.h
  (indeed, it might be possible to not auto-generate these at all, which
  would be nice).
- The handling of VgToolInterface is currently split across vg_needs.c and
  vg_toolint.c, which isn't nice.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3487
2005-03-31 04:37:24 +00:00
Nicholas Nethercote
f474d2e51a A modularisation + refactoring commit. vg_execontext.c has been split into
two halves: stacktrace.c, which deals with getting, traversing and printing
stack traces;  and execontext.c, which deals with storing stack traces
permanently in a way that avoids duplicates, and comparing them.

One nice outcome:  previously we were often creating ExeContexts, which live
forever, even when they were only needed temporarily.  Ie. this was a memory
leak, which has been removed.

As part of this, new headers have been created, carved off core.h and
tool.h.  Lots of function names have changed, too.

In Massif, I also changed a lot of "eip" names to "ip" to make them less
x86-specific.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3429
2005-03-25 23:35:48 +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
Julian Seward
fcbbc8332b Commit half-baked attempts to get memcheck and addrcheck to build.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3350
2005-03-14 00:14:04 +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
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
Nicholas Nethercote
782dd25de9 64-bit cleanness: fix nasty bug... in the memory allocators, redzones
were being kept as UInts.  They were sometimes negated and then used as
indices to arrays, and on 64-bit platforms they get converted
incorrectly (using zero-extension instead of sign extension, I think)
before the indexing happens, giving a totally bogus index.

The fix was to convert all these types to SizeT.  It would be nice to be
able to avoid this automatically somehow in the future.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3158
2004-11-30 13:26:29 +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
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
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
528046b537 64-bit cleanness: make the hash-table have UWord keys instead of UInt keys.
Allows addresses as keys.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2916
2004-11-04 16:39:43 +00:00
Nicholas Nethercote
d98a43bc4f 64-bit cleanness:
- Use SizeT instead of UInt for new_mem_stack and all the related functions.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2907
2004-11-02 13:06:32 +00:00
Nicholas Nethercote
e245f2aeb0 64-bit cleanness: Converted malloc() et al to use SizeT rather than Int.
This required some tricks with casting to maintain Memcheck's silly (ie.
negative) arg checking.  The allocator was also changed accordingly. It
should now be able to allocate more than 4GB blocks on 64-bit platforms.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2906
2004-11-02 12:36:02 +00:00
Nicholas Nethercote
6ff3d742f9 Avoid strange warnings about dereferencing type-punned pointers that occurs
with GCC 3.3+.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2839
2004-10-25 19:46:07 +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
c756c590cf Convert "skin" to "tool" in various places; almost entirely within comments,
nothing that will affect code.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2217
2004-01-21 15:08:04 +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
c2bfdc506c Changed the behaviour of realloc() in Memcheck, Addrcheck and Helgrind.
Previously, when realloc() was asked to make a block bigger, the ExeContext
describing where that block was allocated was increased;  however, if the block
became smaller or stayed the same size, the original ExeContext remained.  This
is correct in one way (that's where the memory manager actually parcelled out
the block) but it's not very intuitive.  This commit changes things so the
ExeContext of a block is always changed upon realloc().  I added a regression
test for it too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1783
2003-07-24 17:39:59 +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
Julian Seward
dd2abcb8e0 In vg_memory.c, startup_segment_callback, fix initialisation ordering
problem which caused the leak checker to misbehave following recent
PLT-bypass workaround.

In short, it is an error to announce to the skin, segments found which
belong to the low-level memory manager, because the skin may then mark
them as accessible to the client.  This is wrong, and the client
should only acquire accessible memory via malloc etc and stack
movement.  Now we carefully avoid mentioning any segment belonging to
the low level memory manager.

Take the opportunity to improve VG_(within_m_state_static) so that it
also detects pointers within the thread table.  This can reduce the
number of blocks the leak checker spuriously thinks are still
reachable.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1751
2003-07-12 12:11:39 +00:00
Julian Seward
33d1e7e957 add_MAC_Chunk: mark shadow block as off-limits to the client so that
the leak checker doesn't see the pointer to the real block.  As
detailed in the comment in this function, this must be masking a
deeper memory management bug.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1750
2003-07-12 01:41:24 +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
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