summaryrefslogtreecommitdiff
path: root/memcheck/mc_main.c
AgeCommit message (Collapse)AuthorFilesLines
2008-07-18When warning about permissions being changed on a large chunk oftom1-1/+2
memory report the actual addresses involved not just the size. Based on patch from John Reiser <jreiser@BitWagon.com>. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8440 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-07-07Merged FORMATCHECK branch (r8368) to trunk.bart1-15/+15
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8369 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-05-05Add comments giving an overview of the origin tracking implementation.sewardj1-37/+244
Also, rename "ocache" to "ocacheL1" to be more consistent with the comments and the rest of the otag cache code. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8007 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-05-03Remove a bit of unused code.sewardj1-28/+2
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7995 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-05-02Dynamically allocate the origin tracking cache as needed (only forsewardj1-14/+42
runs with --track-origins=yes), rather than having it statically allocated. This is important because the cache is large (100MB) and soaking up 100MB of address space for a non-tracking run is not good. Unfortunately this slows down the origin tracker by 1 to 2 %. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7989 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-05-02Re-check complex and fragile bit-twiddling pertaining to indexing intosewardj1-8/+102
the primary map on 64-bit systems. Add extensive comments and startup-time assertions. As a result of this, fix two off-by-one errors in MC_(helperc_MAKE_STACK_UNINIT) (unlikely to be of much significance, but still ..). No other errors were found. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7988 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-05-02Minor cleanups:sewardj1-10/+8
* remove 'extern' in all the headers, as that is irrelevant and wastes horizontal space * fix some 64-bit uncleanness in client(-defined) block handling * remove unneeded #includes git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7987 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-05-02Move the error management code for Memcheck into a new file,sewardj1-1370/+64
mc_errors.c, as it is relatively self contained. This reduces the size of mc_main.c by about 1350 lines. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7986 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-05-01Merge branches/OTRACK_BY_INSTRUMENTATION into the trunk. This addssewardj1-162/+1738
support to Memcheck for tracking the origin of uninitialised values, if you use the --track-origins=yes flag. This currently causes some Memcheck regression tests to fail, because they now print an extra line of advisory text in their output. This will be fixed. The core-tool interface is slightly changed. The version number for the interface needs to be incremented. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7982 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-03-22Moved macro's that specify branch prediction hints to include/pub_tool_basics.hbart1-52/+45
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7745 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-03-03Merge in the DATASYMS branch.sewardj1-25/+132
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7540 a5019735-40e9-0310-863c-91ae7b9d1cf9
2008-02-11Update copyright dates ("200X-2007" --> "200X-2008").sewardj1-2/+2
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7398 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-11-30New options for Memcheck, --malloc-fill=<hexnumber> andsewardj1-0/+7
--fill-free=<hexnumber>, which cause malloc'd(etc) and free'd(etc) blocks to be filled with the specified value. This can apparently be useful for shaking out hard-to-track-down memory corruption. The definedness/addressability of said areas is not affected -- only the contents. Documentation to follow. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7259 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-11-30Make the freed-block-queue volume metrics 64-bit throughout, to avoidsewardj1-3/+4
any wierdness on very large machines in the future. Also, double the default size from 5MB to 10MB, on the basis that programs are now on average twice as lardy as they were when it was set to 5MB, whenever that was. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7256 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-11-09Merge (from branches/THRCHECK) the following amd64-linux stack unwindsewardj1-1/+2
kludges^H^H^H^H^H^H^Henhancements: r6802: For VG_(record_ExeContext) et al, add a new parameter (first_ip_delta) which is added to the initial IP value before the stack is unwound. A safe value to pass is zero, which causes the existing behaviour to be unchanged. This is a kludge needed to work around the incomplete amd64 stack unwind info in glibc-2.5's clone() routine. r7059: Add a last-ditch heuristic-hack to the amd64-linux stack unwinder, which is used when all other methods fail. Seems like GDB has something similar. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7118 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-09-23Fix various format string errors, courtesy of Florian Krohm.njn1-1/+1
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6902 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-09-17Change an Int to a SSizeT to avoid overflows. Fixed bug 148174.njn1-1/+1
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6855 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-09-17Split the OSet interface into two parts: "OSetGen_", which is the existingnjn1-27/+27
interface and provides full power; and "OSetWord_", which is an easier-to-use interface for if you just want to store words. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6841 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-08-28Merge, from CGTUNE branch, a cleaned up version of r6742:sewardj1-0/+3
Another optimisation: allow tools to provide a final_tidy function which they can use to mess with the final post-tree-built IR before it is handed off to instruction selection. In memcheck, use this to remove redundant calls to MC_(helperc_value_check0_fail) et al. Gives a 6% reduction in code size for Memcheck on x86 and a smaller (3% ?) speedup. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6787 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-08-25Changes to m_hashtable:sewardj1-2/+2
Allow hashtables to dynamically resize (patch from Christoph Bartoschek). Results in the following interface changes: * HT_construct: no need to supply an initial table size. Instead, supply a text string used to "name" the table, so that debugging messages ("resizing the table") can say which one they are resizing. * Remove VG_(HT_get_node). This exposes the chain structure to callers (via the next_ptr parameter), which is a problem since callers could get some info about the chain structure which then changes when the table is resized. Fortunately is not used. * Remove VG_(HT_first_match) and VG_(HT_apply_to_all_nodes) as they are unused. * Make the iteration mechanism more paranoid, so any adding or deleting of nodes part way through an iteration causes VG_(HT_next) to assert. * Fix the comment on VG_(HT_to_array) so it no longer speaks specifically about MC's leak detector. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6778 a5019735-40e9-0310-863c-91ae7b9d1cf9
2007-01-08Update copyright dates.sewardj1-2/+2
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6488 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-12-27Remove dead code.njn1-2/+0
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6449 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-12-16Completely overhauled the internals of Memcheck's error handling. All thenjn1-531/+634
different error kinds were reusing the same struct for storing their details. Each one used some but not all the fields, and the AddrInfo was similar, and it was very confusing. So I changed MC_Error and AddrInfo to be tagged unions, like Vex's IRExpr and IRStmt types. The resulting code is a little more verbose but much easier to understand. I also split up several error kinds, which also made things simpler. The user-visible behaviour is identical except for a couple of very minor things that I've documented in the NEWS file for the 3.3.0 release. Ideally I'd get rid of the Addr and Char* fields in the core Error type, which are not always used, and do them similarly within tools. But that would require changing the core/tool interface, so I'm leaving it for the moment. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6402 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-12-15Remove defunct constant.njn1-2/+0
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6401 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-12-13Fix error in aix zeropage handling.sewardj1-1/+1
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6396 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-12-06Fix suppression-matching bogon (Paul Floyd).sewardj1-1/+1
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6378 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-11-28Make it possible to suppress, and auto-generate suppressions for,sewardj1-1/+6
"User" errors; that is, errors resulting from client requests (check memory range is addressible / defined). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6374 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-10-17- Fix a subtle alignment-check bug I introduced into mc_die_mem_stack_12sewardj1-1/+20
- Add comments to many of the functions to make explicit their alignment-check logic git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6314 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-10-17Merge r6112:sewardj1-123/+540
Changes resulting from porting to AIX5: - Auxiliary primary map handling has been redone, so that the performance penalty for hitting memory above the magic 32G limit is much reduced, and also the number of usable maps is limited only by how much memory is available. The current code has been tested on 64-bit AIX for processes up to about 8GB in size. The auxiliary primary maps are now stored in an OSet, "auxmap_L2". However, looking up in an OSet for each memory reference is expensive. So the OSet is 'fronted' by 24-entry array which holds pointers to the 24 most recently used auxiliary primary maps. Accesses to this array are made faster by incrementally rearranging it on every lookup (if the requested map is found in the array, it is moved one element closer to the start of the array). Logically speaking, auxmap_L1 is a cache of auxmap_L2. The L2-L1 relationship is one of inclusion; iow L2 is not a victim cache. There is extensive new sanity check code for these structures. - Along with the auxmap changes are semi-fast cases in mc_LOADVn_slow and mc_STOREVn_slow. These catch naturally aligned, word-size loads which fall into addressible memory, and handle them directly rather than in a byte-by-byte fashion. - Fix longstanding error with alignment checks in {new,die}_mem_stack_N. Previously, these checked the alignment of the new SP value without taking the stack redzone size into account. This is only safe if the redzone size is 8-aligned. The right thing to do is check alignment after adding on the redzone size. - Add a new mechanism which allows specification, on the command line, of address ranges which memcheck is to 'ignore'. Meaning that it regards all writes to those ranges as acceptable and all reads from those ranges as acceptable and returning initialised data. This is done without disturbing the existing finally-balanced bitmap machinery. Instead, in mc_record_address_error, just ignore the error if the address falls inside an ignored-range. There is a new command-line flag --ignore-ranges= to specify the address ranges. Currently up to 4 non-overlapping ranges may be specified. This kind of thing is useful if you want to do some strange thing like map a high-performance network card into memory and can't be bothered to tell memcheck about it through the official channels (intercepting syscalls/ioctls and telling aspacem about them.) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6256 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-10-05A memory pool update from Graydon Hoare.sewardj1-1/+30
Here's an update to the mempool move / change client requests and sanity checking. The following changes are present: - Added one more (hopefully last) client request, a predicate to test whether a mempool anchor address is currently tracked. It turns out mozilla's arena-using code is sufficiently inconsistent in its assumptions that it's very difficult to phrase the valgrind client-request annotations without this request. Namely: sometime arena-init and arena-free operations are assumed to be idempotent. - Fixed a very rapid tool-memory leak in the mempool sanity check routine. The previous version of the patch I posted would use all memory even on my Very Beefy Test Machine within ~15 minutes of browsing with firefox. - Added a little logging code to print the counts of pools and chunks active every ~10000 sanity checks, when running with -v. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6197 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-09-21Add a comment about marking static memory as defined.njn1-0/+10
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6083 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-07-28Add a mempool-trimming client request (Graydon Hoare).sewardj1-1/+11
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5992 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-06-16Fix copy-n-paste error to do with ppc64-linux stack redzone handlingsewardj1-3/+3
(from r5791). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5973 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-06-05Update copyright dates.sewardj1-2/+2
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5954 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-05-22Assertion is too restrictive; it's possible to validly get ansewardj1-1/+1
addressibility error when MC_(clo_undef_value_errors) is True. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5922 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-05-03Vectorise copy_address_range_perms for common cases. This gives aboutsewardj1-17/+82
40% speedup on artificial programs which just do realloc() and nothing else, and about a 3-4% speedup on starting kpresenter-1.5.0 and loading a 16-slide presentation. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5880 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-04-16Remove tool-specific code (which says which tools allow XML) from the corenjn1-1/+1
by introducing a new "need": VG_(needs_xml_output)(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5854 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-04-06Use better variable names.njn1-45/+45
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5830 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-03-31Terminology change: previously in Memcheck we had the four states:njn1-501/+494
noaccess, writable, readable, other Now they are: noaccess, undefined, defined, partdefined As a result, the following names: make_writable, make_readable, check_writable, check_readable, check_defined have become: make_mem_undefined, make_mem_defined, check_mem_is_addressable, check_mem_is_defined, check_value_is_defined (and likewise for the upper-case versions for client request macros). The old MAKE_* and CHECK_* macros still work for backwards compatibility. This is much better, because the old names were subtly misleading. For example: - "readable" really meant "readable and writable". - "writable" really meant "writable and maybe readable, depending on how the read value is used". - "check_writable" really meant "check writable or readable" The new names avoid these problems. The recently-added macro which was called MAKE_DEFINED is now MAKE_MEM_DEFINED_IF_ADDRESSABLE. I also corrected the spelling of "addressable" in numerous places in memcheck.h. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5802 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-03-28Change to some better function names.njn1-29/+29
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5797 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-03-28Change some uses of bytes to bits for consistency.njn1-47/+49
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5796 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-03-27Merge in the COMPVBITS branch to the trunk. This is a big change tonjn1-1274/+2920
Memcheck, replacing the 9-bits-per-byte shadow memory representation to a 2-bits-per-byte representation (with possibly a little more on the side) by taking advantage of the fact that extremely few memory bytes are partially defined. For the SPEC2k benchmarks with "test" inputs, this speeds up Memcheck by a (geometric mean) factor of 1.20, and reduces the size of shadow memory by a (geometric mean) factor of 4.26. At the same time, Addrcheck is removed. It hadn't worked for quite some time, and with these improvements in Memcheck its raisons-d'etre have shrivelled so much that it's not worth the effort to keep around. Hooray! Nb: this code hasn't been tested on PPC. If things go wrong, look first in the fast stack-handling functions (eg. mc_new_mem_stack_160, MC_(helperc_MAKE_STACK_UNINIT)). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5791 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-03-10Add a new kind of memory-painting primitive, which is: 'make_defined'.sewardj1-0/+21
For each byte in the range, if the byte is addressible, make it be initialised, but if it isn't addressible, leave it alone. So it's like a version of make_readable which doesn't alter addressibility. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5736 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-03-08Reinstate the SET/GET_VBITS client requests.sewardj1-86/+88
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5723 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-03-03get_abit_and_vbyte/get_abit can be a significant bottleneck whensewardj1-2/+2
painting/checking huge numbers of bytes resulting from client check requests. Inlining them helps significantly. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5710 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-02-12Extend stack-permissions-change fast-case machinery to handle +/- 112,sewardj1-13/+21
128, 144 and 160. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5640 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-01-20Changes to make function wrapping work better on ppc64-linux:sewardj1-1/+1
- when recording the non-redirected address in guest_NRADDR, also snapshot the current R2 value, as that will be needed to run the original safely - As a consequence, the original-function information extracted by VALGRIND_GET_ORIG_FN is different on ppc64-linux (2 words) from all other platforms (1 word). So change the type of it from void* to a new type OrigFn which can be defined differently for each platform. - Change the CALL_FN_* macros for ppc64-linux to save/restore R2 values appropriately. - ppc64-linux: detect overflow/underflow of the redirect stack and bring Valgrind to a halt if this happens - Update VG_CLREQ_SZB for ppc32/64 (was out of date). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5569 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-01-18Valgrind-side handling (fast case) for the ppc64 ELF stack redzone.sewardj1-0/+68
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5545 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-01-17Increase size of the largest guest state handled.sewardj1-2/+3
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5532 a5019735-40e9-0310-863c-91ae7b9d1cf9
2006-01-05Fix a casting bug in the LOADV8 slow (misaligned) case spotted by Nick.sewardj1-1/+1
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5500 a5019735-40e9-0310-863c-91ae7b9d1cf9