Fix 197259 Unsupported arch_prtctl PR_SET_GS option
(valgrind side).
In summary: we were counting somewhat on the luck for FS,
we now similarly count on luch for GS
See VEX commit log r3043 for more details.
On amd64, We handle GS similar to FS, i.e. consider it is constant.
Note that FS is not always 0 on linux. It looks rather to be constant
in all threads, and is zero in the main thread.
As values for FS and/or GS differs between platforms (linux or darwin),
FS_CONST and GS_CONST are used.
Note that we cannot easily test that the value of GS or FS is the
expected one, as the value might not be set at the begin of execution
but only set after prctl has been executed.
So, we just hope that effectively GS and FS are constant.
Some trials to set GS to other values that the expected
constant value on linux was causing a SEGV.
So, it looks like this is all effectively protected.
In summary: we were counting somewhat on the luck for FS,
we now similarly count on luch for GS
Florian Krohm [Tue, 16 Dec 2014 20:55:58 +0000 (20:55 +0000)]
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.
Florian Krohm [Mon, 15 Dec 2014 21:55:16 +0000 (21:55 +0000)]
Remove quote.txt and newline.txt as they are no longer needed.
Once upon a time those files were used to construct a
header file vex_svnversion.h but that more hassle than it
was worth and eventually it got nuked.
Florian Krohm [Sat, 13 Dec 2014 18:35:00 +0000 (18:35 +0000)]
Fix BZ #116002.
Left justification of strings in myvprintf_str was mixed up.
Now fixed and %s formats changed accordingly.
In function myvprintf_int64: the local buffer was not large
enough to hold ULONG_MAX in binary notation. Numbers were
truncated at 39 digits.
Testcases added.
reach_thread_register cannot be compiled on Mac OS as Mac OS
had no pthread barrier.
(the Makefile.am protects this with a if HAVE_PTHREAD_BARRIER)
But the test should then be protected with a prereq that the
executable exists.
(analysis and fix suggestion by rhyskidd, part of fixing 341613)
Florian Krohm [Fri, 12 Dec 2014 19:32:10 +0000 (19:32 +0000)]
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.
With this change, the user experience will be smoewhat better, e.g.:
VEX: Support for AVX2 requires AVX capabilities
Found: amd64-cx16-rdtscp-sse3-avx2
Cannot continue. Good-bye
Specifically, the patch decouples showing hwcaps and deciding their validity.
show_hwcaps_<ARCH> reports the hwcaps it finds. It never returns NULL.
check_hwcaps checks the hwcaps for feasibility and does not return in case
VEX cannot deal with them.
The function are_valid_hwcaps no longer exists.
Florian Krohm [Wed, 10 Dec 2014 16:08:09 +0000 (16:08 +0000)]
New function vfatal which should be used for user messages
to indicate a situation that can legitimately occur but that
we cannot handle today. The function does not return.
Florian Krohm [Tue, 9 Dec 2014 20:08:46 +0000 (20:08 +0000)]
Detect presence of sse3 instructions on x86.
Set VEX_HWCAPS_X86_SSE3 accordingly.
This came about by grepping the source for VEX_HWCAPS_X86_SSE3
and observing that the flag was tested for (in VEX) but not set.
Florian Krohm [Mon, 8 Dec 2014 14:01:33 +0000 (14:01 +0000)]
The long displacement facility is now required. There were a
few spots in the code where this was assumed implicitly.
Ugly fixes were possible, but requiring this facility is not
unreasonable as it has been around sind 2003. So let's just
do this.
Florian Krohm [Sun, 7 Dec 2014 18:58:59 +0000 (18:58 +0000)]
Remove fixed size arrays in the dwarf-3 parser.
Use proper initialisation functions for the type and variable parser.
Add functions to release the dynamically allocated functions.
No longer maintain content of popped-off stack entries as that is
essentially freed memory and complicates matters unnecessarily.
Part of fixing BZ #337869.
Florian Krohm [Fri, 5 Dec 2014 18:55:39 +0000 (18:55 +0000)]
Encountering a PFPO insn in a client program while running on a host
that does not have that insn now causes an emulation error.
Previously, it caused a failing assertion which was incorrect.
Florian Krohm [Wed, 3 Dec 2014 22:53:00 +0000 (22:53 +0000)]
Add -Wformat -Wformat-security to the list of compile flags.
This was not as straight forward as expected. Specifically, adding the
new flag to CFLAGS in configure.ac did not work and was causing
compiler warnings. For instance, compiling memcheck/tests/execve2.c will
generate a -Wnonnull warning even though the testcase is explicitly
compiled with -Wno-nonnull. The reason is that (a) -Wformat is implied by
-Wnonnull and (b) the list of compiler flags gets assembled in the wrong
order. The culprit appears to be that we modify CFLAGS in configure.ac and
that really is not the right place. Conceptually, configure should determine
tool-chain capabilities and not assemble compiler flags. That should be done
in Makefiles. This patch entangles all this.
So, whatever was added to CFLAGS in configure.ac has now been moved to
Makefile.all.am and Makefile.tool-tests.am. Those are:
-Wno-long-long
-Wwrite-strings
-Wcast-qual
-fno-stack-protector
Note, that this change allows us to simplify Makefile.tool-tests.am which
in the past was disabling some of those flags (e.g. by adding -Wno-cast-qual
again).
In case of the clang compiler, extra command line options are needed. I've
moved those into a separate 'if COMPILER_IS_CLANG' section and not merge
them into baseline flags.
Florian Krohm [Sat, 29 Nov 2014 14:41:32 +0000 (14:41 +0000)]
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.
Florian Krohm [Sat, 29 Nov 2014 13:31:18 +0000 (13:31 +0000)]
Fix up the error processing in VG_(expand_file_name). E.g. giving
--log-file= on the command line results in the following error:
valgrind: --log-file: filename is emptyBad option: --log-file=
...
Relatedly, fix the 1st argument to VG_(expand_file_name) in coredump-elf.c.
This should not contain additional verbiage as it is assumed to be an option
name which us used to construct an error message containing
option_name=file_name
As an aside, this logic in coredump-elf.c seems odd:
If VG_(clo_log_fname_expanded) is not NULL, then it has already been
expanded in main_process_cmd_line_options. Expanding it again would only
make a difference, if the original logfile name contained an environment
variable whose value contained %q{whatever} thereby referring to a yet
another environment variable. That seems strange.
But I'm not touching it.
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.
Florian Krohm [Mon, 24 Nov 2014 17:30:01 +0000 (17:30 +0000)]
As the BEAM checker correctly points out, the conditions on lines 430 and 485
are always false. I'm keeping them as assertions for documentation purposes.
The proof is left as exercise to the reader.
Hint: use conditions on lines 307 and 311 and the fact that old_len and
old_arg are both unsigned entities.
Florian Krohm [Sat, 22 Nov 2014 20:10:21 +0000 (20:10 +0000)]
Add function s390_isel_amode_b12_b20 to compile an expression into an
amode that is either S390_AMODE_B12 or S390_AMODE_B20. This is needed
for compare-and-swap insns. As we're currently not generating amodes
using an index register, there was never a problem.
This change future-proofs the code.
Also add a few more asserts for amodes in the s390_insns supporting
translation chaining.
Fixes BZ #269360.
Florian Krohm [Thu, 20 Nov 2014 15:08:56 +0000 (15:08 +0000)]
This change was triggered by BZ #247974 which suggested to include
VEX/test_main.* in the tarball. We don't want to do that because those
files are really just scaffolding for developers to play with and not
meant for general consumption (and are also bitrotting ATM). Therefore,
this patch moves them to the "useful" subdirectory and adds a crude
Makefile there to build the executable.
Makefile-gcc updated accordingly.
Julian Seward [Wed, 19 Nov 2014 09:15:56 +0000 (09:15 +0000)]
Add a lot more intercepts. Very crude. I am sure this is merely
hiding a whole bunch of problems in the Darwin syscall wrappers. In
particular it suppresses all invalid address errors arising from
AppleIntelHD4000GraphicsGLDriver.dylib, as it appears that maps
hardware into user space and aspacemgr doesn't know anything about it.
Julian Seward [Sat, 15 Nov 2014 10:29:57 +0000 (10:29 +0000)]
* add a logging mechanism to show repeated messages at exponentially
declining rates, so as to reduce the amount of junk spewed out by
the various support functions for the MacOS syscall wrappers.
* add a couple more cases to the resync filter for Yosemite. This
is working pretty well now.
Florian Krohm [Thu, 13 Nov 2014 21:41:28 +0000 (21:41 +0000)]
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
* This option can be used to mark the begin/end of errors in textual
output mode, to facilitate searching/extracting errors in output files
mixing valgrind errors with program output.
* Use the new option in various existing regtests to test the various
possible usage.
Julian Seward [Tue, 11 Nov 2014 12:49:21 +0000 (12:49 +0000)]
Add a nasty temporary kludge to CPUID that allows 64-bit MacOSX 10.10
(Yosemite) to run, until such time as XSAVE and XRSTOR are implemented.
Detailed in the comments. All other targets should be unaffected.