707 Commits

Author SHA1 Message Date
Dirk Mueller
eaf2fd38cd implement a couple more instructions. I've mailed this patch to Julian
and Nick but got no reply. I guess they're okay with it. I tested them
quite a lot so it should be fine.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1834
2003-09-26 00:32:53 +00:00
Dirk Mueller
3545e98607 be more specific which allocation failed
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1833
2003-09-26 00:26:07 +00:00
Nicholas Nethercote
01e3345f23 At startup, now tests if program is statically linked. Bails with a useful
message if so.  If anyone thinks this will break anything, please yell.

Updated FAQ #5 correspondingly, added info on how to combine static and dynamic
libraries.

MERGE TO STABLE(?)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1831
2003-09-25 18:20:17 +00:00
Nicholas Nethercote
ce82c07580 Cleaned up reading of debug info a bit.
Renamed:
  VG_(read_procselfmaps_contents)() --> VG_(read_procselfmaps)()
  VG_(read_procselfmaps)()          --> VG_(parse_procselfmaps)()
  VG_(read_symbols)()               --> VG_(read_all_symbols)()
  VG_(read_symtab_callback)()       --> VG_(read_seg_symbols)()

Removed the Bool 'read_from_file' arg from (what is now)
VG_(parse_procselfmaps)().  If /proc/self/maps needs to be read beforehand, the
code calls (what is now) VG_(read_procselfmaps)() before.  Still using the
static buffer which is not nice but good enough.

More importantly, I split up VG_(new_exe_segment)() into
VG_(new_exeseg_startup)() and VG_(new_exeseg_mmap)().  This is because at
startup, we were stupidly calling VG_(read_symbols)() for every exe seg, which
parses /proc/self/maps completely in order to load the debug info/symbols for
the exe seg (and any others we haven't already got the symbols for).  Despite
the fact that the startup code reads /proc/self/maps to know which segments are
there at startup.  In other words, we were reading /proc/self/maps several
times more often than necessary, and there were nested reads, which Stephan
Kulow's recent depth patch fixed (but in a pretty hacky way;  this commit fixes
it properly).  So VG_(new_exeseg_startup)() now doesn't cause /proc/self/maps
to be re-read.  Unfortunately we do have to re-read /proc/self/maps for mmap(),
because we don't know the filename from the mmap() call (only the file
descriptor, which isn't enough).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1830
2003-09-25 17:54:11 +00:00
Nicholas Nethercote
3534c8fc08 Using start_eip instead of eip for disassembly failure messages.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1827
2003-09-18 08:37:20 +00:00
Dirk Mueller
612b8daeac fix compiler warnings
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1823
2003-09-18 01:39:50 +00:00
Julian Seward
f08f0f0ca3 Suppress a couple more messages when -q applies.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1821
2003-09-17 21:48:26 +00:00
Julian Seward
76b167b551 Add patch from Stephan Kulow to solve the following:
read_procselfmaps calls *record_mapping which
   is startup_segment_callback for init_memory. But this
   again calls through read_symbols read_procselfmaps
   again with read_from_file == True. But this overwrites
   the internal buffer and causes parsing errors.
   (What makes the error a bit funny is that valgrind
    wouldn't have catched that error afaik :)
   Anyway: our solution is to forbid read_from_file from
   with callbacks

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1820
2003-09-17 07:39:28 +00:00
Nicholas Nethercote
c0f0059bf7 Added some skin-visible functions that give skins a bit more control over
how stack snapshots are taken and printed;  they can be used in preference
to VG_(get_ExeContext)() and VG_(pp_ExeContext)().  These are used by
Massif, my heap profiling skin.

Changed --num-callers to allow a backtrace size of 1.

Added code so that when Valgrind fails to disassemble an instruction, the
instructions line/file and address are printed out, which makes it easier to
work out where and what it is.  Required the stack snapshot changes above.

MERGE TO STABLE?


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1819
2003-09-16 07:41:43 +00:00
Nicholas Nethercote
0c7c912c5b Fix problem with adjtimex.
MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1817
2003-09-09 11:27:59 +00:00
Nicholas Nethercote
1cfe4c9b5b With -v option, client program's argv[] now printed at startup. Should be
useful when trying to interpret users' problems.  Each argv is printed on a
separate line, to make it extra clear where each one starts and ends.

MERGE TO STABLE (PLEASE!)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1816
2003-09-09 07:26:21 +00:00
Dirk Mueller
be5cd9c8c1 patch for adjtimex syscall by Bob Van Manen <BVanManen@Scene7.com>
appares to compile for me


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1813
2003-09-05 17:46:54 +00:00
Nicholas Nethercote
138ada5bc2 Fixed readv() and writev() so they won't fall over if they are given a negative
count.  Added a regression test for it.

Updated the basic test stderr filter to strip out line numbers from
vg_intercept.c

MERGE TO STABLE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1812
2003-09-04 21:57:45 +00:00
Nicholas Nethercote
7b2a49544e Fixed brk(); it was almost completely broken.
Added a regression test for it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1810
2003-09-04 20:57:51 +00:00
Dirk Mueller
4d7ce5006f implement waitpid syscall. Patch by Benjamin Lee <benjaminlee@users.sf.net>
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1806
2003-08-26 17:36:26 +00:00
Nicholas Nethercote
29c92969ff Fix up the way SK_(update_extra)() is called.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1803
2003-08-19 16:14:42 +00:00
Nicholas Nethercote
d4192ee3b2 comments change only
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1799
2003-08-14 15:23:55 +00:00
Julian Seward
439cee2a05 Increase VG_N_FORKHANDLERSTACK from 2 to 4. For reasons known only to
itself, pth_atfork1 and 2 fail on R H 7.3 for a size-2 stack, but only
with certain skins.  Don't ask me.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1789
2003-07-26 17:49:58 +00:00
Julian Seward
c924c63b20 VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH): remove leading spaces and
colon created by this mechanism.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1787
2003-07-25 19:58:11 +00:00
Julian Seward
ffbedad97e Fix the strdup-of-OverlapErr-string problem better. Move the
strdup to MAC_(record_overlap_error), wherein we know that
s is a string.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1786
2003-07-24 23:50:17 +00:00
Julian Seward
2e724ba3df construct_error(): strdup the supplied s (string) param which gives
extra info about some kinds of errors.  It was being allocated on the
stack by complain2/3 in mac_malloc_wrappers.c.

