1632 Commits

Author SHA1 Message Date
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
Nicholas Nethercote
fa46b67475 Fixed --sloppy-malloc and --trace-malloc, debugging options that I broke a
while back (sorry).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2461
2004-07-10 13:56:19 +00:00
Tom Hughes
81368d791a Only print a warning about not having identified the cache if we have
actually failed to recognise it...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2460
2004-07-07 07:16:14 +00:00
Nicholas Nethercote
6991ae3a73 minor
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2459
2004-07-06 22:46:41 +00:00
Nicholas Nethercote
4c7cf81a28 Completely overhauled Cachegrind's data structures. With the new
scheme, there are two main structures:

1. The CC table holds a cost centre (CC) for every distinct source code
   line, as found using debug/symbol info.  It's arranged by files, then
   functions, then lines.

2. The instr-info-table holds certain important pieces of info about
   each instruction -- instr_addr, instr_size, data_size, its line-CC.
   A pointer to the instr's info is passed to the simulation functions,
   which is shorter and quicker than passing the pieces individually.

This is nice and simple.  Previously, there was a single data structure
(the BBCC table) which mingled the two purposes (maintaining CCs and
caching instruction info).  The CC stuff was done at the level of
instructions, and there were different CC types for different kinds of
instructions, and it was pretty yucky.  The two simple data structures
together are much less complex than the original single data structure.

As a result, we have the following general improvements:

- Previously, when code was unloaded all its hit/miss counts were stuck
  in a single "discard" CC, and so that code would not be annotated.  Now
  this code is profiled and annotatable just like all other code.

- Source code size is 27% smaller.  cg_main.c is now 1472 lines, down
  from 2174.  Some (1/3?) of this is from removing the special handling
  of JIFZ and general compaction, but most is from the data structure
  changes.  Happily, a lot of the removed code was nasty.

- Object code size (vgskin_cachegrind.so) is 15% smaller.

- cachegrind.out.pid size is about 90+% smaller(!)  Annotation time is
  accordingly *much* faster.  Doing cost-centres at the level of source
  code lines rather than instructions makes a big difference, since
  there's typically 2--3 instructions per source line.  Even better,
  when debug info is not present, entire functions (and even files) get
  collapsed into a single "???" CC.  (This behaviour is no different
  to what happened before, it's just the collapsing used to occur in the
  annotation script, rather than within Cachegrind.)  This is a huge win
  for stripped libraries.

- Memory consumption is about 10--20% less, due to fewer CCs.

- Speed is not much changed -- the changes were not in the intensive
  parts, so the only likely change is a cache improvement due to using
  less memory.  SPEC experiments go -3 -- 10% faster, with the "average"
  being unchanged or perhaps a tiny bit faster.

I've tested it reasonably thoroughly, it seems extremely similar result
as the old version, which is highly encouraging.  (The results aren't
quite the same, because they are so sensitive to memory layout;  even
tiny changes to Cachegrind affect the results slightly.)

Some particularly nice changes that happened:

- No longer need an instrumentation prepass;  this is because CCs are not
  stored grouped by BB, and they're all the same size now.  (This makes
  various bits of code much simpler than before).

- The actions to take when a BB translation is discarded (due to the
  translation table getting full) are much easier -- just chuck all the
  instr-info nodes for the BB, without touching the CCs.

- Dumping the cachegrind.out.pid file at the end is much simpler, just
  because the CC data structure is much neater.

Some other, specific changes:

- Removed the JIFZ special handling, which never did what it was
  intended to do and just complicated things.  This changes the results
  for REP-prefixed instructions very slightly, but it's not important.

- Abbreviated the FP/MMX/SSE crap by being slightly laxer with size
  checking -- not an issue, since this checking was just a pale
  imitation of the stricter checking done in codegen anyway.

- Removed "fi" and "fe" handling from cg_annotate, no longer needed due
  to neatening of the CC-table.

- Factorised out some code a bit, so fewer monolithic slabs,
  particularly in SK_(instrument)().

- Just improved formatting and compacted code in general in various
  places.

- Removed the long-commented-out sanity checking code at the bottom.

