817 Commits

Author SHA1 Message Date
Bart Van Assche
3fd464fbf3 Remove build dependency on Xen header files - closes #308495
From: Ian Campbell <ian.campbell@citrix.com>


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13081
2012-10-23 18:03:28 +00:00
Florian Krohm
79b79d6388 First round of Char/HChar fixups for coregrind and memcheck.
Little bit of ripple in tools, too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13074
2012-10-21 19:43:43 +00:00
Florian Krohm
5371dd0942 Fix some prototypes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13054
2012-10-18 03:17:32 +00:00
Philippe Waroquiers
aff39b640c Fix 308341 vgdb should report process exit (or fatal signal)
patch from Mark Wielaard.
(with small modifications).
Also clarified some comments related to the resume reply.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13052
2012-10-17 21:32:03 +00:00
Florian Krohm
a5928d2ac8 Fix some more Char / HChar mixups
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13042
2012-10-14 16:45:23 +00:00
Florian Krohm
786e11050a Char/ HChar cleanup: The various panic and printf-like functions
all take const HChar * arguments.
__FILE__ and __func__ expand into string literals (or character 
arrays initialised by them), as do strings created by the preprocessor 
e.g. #stuff.
This change reduces the number of warnings from 17000+ to ~5500


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13039
2012-10-14 00:16:28 +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
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
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
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
512e51bb54 Use "orr r9,r9,r9" as the magic insn for IR injection on ARM and
Thumb, since r13 is disallowed for many instructions in the Thumb
encoding.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12956
2012-09-03 21:51:02 +00:00
Florian Krohm
f91af1cab6 Add VALGRIND_VEX_INJECT_IR for ppc32. Should have been included
in r12906.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12912
2012-08-29 14:59:13 +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
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
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
Julian Seward
156ef8b610 Try to fix up ARM stack alignment stuff following r12811. This
fixes two problems: first, r11 (aka fp) can't be used in assembly
for whatever reason.  Secondly, the "bic sp,sp,#7" is not allowed
in Thumb mode, so work around that too.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12832
2012-08-04 19:23:54 +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
Florian Krohm
1ce67e87ef Comment only change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12818
2012-08-03 03:21:42 +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
Tom Hughes
bd2c11aa99 Ensure CALL_FN_xx macros align the stack properly
The CALL_FN_xx macros  in valgrind.h perform function calls by
signalling to valgrind using the client request system. Because
they are making function calls which are invisible to the compiler
they need to make sure that any stack alignment constraints
imposed by the ABI are enforced when making the call.

This commit enforces 16 byte alignment for x86, amd64, ppc32 and
ppc64 platforms, and 8 byte alignment for arm platforms.

It does not touch s390x where the ABI requires 8 byte alignment to
be maintained at all times, not just when making a function call.

It also does not touch mips32 as I'm not currently aware what if
any alignment constraints exist there.

Fixes BZ#304054 and observed alignment faults on amd64 when running
the regtests using a valgrind compiled with gcc 4.7 releases.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12811
2012-08-02 09:23:45 +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
Florian Krohm
e9a06dcf87 Pass first_ip_delta to VG_(record_depth_1_ExeContext) as the function
cannot figure it out by itself.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12775
2012-07-23 15:40:41 +00:00
Petar Jovanovic
e24ea886e5 Add some missing syscall numbers for MIPS.
The header file has been extended with the missing syscall numbers for MIPS,
and sys_prlimit64 has been enabled. This will make none/tests/rlimit64_nofile
pass.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12752
2012-07-16 14:35:26 +00:00
Julian Seward
620ac73938 Add ioctl wrappers for "Linux user input device". Fixes #296229.
(Chase Douglas, chase.douglas@canonical.com)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12737
2012-07-13 13:15:10 +00:00
Tom Hughes
dd70fc4248 Add support for the SIOCSHWTSTAMP ioctl, based on a patch
from Arseny Solokha. Fixes BZ#296792.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12730
2012-07-11 14:33:10 +00:00
Tom Hughes
b53fdb8ea7 Add support for the CDROM_GET_CAPABILITY ioctl based on patch
from Nick Black. Fixes BZ#302827.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12726
2012-07-11 12:02:06 +00:00
Petar Jovanovic
45efe90efe Getting rid of the warnings about incompatible pointer types on MIPS.
vki_signalfn_t has been incorrectly defined in vki-mips32-linux.h, and that
caused warnings elsewhere.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12687
2012-06-30 02:43:29 +00:00
Petar Jovanovic
c370a82bbb Calculate the size of vki_elf_gregset_t via operator sizeof on MIPS platforms.
The value VKI_ELF_NGREG is now defined with the the help of operator sizeof.
Incorrect size triggered an assertion in the file coredump-elf.c.
The issue was reported as coredump problem at:
https://bugs.kde.org/show_bug.cgi?id=270777


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12677
2012-06-27 14:14:26 +00:00
Julian Seward
d971e9300f Merge in a port for mips32-linux, by Petar Jovanovic and Dejan Jevtic,
mips-valgrind@rt-rk.com, Bug 270777.

