Commit Graph

4084 Commits

Author SHA1 Message Date
Christian Borntraeger
9a8022279b fix parent and child tid pointer mixup:
The linux kernel has parent tid pointer first.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13034
2012-10-08 20:26:48 +00:00
Florian Krohm
7d59048401 This is the 2nd installment of the cache info reorganisation.
The host's VexArchInfo is passed to the tool instrumentation
functions. Purely mechanic patch.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13031
2012-10-07 21:59:42 +00:00
Florian Krohm
0d5a9a3523 Fix compile error on ppc. Followup to r13028
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13029
2012-10-07 20:27:38 +00:00
Florian Krohm
a9b2103cf2 This patch is the first installment of the cache info reorganisation.
It's reorg only. No new cache autodetection stuff has been added.

coregrind
pub_tool_cpuid.h is removed as it is no longer exposed to tools.
Its contents has moved to pub_core_cpuid.h.
New file: coregrind/m_cache.c to contain the autodetect code for
cache configurations and define other cache characteristics that
cannot be autodetected (i.e. icaches_maintain_coherence). Most of 
cg-arch/x86-amd64.c was moved here. The cache detection code for
x86-64 needs to be fixed to properly initialise VexCacheInfo. It
currently has cachegrind bias.
m_cache.c exports a single function (to coregrind): 
   VG_(machine_get_cache_info)(VexArchInfo *vai)
This function is called from VG_(machine_get_hwcaps) after hwcaps have
been detected.

cachegrind
Remove cachegrind/cg-{ppc32,ppc43,arm,mips32,s390x,x86-amd64}.c
With the exception of x86/mamd64 those were only establishing a
default cache configuration and that is so small a code snippet that
a separate file is no longer warranted. So, the code was moved to
cg-arch.c. Code was added to extract the relevant info from 
x86-amd64.
New function maybe_tweak_LLc which captures the code to massage the
LLc cache configuration into something the simulator can handle. This
was originally in cg-x86-amd64.c but should be used to all architectures.
Changed warning message about missing cache auto-detect feature
to be more useful. Adapted filter-stderr scripts accordingly.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13028
2012-10-07 19:47:04 +00:00
Tom Hughes
b387dedac0 Allow a null pointer as the second argument to capget.
Patch from Mark Wielaard to fix BZ#307101.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13021
2012-10-04 21:38:27 +00:00
Tom Hughes
f74befe896 Implement a fake /proc/self/auxv file for linux systems.
Patch from Mark Wielaard to fix BZ#253519.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13019
2012-10-04 20:27:38 +00:00
Philippe Waroquiers
fef0367e6e Unbreak build on ppc64 (error: ‘EmWarn_PPC64_redir_underflow’ undeclared)
coregrind/m_translate.c does not compile on ppc64 (ppc32 maybe also?)
due to missing include file.
Note: libvex_emnote.h is unconditionally included, even if only
useful for ppc. I suppose we do not want #ifdef for that.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13017
2012-10-02 20:35:21 +00:00
Florian Krohm
7d6ff1f425 Add include file.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13016
2012-09-30 20:30:40 +00:00
Tom Hughes
2ba34ab159 Implement some extra DW_OPs - more constants and some unary operators.
Patch from Mark Wielaard on BZ#307038.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13010
2012-09-21 09:12:30 +00:00
Tom Hughes
106fc73f9c Rename CfiOp to CfiBinop in preparation for adding unary operators.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13009
2012-09-21 09:04:27 +00:00
Tom Hughes
68757c25a3 When processing DW_OP_plus_uconst make sure we record an add, not
whatever binary operation we happened to see last.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13008
2012-09-21 08:57:46 +00:00
Petar Jovanovic
c27f3e1b76 Enable wrappers for sys_settimeofday and sys_stime on MIPS.
Enable wrappers for MIPS for the following two system calls:

- sys_settimeofday, and
- sys_stime.

