97 Commits

Author SHA1 Message Date
Julian Seward
79a981783a Implement suppressions for leak checks, which is a fairly frequently
asked-for feature.

A leak-check suppression looks like any other, and has the name 'Leak':

{
   example-leak-suppression
   Memcheck,Addrcheck:Leak
   fun:malloc
   fun:foo
   fun:main
}

Fitting this into the core/skin split proved very tricky.  Problem is
we want to scan the suppressions list to find Leak suppressions, but

- The core code can't do it because LeakSupp is a skin-specific
  suppression kind.

- The skin code can't do it because most (all) of the types and
  structures for the suppressions are private to the core.

Eventual "solution" (least-worst thing I could think of) is for the
skins using the leak checker to pass it the value of LeakSupp.
Even that isn't really clean because the skins consider it a value
of type MemCheckSuppKind but the core thinks it must be a
CoreSuppKind, and the two are not to be reconciled.  So I kludged
around this by casting it to a UInt.

Nick, perhaps you know some way to smooth this out?

Apart from that all changes are straightforward.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1390
2002-12-26 01:53:45 +00:00
Julian Seward
5032cf7572 Change the behaviour of VG_(get_fnname) back to what it was, viz, not
adding offsets ("+N") to the end of function names.  Make a new
function VG_(get_fnname_w_offset) with that behaviour and use it for
%y in VG_(printf) et al.

This is needed so that all addresses within a function generate the
same function name.  The offset'd behaviour was breaking the cache
profiler and dependent program kcachegrind.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1381
2002-12-15 13:11:39 +00:00
Julian Seward
9b619594c2 Merge patch from JeremyF:
72-jump

Add some codegen infrastructure to make it easier to generate local
jumps. If you want to generate a local backwards jump, use
VG_(init_target)(&tgt) to initialize the target descriptor, then
VG_(emit_target_back)(&tgt) just before emitting the target
instruction. Then, when emitting the delta for the jump, call
VG_(emit_delta)(&tgt).

Forward jumps are analogous, except that you call VG_(emit_delta)()
then VG_(emit_target_forward)().

The new emit function, VG_(emit_jcondshort_target)() takes a target
pointer rather than a delta.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1364
2002-12-12 23:42:48 +00:00
Julian Seward
9903164536 Merge patches from JeremyF, to do lazy eflags updating:
- D flag is seperated from the rest (OSZCAP)

- Minimise transfers between real and simulated %eflags since these
  are very expensive.

61-special-d

Make the D flag special. Store it separately in the baseblock rather
than in EFLAGs. This is because it is used almost completely unlike
the other flags, and mashing them together just makes maintaining
eflags hard.

62-lazy-eflags

Implements lazy eflags save and restore. Helps a lot.

Hopefully more documentation to follow.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1346
2002-12-08 18:20:01 +00:00
Julian Seward
bf0d5036da Merge patch from JeremyF:
50-fast-cond

Implement Julian's idea for fast conditional jumps. Rather than fully
restoring the eflags register with an expensive push-popf pair, just
test the flag bits directly out of the base block. Faster, and smaller
code too!


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1339
2002-11-30 15:01:01 +00:00
Julian Seward
31fb0482e7 Complete integration of the new code management (sectored FIFO) story.
This commit adds stats gathering / printing (use -v -v), and selection
of sector size decided by asking skins, via
VG_(details).avg_translation_sizeB, the average size of their
translations.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1334
2002-11-30 00:49:43 +00:00
Julian Seward
0191bd2bd6 Merge patch from JeremyF:
27-nvalgrind

Make valgrind.h pay attention to the preprocessor symbol NVALGRIND. If
defined, it compiles out the Valgrind magic sequence and just assigns
the result with the default return. This is analogous to NDEBUG's
effect on assert().


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1320
2002-11-16 11:06:50 +00:00
Nicholas Nethercote
7cf2e186e3 Lots of changes to future-proof the core/skin interface, making it less likely
that changes will cause binary incompatibilities.  Mostly done by hiding naked
structs with function calls.