Valgrind: new non-test files for mips32-linux.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12617
2012-06-07 09:23:23 +00:00
Julian Seward
3e344c57f6 Merge in a port for mips32-linux, by Petar Jovanovic and Dejan Jevtic,
mips-valgrind@rt-rk.com, Bug 270777.

Valgrind: changes to existing files.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12616
2012-06-07 09:13:21 +00:00
Julian Seward
ede903f6be Add macros I_REPLACE_SONAME_FNNAME_Z{U,Z} for general end-user use.
The I_WRAP_SONAME_FNNAME_Z{U,Z} equivalents have been present for
years.  Seems inconsistent for the REPLACE versions to be missing.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12613
2012-06-05 07:12:15 +00:00
Julian Seward
76d7802c9f m_machine: add new function VG_(machine_get_size_of_largest_guest_register)
cachegrind: use the new function to abort startup if the minumum line
  size is smaller than the size of the largest guest register.
Partially derived from a patch by Josef Weidendorfer.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12605
2012-06-03 22:40:07 +00:00
Philippe Waroquiers
ec2e7c2bdf fix the warning introduced by fixing SETTLS clone flag PRE_READ logic
on amd64, vki_modify_ldt_t was defined as void (not very clear why).
sizeof (void) cannot be taken (or more precisely can be taken,
but nobody knows what that means and what gcc does).
So, uncommended the (supposedly) correct definition of the type.
Note that I checked the definition on debian 6.0, kernel 2.6.32
and the structure is still ok.

Still needed to look at the other platforms not properly
handling the *SETTID and the SETTLS flags in clone PRE_READ
logic and/or not defining the type vki_modify_ldt_t



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12589
2012-05-27 20:21:02 +00:00
Christian Borntraeger
188189536d add some intial kvm ioctls (low hanging fruits). This gets rid of some valgrind
warnings regarding KVM ioctl without a length/direction specifier.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12578
2012-05-23 15:59:40 +00:00
Julian Seward
5955f3bdec Fix VALGRIND_MINOR/VALGRIND_MAJOR symbols. This got forgotten about
in 3.7.0 (oops).



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12573
2012-05-21 21:57:05 +00:00
Philippe Waroquiers
0ea6d36f1d fix 219156 support static malloc or alternate malloc lib (e.g. tcmalloc) with new option --soname-synonyms
* pub_tool_redir.h : define the prefix to be used for "soname synonym"
  place holder
* vg_replace_malloc.c : define synonym place holder for malloc related
  functions
* m_redir.c : when detecting a soname synonym place holder redir spec, search
  in clo_soname_synonyms if there is a synonym pattern.
  If yes, replace the soname pattern. If not, ignore the redir spec.
* various files: implement or document the new clo --soname-synonyms
* new test memcheck/tests/static_malloc.vgtest



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12559
2012-05-11 19:33:46 +00:00
Julian Seward
8b6f93641c Add translation chaining support for amd64, x86 and ARM
(Valgrind side).  See #296422.



git-svn-id: svn://svn.valgrind.org/valgrind/branches/TCHAIN@12484
2012-04-02 21:56:03 +00:00
Julian Seward
742df20540 Turn no-op versions of INNER_REQUEST into statements, not values,
since gcc complains about "statement with no effect" or some such for
the simple "0" version.  Also, make the formal parameter names a bit
more unique.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12426
2012-03-07 17:11:44 +00:00
Tom Hughes
1e1da9ff38 Add support for the HCIINQUIRY ioctl.
Patch from Andrew Brampton to fix BZ#283961.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12421
2012-03-07 11:22:42 +00:00
Tom Hughes
137aace5a3 Add support for the I2C_RDWR ioctl.
Patch from arnaud mouiche to fix BZ#286261.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12420
2012-03-07 10:21:33 +00:00
Philippe Waroquiers
74d44d1764 * README_DEVELOPERS : complete/enhance the section about outer/inner
* manual-core.xml : fix a typo
* include/pub_tool_inner.h : new file, defining macros for inner annotation
  include/Makefile.am : reference this new file.
* syswrap-linux.c : when ENABLE_INNER, register the stacks for the outer.
   (otherwise, nothing works properly).
* m_redir.c : avoid inner interpreting the outer vgpreload instructions.
* sema.c : annotate the semaphore with RWLOCK annotations for helgrind
* ticket-lock-linux.c : similar.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12414
2012-03-03 12:01:48 +00:00
Tom Hughes
baec53c5f1 Add support for the sendmmsg and recvmmsg system calls. Fixes BZ#277779.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12376
2012-02-10 11:30:09 +00:00
Tom Hughes
dc42e147f5 Add support for some SCSI ioctls. Patch from Jakub Jelinek on BZ#292627.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12375
2012-02-10 10:41:07 +00:00
Tom Hughes
7104ded0a5 Add support for the F_GETOWN_EX and F_SETOWN_EX fcntl calls.
Patch from Jakub Jelinek to fix BZ#292626.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12373
2012-02-09 12:21:47 +00:00
Tom Hughes
f65fa07cc9 Update linux system call lists.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12370
2012-02-09 11:38:10 +00:00
Bart Van Assche
6153849464 <valgrind/valgrind.h>: Fix for Intel C/C++ compiler in MSVC compatibility mode.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12361
2012-01-31 10:13:51 +00:00
Philippe Waroquiers
ce806ed31f (fixes bug 289939 wish: complete monitor cmd 'leak_check' with details
about leaked or reachable blocks)