If the constructed error is found to be a duplicate, free the strdup'd
space.  That limits the worst-case space leak to one strdup'd string
for each different error we keep track of, and the latter by default
is limited to 300.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1785
2003-07-24 21:29:40 +00:00
Nicholas Nethercote
1cc2127659 Moved vg_kerneliface.h from coregrind/ to include/, where it was needed for
external skin compilation to work.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1784
2003-07-24 19:35:00 +00:00
Nicholas Nethercote
0f871c249c A big commit size-wise, but small concept-wise: removed the ThreadState type
from skin's view, replacing all instances with ThreadId.  Much cleaner.  Had to
change the way VG_(get_ExeContext)() worked a little.  Changed the core/skin
major interface because this breaks the old version.  Also fixed a few minor
related things here and there.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1782
2003-07-24 08:45:32 +00:00
Julian Seward
53220a1cbb Use init_ExeContext_storage instead of relying (unintentionally) on
properties of 'static'.  Also, de-globalise this function.  Some days
I really yearn for a proper module system in C.  Come back Haskell,
all is forgiven :-)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1781
2003-07-23 23:01:11 +00:00
Nicholas Nethercote
ca5ea7998a Just clarified VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH)'s workings a bit.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1780
2003-07-23 09:40:50 +00:00
Nicholas Nethercote
fa19839b93 Fix a problem in VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH)(): when removing the
added paths, it was taking out the colon between the removed entry and the
following, which meant the following was interpreted as having a big chunk of
whitespace at the start, which broke some things.

eg. was:

  "foo:bar"  --> "    bar"

now:

  "foo:bar"  --> "   :bar"

in which case "   " is considered a separate path in it's own right, albeit one
that doesn't mean anything.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1779
2003-07-23 09:22:02 +00:00
Nicholas Nethercote
aca466757f Changed behaviour of VALGRIND_COUNT_LEAKS slightly. Previously, the numbers it
returned (bytes leaked, dubious, etc) were incremented for every leak check
performed.  So if you called VALGRIND_DO_LEAK_CHECK twice in a row, the totals
would be updated twice by the same amount.  This was a bit silly.  So now
COUNT_LEAKS just returns the numbers of bytes leaked found from the previous
leak check.  I even updated the docs, and changed the regression test so old
version fail but the new version passes (by doing two DO_LEAK_CHECKS in a row).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1778
2003-07-22 22:03:58 +00:00
Nicholas Nethercote
53fcf82ef1 wibble
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1775
2003-07-22 10:50:41 +00:00
Nicholas Nethercote
1060d6b3e2 Fix stupid compile error; I iz stupid.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1772
2003-07-21 11:42:27 +00:00
Nicholas Nethercote
fa2c6d8424 Fix: I thought VG_(malloc)() always zeroed memory. It does at first (because
it's mmapped in from /dev/zero), but when recycled may not.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1771
2003-07-21 10:52:07 +00:00
Nicholas Nethercote
6b57397875 This commit fixed some bugs in error and suppression handling. Basically, I
had forgotten that some errors (PThread errors) are found by the core, rather
than skins and so the skin shouldn't be involved in handling them.  This commit
fixes the problem.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1770
2003-07-21 10:38:23 +00:00
Julian Seward
b3ff4b514a Do the symbol substitution game for glibc-2.2.93 too (Red Hat 8).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1762
2003-07-16 19:59:59 +00:00
Julian Seward
2b50eb4a3b VG_(setup_code_redirect_table): do errno etc entry-point redirection
for glibc-2.3.1 too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1758
2003-07-14 20:50:36 +00:00
Julian Seward
15425ad0fd Intercept waitpid() so as to make it non-blocking. Yet another
ghastly hack.  Roll on proper clonethread-based handling of blocking
syscalls.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1756
2003-07-13 19:22:54 +00:00
Julian Seward
f7f560b8e1 Add patch from Sami Liedes <sliedes@cc.hut.fi> making GDB use more flexible:
--gdb-path=/path/to/gdb   allows running some alternate GDB
--input-fd=<n>            allows reading input from some fd other than stdin
I even updated the docs :-)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1754
2003-07-13 10:54:33 +00:00
Julian Seward
79eff13d46 Refine the PLT-bypassing-bypassing machinery so it works on Red Hat 9.
This means we are now are zero regression test failures on RH9 too.  Yay.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1752
2003-07-13 00:53:22 +00:00
Julian Seward
dd2abcb8e0 In vg_memory.c, startup_segment_callback, fix initialisation ordering
problem which caused the leak checker to misbehave following recent
PLT-bypass workaround.