Phew.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2458
2004-07-06 21:54:20 +00:00
Nicholas Nethercote
6cf57dabba Remove unused variable.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2457
2004-07-03 20:27:39 +00:00
Nicholas Nethercote
0362ed10c0 Fix meaningless typo.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2456
2004-07-02 15:28:34 +00:00
Jeremy Fitzhardinge
65a4962721 Clarify that you can also iterate from the result of a SkipList_Find.
(Comment change only)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2455
2004-07-02 00:22:36 +00:00
Nicholas Nethercote
2a48390f98 Couple of clarifying comments about skip lists. (Comment change only)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2454
2004-07-01 12:21:03 +00:00
Julian Seward
0913b43c70 Fix confusing and wrong comment in definition of live ranges in
reg-alloc.  (Comment change only).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2453
2004-07-01 11:38:36 +00:00
Nicholas Nethercote
267ce9fcca Fixed variable name mixup, removed no-longer-used VG_STACK_SIZE_W.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2452
2004-06-30 17:34:30 +00:00
Jeremy Fitzhardinge
7d1ebc2403 Add some comments describing the various kinds of magic going on in the
skiplist implementation.  Also, fix a bug which allocated way too much memory
for the list head (found by Nick).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2451
2004-06-30 01:27:06 +00:00
Tom Hughes
a2a0946b8a Make VPATH builds work so that valgrind can be built in a different
directory from the source tree. This resolves bug 83040.

Based on patch from Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2450
2004-06-29 09:45:37 +00:00
Tom Hughes
4453c3f527 Remove the .in_place directory on a make distclean.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2449
2004-06-28 21:52:40 +00:00
Tom Hughes
857d0841bb Fixed typo in makefile.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2448
2004-06-28 21:37:58 +00:00
Tom Hughes
4a5e522a21 Bumped the core interface major version number to reflect changes
made to the interface when removing nested functions.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2447
2004-06-27 18:10:21 +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
Tom Hughes
0142b68d33 Removed duplicate call to rw_remap.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2445
2004-06-27 13:26:44 +00:00
Tom Hughes
03df333128 Commit the patch from bug 69508 that seeks to make more of the pthread
stack attribute related functions work properly as it seems to be a
sensible thing to improve even if it isn't enough to get the JVM running
under valgrind now.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2444
2004-06-27 12:48:53 +00:00
Nicholas Nethercote
c6cf3e0237 typo
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2443
2004-06-27 12:38:17 +00:00
Nicholas Nethercote
4978146393 Printing slightly more informative message when mmap fails.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2442
2004-06-27 12:30:15 +00:00
Nicholas Nethercote
22996ecc7e Changed (client-heap-size : client-map-seg-size) ratio from 3:1 to 1:2.
As a result, can now mmap much more memory (eg. for Memcheck, 850MB up from
250MB, for Nulgrind 1750MB up from 700MB).  The heap is smaller, but that
doesn't matter much, since programs use brk() directly only rarely, and
malloc() falls back on mmap() if brk() fails anyway.

Also changed the debug info printing for memory layout slightly.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2441
2004-06-27 12:29:56 +00:00
Tom Hughes
f9a0e004f5 Implement an emulated soft limit for file descriptors in addition to
the current reserved area, which effectively acts as a hard limit. The
setrlimit system call now simply updates the emulated limits as best
as possible - the hard limit is not allowed to move at all and just
returns EPERM if you try and change it.

This should stop reductions in the soft limit causing assertions when
valgrind tries to allocate descriptors from the reserved area.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2440
2004-06-26 11:27:52 +00:00
Tom Hughes
1cd4efbe5a Ignore all addrcheck test output files.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2439
2004-06-25 23:25:10 +00:00
Nicholas Nethercote
594e6f8e3c Reduce rounding size for gap between shadow memory and Valgrind's space from
64MB to 1MB.  Gives tools a bit more address space to play with.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2438
2004-06-23 16:15:06 +00:00
Nicholas Nethercote
c12f9856bd Remove unused #define
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2437
2004-06-22 14:20:20 +00:00
Nicholas Nethercote
17afdbd107 Convert VG_(exitcode), a global variable, into a local variable.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2436
2004-06-22 14:18:42 +00:00
Nicholas Nethercote
e55637b2b6 Remove a function and global variable no longer needed.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2435
2004-06-22 14:09:52 +00:00
Nicholas Nethercote
58ae9c9722 Update .cvsignore files
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2434
2004-06-22 14:01:40 +00:00
Nicholas Nethercote
dfd4f18e47 Slightly disentangle main().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2433
2004-06-22 14:00:09 +00:00
Nicholas Nethercote
c5292d2c44 Remove two no-longer-used global vars.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2432
2004-06-22 13:19:21 +00:00
Tom Hughes
2a63d16c76 Prevent applications from blocking SIGVGINT in the proxy threads.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2431
2004-06-22 08:43:29 +00:00
Nicholas Nethercote
2b499cb838 Streamlined --help message a bit.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2430
2004-06-21 13:27:11 +00:00
Nicholas Nethercote
2fab200ad0 Renamed the following options:
--logfile-fd  -->  --log-fd
  --logfile     -->  --log-file
  --logsocket   -->  --log-socket