This patch implements two new memcheck gdbserver monitor commands:
  block_list <loss_record_nr>
        after a leak search, shows the list of blocks of <loss_record_nr>
  who_points_at <addr> [<len>]
        shows places pointing inside <len> (default 1) bytes at <addr>
        (with len 1, only shows "start pointers" pointing exactly to <addr>,
         with len > 1, will also show "interior pointers")


Compiled and reg-tested on f12/x86, deb5/amd64, f16/ppc64.

The 'block_list' command is implemented on top of the 
lr_array/lc_chunks/lc_extras arrays used during the last leak search.
NB: no impact on the memory for the typical Valgrind usage where a leak
search is only done at the end of the run.
Printing the block_list of a loss record simply consists in scanning the
lc_chunks to find back the chunks corresponding to the loss record for which
block lists is requested.

The 'who_points_at' command is implemented by doing a scan similar to 
(but simpler than) the leak search scan.
lc_scan_memory has been enhanced to have a mode to search for a specific
address, rather than to search for all allocated blocks.
VG_(apply_to_GP_regs) has been enhanced to also provide the ThreadId and
register name in the callback function.

The patch touches multiple files (but most changes are easy/trivial or factorise
existing code).

Most significant changes are in memcheck/mc_leakcheck.c :
    * changed the LC_Extra struct to remember the clique for indirect leaks
      (size of structure not changed).
    * made lr_array a static global
    * changed lc_scan_memory:
        to have a search mode for a specific address (for who_points_at)
        (for leak search) to pass a 'current clique' in addition to the clique
         leader
         so as to have a proper clique hierarchy for indirectly leaked blocks.
    * print_results: reset values at the beginning of the print_result of the
      next leak search, rather than at the end of print_results of the previous
       leak search.
      This allows to continue showing the same info for loss records till a new
      leak search is done.
    * new function print_clique which recursively prints a group of leaked
      blocks, starting from the clique leader.
    * new function MC_(print_block_list) : calls print_clique for each clique
      leader found for the given loss record.
    * static void scan_memory_root_set : code extracted from
      MC_(detect_memory_leaks) (no relevant change)
    * void MC_(who_points_at) : calls scan_memory_root_set, lc_scan_memory
        and VG_(apply_to_GP_regs)(search_address_in_GP_reg) to search 
        pointers to the given address.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12357
2012-01-26 23:13:52 +00:00
Bart Van Assche
deb44ff6f0 Pool allocator: change the semantics of VG_(releasePA)() according to comment http://bugs.kde.org/show_bug.cgi?id=282230#c50.
This change also makes the semantics of releasePA match the semantics of
other release functions, e.g. those in XPCOM (see also http://developer.mozilla.org/en/XPCOM_Interface_Reference/nsISupports#Release%28%29).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12343
2012-01-18 08:12:16 +00:00
Philippe Waroquiers
be97cddd7a Fixes 282230 group allocator for small fixed size, use it for MC_Chunk/SEc vbit
* new files include/pub_tool_groupalloc.h and coregrind/m_groupalloc.c
  implementing a group allocator (based on helgrind group alloc).
* include/Makefile.am coregrind/Makefile.am : added pub_tool_groupalloc.h
  and m_groupalloc.c
* helgrind/libhb_core.c : use pub_tool_groupalloc.h/m_groupalloc.c
  instead  of the local implementation.
* include/pub_tool_oset.h coregrind/m_oset.c : new function
  allowing to create an oset that will use a pool allocator.
  new function allowing to clone an oset (so as to share the pool alloc)
* memcheck/tests/unit_oset.c drd/tests/unit_bitmap.c : modified
  so that it compiles with the new m_oset.c
* memcheck/mc_main.c : use group alloc for MC_Chunk
  memcheck/mc_include.h : declare the MC_Chunk group alloc
* memcheck/mc_main.c : use group alloc for the nodes of the secVBitTable OSet
* include/pub_tool_hashtable.h coregrind/m_hashtable.c : pass the free node
  function in the VG_(HT_destruct).
  (needed as the hashtable user can allocate a node with its own alloc,
  the hash table destroy must be able to free the nodes with the user
  own free).
* coregrind/m_gdbserver/m_gdbserver.c : pass free function to VG_(HT_destruct)
* memcheck/mc_replace_strmem.c memcheck/mc_machine.c
  memcheck/mc_malloc_wrappers.c memcheck/mc_leakcheck.c
  memcheck/mc_errors.c memcheck/mc_translate.c : new include needed
  due to group alloc.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12341
2012-01-17 21:16:30 +00:00