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 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/memcheck/mac_needs.c b/memcheck/mac_needs.c
index e1ef58a..1de70cd 100644
--- a/memcheck/mac_needs.c
+++ b/memcheck/mac_needs.c
@@ -114,7 +114,7 @@
    err_extra->axskind   = ReadAxs;
    err_extra->size      = 0;
    clear_AddrInfo ( &err_extra->addrinfo );
-   err_extra->isWrite   = False;
+   err_extra->isUnaddr  = True;
 }
 
 __attribute__ ((unused))
@@ -148,7 +148,7 @@
    switch (VG_(get_error_kind)(e1)) {
       case CoreMemErr: {
          Char *e1s, *e2s;
-         if (e1_extra->isWrite != e2_extra->isWrite)   return False;
+         if (e1_extra->isUnaddr != e2_extra->isUnaddr) return False;
          e1s = VG_(get_error_string)(e1);
          e2s = VG_(get_error_string)(e2);
          if (e1s == e2s)                               return True;
@@ -158,7 +158,7 @@
 
       case UserErr:
       case ParamErr:
-         if (e1_extra->isWrite != e2_extra->isWrite)           return False;
+         if (e1_extra->isUnaddr != e2_extra->isUnaddr)         return False;
          if (VG_(get_error_kind)(e1) == ParamErr 
              && 0 != VG_(strcmp)(VG_(get_error_string)(e1),
                                  VG_(get_error_string)(e2)))   return False;
@@ -255,6 +255,10 @@
          VG_(pp_ExeContext)(ai->lastchange);
          break;
       }
+      case Register:
+         // print nothing
+         sk_assert(0 == a);
+         break;
       default:
          VG_(skin_panic)("MAC_(pp_AddrInfo)");
    }
@@ -293,7 +297,7 @@
                                         "stated on the next line");
                break;
             default: 
-               VG_(skin_panic)("SK_(pp_SkinError)(axskind)");
+               VG_(skin_panic)("SK_(pp_shared_SkinError)(axskind)");
          }
          VG_(pp_ExeContext)( VG_(get_error_where)(err) );
          MAC_(pp_AddrInfo)(VG_(get_error_address)(err), &err_extra->addrinfo);
@@ -445,24 +449,24 @@
 
 /* This is for memory errors in pthread functions, as opposed to pthread API
    errors which are found by the core. */
-void MAC_(record_core_mem_error) ( ThreadId tid, Bool isWrite, Char* msg )
+void MAC_(record_core_mem_error) ( ThreadId tid, Bool isUnaddr, Char* msg )
 {
    MAC_Error err_extra;
 
    MAC_(clear_MAC_Error)( &err_extra );
-   err_extra.isWrite = isWrite;
+   err_extra.isUnaddr = isUnaddr;
    VG_(maybe_record_error)( tid, CoreMemErr, /*addr*/0, msg, &err_extra );
 }
 
-void MAC_(record_param_error) ( ThreadId tid, Addr a, Bool isWrite, 
-                               Char* msg )
+void MAC_(record_param_error) ( ThreadId tid, Addr a, Bool isReg,
+                                Bool isUnaddr, Char* msg )
 {
    MAC_Error err_extra;
 
    sk_assert(VG_INVALID_THREADID != tid);
    MAC_(clear_MAC_Error)( &err_extra );
-   err_extra.addrinfo.akind = Undescribed;
-   err_extra.isWrite = isWrite;
+   err_extra.addrinfo.akind = ( isReg ? Register : Undescribed );
+   err_extra.isUnaddr = isUnaddr;
    VG_(maybe_record_error)( tid, ParamErr, a, msg, &err_extra );
 }
 
@@ -529,7 +533,7 @@
    case FreeErr:
    case IllegalMempoolErr:
    case FreeMismatchErr: {
-      MAC_Error* extra = (MAC_Error*)VG_(get_error_extra)(err);
+      MAC_Error* extra = VG_(get_error_extra)(err);
       if (extra != NULL && Undescribed == extra->addrinfo.akind) {
          describe_addr ( VG_(get_error_address)(err), &(extra->addrinfo) );
       }