1033 Commits

Author SHA1 Message Date
Julian Seward
37f7ddaea7 PRE(sys_prctl): handle PR_SET_SECCOMP.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14994
2015-03-10 11:05:10 +00:00
Florian Krohm
ec19425185 Include pub_core_aspacemgr.h only where needed.
Also fixes BZ #344235.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14966
2015-02-26 17:48:07 +00:00
Mark Wielaard
5fa9a30cea Bug #344318 socketcall should wrap recvmmsg and sendmmsg
Some architectures, e.g. s390, don't have dedicated recvmmsg and sendmmsg
system calls, but use the socketcall multiplexing system call with
SYS_RECVMMSG or SYS_SENDMMSG (just like the accept4 systemcall can also
be called through socketcall). Create separate helpers for recvmmsg and
sendmmsg helpers that can be used by either the direct syscall or the
socket call.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14964
2015-02-25 14:00:14 +00:00
Rhys Kidd
f3c4b1a67a Fix OS X 10.10 (Yosemite) - missing system calls and fcntl code, courtesy of Bill Zissimopoulos
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14951
2015-02-21 12:24:18 +00:00
Florian Krohm
00ffec50e5 Pass in a mask of segment kinds to VG_(get_segment_starts)
and VG_(am_get_segment_starts) to indicate which segments
should be collected. That should solve the following problem:
in m_main.c we used to:

      seg_starts = VG_(get_segment_starts)( &n_seg_starts );

      for (i = 0; i < n_seg_starts; i++) {
         Word j, n;
         NSegment const* seg 
            = VG_(am_find_nsegment)( seg_starts[i] );
         vg_assert(seg);
         if (seg->kind == SkFileC || seg->kind == SkAnonC) {

         ...
         // ... dynamic memory allocation for valgrind
         ...
      }

This caused the vassert(seg) to fire because the dynamic memory
allocation further down the loop changed segments such that a 
valgrind segment which used to be non-SkFree suddenly became 
SkFree and hence VG_(am_find_nsegment) returned NULL. Whoom.

With this revision we only collect the segments we're really
interested in. For the example above that is all client segments.
So if V allocates memory -- fine. That will not change the layout
of client segments.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14949
2015-02-20 14:00:23 +00:00
Julian Seward
199646a9cd Correctly handle prctl(VKI_PR_SET_PTRACER, ..) so as to avoid false
positives (eg when running Wine).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14946
2015-02-18 15:46:19 +00:00
Florian Krohm
798e5a7707 Translations are allowed from all client segments. Update comments
and rename VG_(am_set_segment_hasT_if_SkFileC_or_SkAnonC) to 
VG_(am_set_segment_hasT_if_client_segment). Change it so it handles
all client segments.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14936
2015-02-16 22:58:30 +00:00
Florian Krohm
7f6f4f0a01 Update a few comments.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14935
2015-02-16 22:29:03 +00:00
Florian Krohm
d47181fd7d Add command line flag --max-threads=<integer> to increase the number of
threads that valgrind can handle. No recompile is needed. 
Part of fixing BZ #337869.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14932
2015-02-13 19:08:26 +00:00
Julian Seward
b4287f205a arm32-linux: for the magic-call CALL_FN_* macros, add r12 to the asm
trash list.  Not doing so was causing r12 to get corrupted by the
called function, which lead to some very strange failures in Helgrind
on arm32.  Fixes #344033.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14929
2015-02-11 19:46:27 +00:00
Julian Seward
43d073531e Update to track v4l2 API for kernel version 3.19 changes. Patch from
Hans Verkuil (hverkuil@xs4all.nl).  Fixes #343069.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14909
2015-02-05 15:59:01 +00:00
Julian Seward
fc8c7cbd98 Add wrapper support for I2C_SMBUS ioctls. Patch from
super.firetwister@gmail.com.  Fixes #342603.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14908
2015-02-05 15:52:46 +00:00
Julian Seward
45a0fb5e69 Allow the user to specify precise-exception behaviour for translations
made from file-backed mappings (AOT code, basically) that is different
from the default behaviour as specified by --vex-iropt-register-updates.

New flag is --px-file-backed=, with the same possible args as
--vex-iropt-register-updates has.

Add a new flag --px-default, which is a short alias for
--vex-iropt-register-updates.

Add one line of stats output when --stats=yes, showing counts of how
many translations have been made under each of the 4 different PX
optimisation settings.

No user-visible change if you don't use the new flags.

Relies on VEX API change in r3084.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14906
2015-02-05 12:59:46 +00:00
Florian Krohm
aa74d46212 Replace the SegName array with a simple string table.
The validity of this change follows from the following observations:

(1) There is a single source for allocating and storing segment names,
    namely allocate_segname.
(2) For all invocations of allocate_segname the returned value (which
    represents the segmant name) is assigned to NSegment::fnIdx.
(3) All but one assignments to NSegment::fnIdx assign allocate_segname.
    The single exception assigns -1 in init_nsegment. That function is
    called whenever a new segment (named or unnamed) is allocated.

For a segment name to become unused there must be an assignment to
NSegment::fnIdx which was previously assigned a return value from 
allocate_segname. There is no such assignment.
It follows that all segment names are in use at all times, hence
SegName::inUse == True for all SegNames. So we can constant fold it
and don't need to represent it.
Pass 3 in preen_nsegments is obsolete as there are no segment names to
garbage collect.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14898
2015-01-31 00:29:50 +00:00
Florian Krohm
cb3b3b58b1 Remove unused field from NSegment structure.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14891
2015-01-27 20:46:19 +00:00
Florian Krohm
e70cb7b851 VG_(am_get_filename) returns a pointer to memory that belongs to the
address space manager. Callers should neither modify the string nor
free it (as the string resides is statically allocated memory). That
calls for a   const HChar *
The type change exposed two bugs. One in m_addrinfo.c and one in 
m_debuginfo.c. In both cases the returned string could possibly be freed later
on. So we need to strdup it first. Now fixed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14886
2015-01-24 00:02:19 +00:00
Florian Krohm
cc4ea69830 Move comments next to the function prototypes they describe.
No functional change.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14885
2015-01-23 19:55:31 +00:00
Julian Seward
af929fb880 Write proper wrappers for ioctls ION_IOC_ALLOC, ION_IOC_MAP and
ION_IOC_IMPORT, and add a wrapper for SYNC_IOC_MERGE.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14883
2015-01-23 12:00:25 +00:00
Florian Krohm
cbd27b7288 Export VG_(discard_tranalsations_safely) to the tools. It is
only allowed to be called in certain contexts which is
enforced at runtime.
Change callgrind accordingly.
New header file pub_tool_transtab.h added.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14867
2015-01-13 17:33:59 +00:00
Florian Krohm
d64b630f9a Add VG_(gettimeofday) such that callgrind can use it without
a bloody hack.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14857
2015-01-08 14:43:29 +00:00
Florian Krohm
a9aa079113 Change most remaining use of Addr64 in coregrind and the tools to Addr.
Tracking VEX r3056.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14846
2015-01-04 17:20:45 +00:00
Florian Krohm
a3842cf5b6 The definition of type Addr has moved to VEX and
the resteer callback has changed (VEX r3050). Track those changes.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14840
2014-12-31 12:11:15 +00:00
Florian Krohm
8bfff4f698 Import offsetof and vg_alignof from VEX (tracking VEX r3049).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14839
2014-12-29 22:19:24 +00:00
Florian Krohm
e61bbd6a9d Move definition of type SizeT to VEX (see VEX r3046).
Enhance printeffery to print SizeT values.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14836
2014-12-29 19:06:40 +00:00
Florian Krohm
5af4195103 Remove the type AddrH. The code assumes in many places that the host
and guest architecture are the same. So the type is really pointless
nowadays.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14834
2014-12-29 17:04:46 +00:00
Philippe Waroquiers
d1b502efef Fix 341539 VG_(describe_addr) should not describe address as belonging to client
segment if it is past the heap end

Describes specifically an address that is in the brk data segment
or in the 'reduced' (after brk reduction) section of the brk data segment.

Based on a patch from Ivo Raisr.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14833
2014-12-28 17:30:22 +00:00
Florian Krohm
115f5cd399 Simplify the VG_(get_filename_linenum) interface by removing
the dirname_available parameter. It's redundant. The value
of the returned directory name can be tested instead.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14814
2014-12-16 20:55:58 +00:00
Florian Krohm
f7c5c06c5d Add limited support for printing floating point numbers to
VG_(debugLog_vprintf). 
Remove function VG_(percentify) and fix up its call sites (part of
fixing BZ #337869.
Allow the width in a format specification to be '*', i.e. the width is
given as an additional function argument.

The limitations for printing floating point numbers are:
(1) %f is the only supported format. Width and precision can be
    specified.
(2) Funny numbers (NaN and such) are not supported.
(3) Floating point numbers need to be benign in the sense that their
    integral part fits into an ULong.
This is good enough for our purposes.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14806
2014-12-12 19:32:10 +00:00
Florian Krohm
69d42e3d4b Fix BZ 334802. Patch by Mark Wielaard with a few mods to make it apply.
r14794 is related as well.
Also: remove -Wno-format-zero-length from compile options.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14795
2014-11-29 14:41:32 +00:00
Philippe Waroquiers
01782fe668 Change pub_tool_addrinfo.h AddrInfo and VG_(describe_addr) so as to describe
anonymous or file mmap-ed segments and shared memory segments.

* pub_tool_addrinfo.h:
    new AddrTag Addr_SegmentKind  // Client segment (mapped memory)
    new struct SegmentKind in AddrInfo

* m_addrinfo.c:
   If address is still undescribed, try to describe by findinf a client segment.

* update various tests

* mc_errors.c:
  add a call to VG_(clear_addrinfo) in MC_(pp_describe_addr)
  as the memory allocated in the local AddrInfo has to be cleared once
  info is printed.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14779
2014-11-24 17:46:41 +00:00
Florian Krohm
aa4f59d003 Use unsigned long int instead of unsigned long long int on LP64
platforms. This avoids warnings when compiling with -pedantic.
Fixes BZ #211926.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14732
2014-11-19 07:41:19 +00:00
Florian Krohm
ac3b22e6af Merge revisions 14445 and 14446 from the BUF_REMOVAL branch to trunk.
Two things:
- remove the buffer argument from VG_(DebugInfo_sect_kind)
- allocate AddrInfo::SectKind::objname dynamically


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14719
2014-11-13 21:41:28 +00:00
Julian Seward
2b9da24a5c * add syscall wrappers for some new OSX 10.10 specific calls
necp_match_policy
    sysctlbyname
      getattrlistbulk (kludged)

* add initial entries for the resync-filter on OSX 10.10.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14718
2014-11-13 16:30:09 +00:00
Tom Hughes
fa63a472b7 Update system call lists.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14705
2014-11-09 13:59:51 +00:00
Philippe Waroquiers
993eded14d Comment only changes.
* Clarify in the dedup pool comments that all bytes of elements are compared.
* pub_core_options.h : remove old/misplaced comment for clo_trace_children
                       and replace by a more clear comment (matching the --help)


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14704
2014-11-07 22:16:27 +00:00
Julian Seward
6f2d1b4dd5 Add a no-op wrapper for a new-in-10.10 syscall: getattrlistbulk
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14701
2014-11-07 00:05:56 +00:00
Julian Seward
a2ca87cf7b Adds initial support for new syscalls on MacOS X 10.10, including new
syscall numbers, and dummy wrappers for bsdthread_ctl and
sysctlbyname.  Mash up of patches from fxcoudert@gcc.gnu.org and Rhys
Kidd (rhyskidd@gmail.com).  Part of bug 339045.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14698
2014-11-06 20:29:01 +00:00
Julian Seward
eb219c4398 Fix symbol name typo (correct: DARWIN_VERS wrong: DARWIN_VERSION).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14694
2014-11-05 21:27:36 +00:00
Florian Krohm
d2723ddc9b Merge r14308 from the BUF_REMOVAL branch to trunk
Changes VG_(describe_IP) to return the untruncated result in a statically
allocated local buffer. Fix call sites and update two .exp files who had
truncated names.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14685
2014-11-03 22:43:42 +00:00
Philippe Waroquiers
80ae5a2395 fix 338995 shmat with hugepages (SHM_HUGETLB) fails with EINVAL
Bug is not really fixed, instead the SHM_HUGETLB flag is ignored.
Note that it is not straightforward to properly fix this,
as this implies either to learn aspacemgr what huge pages are.
Also, the trick used in the fix for 333051 cannot be used easily,
because the SHM_HUGETLB flag is given in shmget, while the mmap
is done in shmat.

So, the easiest is to just ignore the SHM_HUGETLB flag.

SHM_HUGETLB is supposed to only give a performance impact.
Ignoring it should be benign.
Theoretically, the caller might expect a sucessful shmget(SHM_HUGETLB)+shmat
to give pages aligned on e.g. 1MB.
In this case, bad luck, the program will misbehave under valgrind.
To warn of this, a warning is given (once) when SHM_HUGETLB is seen.

The map_unmap.c test has been restructured somewaht to allow
TEST_SHM_HUGETLB to be tested independently (or not) of the TEST_MAP_HUGETLB.

Note also that by default, testing  MAP_HUGETLB and SHM_HUGETLB
is disabled as usually, huge pages are not enabled.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14683
2014-11-01 22:00:50 +00:00
Florian Krohm
645563670a Merge revisions 14222, 14268, and 14270 from the BUF_REMOVAL branch to trunk.
Assorted fixes in exp-bbv to eliminate a few buffers.
Implement a suggestion found in the massif source, namely to add the
equivalent of fprintf to m_libcprint. Good suggestion. Thusly
- VgFile: similar to FILE; buffered output, 8k buffer
- VG_(fopen): similar to fopen, but with arguments as in VG_(open)
- VG_(fprintf) and VG_(vfprintf): like [v]fprintf with VgFile 1at argument
- VG_(fclose)
Change massif, exp-bbv and cachegrind to use this functionality.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14678
2014-10-30 22:17:56 +00:00
Florian Krohm
d7cc7eac99 Merge revisions 14255, 14293, and 14294 from the BUF_REMOVAL branch to trunk.
The functions VG_(get_filename) and VG_(get_filename_lineno) now return
a pointer to filename and directory name instead of copying them into
buffers passed in from the caller.
The returned strings are persistent as long as the DebugInfo to which
they belong is not discarded. The caller therefore needs to stash them
away as needed.
Function VG_(strncpy_safely) has been removed as it is no longer needed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14668
2014-10-27 12:06:35 +00:00
Florian Krohm
665280aeaf Merge r14202 from the BUF_REMOVAL branch to trunk.
This patch changes the interface and behaviour of VG_(demangle) and
VG_(maybe_Z_demangle). Instead of copying the demangled name into a
fixed sized buffer that is passed in from the caller (HChar *buf, Int n_buf),
the demangling functions will now return a pointer to the full-length
demangled name (HChar **result). It is the caller's responsiblilty to
make a copy if needed. 

This change in function parameters ripples upward
- first: to get_sym_name
- then to the convenience wrappers
  - VG_(get_fnname)
  - VG_(get_fnname_w_offset)
  - VG_(get_fnname_if_entry)
  - VG_(get_fnname_raw)
  - VG_(get_fnname_no_cxx_demangle)
  - VG_(get_datasym_and_offset)

The changes in foComplete then forces the arguments of
  - VG_(get_objname) to be changed as well

There are some issues regarding the ownership and persistence of
character strings to consider.
In general, the returned character string is owned by "somebody else"
which means the caller must not free it. Also, the caller must not 
modify the returned string as it possibly points to read only memory.
Additionally, the returned string is not necessarily persistent. Here are
the scenarios:
- the returned string is a demangled function name in which case the
  memory holding the string will be freed when the demangler is called again.
- the returned string hangs off of a DebugInfo structure in which case
  it will be freed when the DebugInfo is discarded
- the returned string hangs off of a segment in the address space manager
  in which case it may be overwritten when the segment is merged with
  another segment
So the rule of thunb here is: if in doubt strdup the string.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14664
2014-10-25 19:20:38 +00:00
Florian Krohm
a3a57c92df Constify coregrind.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14656
2014-10-22 22:25:30 +00:00
Florian Krohm
d0dd4cbf30 Change VG_(allocEltDedupPA) to return a pointer to const. The reason is
that once an element has been allocated and added to the pool it must
not be modified afterwards. See the documentation in pub_tool_deduppoolalloc.h
The rest of the patch is ripple.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14654
2014-10-22 17:42:37 +00:00
Florian Krohm
070ad41c3b Enable -Wcast-qual when compiling the valgrind source.
Testcases are not compiled with -Wcast-qual.
Introduce CONST_CAST macro to work around in the few spots
where a cast that drops type qualifiers is needed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14652
2014-10-22 12:53:16 +00:00
Florian Krohm
17fe8c0a09 Add support for ioctl(fd, TIOCSIG, signal_number) which used
to issue a false complaint. Fixes BZ #339706
Source patch by David Herrmann (dh.herrmann@gmail.com).
Testcase by myself.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14646
2014-10-21 07:20:20 +00:00
Florian Krohm
9d16aabb17 Constify the tool interface.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14642
2014-10-20 19:02:38 +00:00
Florian Krohm
aa351c61c1 Constify.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14641
2014-10-18 20:56:13 +00:00
Florian Krohm
9959f9acb0 Constify m_oset, m_sparsewa, and m_wordfm.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14640
2014-10-18 16:17:13 +00:00