In short, it is an error to announce to the skin, segments found which
belong to the low-level memory manager, because the skin may then mark
them as accessible to the client.  This is wrong, and the client
should only acquire accessible memory via malloc etc and stack
movement.  Now we carefully avoid mentioning any segment belonging to
the low level memory manager.

Take the opportunity to improve VG_(within_m_state_static) so that it
also detects pointers within the thread table.  This can reduce the
number of blocks the leak checker spuriously thinks are still
reachable.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1751
2003-07-12 12:11:39 +00:00
Julian Seward
407cd63e50 Whitespace-only change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1749
2003-07-12 01:26:52 +00:00
Julian Seward
9ee2fd8e43 A new implementation of pthread_once() which I believe should comply
properly with POSIX, and not get assertion failures when the same
thread makes nested calls to pthread_once with different once_control
pointers.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1746
2003-07-11 00:12:58 +00:00
Julian Seward
e4397da1ca A bit of cleaning up now that symbol table reading is no longer optional.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1745
2003-07-10 23:31:27 +00:00
Julian Seward
1f01517ca3 Add a new mechanism for intercepting calls, which doesn't depend on
the vagaries of the dynamic linker.  In particular this has been
devised so as to work around errno/h_errno/resolver-state misbehaviour
caused by excessive PLT bypassing in glibc-2.3.2: we need to intercept
calls to __errno_location(), __h_errno_location() and __res_state(),
in threaded programs, but we can't always do that because some calls
made internally within glibc-2.3.2 bypass the PLT.

New mechanism is:

- In vg_symtab2.c, VG_(setup_code_redirect_table), search the
  symbol tables to find the entry points of the above functions,
  and find the corresponding entry points replacements in our
  vg_libpthread.c.  Put these pairs into a table,
  VG_(code_redirect_table).

- In vg_translate.c, VG_(translate), consult the table each time
  a translation is made, and if a hit is found, translate from
  the substitute address instead.

This seems to make corecheck/tests/res_search work properly,
although for some as-yet unknown reason breaks the corecheck
skin.  All other skins appear unaffected.

One unfortunate effect is that the lazy debug info scheme is now
nullified, since we always need to read debug info in order to
generate the redirection table.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1743
2003-07-10 00:17:58 +00:00
Julian Seward
c39a6ef339 load_one_suppressions_file(): Make sure to finish reading
up-to-and-including the '}' when the number of callers is >=
VG_N_SUPP_CALLERS.  (Jeffrey Stedfast)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1728
2003-07-06 01:40:11 +00:00
Julian Seward
090be413d9 Fix up weak binding for pthread_mutexattr_setpshared.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1726
2003-07-06 01:29:49 +00:00
Julian Seward
cceee45f87 Implement pthread_mutexattr_setpshared (Nick did this).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1724
2003-07-06 01:23:11 +00:00
Julian Seward
0cd35f9d8e Handle XCHG eAX,eBP.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1723
2003-07-06 01:17:33 +00:00
Julian Seward
8fa2136dcf string_match_wrk(): increase max recursion depth to 500.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1722
2003-07-06 01:14:42 +00:00
Julian Seward
abd3770037 VGR_(select): be robust against negative timeout values (treat as zero).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1721
2003-07-06 01:11:47 +00:00
Julian Seward
7db17cbe3c The Pentium 4 recycles the CS segment override prefix (0x2E) to mean
'predict not taken' when it appears before a conditional branch.
Valgrind 1.9.6 doesn't know how to handle this.  The appended patch
makes it ignore the prefix in this case, which should be safe.

A DS segment override means 'predict taken', but valgrind already
ignores that on a conditional branch, so nothing needs to be done.

(Zack Weinberg)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1720
2003-07-06 01:05:10 +00:00
Dirk Mueller
faf02201e5 spelling fixes
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1715
2003-07-04 16:18:15 +00:00
Nicholas Nethercote
752b7a599c Added (trivially) "XCHG eAX,eSP" instruction.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1711
2003-06-29 17:28:23 +00:00