Structs hidden in this way were: UCodeBlock, SkinSupp and SkinError (which were
merged back with CoreSupp and CoreError into single types Supp and Error),
ShadowChunk, VgDetails, VgNeeds and VgTrackEvents.  The last three are the most
important ones, as they are (I think) the most likely to change.

Suitable get()/set() methods were defined for each one.  The way UCodeBlocks
are copied for instrumentation by skins is a little different now, using
setup_UCodeBlock.  Had to add a few other functions here n there.  Changed
how SK_(complete_shadow_chunk) works a bit.

Added a file coregrind/vg_needs.c which contains all the get/set functions.
It's pretty simple.

The changes are not totally ideal -- eg. ShadowChunks has get()/set() methods
for its `next' field which arguably shouldn't be exposed (betraying the fact
that it's a linked list), and the get()/set() methods are a bit cumbersome at
times, esp. for `Error' because the fields are accessed quite a few times, and
the treatment of Supps and Errors is a bit inconsistent (but they are used in
different ways), and sizeof_shadow_blocks is still a hack.  But still better
than naked structs.  And one advantage is that a bit of sanity checking can be
performed by the get()/set() methods, as is done for VG_({get,set}_sc_extra)()
to make sure no reading/writing occurs outside the allowed area.

I didn't do it for UInstr, because its fields are accessed directly in lots and
lots of spots, which would have been a great big pain and I was a little
worried about overhead of calling lots of extra functions, although in practice
translation times are small enough that it probably doesn't matter.

Updated the example skin and the docs, too, hurrah.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1314
2002-11-14 12:42:47 +00:00
Julian Seward
18b7ed0c53 Merge patch from JeremyF:
39-lock-prefix

Add a new UInstr LOCK to represent a "lock" prefix in the instruction
stream. This has the same semantics as NOP, but allows a skin to tell
whether a group of UInstrs associated with an x86 instruction are
meant to be locked.

HELGRIND: uses the LOCK UInstr to automatically take and release a
special __BUS_HARDWARE_LOCK__ around locked instructions. This only
works properly if all instructions touching a given address are locked
(even reads).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1310
2002-11-13 22:42:13 +00:00
Julian Seward
8cd862b1cb Merge patch from JeremyF:
33-pre_mutex_lock

HELGRIND: two updates: add a pre_mutex_lock tracking function, so the
skin can do something before the thread blocks. This allows us to do
lock ordering tests before the thread blocks in the deadlock we'd like
to report...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1306
2002-11-13 22:29:34 +00:00
Julian Seward
f2beb7256a Merge patch from JeremyF:
32-hg-lifetime-segments

HELGRIND: implement the algorithm described in "Runtime Checking of
Multithreaded Applications with Visual Threads". Rather than working
with thread IDs, this algorithm breaks the lifetime of a thread up
into thread lifetime segments, and arranges them in an interference
graph.

If a memory location is in exclusive state and it is touched by
another thread, it compares the TLSs of the old owner and the new
thread. If the two TLSs can't possibly overlap in time (for example,
one TLS is the parent before a child thread is created, and the other
TLS is the child thread) the memory location's ownership is
transferred rather than moving it into a shared state. This allows a
parent thread to set up some memory and then create a new child,
handing ownership of that memory to the child, without generating
spurious errors.

At present the only synchonization events used to create new TLSs are
thread create and thread join, though in principle any synchronization
event would work.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1305
2002-11-13 22:25:51 +00:00
Julian Seward
52c333e71f Merge patch from JeremyF:
31-hg-shadow-execontext

HELGRIND: Add option to record ExeContext for every word access. This
is probably very slow and memory hungry, but it helps make the error
reports more useful. Defaults to off.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1304
2002-11-13 22:22:25 +00:00
Nicholas Nethercote
488ff9a93a Changed Makefiles so that the following files are installed:
valgrind.h --> $prefix/include/valgrind/valgrind.h
  memcheck.h --> $prefix/include/valgrind/memcheck.h

