Nicholas Nethercote da695aa41a atoll() is a terrible function -- you can't do any error checking with it.
Some of our option processing code uses it.  This means that eg.
'--log-fd=9xxx' logs to fd 9, and '--log-fd=blahblahblah' logs to 0 (because
atoll() returns 0 if the string doesn't contain a number!)

It turns out that most of our option processing uses VG_(strtoll*) instead
of VG_(atoll).  The reason that not all of it does is that the
option-processing macros are underpowered -- they currently work well if you
just want to assign the value to a variable, eg:

        VG_BOOL_CLO(arg, "--heap",   clo_heap)
   else VG_BOOL_CLO(arg, "--stacks", clo_stacks)

   else VG_NUM_CLO(arg, "--heap-admin", clo_heap_admin)
   else VG_NUM_CLO(arg, "--depth",      clo_depth)

(This works because they are actually an if-statement, but it looks odd.)

VG_NUM_CLO uses VG_(stroll10).  But if you want to do any checking or
processing, you can't use those macros, leading to code like this:

      else if (VG_CLO_STREQN(9,  arg, "--log-fd=")) {
         log_to            = VgLogTo_Fd;
         VG_(clo_log_name) = NULL;
         tmp_log_fd        = (Int)VG_(atoll)(&arg[9]);
      }

So this commit:
- Improves the *_CLO_* macros so that they can be used in all circumstances.
  They're now just expressions (albeit ones with side-effects, setting the
  named variable appropriately).  Thus they can be used as if-conditions,
  and any post-checking or processing can occur in the then-statement.  And
  malformed numeric arguments (eg. --log-fd=foo) aren't accepted.  This also
  means you don't have to specify the lengths of any option strings anywhere
  (eg.  the 9 in the --log-fd example above).  The use of a wrong number
  caused at least one bug, in Massif.
- Updates all places where the macros were used.
- Updates Helgrind to use the *_CLO_* macros (it didn't use them).
- Updates Callgrind to use the *_CLO_* macros (it didn't use them), except
  for the more esoteric option names (those with numbers in the option
  name).  This allowed getUInt() and getUWord() to be removed.
- Improves the cache option parsing in Cachegrind and Callgrind -- now uses
  VG_(strtoll10)(), detects overflow, and is shorter.
- Uses INT instead of NUM in the macro names, to distinguish better vs. the
  DBL macro.
- Removes VG_(atoll*) and the few remaining uses -- they're wretched
  functions and VG_(strtoll*) should be used instead.
- Adds the VG_STREQN macro.
- Changes VG_BINT_CLO and VG_BHEX_CLO to abort if the given value is outside
  the range -- the current silent truncation is likely to cause confusion as
  much as anything.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9255
2009-02-25 01:01:05 +00:00
2009-02-22 22:25:31 +00:00
2009-02-23 07:28:54 +00:00
2007-12-02 02:08:17 +00:00
2003-12-16 02:15:21 +00:00
2008-10-21 23:09:25 +00:00
2002-03-22 01:27:54 +00:00
2009-02-09 01:52:55 +00:00
2007-12-09 02:24:02 +00:00

Release notes for Valgrind
~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are building a binary package of Valgrind for distribution,
please read README_PACKAGERS.  It contains some important information.

If you are developing Valgrind, please read README_DEVELOPERS.  It contains
some useful information.

For instructions on how to build/install, see the end of this file.

Valgrind works on most, reasonably recent Linux setups.  If you have
problems, consult FAQ.txt to see if there are workarounds.

Executive Summary
~~~~~~~~~~~~~~~~~
Valgrind is an award-winning suite of tools for debugging and profiling
Linux programs. With the tools that come with Valgrind, you can
automatically detect many memory management and threading bugs, avoiding
hours of frustrating bug-hunting, making your programs more stable. You can
also perform detailed profiling, to speed up and reduce memory use of your
programs.

The Valgrind distribution currently includes five production grade
tools: a memory error detector, a thread error detector, a cache
profiler, a call graph profiler and a heap profiler.  Experimental
tools are also included.  They are distinguished by the "exp-" prefix
on their names.

To give you an idea of what Valgrind tools do, when a program is run
under the supervision of Memcheck, the memory error detector tool, all
reads and writes of memory are checked, and calls to malloc/new/free/delete
are intercepted.  As a result, Memcheck can detect if your program:

   - Accesses memory it shouldn't (areas not yet allocated, areas that have
     been freed, areas past the end of heap blocks, inaccessible areas of
     the stack).

   - Uses uninitialised values in dangerous ways.

   - Leaks memory.

   - Does bad frees of heap blocks (double frees, mismatched frees).

   - Passes overlapping source and destination memory blocks to memcpy() and
     related functions.

Problems like these can be difficult to find by other means, often
lying undetected for long periods, then causing occasional,
difficult-to-diagnose crashes.  When one of these errors occurs, you can
attach GDB to your program, so you can poke around and see what's going
on.

Valgrind is closely tied to details of the CPU, operating system and
to a less extent, compiler and basic C libraries. This makes it
difficult to make it portable.  Nonetheless, it is available for
the following platforms: x86/Linux, AMD64/Linux and PPC32/Linux.

Valgrind is licensed under the GNU General Public License, version 2. 
Read the file COPYING in the source distribution for details.


Documentation
~~~~~~~~~~~~~
A comprehensive user guide is supplied.  Point your browser at
$PREFIX/share/doc/valgrind/manual.html, where $PREFIX is whatever you
specified with --prefix= when building.


Building and installing it
~~~~~~~~~~~~~~~~~~~~~~~~~~
To install from the Subversion repository :

  0. Check out the code from SVN, following the instructions at
     http://www.valgrind.org/downloads/repository.html.

  1. cd into the source directory.

  2. Run ./autogen.sh to setup the environment (you need the standard
     autoconf tools to do so).

  3. Continue with the following instructions...

To install from a tar.bz2 distribution:

  4. Run ./configure, with some options if you wish. The standard
     options are documented in the INSTALL file.  The only interesting
     one is the usual --prefix=/where/you/want/it/installed.

  5. Do "make".

  6. Do "make install", possibly as root if the destination permissions
     require that.

  7. See if it works.  Try "valgrind ls -l".  Either this works, or it
     bombs out with some complaint.  In that case, please let us know
     (see www.valgrind.org).

Important!  Do not move the valgrind installation into a place
different from that specified by --prefix at build time.  This will
cause things to break in subtle ways, mostly when Valgrind handles
fork/exec calls.


The Valgrind Developers
Description
No description provided
Readme 51 MiB
Languages
C 94.6%
Assembly 1.7%
C++ 1.1%
Makefile 0.6%
Perl 0.5%
Other 1.4%