to be consistent with each other and other options (esp. --input-fd).  Also
renamed some related variables.  The old names still work, for backwards
compatibility, but they're not documented.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2429
2004-06-21 12:42:35 +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
Tom Hughes
827e3bebb6 Don't try and validate the contents of the environment passed to
the execve system call if the envp pointer is null as it causes
valgrind to die with a segmentation fault.

CCMAIL: 83573-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2427
2004-06-19 13:02:34 +00:00
Tom Hughes
96d29fe8ac Add support for the FIGETBSZ and FIBMAP ioctls based on a patch
from Joseph D Wagner <theman@josephdwagner.info>.

CCMAIL: 83025-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2426
2004-06-19 12:41:05 +00:00
Tom Hughes
0546e3739c Add support for the HDIO_GET_IDENTITY ioctl based on patch
from Jim McDonald <jim@mcdee.net>.

CCMAIL: 83340-done@bugs.kde.org


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2425
2004-06-19 12:12:01 +00:00
Tom Hughes
c88651b1fc Add support for SIOCGMIIPHY, SIOCGMIIREG and SIOCSMIIREG ioctls and
improve the checking of other interface related ioctls.

Based in part on a patch from Jim McDonald <jim@mcdee.net> supplied
as a fix for bug #83344.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2424
2004-06-17 23:04:58 +00:00
Oswald Buddenhagen
efb2984d2e make "make dist" work.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2423
2004-06-17 13:25:47 +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
Tom Hughes
3561ea08ca Added VG_(cpuid) to replace the various bits of inline assembler used
to query the CPU characteristics as the use of four implicit registers
causes havoc when GCC tries to inline and optimise the assembler.

Fix to bug #79696.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2421
2004-06-16 20:51:45 +00:00
Nicholas Nethercote
84f99902f0 Reinstate -h option, which disappeared at some point.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2420
2004-06-16 11:56:29 +00:00
Nicholas Nethercote
63c632f5f3 Removed documentation references to the 'ioctl-VTIME' and 'truncate-writes'
weird hacks, which no longer exist thanks to the proxy lwp stuff.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2419
2004-06-16 11:51:08 +00:00
Nicholas Nethercote
9ce21c9e69 Fixed up various command line option scenarios:
- If no tool is specified, V now gives a short message and a list of
    available tools.  This was meant to happen previously, but a bug prevented
    it from working properly;  it gave the usage message instead.

  - If a bad option is given, V now gives a short message rather than the full
    --help.  This make V consistent with all other programs I looked at.

  - Now returning 0 when you do 'valgrind --help' and 'valgrind --version'
    as other programs do.

  - Removed VG_(startup_logging)() and VG_(shutdown_logging)() as they were
    empty and have been for a long time (always?).

  - Added various tests for these scenarios.  Had to change the regtest
    script slightly to allow for malformed command lines.

This addresses bug (wishlist) #82999.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2418
2004-06-15 10:54:40 +00:00
Nicholas Nethercote
bde18dba08 Cater for systems lacking AT_SYSINFO.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2417
2004-06-15 08:34:10 +00:00
Tom Hughes
05f8bea376 Don't bother trying to test semtimedop if it isn't available.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2416
2004-06-14 17:27:41 +00:00
Tom Hughes
d5fcc39f7d Include config.h so that the test for semtimedop works.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2415
2004-06-14 13:15:40 +00:00
Tom Hughes
d9d4e91c04 Fixed the sem test to work on systems with semtimedop.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2414
2004-06-14 12:33:43 +00:00
Nicholas Nethercote
f89b31fc98 Unbreak compilation due to missing #define.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2413
2004-06-14 11:56:59 +00:00