Resolves https://bugs.kde.org/show_bug.cgi?id=306783
Patch contributed bederic M. <dark_footix@yahoo.fr>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12995
2012-09-18 17:19:36 +00:00
Florian Krohm
a81c8362b1 Be more flexible by allowing the compile command to be prefixed,
e.g. ccache gcc whatever... This fixes bugzilla #252955.
Patch from  Stephen McCamant <smcc@CS.Berkeley.EDU>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12977
2012-09-15 19:31:07 +00:00
Petar Jovanovic
fada2c7657 Setup correct minimum malloc'd block size for MIPS.
Correct minimum malloc's block size for MIPS is 8.
This fixes massif/tests/big-alloc.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12974
2012-09-15 01:04:06 +00:00
Petar Jovanovic
ca7f132547 Enable pre-wrapper for sys_shutdown for MIPS.
Small change to enable wrapper for sys_shutdown for MIPS.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12970
2012-09-14 13:12:37 +00:00
Bart Van Assche
7672eb4cb5 valgrind: Support Xen toolstack process ioctls
From: Ian Campbell <Ian.Campbell@citrix.com>

Under Xen the toolstack is responsible for managing the domains in
the system, e.g. creating, destroying, and otherwise manipulating
them.

To do this it uses a number of ioctls on the /proc/xen/privcmd
device. Most of these (the MMAPBATCH ones) simply set things up such
that a subsequenct mmap call will map the desired guest memory. Since
valgrind has no way of knowing what the memory contains we assume
that it is all initialised (to do otherwise would require valgrind to
be observing the complete state of the system and not just the given
process).

The most interesting ioctl is XEN_IOCTL_PRIVCMD_HYPERCALL which
allows the toolstack to make arbitrary hypercalls. Although the
mechanism here is specific to the OS of the guest running the
toolstack the hypercalls themselves are defined solely by the
hypervisor. Therefore I have split support for this ioctl into a part
in syswrap-linux.c which handles the ioctl itself and passes things
onto a new syswrap-xen.c which handles the specifics of the
hypercalls themselves. Porting this to another OS should just be a
matter of wiring up syswrap-$OS.c to decode the ioctl and call into
syswrap-xen.c. In the future we may want to split this into
syswrap-$ARCH-xen.c but for now this is x86 only.

The hypercall coverage here is pretty small but is enough to get
reasonable(-ish) results out of the xl toolstack when listing,
creating and destroying domains.

One issue is that the hypercalls which are exlusively used by the
toolstacks (as opposed to those used by guest operating systems) are
not considered a stable ABI, since the hypervisor and the lowlevel
tools are considered a matched pair. This covers the sysctl and
domctl hypercalls which are a fairly large chunk of the support
here. I'm not sure how to solve this without invoking a massive
amount of duplication. Right now this targets the Xen unstable
interface (which will shortly be released as Xen 4.2), perhaps I can
get away with deferring this problem until the first change .

On the plus side the vast majority of hypercalls are not of interest
to the toolstack (they are used by guests) so we can get away without
implementing them.

