Florian Krohm [Thu, 30 Oct 2014 22:17:56 +0000 (22:17 +0000)]
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.
Florian Krohm [Wed, 29 Oct 2014 13:57:49 +0000 (13:57 +0000)]
Configury and Makefile tweaks to support compilation with Intel's
ICC Compiler. Patch mostly by Gregory Czajkowski <gregczajkowski@yahoo.com>.
Fixes BZ #339542.
Florian Krohm [Tue, 28 Oct 2014 20:52:07 +0000 (20:52 +0000)]
Merge revision 14309 from BUF_REMOVAL branch to trunk.
Eliminates a fixed size buffer in helgrind. Instead of building up a
string in a buffer and then writing the string to stdout can as well
write to stdout directly.
Florian Krohm [Tue, 28 Oct 2014 20:28:32 +0000 (20:28 +0000)]
When traversing VG_(args_for_client) there is no need to check
the array element for NULL. Function VG_(split_up_argv), which
sets up that array, ensures that no element is NULL.
Florian Krohm [Mon, 27 Oct 2014 12:06:35 +0000 (12:06 +0000)]
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.
Florian Krohm [Sun, 26 Oct 2014 19:16:14 +0000 (19:16 +0000)]
Merge r14289 from the BUF_REMOVAL branch to trunk.
Change CLG_(get_debug_info) to not build up an absolute pathname in its
'file' parameter. Instead give it an additional parameter to hold the
directory name. Callers can then build up the absolute pathname if needed.
This change will come in handy soonish when VG_(get_filename_lineno) will be
changed and those buffers will disappear.
The change has a bit of ripple to get_fn_node_inseg and CLG_(get_file_node).
Florian Krohm [Sun, 26 Oct 2014 17:12:12 +0000 (17:12 +0000)]
Merge r14288 from the BUF_REMOVAL branch to trunk.
What it does it changing cachegrind's get_debug_info function such
that it no longer builds up an absolute pathname. Instead the function
get an additional parameter for the directory name and the absolute
pathname is built when it is needed. This will come in handy soonish
when VG_(get_filename_lineno) will be changed and those buffers will
disappear.
Florian Krohm [Sat, 25 Oct 2014 19:20:38 +0000 (19:20 +0000)]
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.
Julian Seward [Thu, 23 Oct 2014 19:48:01 +0000 (19:48 +0000)]
Darwin only: add a filter mechanism that aims to remove pointless
memory-map resync operations. Without the filter, such operations
come to dominate the running time of complex apps with thousands of
memory segments (eg Firefox) and it becomes unusably slow. With
the filter in place, the huge performance loss is mostly avoided.
Has no meaning and no effect on non-Darwin targets. Controlled by
flag --resync-filter=no|yes|verbose [yes]. Filter is currently only
set up for Mac OS X 10.9 (Mavericks) 64 bit and will not produce
any performance benefit on any other configuration.
Florian Krohm [Wed, 22 Oct 2014 17:42:37 +0000 (17:42 +0000)]
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.
Florian Krohm [Wed, 22 Oct 2014 12:53:16 +0000 (12:53 +0000)]
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.
Florian Krohm [Wed, 22 Oct 2014 09:44:34 +0000 (09:44 +0000)]
Change the initialisation of the newly allocated struct sched_lock
object. Just memset the whole thing to 0. That avoids a cast that
drops type qualifiction.
Florian Krohm [Wed, 22 Oct 2014 09:25:03 +0000 (09:25 +0000)]
Followup to r14646. The symbol TIOCSIG is not necessarily defined,
e.g. on s390x with glibc 2.3.4. Modify the testcase to bypass the ioctl
call in that case.
Florian Krohm [Tue, 21 Oct 2014 07:20:20 +0000 (07:20 +0000)]
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.
Florian Krohm [Mon, 20 Oct 2014 20:59:13 +0000 (20:59 +0000)]
Fix some testcases which implicitly assumed that TMPDIR was either
not set or set to /tmp This is not always true. Fixes BZ 340115.
Patch by rhyskidd@gmail.com.
Florian Krohm [Sat, 18 Oct 2014 10:58:05 +0000 (10:58 +0000)]
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.
Julian Seward [Fri, 17 Oct 2014 15:05:01 +0000 (15:05 +0000)]
-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.
Julian Seward [Wed, 15 Oct 2014 16:12:11 +0000 (16:12 +0000)]
di_notify_ACHIEVE_ACCEPT_STATE: before starting to parse the ELF file,
truncate overlaps in the DebugInfoMappings that have been collected by
the DebugInfo's FSM. Not doing so can confuse ML_(read_elf_debug_info)'s
computation of bias values. Observed to be a problem when reading EDIDX
sections for objects mangled by Mike Hommey's elfhack program.
See http://bugzilla.mozilla.org/show_bug.cgi?id=788974
Florian Krohm [Tue, 14 Oct 2014 21:01:33 +0000 (21:01 +0000)]
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.
Julian Seward [Mon, 13 Oct 2014 13:03:50 +0000 (13:03 +0000)]
Modify the compiler detection test so as to accept "Apple LLVM version
5.1" (etc) and identify it as a Clang variant. Without that, it gets
misidentified as a gcc variant, which causes problems with Makefile.am's
that use the derived COMPILER_IS_CLANG conditional.
follow up to fix for 339721 assertion 'check_sibling == sibling' failed in readdwarf3.c ...
The fix committed in revision 14603 is properly fixing the bug 339721.
However, when enabling the dwarf tracing, the DW_FORM_ref_sig8 causes
a segmentation violation, as the tracing code is shared with the
reading code. But the DW_FORM_ref_sig8 reading code is dereferencing
some data structure that is only initialised when --read-var-info=yes.
So, in case DW_FORM_ref_sig8 form reading is done and --read-var-info=no,
then check that we are tracing, and avoid dereferencing the (not initialised)
signature hash table.
Florian Krohm [Tue, 7 Oct 2014 18:36:28 +0000 (18:36 +0000)]
Merge revisions 14372 and 14607 from the BUF_REMOVAL branch to trunk.
This change makes VG_(clo_suppressions), VG_(clo_fullpath_after),
and VG_(clo_req_tsyms) XArrays. They used to be arrays of fixed size.
Florian Krohm [Tue, 7 Oct 2014 14:28:52 +0000 (14:28 +0000)]
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.
fix 339721 assertion 'check_sibling == sibling' failed in readdwarf3.c ...
The skip code was wrongly skipping 16 bytes, while only 8 are read
for a DW_FORM_ref_sig8.
Note that the problem is made visible by an assert when using
--trace-symtab=yes but in fact this is a real bug in the dwarf reader,
that was introduced in one of the optimisations done for the inline info.
It can manifest itself with other symptoms:
One of the 2 following assertions can fail:
vg_assert (check_sibling == sibling);
vg_assert (get_position_of_Cursor (&check_skip)
== get_position_of_Cursor (&c));
Or the following error can be given:
--29973-- WARNING: Serious error when reading debug info
--29973-- When reading debug info from /home/philippe/valgrind/trunk_untouched/memcheck/tests/dw4:
--29973-- Overrun whilst reading .debug_info section
Florian Krohm [Mon, 6 Oct 2014 21:04:14 +0000 (21:04 +0000)]
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
Florian Krohm [Mon, 6 Oct 2014 16:41:14 +0000 (16:41 +0000)]
Entangle header files a bit. Specifically, pub_core_basics.h no longer
includes libvex.h. It isn't needed to successfully compile pub_core_basics.h
standalone and the declarations libvex.h provides aren't used as broadly as
the comment in the code implied.
Move the guest-specific includes and some ifdeffery to the new file
pub_core_guest.h
For the curious reader: The change above avoids a problem when linking the
linux-launcher which previously included libvex.h indirectly. libvex.h also
defines the inline function LibVEX_Alloc which, when emitted, causes the
link step to fail due to unresoled references (as the launcher does not link
against libvex.a). See also BZ #339542.
Florian Krohm [Wed, 1 Oct 2014 14:16:05 +0000 (14:16 +0000)]
Merge revisions 14337, 14596 from the BUF_REMOVAL branch to trunk.
Change callgrind's init_cmdbuf function to allocate a large enough
buffer for the command line.
Merge six easy pieces from the BUF_REMOVAL branch:
r14271 Audit a few buffer sizes, increase one.
r14280 Audit buffer size.
r14296 Remove a few unneeded header files.
r14310 Replace fixed size buffers with a large enough buffers.
r14338 Remove a dead assignment in print_bbcs and make global variable
print_fd a local variable.
r14359 Remove a benign macro redefinition in cachegrind.
Merge revisions 14216,14591,14593 from the BUF_REMOVAL branch to trunk.
Chang the semantics of VG_(getgroups) to support querying the number
of supplementary group IDs which simplifies obtaining them and gets
rid of fixed size buffers.
Merge revisions 14212 and 14586 from the BUF_REMOVAL branch to trunk.
The change eliminates the use of fixed size buffers for path names.
There was a comment in the code that dynamic memory allocation could
not be used. But that is no longer true.
Clean up #includes.
Merge r14229 from the BUF_REMOVAL branch to trunk.
Function MC_(snprintf_delta) requires a buffer of size 31 or larger to
avoid overflow.Add an assert, change and document the buffer size and
fix all call sites. Remove magic constants along the way.
Merge r14208 from BUF_REMOVAL branch to trunk.
In function read_dot_valgrindrc use a large enough buffer
allocated on the stack.
Also assert that the passed in directory is not NULL. This is
true at all call sites. The old code would have attempted to read
/.valgrindrc for dir == NULL and I don't think we want that.
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.
Merge revisions 14203,14574,14575 from the BUF_REMOVAL
branch to trunk.
This change eliminates the fixed size buffers in VG_(basename)
and VG_(dirname).
Remove unneeded header file which does not exist on Darwin.
Disable test for darwin as pthread_setname_np is not implemented.
But setting and observing the threadname is what this test is all about.
Petar Jovanovic [Sat, 27 Sep 2014 05:18:21 +0000 (05:18 +0000)]
mips: extend mips_features with a check for FPU
Extend mips_features with "hard-float" query to which mips_features will
respond whether or not the platform is meant to have a floating point unit.
The query is not a runtime check, but a built-time check.
The testbuckets none/tests/ppc{32,64} did not build in case the
toolchain did not support -maltivec -mabi=altivec.
This should work now. Fixes BZ #338731