Remove existing non-working support for self-modifying code, and instead
add a simple compromise, in which the client can notify valgrind
that certain code address ranges are invalid and should be retranslated.
This is done using the VALGRIND_DISCARD_TRANSLATIONS macro in valgrind.h.

At the same time take the opportunity to close the potentially fatal
loophole that translations for executable segments were not being
discarded when those segments were munmapped.  They are now.

Documentation updated.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@274 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/vg_clientperms.c b/vg_clientperms.c
index 02d0b7b..e9ecbc4 100644
--- a/vg_clientperms.c
+++ b/vg_clientperms.c
@@ -385,6 +385,10 @@
          VG_(detect_memory_leaks)();
          return 0; /* return value is meaningless */
 
+      case VG_USERREQ__DISCARD_TRANSLATIONS:
+         VG_(invalidate_translations)( arg[1], arg[2] );
+         return 0;  /* return value is meaningless */
+
       default:
          VG_(message)(Vg_UserMsg, 
                       "Warning: unknown client request code %d", arg[0]);