Note: a hypercall only reads as many words from the ioctl arg
struct as there are actual arguments to that hypercall and the
toolstack only initialises the arguments which are used. However
there is no space in the DEFN_PRE_TEMPLATE prototype to allow this to
be communicated from syswrap-xen.c back to syswrap-linux.c. Since a
hypercall can have at most 5 arguments I have hackily stolen ARG8 for
this purpose.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12963
2012-09-09 18:30:17 +00:00
Petar Jovanovic
a81ca9f338 Restore unwind regs structure if VG_(use_CF_info) fails on MIPS.
If VG_(use_CF_info) fails to find the next frame using loaded debug symbols, it
will still change the data in uregs. Thus, we need to have uregs_copy before
calling VG_(use_CF_info), and restore uregs if the call returns wrong data.
This fixes drd/tests/tc04_free_lock on MIPS.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12962
2012-09-09 01:56:56 +00:00
Bart Van Assche
2f907e6480 drd: Suppress race reports on .got sections too
This is a slightly modified version of a patch provided by Petar Jovanovic
<petar.jovanovic@rt-rk.com>.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12960
2012-09-06 14:08:26 +00:00
Julian Seward
7b418bfd3e "Fix" stack bounds check when compiled by Clang 4.0. Fix from Andrew
Morrow, analysis by Florian Krohm.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12947
2012-09-02 21:17:36 +00:00
Florian Krohm
7ccbc2abb5 Fix an uninitialised variable found be BEAM.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12927
2012-09-01 23:48:09 +00:00
Julian Seward
4858401fb6 Guard against negative symbol sizes in ELF symbol tables, which
lead to assertion failures in ML_(find_rx_mapping).  Most closely
related to #304980.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12923
2012-09-01 20:08:35 +00:00
Florian Krohm
6805920360 s390: Detect floating point extension facility. Update s390-features.c
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12920
2012-08-30 20:30:32 +00:00
Florian Krohm
0d0e6346db Add a tester for V-bit propagation through IROps.
The tester is located in memcheck/tests/vbit-test.
It needs the following support on the valgrind / VEX side:
(1) a new client request VG_USERREQ__VEX_INIT_FOR_IRI
(2) a new "special instruction" on all architectures inserted via
    VALGRIND_VEX_INJECT_IR
(3) VEX changes to detect the special insn and insert IR (ir_inject.c)

The README file in vbit-test has some more information.
See also VEX r2490.  Fixes bugzilla #300102.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12906
2012-08-28 16:50:39 +00:00
Florian Krohm
e32ad1d0ae s390: Add zEC12 machine model. Fix spelling for some older models.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12905
2012-08-28 13:33:10 +00:00
Florian Krohm
7bea862277 On s390: detect presence of stckf hardware facility.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12902
2012-08-26 04:23:08 +00:00
Florian Krohm
cd528bd768 Followup patch to r12899, purely mechanical. Rename:
VexEmWarn -> VexEmNote
EmWarn_NUMBER -> EmNote_NUMBER
guest_EMWARN -> guest_EMNOTE
LibVEX_EmWarn_string -> LibVEX_EmNote_string
offB_EMWARN -> offB_EMNOTE
EmWarn_NONE -> EmNote_NONE
See also VEX r2484


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12900
2012-08-26 03:22:09 +00:00
Julian Seward
91c005fe90 Fix skipping of block forms when this code is compiled by gcc 4.8 -- it
has always been incorrect, modifying 'p' twice between sequence points.
Fixes #305513.  (Mark Wielaard, mjw@redhat.com)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12892
2012-08-24 14:38:56 +00:00
Julian Seward
a75f51bbcb Fix up range checking in ML_(addLineInfo). Avoids assertion failure
reported in #304980.  Based on a patch by Jiri Hruska (jirka@fud.cz).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12891
2012-08-24 14:05:01 +00:00
Julian Seward
ed29b0b6a8 Fix POST(posix_spawn) on Darwin so it marks the returned pid as defined.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12883
2012-08-20 10:40:02 +00:00
Philippe Waroquiers
3abbddda09 fix 301281 valgrind hangs on OS X when the process calls system()
After looking more in depth, gdbserver must not be terminated
in PRE(posix_spawn) on MacOS: this is running in the parent and
(on MacOS) is a single syscall similar to a fork+exec.
On linux, posix_spawn is implemented using 2 syscalls
(fork followed by exec).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12882
2012-08-20 09:27:15 +00:00
Philippe Waroquiers
32fe40711e fix n-i-bz vgdb ptrace calls wrong on mips, causing blocked syscalls to fail
(patch from Petar Jovanovic).

The mips specific code of vgdb.c was storing the arguments
at wrong places in the ptrace setreg. This caused the blocked syscall(s)
to return with an error rather than to be properly restarted.
With this commit, the gdbsrv tests are not blocking anymore
with Valgrind mips32 running on mips64 GNU/Linux.
vgdb is believed to be functional, even if process is blocked in a syscall.