This mirrors the lib/ structure.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1289
2002-11-12 10:53:31 +00:00
Nicholas Nethercote
9c534e3a5f Added a basic core/skin interface versioning system. Each skin must use the
macro VG_DETERMINE_INTERFACE_VERSION exactly once.  If the X.Y core and skin
versions don't have a matching X (indicating binary incompatibility), Valgrind
will abort execution immediately at startup.

I even documented it in the skins guide!


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1279
2002-11-08 15:48:16 +00:00
Julian Seward
d9b5337f4b Implement --logfile=<file>, which causes all the log output to be
written to "<file>.pid<pid>".  Useful for tracing trees of processes.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1269
2002-10-27 20:28:29 +00:00
Julian Seward
7240057bc8 Merge patch from Jeremy Fitzhardinge:
14-hg-mmap-magic-virgin
  This does two things:

  1. change the signatures of the new_mem_mmap and change_mem_mprotect
  functions to remove the pointless 'nn' argument. This makes them match
  the signature of new_mem_startup...

  2. change helgrind to mark memory created by mmap as if it were the
  same as other magically pre-inited memory. Implement this by pointing
  helgrind's new_mem_mmap function at new_mem_startup.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1263
2002-10-23 21:46:13 +00:00
Julian Seward
61ff08d6e5 Merge patch from Jeremy Fitzhardinge:
13-kill-1ifroot
  Kill VG_(get_current_tid_1_if_root)() and replace it with the slightly
  more appetising (though still hackish)
  VG_(get_current_or_recent_tid)(). This is intended for use when
  there's no thread actually loaded into the baseblock, but we're doing
  work on behalf of the the thread that was last running (such as during
  a syscall).

  This probably fixes a bug with helgrind misattributing memory created
  with mmap to thread 1 rather than the thread which called mmap (though
  the behaviour is still probably wrong: mmapped memory should be
  magically_inited).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1262
2002-10-23 21:38:22 +00:00
Julian Seward
c6797e9615 Merge patch from Jeremy Fitzhardinge:
14-sprintf
  Update to core VG_(printf)/sprintf/vprintf. They've been modified to
  return the number of characters they generated (either printed, put
  into the buffer, or sent). Also adds a new %y format, which takes an
  Addr argument and looks up a symbol. It takes a '(' flag (ie: "%(y")
  which surrounds the symbol in parens if it could be found.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1253
2002-10-22 04:45:48 +00:00
Julian Seward
9332fb832a Merge patch from Jeremy Fitzhardinge:
08-skin-clientreq
  Introduce a systematic way for skins to distinguish each other's
  client requests. Uses the de-facto standard two-letter identifiers in
  the top two bytes of the client request code. Also changes the
  interface to SK_(handle_client_request) so that a skin can say whether
  or not it handled the request, which allows correct setting of the
  default return value if the request was not handled.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1251
