1188 Commits

Author SHA1 Message Date
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
Florian Krohm
f5e2bdbddc Change the definition of VgHashTable to not have pointer type.
This is (a) consistent with how the other containers are defined
and, more importantly, (b) allows the constification of the hash table API.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14639
2014-10-18 10:58:05 +00:00
Julian Seward
f015e52c05 -Wmissing-enum seems to have arrived at the MacOS builds for some
reason, and complains about missing cases in sr_isError, sr_Res,
sr_ResHI, sr_Err.  Add cases to keep it happy.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14634
2014-10-17 15:05:01 +00:00
Florian Krohm
77c3a4ef7c Merge revisions 14210 and 14626 from the BUF_REMOVAL branch to trunk.
Change VG_(resolve_filename) to not truncate the result which is returned
in a static buffer now. Fix callsites.
Simplify VG_(di_notify_pdb_debuginfo) to use VG_(resolve_filename).
Fix VG_(readlink) prototype.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14628
2014-10-14 21:01:33 +00:00
Florian Krohm
5929994d48 Merge revisions 14230, 14602, and 14604 from the BUF_REMOVAL branch to trunk.
The change eliminates the fixed size buffers in gen_suppression and
show_used_suppressions. This is achieved by changing the return type from
VG_TDICT_CALL(tool_get_extra_suppression_info and
VG_TDICT_CALL(tool_print_extra_suppression_use from Bool to SizeT.
A return value of 0 indicates that nothing (except the terminating '\0'
which is always inserted) was written to the buffer. This corresponds to the
previous False return value. A return value which is equal to the buffer
size (that was passed in as function argument) indicates that the buffer was
not large enough. The caller then resizes the buffer and retries.
Otherwise, the buffer was large enough.
Regtested with a resize value of 1.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14606
2014-10-07 14:28:52 +00:00
Florian Krohm
2891e3ceaa Followup to r14600. Copy the contents of pub_core_guest.h to pub_tool_guest.h
to make it available to tools. This allows to remove quite a bit of
ifdeffery from memcheck's mc_machine.c


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14601
2014-10-06 21:04:14 +00:00
Florian Krohm
76575e29cf Merge 14206,14207,14261,14577,14578 from BUF_REMOVAL branch to trunk.
This changes VG_(record_startup_wd) to dynamically allocate a large
enough buffer for the directory name. As the dynamic memory manager has
started up a while ago, this is quite safe. Also rewrite VG_(get_startup_wd)
to simply return the directory name. No more messing with copying it
around. Adapt call sites.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14579
2014-09-27 17:42:07 +00:00
Christian Borntraeger
3b8b96e924 implement KVM_KVMCLOCK_CTRL. Interestingly, the kernel does not check
the parameter. QEMU does pass 0 nevertheless as parameter.

bugzilla:  [Bug 339424] Full support of KVM ioctl


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14569
2014-09-26 18:44:40 +00:00
Florian Krohm
e383c673dd Ripple from constifying parameters of instrumentation functions and
callbacks from VexTranslateArgs. See VEX r2958.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14564
2014-09-24 12:06:55 +00:00
Philippe Waroquiers
80f3d4e69a Handle explicitely all enum values in 'switch' on AddrInfo tag
(reported by Florian)

Note that Addr_Undescribed will cause an assert if such
an undescribed addrinfo is pretty printed, as normally
such addrinfo should always be described before being pretty printed.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14558
2014-09-19 18:58:18 +00:00
Florian Krohm
16a796694c Remove a comment that is no longer valid. The real reason we (now)
don't provide strtoll etc is that we don't need the flexibility and
are too lazy to implement the general case :) But that does not
warrant a comment in the code.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14540
2014-09-15 20:18:39 +00:00
Florian Krohm
c88dc7f039 Tidy up m_xarray.c.
VG_(newXA) and VG_(cloneXA) never return NULL. Remove pointless asserts.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14539
2014-09-15 18:50:17 +00:00
Florian Krohm
bbc6e90d5b Document NULL-ness of the return value of the dedup allocation functions.
Avoid conflict with reserved name 'free'.
Remove a few pointless asserts.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14538
2014-09-15 07:21:36 +00:00
Florian Krohm
1e6ce59bc5 Document that VG_(newPA) and VG_(allocEltPA) never return NULL.
Remove a few pointless asserts.
Avoid conflict with reserved name 'free'.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14537
2014-09-14 22:44:53 +00:00
Florian Krohm
17f4960a2c Document that VG_(newRangeMap) never returns NULL.
Remove pointless asserts.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14536
2014-09-14 22:19:52 +00:00
Florian Krohm
66a167b4c4 Tidy up m_wordfm.
First, as the allocator function does not fail, there is no need
to assert its return value.
Second, remove commented out (since r8765) function VG_(isEmptyFM).
Third, remove VG_(getNodeSizeFM) from the API. The details of the
implementation do not need to be exposed.
Fourth, for consistency require that the copy functions for keys and
values in VG_(dopyFM) (which are essentially like allocators) return
non-NULL values for non-NULL arguments if they return.
Fifth, document NULL-ness of return values for VG_(newFM), VG_(dopyFM),
and VG_(newBag). Remove pointless asserts at call sites.
Six, change avl_dopy to assert that the node the function is
supposed to copy is not NULL. It is called that way anyhow. With 
that change the function never returns NULL which allows us to
simplify the call sites. Checking the return value is no longer needed.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14535
2014-09-14 22:11:44 +00:00
Florian Krohm
6790a772de Document that VG_(newSWA) never returns NULL (because its
allocation function does not). Audit call sites.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14533
2014-09-13 22:39:31 +00:00
Florian Krohm
a51a7bb1db Document the NULL-ness of the return values of HT_construct and HT_to_array.
Audit call sites.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14532
2014-09-13 22:31:13 +00:00
Florian Krohm
2aa67544d6 Tidy up m_oset.c
- Document that the allocation function must ot return NULL.
- As a conequence of the previous requirement the various Create and AllocNode
  functions cannot return NULL. Remove pointless asserts at call sites.
- Remove documentation of undefined function  CreateWithCmp.
- Names of library functions (such as 'free') are reserved as a are names
  beginning with underscores. Don't use those.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14531
2014-09-13 22:04:33 +00:00
Florian Krohm
3b95ad549a Use wrapper functions VG_(malloc) and friends consistently across the
board (instead of e.g. VG_(arena_malloc)(VG_AR_CORE,...). This change
also benefits static analysers. We can tell tools that VG_(malloc) allocates
and VG_(free) deallocates and that they are a pair. But we cannot do that for 
arena_malloc/free.
Also provide a wrapper VG_(realloc_shrink).


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14517
2014-09-11 21:19:17 +00:00
Florian Krohm
4754dd70f2 Rename VG_(malloc_usable_size) to VG_(cli_malloc_usable_size)
because it operates on the CLIENT arena. Given that VG_(malloc)
operates on the CORE arena, it was unexpected for VG_(mallos_usable_size)
to use a different arena. 
Move function definition to the proper place (next to VG_(cli_malloc))
and fix call sites.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14516
2014-09-11 20:15:23 +00:00
Mark Wielaard
5633e22712 Bug 338974 glibc 2.20 changed size of struct sigaction sa_flags on s390
To track POSIX glibc and the kernel agreed to change the type of the
sa_flags field in struct sigaction to an int. There is now a int
__glibc_reserved0 padding field that can be passed undefined.
See https://sourceware.org/ml/libc-alpha/2014-09/msg00161.html

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14508
2014-09-10 12:08:15 +00:00
Julian Seward
50618eb024 Improved argument checking for sys_kcmp. Derived from patch from
Christian Borntraeger.  Followup to r14451.  Pertains to #338106.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14473
2014-09-05 21:11:18 +00:00
Christian Borntraeger
4952a40890 add more system call numbers for s390. While we are at it
also wire up the common linux kcmp system call.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14461
2014-09-04 19:57:17 +00:00
Julian Seward
775ae0473b Patch adding support for V4L2/media ioctls. Patch from Hans Verkuil
(hverkuil@xs4all.nl).  Fixes #338023.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14455
2014-09-04 11:08:45 +00:00
Julian Seward
29797aa4c0 Add Xen 4.4 evtchn ioctl wrappers. Patch from Antony Saba
(antony.saba@fireeye.com).  Second of two patches from #337740.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14454
2014-09-04 11:02:24 +00:00
Julian Seward
a4830754d0 Add support for Xen hypercalls used by libvmi. Patch from Antony Saba
(antony.saba@fireeye.com).  First of two patches from #337740.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14453
2014-09-04 10:59:50 +00:00
Julian Seward
8f579dba61 Add support for sys_kcmp. Patch from Chris Jones
(cjones.bugs@gmail.com).  Fixes #338106.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14451
2014-09-04 10:17:08 +00:00
Julian Seward
7e3f04874a Improvements for Android:
* All Linux targets: add minimal ioctl support for the ION_IOC family

* Android targets: change proprietary-ioctl support for GPUs from
  being a build-time #define kludge to being controlled by --kernel-variant,
  as it should be.  Update documentation accordingly.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14440
2014-09-03 15:19:25 +00:00
Tom Hughes
612c18619d Add support for some more tun/tap ioctls. BZ#315952.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14432
2014-09-02 12:54:29 +00:00
Julian Seward
506af73036 VG_(getdents64) is only needed on Linux, and causes build problems
on Darwin, so make it exist only on Linux.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14421
2014-09-01 22:26:18 +00:00
Julian Seward
fd963d5022 Add a missing VKI_ prefix. No functional change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14417
2014-09-01 21:25:03 +00:00
Florian Krohm
5f03bb301d Followup to r13469. lineno has already been asserted to be != NULL.
No need to check it again.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14413
2014-09-01 21:03:54 +00:00
Julian Seward
0b41710542 Rename a bunch of __unused fields to __unused0, since some Android
NDK's appear to #define __unused to __attribute__((__unused__)),
causing the build to fail in bizarre ways.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14412
2014-09-01 20:50:56 +00:00
Petar Jovanovic
27823080d3 mips64: add missing system call numbers
r14384 introduced use of getdents64 syscall and we missed a system call
value for MIPS64, so it broke the build for it. Add missing values now.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14409
2014-09-01 16:47:34 +00:00
Florian Krohm
10e841dbaa Fix a comment. No functional change.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14408
2014-09-01 15:56:05 +00:00
Mark Wielaard
a93b787140 Bug 338703 helgrind on arm-linux gets false positives in dynamic loader.
There are a couple of issues with helgrind on arm-linux with glibc:

- Thread creation stack traces cannot unwind through clone
  (cfi ends right after syscall)
- ld.so has a special "hard float" name that isn't recognized as special
  (ld-linux-armhf.so.3)
- Races are found when manipulating GOT sections.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14407
2014-09-01 15:29:55 +00:00
Philippe Waroquiers
3159bc49c8 Improve description of an address that is on a stack but below sp.
An address below the sp will be described as being on a stack, but below sp.

The stack for such an address is found in the registered stacks.

Also, if there is a guard page at the end of the stack (lowest address)
an address in this page will be described as being in thread guard page.
A guard page is recognised as being a page not readable/writable/executable.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14399
2014-08-31 22:27:19 +00:00
Julian Seward
24b6d8ea1f Helgrind needs to know the soname of ld.so, and on arm64-linux
it is different (ld-linux-aarch64.so.1) from all other targets.
(Why?)  This makes Helgrind at least somewhat usable on arm64-linux.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14396
2014-08-30 19:21:48 +00:00
Philippe Waroquiers
51c6c85e22 The semantic of the stack bounds is not consistent or is not described.
At various places, there were either some assumption that the 'end'
boundary (highest address) was either not included, included,
or was the highest addressable word, or the highest addressable byte.
This e.g. was very visible when doing:
  ./vg-in-place -d -d ./helgrind/tests/tc01_simple_race|&grep regi
giving
  --24040:2:stacks     register 0xBEDB4000-0xBEDB4FFF as stack 0
  --24040:2:stacks     register 0x402C000-0x4A2C000 as stack 1
showing that the main stack end was (on x86) not the highest word
but the highest byte, while for the thread 1, the registered end
was a byte not part of the stack.

The attached patch ensures that stack bounds semantic are documented and
consistent. Also, some of the stack handling code is factorised.

The convention that the patch ensures and documents is:
start is the lowest addressable byte, end is the highest addressable byte.
(the words 'min' and 'max' have been kept when already used, as this wording is 
consistent with the new semantic of start/end).

In various debug log, used brackets [ and ] to make clear that
both bounds are included.

The code to guess and register the client stack was duplicated
in all the platform specific syswrap-<plat>-<os>.c files.
Code has been factorised in syswrap-generic.c

The patch has been regression tested on
   x86, amd64, ppc32/64, s390x.
It has been compiled and one test run on arm64.
Not compiled/not tested on darwin, android, mips32/64, arm


More in details, the patch does the following:

coregrind/pub_core_aspacemgr.h
include/valgrind.h
include/pub_tool_machine.h
coregrind/pub_core_scheduler.h
coregrind/pub_core_stacks.h
  - document start/end semantic in various functions
 also in pub_tool_machine.h:
  - replaces unclear 'bottommost address' by 'lowest address'
    (unclear as stack bottom is or at least can be interpreted as
     the 'functional' bottom of the stack, which is the highest
      address for 'stack growing downwards').
coregrind/pub_core_initimg.h
  replace unclear clstack_top by clstack_end
coregrind/m_main.c
  updated to clstack_end

coregrind/pub_core_threadstate.h
  renamed client_stack_highest_word to client_stack_highest_byte
coregrind/m_scheduler/scheduler.c
  computes client_stack_highest_byte as the highest addressable byte
  Update comments in call to VG_(show_sched_status)
coregrind/m_machine.c
coregrind/m_stacktrace.c
  updated to client_stack_highest_byte, and switched 
    stack_lowest/highest_word to stack_lowest/highest_byte accordingly

coregrind/m_stacks.c
  clarify semantic of start/end,
  added a comment to indicate why we invert start/end in register call
  (note that the code find_stack_by_addr was already assuming that
  end was included as the checks were doing e.g.
    sp >= i->start && sp <= i->end

coregrind/pub_core_clientstate.h
coregrind/m_clientstate.c
  renames Addr  VG_(clstk_base) to Addr  VG_(clstk_start_base)
    (start to indicate it is the lowest address, base suffix kept
     to indicate it is the initial lowest address).

coregrind/m_initimg/initimg-darwin.c
   updated to  VG_(clstk_start_base)
   replace unclear iicii.clstack_top by iicii.clstack_end
   updated clstack_max_size computation according to both bounds included.

coregrind/m_initimg/initimg-linux.c
   updated to  VG_(clstk_start_base)
   updated VG_(clstk_end) computation according to both bounds included.
   replace unclear iicii.clstack_top by iicii.clstack_end

coregrind/pub_core_aspacemgr.h
  extern Addr VG_(am_startup) : clarify semantic of the returned value
coregrind/m_aspacemgr/aspacemgr-linux.c
   removed a copy of a comment that was already in pub_core_aspacemgr.h
     (avoid double maintenance)
   renamed unclear suggested_clstack_top to suggested_clstack_end
    (note that here, it looks like suggested_clstack_top was already
     the last addressable byte)

* factorisation of the stack guessing and registration causes
  mechanical changes in the following files:
      coregrind/m_syswrap/syswrap-ppc64-linux.c
      coregrind/m_syswrap/syswrap-x86-darwin.c
      coregrind/m_syswrap/syswrap-amd64-linux.c
      coregrind/m_syswrap/syswrap-arm-linux.c
      coregrind/m_syswrap/syswrap-generic.c
      coregrind/m_syswrap/syswrap-mips64-linux.c
      coregrind/m_syswrap/syswrap-ppc32-linux.c
      coregrind/m_syswrap/syswrap-amd64-darwin.c
      coregrind/m_syswrap/syswrap-mips32-linux.c
      coregrind/m_syswrap/priv_syswrap-generic.h
      coregrind/m_syswrap/syswrap-x86-linux.c
      coregrind/m_syswrap/syswrap-s390x-linux.c
      coregrind/m_syswrap/syswrap-darwin.c
      coregrind/m_syswrap/syswrap-arm64-linux.c
 Some files to look at more in details:
  syswrap-darwin.c : the handling of sysctl(kern.usrstack) looked
    buggy to me, and has probably be made correct by the fact that
     VG_(clstk_end) is now the last addressable byte. However,unsure
    about this, as I could not find any documentation about 
    sysctl(kern.usrstack). I only find several occurences on the web,
    showing that the result of this is page aligned, which I guess
    means it must be 1+ the last addressable byte.
  syswrap-x86-darwin.c and syswrap-amd64-darwin.c
   I suspect the code that was computing client_stack_highest_word
   was wrong, and the patch makes it correct.
  syswrap-mips64-linux.c
    not sure what to do for this code. This is the only code
    that was guessing the stack differently from others.
    Kept (almost) untouched. To be discussed with mips maintainers.

coregrind/pub_core_libcassert.h
coregrind/m_libcassert.c
  * void VG_(show_sched_status):
     renamed Bool valgrind_stack_usage to Bool stack_usage
     if stack_usage, shows both the valgrind stack usage and
     the client stack boundaries
coregrind/m_scheduler/scheduler.c
coregrind/m_gdbserver/server.c
coregrind/m_gdbserver/remote-utils.c
   Updated comments in callers to VG_(show_sched_status)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14392
2014-08-29 22:53:19 +00:00
Mark Wielaard
455f32995d Use getdents64 syscall on linux.
getdents has been deprecated since linux 2.4 and newer arches (arm64)
might no longer provide the getdents syscall. Use getdents64 for reading
the /proc/self/fd/ dir so --track-fds=yes works reliable on all arches.
Without this the none/tests/fdleak*vgtest might fail.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14384
2014-08-29 14:28:30 +00:00
Mark Wielaard
0a0862f83c include/vki/vki-scnums-arm64-linux.h use correct __NR_lseek define.
This caused memcheck/tests/linux/proc-auxv.vgtest to fail because
our internal VG(lseek) would return ENOSYS.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14383
2014-08-29 11:44:20 +00:00
Philippe Waroquiers
2f460aaec6 The attached patch cleanups the clo processing
of clo which are (or should be) 'enum set'.

* pub_tool_options.h : add new macrox VG_USET_CLO and VG_USETX_CLO to
  parse an 'enum set' command line option (with or without "all" keyword).

* use VG_USET_CLO for existing enum set clo options:
   memcheck --errors-for-leak-kinds, --show-leak-kinds, --leak-check-heuristics
   coregrind --vgdb-stop-at

* change --sim-hints and --kernel-variants to enum set
  (this allows to detect user typos: currently, a typo in a sim-hint
   or kernel variant is silently ignored. Now, an error will be given
   to the user)

* The 2 new sets (--sim-hints and --kernel-variants) should not make
  use of the 'all' keyword => VG_(parse_enum_set) has a new argument
  to enable/disable the use of the "all" keyword.

* The macros defining an 'all enum' set definition was duplicating
  all enum values (so addition of a new enum value could easily
  give a bug). Removing these macros as they are unused
  (to the exception of the leak-kind set).
  For this set, the 'all macro' has been replaced by an 'all function',
  coded using parse_enum_set parsing the "all" keyword.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14301
2014-08-17 20:03:51 +00:00
Philippe Waroquiers
135719b57e Reduce memory needed for symbols, by having the tocptr and local_ep
(used for ppc64 platforms) #ifdef-ed and accessed by macros
that becomes NOP on non ppc64 platforms.
This decreases the debuginfo memory by about 2.5 Mb on a big 32 bit application.

Note : doing that, some questions were encountered in the way
tocptr and local_ep have (or do not have) to be copied/maintained
in storage.c canonicaliseSymtab



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14273
2014-08-13 21:25:45 +00:00
Florian Krohm
c30cf0c674 Remove function VG_(sysnum_string_extra) as it was just a wrapper
around VG_(sysnum_string). Also remove associated macro
VG_SYSNUM_STRING_EXTRA.
The VG_SYSNUM_STRING macro returned a pointer to a variable which 
is out of scope. Using that value may cause undefined behaviour.
Change VG_(sysnum_string) to return pointer to static buffer instead.
Fix call sites.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14264
2014-08-12 11:43:17 +00:00
Florian Krohm
5d0841b870 Correct a comment. We really should not specify the default values
here. Double maintenance.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14262
2014-08-11 15:48:51 +00:00