The following tests are still failing
gdbserver_tests/mcbreak                  (stdout)
gdbserver_tests/mcbreak                  (stdoutB)
gdbserver_tests/mcbreak                  (stderrB)
gdbserver_tests/mcsignopass              (stderr)
gdbserver_tests/mcsignopass              (stdoutB)
gdbserver_tests/mcsigpass                (stderr)
gdbserver_tests/mcsigpass                (stdoutB)
gdbserver_tests/nlcontrolc               (stdoutB)
gdbserver_tests/nlsigvgdb                (stderr)
gdbserver_tests/nlsigvgdb                (stderrB)

Of the above, nlsigvgdb failure is still strange.
Others looks like "normal" differences due e.g. to mips specific gdb
behaviour and/or none/tests/faultstatus (re-used in gdbsrv tests)
behaving differently on mips.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12881
2012-08-18 11:06:04 +00:00
Philippe Waroquiers
6bae0a6e36 Fix 301281 valgrind hangs on OS X when the process calls system()
This should fix the bug (but could not test it : no MacOSX).
See equivalent code in syswrap-generic.c and comment
in pub_tool_gdbserver.h:
// tid == 0 indicates to stop gdbserver and report to gdb
// that the valgrind-ified process has exited.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12879
2012-08-18 09:50:27 +00:00
Julian Seward
e81fb2f3e4 On Darwin, use __NR_poll_nocancel rather than __NR_poll, as per the
comment at the top of the file.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12878
2012-08-18 06:45:07 +00:00
Philippe Waroquiers
0b5f81bfd3 Fix n-i-bz shmat of a segment > 4Gb does not work
Problem was created by get_shm_size returning an UInt rather
than a SizeT.

see http://sourceforge.net/mailarchive/message.php?msg_id=29682827



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12874
2012-08-16 19:40:52 +00:00
Philippe Waroquiers
15493bb541 Implement --vex-iropt-register-updates=sp-at-mem-access
Option sp-at-mem-access can be used by tools which do not
need an up to date BP and IP at each mem access.
It is needed however to have SP up to date at each memory
access, as an up to date SP is needed to grow the stack in
m_signals.c

Tools massif, cachegrind and callgrind are using sp-at-mem-access
as default.
None tool could also use sp-at-mem-access but default is kept
to unwindregs-at-mem-access (similar to memcheck, drd, helgrind, exp-sgcheck).

exp-dhat, exp-bbv, lackey have not been looked at to see if they
could make use of sp-at-mem-access.

Validated on x86, amd64, ppc64 and s390x.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12872
2012-08-14 22:28:31 +00:00
Tom Hughes
1592db60c5 Add support for the tee and vmsplice system calls. BZ#304561.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12861
2012-08-08 08:03:44 +00:00
Julian Seward
fae30e8323 Add a couple of useful examples to the --help text for
--soname-synonyms.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12855
2012-08-07 14:46:34 +00:00
Florian Krohm
5fd9d2ae08 Change script to also handle IBM's copyright notice.
Update copyright notices.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12853
2012-08-06 18:34:24 +00:00
Julian Seward
4a3633e266 Update copyright dates to include 2012.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12843
2012-08-05 15:46:46 +00:00
Petar Jovanovic
a4785b9adf Fixing incorrect case in putSyscallArgsIntoGuestState for __NR_syscall.
Previously unused arg8 is now used to hold NR_syscall value when that call is
executed. This is important, so putSyscallArgsIntoGuestState can correctly
fill up the guest state. This is MIPS-only change.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12836
2012-08-05 02:22:52 +00:00
Philippe Waroquiers
ab7b338320 301265 - add x86 support to Android build
Patch by Dragos Tatulea.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12835
2012-08-05 00:08:25 +00:00
Philippe Waroquiers
08c619389b fix 284540 (optimise suppression matching)
Before this patch, matching an error stack trace with many suppression
patterns was implying to repeating the translation of the IPs of the
stack trace to the function name or object name for each suppr pattern.

This patch introduces a "lazy input completer" in the generic match
so that an IP is (in the worst case) translated once to its function
name and once to its object name.