2002-10-22 04:14:35 +00:00
Julian Seward
976b63337a Common up leak detection stuff which was previously duplicated in Memcheck
and Addrcheck.  In coregrind/vg_memory.c, create

   void VG_(generic_detect_memory_leaks

and remove several hundred lines of code from both ac_main.c and mc_main.c.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1250
2002-10-21 07:29:59 +00:00
Julian Seward
eba1b443e5 merge patches from Jeremy Fitzhardinge:
14-hg-tid
  HELGRIND: This fixes a bug in Helgrind in which all memory access by
  syscalls was being treated as if it were happening in thread 1. This
  is because the eraser_mem_read/write functions were using
  get_current_tid_1_if_root() to get the current tid. Unfortunately,
  during syscalls there is no current thread, so it was getting
  1_if_root. This patch fixes this by using what thread ID information
  we're given, and only using get_current_tid() if we're recording a
  memory access performed by code (rather than by a syscall).

... which relies on ...

06-memops
  Implement VG_(memcpy/memset).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1247
2002-10-20 19:40:32 +00:00
Julian Seward
1778e7985a Merge 13-data-syms from Jeremy Fitzhardinge:
Fix to the ELF file reader to make sure that each SegInfo includes not
only the text mapped from an ELF file, but also the data and bss. This
allows the data symbols to be extracted. Also adds a new needs boolean
to allow a skin to specify if it needs data symbols. As a nice
side-effect, it removes the "offset" hack: the offset is the mapped
address in the ELF Phdr: it is (mapped_address - phdr_vaddr).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1246
2002-10-20 19:29:21 +00:00
Julian Seward
dfa3421369 Merge 07-seginfo from Jeremy Fitzhardinge:
API for skins to extract information about mapped segments.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1245
2002-10-20 18:35:48 +00:00
Nicholas Nethercote
20f83c6132 Added VG_(rename) (untested), and made VG_(bbs_done) visible to skins, both at
the request of Josef Weidendorfer for his KCachegrind stuff.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1231
2002-10-14 09:25:37 +00:00
Nicholas Nethercote
534ab14977 Moved the following macros, which were defined multiple times in multiple
files, into vg_skin.h:

    uInstr0, uInstr1, uInstr2, uInstr3, nameIReg, nameISize, nameSReg,
    newTemp, newShadow, uLiteral, uCCall

As macros they avoid namespace problems (they expand to VG_(whatever)) so
this should work fine.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1182
2002-10-04 14:34:15 +00:00
Nicholas Nethercote
c5fbb49521 Added (untested) system call VG_(unlink)().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1177
2002-10-04 10:29:38 +00:00
Nicholas Nethercote
3c7b9b2e03 Changed startup message to give information about skin and core separately.
Added "version" and "copyright_author" fields for skins to supply.

Now startup message looks something like this:

==12698== cachegrind, an I1/D1/L2 cache profiler for x86-linux.
==12698== Copyright (C) 2002, and GNU GPL'd, by Nicholas Nethercote.
==12698== Built with valgrind-HEAD, a program execution monitor.
==12698== Copyright (C) 2000-2002, and GNU GPL'd, by Julian Seward.
==12698== Estimated CPU clock rate is 1422 MHz
==12698== For more details, rerun with: -v

The skin can specify a version number, but the skins that will be distributed
with Valgrind don't.

Also changed "x86 GNU/Linux" to the wicked "x86-linux" at Julian's request.

Updated default regression test filter to handle this new startup message.

----

Also moved the skin's name, description, etc., fields out of VG_(needs) into a
new struct VG_(details), since they are logically quite different to the needs.
Did a little code formatting, etc., for this.  Updated skin docs
correspondingly, too.

Also renamed the need `run_libc_freeres' --> `libc_freeres' so it's a noun
phrase rather than a verb phrase.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1172
2002-10-03 14:05:52 +00:00
Nicholas Nethercote
3bbf66f4e1 Fixed stupid mistake. Fortunately the value is only used for initialisation
and is then always overwritten by liveness analysis.  Still...


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1168
2002-10-03 08:57:01 +00:00
Nicholas Nethercote
089e7e3bcb Updated file descriptions in the copyright notices to reflect the core/skin
split.  Each skin now has its own two-line description.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1166
2002-10-02 13:26:35 +00:00
Nicholas Nethercote
41a0bcbbbb Changes made so that skin error "report this bug to" messages are distinguished
from core error ones:

  - Split up VG_(panic) into VG_(core_panic) and VG_(skin_panic)

  - Likewise, split vg_assert into vg_assert and sk_assert

  - Added a new need string: `bug_reports_to'

  - Removed VG_(skin_error) which was a previous wussy attempt at this change.
    This removed the need for the hacky redeclaration of VG_(skin_error) in
    vg_profile.c, which is good.

At the moment, Julian and Nick's email addresses are hard-coded into each skin
individually, rather than using a #define in vg_skin.h, because that didn't
feel quite right to me...  jseward@acm.org is still done with a #define for
core errors, though.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1164
2002-10-02 11:08:25 +00:00
Nicholas Nethercote
86f876238e Update and add .cvsignore files.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1156
2002-10-01 11:50:39 +00:00
Julian Seward
45e965200b Rename VG_(kill) and VG_(sigpending) to VG_(kkill) and VG_(ksigpending)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1145
2002-09-30 23:12:33 +00:00
Julian Seward
a03f1877f6 Second half of the LDT support. It basically works now.
- New core uinstrs, GETSEG, PUTSEG (save and restore segment regs)

- New core uinstr USESEG, which takes a segment selector and a
  virtual address, and returns a linear address -- and also does
  a limit check.  This calls through to VG_(use_ldt) in vg_ldt.c.

- Insn parser (disAMode) made aware of segment override prefixes

- Obvious fixes to insn emitter and translators

None of the skins understand these new uinstrs, so only --skin=none
works with them at the mo.  This and some other rough edges still
need to be fixed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1139
2002-09-30 12:33:11 +00:00
Nicholas Nethercote
3c9c4b2074 Added profiling events for core/skin cheap/expensive sanity checks.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1138
2002-09-30 11:24:00 +00:00
Nicholas Nethercote
4cd67f62e6 Converted all functions visible from vg_skin.h with names in CamelCaps to
use_under_scores instead, to be consistent.

Also added some missing 'extern's on function declarations in vg_skin.h.

Also added a quick note in vg_regtest.in on the simplest way to run regression
tests.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1135
2002-09-30 10:23:54 +00:00
Nicholas Nethercote
ece3c54af1 Moved the OINK macro into vg_skin.h so that skins can use it.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1124
2002-09-27 10:42:20 +00:00
Nicholas Nethercote
69f08db9a5 Lots of minor comment changes, etc, just to make it clearer to skin writers.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1121
2002-09-27 10:24:48 +00:00
Nicholas Nethercote
8ebeaef638 Change #include so that "make distcheck" works.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1109
2002-09-24 11:23:50 +00:00
Nicholas Nethercote
d8dcbbc58a Changed name of core/ to coregrind/, since 'core' files/dirs have a habit
of being removed with extreme prejudice.

Also added a couple of necessary Makefile.am files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1100
2002-09-23 16:24:41 +00:00
Nicholas Nethercote
f1689b96db Changed lots of files for the new core/ + skin/ directory structure:
- changed lots of Makefile.am files
   - changed configure.in
   - changed lots of #include lines for changed file names
   - changed lots of file headers n footers for changed file names
   - changed vg_regtest to handle new directory structure -- recursively
     traverses subdirectories for .vgtest test files
   - changed lots of paths in memcheck/ regression test expected outputs


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1090
2002-09-23 11:21:57 +00:00
Nicholas Nethercote
afebe61b37 Files updated, added and removed in order to turn the ERASER branch into HEAD
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1086
2002-09-23 09:36:25 +00:00
Julian Seward
4cd4d6138c Fix typo in VALGRIND_MAKE_WRITABLE.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@393
2002-06-06 08:38:45 +00:00
Julian Seward
6610ca19b3 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
2002-05-16 11:06:21 +00:00
Julian Seward
37f7143de6 Minor profiling improvements. Add a couple of cost centers.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@223
2002-05-07 09:25:30 +00:00
Julian Seward
93b2c2ed95 Get rid of the muraroa.demon.co.uk references since that account is
soon to disappear.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@83
2002-04-16 02:51:05 +00:00
Julian Seward
7a36f60133 Mega-merge of my last 2 weeks hacking. This basically does the groundwork
for pthread_* support.  Major changes:

* Valgrind now contains a (skeletal!) user-space pthreads
  implementation.  The exciting bits are in new file vg_scheduler.c.
  This contains thread management and scheduling, including nasty crud
  to do with making some syscalls (read,write,nanosleep) nonblocking.
  Also implementation of pthread_ functions: create join
  mutex_{create,destroy,lock,unlock} and cancel.

* As a side effect of the above, major improvements to signal handling
  and to the client-request machinery.  This is now used to intercept
  malloc/free etc too; the hacky way this is done before is gone.
  Another side effect is that vg_dispatch.S is greatly simplified.
  Also, the horrible hacks to do with delivering signals to threads
  blocked in syscalls are gone, since the new mechanisms cover this case
  easily.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@52
2002-04-12 11:12:52 +00:00
Julian Seward
72a784f3b1 Initial revision
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2
2002-03-22 01:27:54 +00:00