It is a "lazy" completer in the sense that only the needed IP to fun or obj
name are done.

On a artificial test case, has given a factor 3 in performance.
On another big (real) application, gave a factor 2 to 3.
(there was less matching to do, but probably more debug info to search).

match-overrun.supp completed to have non matching suppr first to
better exercise the lazy completer.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12824
2012-08-03 23:11:39 +00:00
Julian Seward
e9cda68ea7 Add support for sys_shm_unlink on Darwin. Fixes #288298.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12819
2012-08-03 07:47:01 +00:00
Julian Seward
e15baee3f8 Back off from 32 alignment of various guest state bits. We don't
actually need it, and gcc on MacOS simply fails (for whatever reason)
to actually honour requests for 32 alignment, and fall back to the
previous setting (16 alignment).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12817
2012-08-02 22:08:53 +00:00
Julian Seward
dc0ca811ec Un-break the build on OSX < 10.8 following r12814
(which was initial OSX 10.8 support)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12815
2012-08-02 18:51:51 +00:00
Julian Seward
f0c0f9f3ce Add initial support for MacOSX 10.8. Note this is still very borked
and pretty much unusable for real work.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12814
2012-08-02 18:25:04 +00:00
Julian Seward
0b3c2d6642 Back out r12466, which stopped non-MAP_FIXED mmaps by the client on
Darwin from returning address zero (however insane that is).  r12466
appears to cause other applications to break (TextEdit, for one).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12813
2012-08-02 10:40:31 +00:00
Philippe Waroquiers
a3a7ba3ebf Avoid asserting when a segment is mapped both rw and rx.
If a segment is mapped with permission rwx, then map->rx
and map->rw will be true.
But due to the if (map->rx) {
                 ...
               } else if (map->rw) {
                 ...
the  (map->rw) part will not be executed.
If this mapping is the one which "gives" the nonempty rw map,
then this mapping will not be seen, and the following
vg_assert(has_nonempty_rw);
will fail.

This assert can be reproduced by doing
setarch i686 -X
./vg-in-place --tool=none none/tests/map_unmap

Note: the setarch i686 -X above has as effect to make all read
mapping also executable. So, a rw mapping becomes rwx and then
triggers the above asserts.

The setarch i686 -X also introduces a discrepancy between
the kernel mappings (rwx) and the valgrind aspacemgr view
(which believes it is a rw mapping).
This discrepancy causes a crash if giving --sanity-level=3.
A possible fix is to have valgrind calling the personality system call
and detecting if the READ_IMPLIES_EXEC bit (the -X arg to setarch)
was set, and then modify aspacemgr so that all read mapped segments
are automatically mapped x also.

This commit is the minimal fix allowing to run executables
launched with this READ_IMPLIES_EXEC.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12810
2012-08-01 22:27:29 +00:00
Philippe Waroquiers
36ca11463d Remove --vex-iropt-precise-memory-exns, implement --vex-iropt-register-updates
* Option --vex-iropt-precise-memory-exns has been removed.
  It is replaced by --vex-iropt-register-updates which accepts
  3 values : 'unwindregs-at-mem-access' (replacing
  --vex-iropt-precise-memory-exns=no), 'allregs-at-mem-access'
  (replacing --vex-iropt-precise-memory-exns=yes)
  and a new value 'allregs-at-each-insn'.
  'allregs-at-each-insn' allows the Valgrind gdbserver to always
  show up to date values to GDB.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12809
2012-08-01 22:03:12 +00:00
Philippe Waroquiers
d045b4236a Implement --redzone-size and --core-redzone-size
* For tools replacing the malloc library (e.g. Memcheck, Helgrind, ...),
  the option --redzone-size=<number> allows to control the padding 
  blocks (redzones) added before and after each client allocated block.
  Smaller redzones decrease the memory needed by Valgrind. Bigger
  redzones increase the chance to detect blocks overrun or underrun.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12807
2012-07-31 22:17:28 +00:00