]> git.ipfire.org Git - thirdparty/valgrind.git/log
thirdparty/valgrind.git
5 years agoImplement And1 and Or1 for the x86 insn selector.
Julian Seward [Fri, 22 Nov 2019 07:32:03 +0000 (08:32 +0100)] 
Implement And1 and Or1 for the x86 insn selector.

5 years agoTidy up ir_opt.c aspects relating to the 'grail' work. In particular:
Julian Seward [Thu, 21 Nov 2019 19:03:47 +0000 (20:03 +0100)] 
Tidy up ir_opt.c aspects relating to the 'grail' work.  In particular:

* Rewrite do_minimal_initial_iropt_BB so it doesn't do full constant folding;
  that is unnecessary expense at this point, and later passes will do it
  anyway

* do_iropt_BB: don't flatten the incoming block, because
  do_minimal_initial_iropt_BB will have run earlier and done so.  But at least
  for the moment, assert that it really is flat.

* VEX/priv/guest_generic_bb_to_IR.c create_self_checks_as_needed: generate
  flat IR so as not to fail the abovementioned assertion.

I believe this completes the target-independent aspects of this work, and also
the x86_64 specifics (of which there are very few).

5 years agoAdd statistics printing for the new trace construction algorithm.
Julian Seward [Thu, 21 Nov 2019 07:55:43 +0000 (08:55 +0100)] 
Add statistics printing for the new trace construction algorithm.

5 years agoAdd a change that should have been part of 6e4db6e9172a55a983105c8e73c89987ce97308a.
Julian Seward [Tue, 19 Nov 2019 07:20:31 +0000 (08:20 +0100)] 
Add a change that should have been part of 6e4db6e9172a55a983105c8e73c89987ce97308a.

5 years agoRationalise --vex-guest* flags in the new IRSB construction framework
Julian Seward [Mon, 18 Nov 2019 18:12:49 +0000 (19:12 +0100)] 
Rationalise --vex-guest* flags in the new IRSB construction framework

* removes --vex-guest-chase-cond=no|yes.  This was never used in practice.

* rename --vex-guest-chase-thresh=<0..99> to --vex-guest-chase=no|yes.  In
  otherwords, downgrade it from a numeric flag to a boolean one, that can
  simply disable all chasing if required.  (Some tools, notably Callgrind,
  force-disable block chasing, so this functionality at least needs to be
  retained).

5 years agoFold Iop_CmpEQ32x8(x,x) to all-1s ..
Julian Seward [Sat, 16 Nov 2019 07:30:10 +0000 (08:30 +0100)] 
Fold Iop_CmpEQ32x8(x,x) to all-1s ..

.. hence treating it as a dependency-breaking idiom.  Also handle the
resulting IRConst_V256(0xFFFFFFFF) in the amd64 insn selector.

5 years agoinsn_has_no_other_exits_or_PUTs_to_PC: also check Ist_PutI and Ist_Dirty for writes...
Julian Seward [Wed, 13 Nov 2019 14:45:11 +0000 (15:45 +0100)] 
insn_has_no_other_exits_or_PUTs_to_PC: also check Ist_PutI and Ist_Dirty for writes to the PC.

5 years agoanalyse_block_end: tidy this up ..
Julian Seward [Tue, 12 Nov 2019 19:16:54 +0000 (20:16 +0100)] 
analyse_block_end: tidy this up ..

.. and check more carefully for unexpected control flow in the blocks being
analysed.

5 years agoiselFltExpr_wrk: handle Iex_ITE, presumably caused by newly-created guarding machinery.
Julian Seward [Mon, 11 Nov 2019 16:06:54 +0000 (17:06 +0100)] 
iselFltExpr_wrk: handle Iex_ITE, presumably caused by newly-created guarding machinery.

5 years agoClean up machinery to do with conditionalising IRStmts:
Julian Seward [Mon, 11 Nov 2019 15:11:20 +0000 (16:11 +0100)] 
Clean up machinery to do with conditionalising IRStmts:

* document some functions

* change naming and terminology from 'speculation' (which it isn't)
  to 'guarding' (which it is)

* add a new function |primopMightTrap| so as to avoid conditionalising
  IRExprs involving potentially trappy IROps

5 years agoInitial implementation of C-source-level &&-idiom recovery
Julian Seward [Mon, 21 Oct 2019 09:19:59 +0000 (11:19 +0200)] 
Initial implementation of C-source-level &&-idiom recovery

This branch contains code which avoids Memcheck false positives resulting from
gcc and clang creating branches on uninitialised data.  For example:

   bool isClosed;
   if (src.isRect(..., &isClosed, ...) && isClosed) {

clang9 -O2 compiles this as:

   callq  7e7cdc0 <_ZNK6SkPath6isRectEP6SkRectPbPNS_9DirectionE>

   cmpb   $0x0,-0x60(%rbp)  // "if (isClosed) { .."
   je     7ed9e08           // "je after"

   test   %al,%al           // "if (return value of call is nonzero) { .."
   je     7ed9e08           // "je after"

   ..
   after:

That is, the && has been evaluated right-to-left.  This is a correct
transformation if the compiler can prove that the call to |isRect| returns
|false| along any path on which it does not write its out-parameter
|&isClosed|.

In general, for the lazy-semantics (L->R) C-source-level && operator, we have
|A && B| == |B && A| if you can prove that |B| is |false| whenever A is
undefined.  I assume that clang has some kind of interprocedural analysis that
tells it that.  The compiler is further obliged to show that |B| won't trap,
since it is now being evaluated speculatively, but that's no big deal to
prove.

A similar result holds, per de Morgan, for transformations involving the C
language ||.

Memcheck correctly handles bitwise &&/|| in the presence of undefined inputs.
It has done so since the beginning.  However, it assumes that every
conditional branch in the program is important -- any branch on uninitialised
data is an error.  However, this idiom demonstrates otherwise.  It defeats
Memcheck's existing &&/|| handling because the &&/|| is spread across two
basic blocks, rather than being bitwise.

This initial commit contains a complete initial implementation to fix that.
The basic idea is to detect the && condition spread across two blocks, and
transform it into a single block using bitwise &&.  Then Memcheck's existing
accurate instrumentation of bitwise && will correctly handle it.  The
transformation is

   <contents of basic block A>
   C1 = ...
   if (!C1) goto after
   .. falls through to ..

   <contents of basic block B>
   C2 = ...
   if (!C2) goto after
   .. falls through to ..

   after:

 ===>

   <contents of basic block A>
   C1 = ...
   <contents of basic block B, conditional on C1>
   C2 = ...
   if (!C1 && !C2) goto after
   .. falls through to ..

   after:

This assumes that <contents of basic block B> can be conditionalised, at the
IR level, so that the guest state is not modified if C1 is |false|.  That's
not possible for all IRStmt kinds, but it is possible for a large enough
subset to make this transformation feasible.

There is no corresponding transformation that recovers an || condition,
because, per de Morgan, that merely corresponds to swapping the side exits vs
fallthoughs, and inverting the sense of the tests, and the pattern-recogniser
as implemented checks all possible combinations already.

The analysis and block-building is performed on the IR returned by the
architecture specific front ends.  So they are almost not modified at all: in
fact they are simplified because all logic related to chasing through
unconditional and conditional branches has been removed from them, redone at
the IR level, and centralised.

The only file with big changes is the IRSB constructor logic,
guest_generic_bb_to_IR.c (a.k.a the "trace builder").  This is a complete
rewrite.

There is some additional work for the IR optimiser (ir_opt.c), since that
needs to do a quick initial simplification pass of the basic blocks, in order
to reduce the number of different IR variants that the trace-builder has to
pattern match on.  An important followup task is to further reduce this cost.

There are two new IROps to support this: And1 and Or1, which both operate on
Ity_I1.  They are regarded as evaluating both arguments, consistent with AndXX
and OrXX for all other sizes.  It is possible to synthesise at the IR level by
widening the value to Ity_I8 or above, doing bitwise And/Or, and re-narrowing
it, but this gives inefficient code, so I chose to represent them directly.

The transformation appears to work for amd64-linux.  In principle -- because
it operates entirely at the IR level -- it should work for all targets,
providing the initial pre-simplification pass can normalise the block ends
into the required form.  That will no doubt require some tuning.  And1 and Or1
will have to be implemented in all instruction selectors, but that's easy
enough.

Remaining FIXMEs in the code:

* Rename `expr_is_speculatable` et al to `expr_is_conditionalisable`.  These
  functions merely conditionalise code; the speculation has already been done
  by gcc/clang.

* `expr_is_speculatable`: properly check that Iex_Unop/Binop don't contain
  operatins that might trap (Div, Rem, etc).

* `analyse_block_end`: recognise all block ends, and abort on ones that can't
  be recognised.  Needed to ensure we don't miss any cases.

* maybe: guest_amd64_toIR.c: generate better code for And1/Or1

* ir_opt.c, do_iropt_BB: remove the initial flattening pass since presimp
  will already have done it

* ir_opt.c, do_minimal_initial_iropt_BB (a.k.a. presimp).  Make this as
  cheap as possible.  In particular, calling `cprop_BB_wrk` is total overkill
  since we only need copy propagation.

* ir_opt.c: once the above is done, remove boolean parameter for `cprop_BB_wrk`.

* ir_opt.c: concatenate_irsbs: maybe de-dup w.r.t. maybe_unroll_loop_BB.

* remove option `guest_chase_cond` from VexControl (?).  It was never used.

* convert option `guest_chase_thresh` from VexControl (?) into a Bool, since
the revised code here only cares about the 0-vs-nonzero distinction now.

5 years agoRemove some trailing whitespaces ...
Philippe Waroquiers [Sat, 19 Oct 2019 15:47:35 +0000 (17:47 +0200)] 
Remove some trailing whitespaces ...

5 years agoEnhance callgrind option --collect-system.
Philippe Waroquiers [Thu, 10 Oct 2019 19:42:01 +0000 (21:42 +0200)] 
Enhance callgrind option --collect-system.

  - The command option --collect-systime has been enhanced to specify
    the unit used to record the elapsed time spent during system calls.
    The command option now accepts the values no|yes|msec|usec|nsec,
    where yes is a synonym of msec.  When giving the value nsec, the
    system cpu time of system calls is also recorded.

Note that the nsec option is not supported on Darwin.

5 years agoxb monitor command: fix adressability for first byte of a line
Philippe Waroquiers [Sat, 28 Sep 2019 20:18:23 +0000 (22:18 +0200)] 
xb monitor command: fix adressability for first byte of a line

The addressability of the first byte of a new line was used for the first
byte of the previous line.

Fix by first outputting the line, then getting the addressability of
the first byte of the new line.

5 years agomips64: add missing syscall values for N32
Petar Jovanovic [Thu, 26 Sep 2019 15:21:34 +0000 (15:21 +0000)] 
mips64: add missing syscall values for N32

Add missing syscall values for N32.
This fixes build issue with MIPS64 N32.

5 years agomips64: fix do_syscall_WRK for N32
Petar Jovanovic [Thu, 26 Sep 2019 15:18:34 +0000 (15:18 +0000)] 
mips64: fix do_syscall_WRK for N32

Load correctly pointer to V1_A3_val on N32.

Patch by Stefan Maksimovic.

5 years agoinclude/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64
Eugene Syromyatnikov [Fri, 8 Mar 2019 03:07:00 +0000 (04:07 +0100)] 
include/vki: fix vki_siginfo_t definition on amd64, arm64, and ppc64

As it turned out, the size of vki_siginfo_t is incorrect on these 64-bit
architectures:

    (gdb) p sizeof(vki_siginfo_t)
    $1 = 136
    (gdb) ptype struct vki_siginfo
    type = struct vki_siginfo {
        int si_signo;
        int si_errno;
        int si_code;
        union {
            int _pad[29];
            struct {...} _kill;
            struct {...} _timer;
            struct {...} _rt;
            struct {...} _sigchld;
            struct {...} _sigfault;
            struct {...} _sigpoll;
        } _sifields;
    }

It looks like that for this architecture, __VKI_ARCH_SI_PREAMBLE_SIZE
hasn't been defined properly, which resulted in incorrect
VKI_SI_PAD_SIZE calculation (29 instead of 28).

    <6a9e4>   DW_AT_name        : (indirect string, offset: 0xcf59): _sifields
    <6a9ef>   DW_AT_data_member_location: 16

This issue has been discovered with strace's "make check-valgrind-memcheck",
which produced false out-of-bounds writes on ptrace(PTRACE_GETSIGINFO) calls:

    SYSCALL[24264,1](101) sys_ptrace ( 16898, 24283, 0x0, 0x606bd40 )
    ==24264== Syscall param ptrace(getsiginfo) points to unaddressable byte(s)
    ==24264==    at 0x575C06E: ptrace (ptrace.c:45)
    ==24264==    by 0x443244: next_event (strace.c:2431)
    ==24264==    by 0x443D30: main (strace.c:2845)
    ==24264==  Address 0x606bdc0 is 0 bytes after a block of size 144 alloc'd

(Note that the address passed is 0x606bd40 and the address reported is
0x606bdc0).

After the patch, no such errors observed.

* include/vki/vki-amd64-linux.h [__x86_64__ && __ILP32__]
(__vki_kernel_si_clock_t): New typedef.
[__x86_64__ && __ILP32__] (__VKI_ARCH_SI_CLOCK_T,
__VKI_ARCH_SI_ATTRIBUTES): New macros.
[__x86_64__ && !__ILP32__] (__VKI_ARCH_SI_PREAMBLE_SIZE): New macro,
define to 4 ints.
* include/vki/vki-arm64-linux.h (__VKI_ARCH_SI_PREAMBLE_SIZE): Likewise.
* include/vki/vki-ppc64-linux.h [__powerpc64__] (__VKI_ARCH_SI_PREAMBLE_SIZE):
Likewise.
* include/vki/vki-linux.h [!__VKI_ARCH_SI_CLOCK_T]
(__VKI_ARCH_SI_CLOCK_T): New macro, define to vki_clock_t.
[!__VKI_ARCH_SI_ATTRIBUTES] (__VKI_ARCH_SI_ATTRIBUTES): New macro,
define to nil.
(struct vki_siginfo): Use __VKI_ARCH_SI_CLOCK_T type for _utime and
_stime fields.  Add __VKI_ARCH_SI_ATTRIBUTES.

Resolves: https://bugs.kde.org/show_bug.cgi?id=405201
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Eugene Syromyatnikov <evgsyr@gmail.com>
5 years agoHave VG_(is_in_syscall) return False if no syscall was done yet.
Philippe Waroquiers [Tue, 10 Sep 2019 20:47:58 +0000 (22:47 +0200)] 
Have VG_(is_in_syscall) return False if no syscall was done yet.

As when no syscall was done yet, the syscallInfo pointer is still null,
we return False if this is null, rather than SEGV due to null ptr.

This can at least happen when reporting the scheduler status before
the first syscall was done.

5 years agoremove CRLF line terminators from several files
Petar Jovanovic [Tue, 3 Sep 2019 12:20:10 +0000 (12:20 +0000)] 
remove CRLF line terminators from several files

Convert from dos to unix text files:

./none/tests/amd64-linux/cet_nops_fs.c
./none/tests/amd64-linux/cet_nops_gs.c
./none/tests/mips32/mips32_dspr2.c
./none/tests/mips32/mips32_dsp.c

5 years agomips: Add nanoMIPS support to Valgrind 2/4
Petar Jovanovic [Tue, 3 Sep 2019 11:55:56 +0000 (11:55 +0000)] 
mips: Add nanoMIPS support to Valgrind 2/4

Necessary changes to support nanoMIPS on Linux.

Part 2/4 - Coregrind changes

Patch by Aleksandar Rikalo, Dimitrije Nikolic, Tamara Vlahovic and
Aleksandra Karadzic.

Related KDE issue: #400872.

5 years agoAnnounce fix 411134 Allow the user to change a set of command line options during...
Philippe Waroquiers [Sat, 31 Aug 2019 13:15:26 +0000 (15:15 +0200)] 
Announce fix 411134  Allow the user to change a set of command line options during execution

Note that the fix for 411134 contains a bunch of white space only changes.
To see the diff without the white spaces, do:
  git diff -w 3a803036^..3a803036

5 years agoAllow the user to change a set of command line options during execution.
Philippe Waroquiers [Wed, 21 Aug 2019 12:33:39 +0000 (14:33 +0200)] 
Allow the user to change a set of command line options during execution.

This patch changes the option parsing framework to allow a set of
core or tool (currently only memcheck) options to be changed dynamically.

Here is a summary of the new functionality (extracted from NEWS):
* It is now possible to dynamically change the value of many command
  line options while your program (or its children) are running under
  Valgrind.
  To have the list of dynamically changeable options, run
     valgrind --help-dyn-options
  You can change the options from the shell by using vgdb to launch
  the monitor command "v.clo <clo option>...".
  The same monitor command can be used from a gdb connected
  to the valgrind gdbserver.
  Your program can also change the dynamically changeable options using
  the client request VALGRIND_CLO_CHANGE(option).

Here is a brief description of the code changes.
* the command line options parsing macros are now checking a 'parsing' mode
  to decide if the given option must be handled or not.
  (more about the parsing mode below).

* the 'main' command option parsing code has been split in a function
  'process_option' that can be called now by:
     - early_process_cmd_line_options
        (looping over args, calling process_option in mode "Early")
     - main_process_cmd_line_options
        (looping over args, calling process_option in mode "Processing")
     - the new function VG_(process_dynamic_option) called from
       gdbserver or from VALGRIND_CLO_CHANGE (calling
        process_option in mode "Dynamic" or "Help")

* So, now, during startup, process_option is called twice for each arg:
   - once during Early phase
   - once during normal Processing
  Then process_option can then be called again during execution.

So, the parsing mode is defined so that the option parsing code
behaves differently (e.g. allows or not to handle the option)
depending on the mode.

// Command line option parsing happens in the following modes:
//   cloE : Early processing, used by coregrind m_main.c to parse the
//      command line  options that must be handled early on.
//   cloP : Processing,  used by coregrind and tools during startup, when
//      doing command line options Processing.
//   clodD : Dynamic, used to dynamically change options after startup.
//      A subset of the command line options can be changed dynamically
//      after startup.
//   cloH : Help, special mode to produce the list of dynamically changeable
//      options for --help-dyn-options.
typedef
   enum {
      cloE = 1,
      cloP = 2,
      cloD = 4,
      cloH = 8
   } Clo_Mode;

The option parsing macros in pub_tool_options.h have now all a new variant
*_CLOM with the mode(s) in which the given option is accepted.
The old variant is kept and calls the new variant with mode cloP.
The function VG_(check_clom) in the macro compares the current mode
with the modes allowed for the option, and returns True if qq_arg
should be further processed.

For example:

// String argument, eg. --foo=yes or --foo=no
   (VG_(check_clom)                                                     \
    (qq_mode, qq_arg, qq_option,                                        \
     VG_STREQN(VG_(strlen)(qq_option)+1, qq_arg, qq_option"=")) &&      \
    ({const HChar* val = &(qq_arg)[ VG_(strlen)(qq_option)+1 ];         \
      if      VG_STREQ(val, "yes") (qq_var) = True;                     \
      else if VG_STREQ(val, "no")  (qq_var) = False;                    \
      else VG_(fmsg_bad_option)(qq_arg, "Invalid boolean value '%s'"    \
                                " (should be 'yes' or 'no')\n", val);   \
      True; }))

   VG_BOOL_CLOM(cloP, qq_arg, qq_option, qq_var)

To make an option dynamically excutable, it is typically enough to replace
    VG_BOOL_CLO(...)
by
    VG_BOOL_CLOM(cloPD, ...)

For example:
-   else if VG_BOOL_CLO(arg, "--show-possibly-lost", tmp_show) {
+   else if VG_BOOL_CLOM(cloPD, arg, "--show-possibly-lost", tmp_show) {

cloPD means the option value is set/changed during the main command
Processing (P) and Dynamically during execution (D).

Note that the 'body/further processing' of a command is only executed when
the option is recognised and the current parsing mode is ok for this option.

5 years agoarm64 fixup for statx support on older kernels
Mark Wielaard [Fri, 23 Aug 2019 20:17:57 +0000 (22:17 +0200)] 
arm64 fixup for statx support on older kernels

Turns out (older) arm64 linux kernels don't have statx, but also not
stat64 and no stat syscalls.  It uses fstatat instead. The new statx
patch also added a check for stat.  So That needs a special case for
arm64.

Follow up for bug #400593.

5 years agomips: Add nanoMIPS support to Valgrind 1/4
Petar Jovanovic [Wed, 21 Aug 2019 16:08:42 +0000 (16:08 +0000)] 
mips: Add nanoMIPS support to Valgrind 1/4

Necessary changes to support nanoMIPS on Linux.

Part 1/4 - VEX changes

Patch by Aleksandar Rikalo, Dimitrije Nikolic, Tamara Vlahovic and
Aleksandra Karadzic.

nanoMIPS architecture in brief

Designed for embedded devices, nanoMIPS is a variable lengths instruction
set architecture (ISA) offering high performance in substantially reduced
code size.

The nanoMIPS ISA combines recoded and new 16-, 32-, and 48-bit instructions
to achieve an ideal balance of performance and code density.
It incorporates all MIPS32 instructions and architecture modules including
MIPS DSP and MIPS MT, as well as new instructions for advanced code size
reduction.

nanoMIPS is supported in release 6 of the MIPS architecture. It is first
implemented in the new MIPS I7200 multi-threaded multi-core processor
series. Compiler support is included in the MIPS GNU-based development
tools.

Related KDE issue: #400872.

5 years agomips32: hook up vmsplice syscall
Petar Jovanovic [Wed, 21 Aug 2019 12:47:11 +0000 (12:47 +0000)] 
mips32: hook up vmsplice syscall

Hook up vmsplice syscall for mips32.

This fixes vmsplice01 failure in the LTP test suite.

5 years agomips32: hook up vhangup syscall
Petar Jovanovic [Tue, 20 Aug 2019 13:30:45 +0000 (13:30 +0000)] 
mips32: hook up vhangup syscall

Hook up vhangup syscall for mips32.

This fixes vhangup01 in the LTP test suite.

5 years agomips32: hook up utimes syscall
Petar Jovanovic [Tue, 20 Aug 2019 13:17:02 +0000 (13:17 +0000)] 
mips32: hook up utimes syscall

Hook up utimes syscall for mips32.

This fixes utimes01 in the LTP test suite.

5 years agomips32: hook up unshare syscall
Petar Jovanovic [Tue, 20 Aug 2019 12:41:59 +0000 (12:41 +0000)] 
mips32: hook up unshare syscall

Hook up unshare syscall for mips32.

This fixes unshare02 in the LTP test suite.

5 years agomips32: hook up truncate64 syscall
Petar Jovanovic [Tue, 20 Aug 2019 12:29:57 +0000 (12:29 +0000)] 
mips32: hook up truncate64 syscall

Hook up truncate64 syscall for mips32.

This helps truncate02_64 and several other tests pass without warnings in
the LTP test suite.

5 years agomips32: hook up getitimer syscall
Petar Jovanovic [Mon, 19 Aug 2019 17:37:17 +0000 (17:37 +0000)] 
mips32: hook up getitimer syscall

Hook up getitimer syscall for mips32.

This fixes getitimer01 and several other tests in the LTP test suite.

5 years agomips32: hook up sethostname syscall
Petar Jovanovic [Mon, 19 Aug 2019 17:23:58 +0000 (17:23 +0000)] 
mips32: hook up sethostname syscall

Hook up sethostname syscall for mips32.

This fixes sethostname01 and several other tests in the LTP test suite.

5 years agoupdate NEWS with fix for #400593
Petar Jovanovic [Mon, 19 Aug 2019 14:38:34 +0000 (14:38 +0000)] 
update NEWS with fix for #400593

The KDE issue #400593 has been fixed in

  commit c6a6cf929f3e2a9bf5d7f09f334ed4d67f2d6e18
  Use statx rather than other stat system calls

5 years agoBug 400538 - vex amd64->IR: unhandled instruction bytes: 0x48 0xCF (IRETQ).
Julian Seward [Mon, 19 Aug 2019 14:03:01 +0000 (16:03 +0200)] 
Bug 400538 - vex amd64->IR: unhandled instruction bytes: 0x48 0xCF (IRETQ).

Patch from Daniel Lehman <dlehman25@gmail.com>.

5 years agoFix README_DEVELOPERS tool executable in debugging instruction examples.
Philippe Waroquiers [Sun, 18 Aug 2019 22:26:18 +0000 (00:26 +0200)] 
Fix README_DEVELOPERS tool executable in debugging instruction examples.

5 years agoFix compilation problem when __NR_preadv2 __NR_pwritev2 are undefined
Philippe Waroquiers [Sat, 17 Aug 2019 16:27:22 +0000 (18:27 +0200)] 
Fix compilation problem when __NR_preadv2 __NR_pwritev2 are undefined

check_preadv2_pwritev2.c: In function ‘main’:
check_preadv2_pwritev2.c:12:12: error: ‘__NR_preadv2’ undeclared (first use in this function)
    syscall(__NR_preadv2, 0, NULL, 0, 0, 0);
            ^
check_preadv2_pwritev2.c:12:12: note: each undeclared identifier is reported only once for each function it appears in
check_preadv2_pwritev2.c:15:12: error: ‘__NR_pwritev2’ undeclared (first use in this function)
    syscall(__NR_pwritev2, 0, NULL, 0, 0, 0);

5 years agomemcheck/tests/sys-preadv2_pwritev2: Check whether these syscalls are supported
Stefan Maksimovic [Fri, 16 Aug 2019 23:23:21 +0000 (16:23 -0700)] 
memcheck/tests/sys-preadv2_pwritev2: Check whether these syscalls are supported

[ bvanassche: changed the order of check_PROGRAMS ]

5 years agoUpdate s390x maintainership in AUTHORS
Andreas Arnez [Fri, 16 Aug 2019 18:06:53 +0000 (20:06 +0200)] 
Update s390x maintainership in AUTHORS

I have taken over maintainership of the s390x support some time ago.
Update the AUTHORS file to reflect that.

5 years agoUse statx rather than other stat system calls
Petar Jovanovic [Fri, 16 Aug 2019 15:57:50 +0000 (15:57 +0000)] 
Use statx rather than other stat system calls

*STAT* system calls other than statx are becoming deprecated.
Coregrind should use statx as the first candidate in order to achieve
"stat" functionality.

There are also systems that do not even support older "stats".

This fixes KDE #400593.

Patch by Aleksandar Rikalo.

5 years agoMake references from README_DEVELOPERS/README.solaris to README for build/install
Philippe Waroquiers [Thu, 15 Aug 2019 14:54:05 +0000 (16:54 +0200)] 
Make references from README_DEVELOPERS/README.solaris to README for build/install

If someone wants to build/install and starts in these 2 files,
a reference to the README instructions is helpful.

5 years agomips32: hook up sched_rr_get_interval syscall
Petar Jovanovic [Wed, 14 Aug 2019 15:43:10 +0000 (15:43 +0000)] 
mips32: hook up sched_rr_get_interval syscall

Hook up sched_rr_get_interval syscall for mips32.

This fixes sched_rr_get_interval01 and several other tests in the LTP test
suite.

5 years agomips32: hook up sched_setparam syscall
Petar Jovanovic [Wed, 14 Aug 2019 15:36:07 +0000 (15:36 +0000)] 
mips32: hook up sched_setparam syscall

Hook up sched_setparam syscall for mips32.

This fixes sched_setparam01 and several other tests in the LTP test suite.

5 years agomips: hook up tee syscall correctly
Petar Jovanovic [Wed, 14 Aug 2019 15:27:25 +0000 (15:27 +0000)] 
mips: hook up tee syscall correctly

Hook up sys_tee for mips32 and mips64 correctly.
For mips64, it is just a simplification to use generic linux implementation.

This fixes tee01 test in the LTP test suite for mips32.

5 years agoupdate .gitignore with memcheck/tests/linux/sys-preadv* files
Petar Jovanovic [Wed, 14 Aug 2019 15:18:13 +0000 (15:18 +0000)] 
update .gitignore with memcheck/tests/linux/sys-preadv* files

Add
   memcheck/tests/linux/sys-preadv2_pwritev2
   memcheck/tests/linux/sys-preadv_pwritev

to .gitignore.

5 years agomake pth_self_kill_15_other test deterministic
Petar Jovanovic [Tue, 13 Aug 2019 14:51:37 +0000 (14:51 +0000)] 
make pth_self_kill_15_other test deterministic

Modify the pth_self_kill_15_other test to make its behaviour deterministic
by introducing a pthread_join call. Do so by modifying the signal handler
for SIGTERM for the spawned thread which would issue the pthread_join call
prior to exiting.

This fixes KDE #410599.

Patch by Stefan Maksimovic.

5 years agomips32: add sync_file_range syscall support
Petar Jovanovic [Tue, 13 Aug 2019 14:30:30 +0000 (14:30 +0000)] 
mips32: add sync_file_range syscall support

Hook up sync_file_range for mips32.

Along with the change for passing 7th argument in syscalls, this will fix
sync_file_range01 failure within LTP test suite.

Patch by Nikola Milutinovic.

5 years agomips: pass 7th argument in syscalls
Petar Jovanovic [Tue, 13 Aug 2019 12:19:30 +0000 (12:19 +0000)] 
mips: pass 7th argument in syscalls

Only arg1 to arg6 have been passed down to kernel for syscalls.
This patch ensures that arg7 is also passed down for syscalls.
In addition to this, ensure that we have 16-byte aligned stack during
mips64 syscall.

Along with the change for sync_file_range, this will fix sync_file_range01
failure within LTP test suite.

Patch by Nikola Milutinovic.

5 years agomips: hook up splice syscall correctly
Petar Jovanovic [Mon, 5 Aug 2019 16:28:48 +0000 (16:28 +0000)] 
mips: hook up splice syscall correctly

Hook up splice syscall for mips32 and mips64 correctly.
This fixes splice01 and several other tests in the LTP test suite.

5 years agomips32: hook up lsetxattr syscall
Petar Jovanovic [Mon, 5 Aug 2019 16:00:45 +0000 (16:00 +0000)] 
mips32: hook up lsetxattr syscall

Hook up lsetxattr syscall for mips32.
This fixes llistxattr01 and several other tests in the LTP test suite.

5 years agos390x: Fix vector facility (vx) check in test suite
Andreas Arnez [Tue, 6 Aug 2019 16:29:46 +0000 (18:29 +0200)] 
s390x: Fix vector facility (vx) check in test suite

When checking the prereqisuites of running a vector test case, it is not
sufficient to check for the appropriate CPU facility bit.  It must also be
verified that the kernel and hypervisor(s) have actually enabled the
vector facility.  There are various ways of checking this.  E.g., we could
try executing a vector instruction and handle any signals.  Or we can
check the HWCAP for the appropriate bit.  This patch does the latter.

6 years agomips32: hook up fsetxattr syscall
Petar Jovanovic [Fri, 2 Aug 2019 16:56:25 +0000 (16:56 +0000)] 
mips32: hook up fsetxattr syscall

Hook up fsetxattr syscall for mips32.
This fixes fgetxattr03 and several other tests in the LTP test suite.

6 years agomips32: enable support for setxattr
Petar Jovanovic [Tue, 23 Jul 2019 13:24:16 +0000 (13:24 +0000)] 
mips32: enable support for setxattr

Enable support for setxattr syscall for mips32.

6 years agomips: hook up preadv, preadv2, pwritev and pwritev2 correctly
Petar Jovanovic [Mon, 22 Jul 2019 17:56:33 +0000 (19:56 +0200)] 
mips: hook up preadv, preadv2, pwritev and pwritev2 correctly

Use the correct generic linux sys wrapper.

Follow-up for

  commit b0861063a8d2a55bb7423e90d26806bab0f78a12
  Author: Alexandra Hajkova <ahajkova@redhat.com>
  Date:   Tue Jun 4 13:47:14 2019 +0200

    Add support for preadv2 and pwritev2 syscalls

This should fix
memcheck/tests/linux/sys-preadv2_pwritev2 (stderr)
memcheck/tests/linux/sys-preadv_pwritev  (stderr)

on mips32/mips64.

6 years agoUpdate references to non-existent configure.in
Andrew Gaul [Sun, 14 Jul 2019 04:54:50 +0000 (21:54 -0700)] 
Update references to non-existent configure.in

6 years agoBug 350228 - Unhandled ioctl 0x6458 (i965/mesa). Patch from austinenglish@gmail...
Julian Seward [Thu, 11 Jul 2019 15:46:47 +0000 (17:46 +0200)] 
Bug 350228 - Unhandled ioctl 0x6458 (i965/mesa).  Patch from austinenglish@gmail.com.

6 years agoFix 409141 and 409367: valgrind hangs or loops when a process sends a signal to itself.
Philippe Waroquiers [Tue, 2 Jul 2019 19:43:41 +0000 (21:43 +0200)] 
Fix 409141 and 409367: valgrind hangs or loops when a process sends a signal to itself.

The loop scenario:
  The main thread sends a signal 15 to another thread, and then calls the exit syscall.
  The exit syscall done by thread 1 marks all threads as needing
  to die using exitreason VgSrc_ExitProcess.
  The main thread then gets all other threads out of their blocking syscall
  to let them die, and then "busy polls" for all other threads to disappear.
  However, when the second thread is out of its syscall, it gets the signal 15,
  which is a fatal signal.  This second thread then changes the exit reason
  of all threads to VgSrc_FatalSig, and itself starts to busy poll for all
  other threads to disappear.
  This then loops forever.

  The fix for this consists in not handling the fatal signal in the
  second thread when the process is already busy dying.  Effectively,
  the exit syscall should be processed "atomically": either the process
  is running, or it is dead once the syscall is done.
  Under valgrind, when threads are marked as being ' VgSrc_ExitProcess',
  the guest process should be considered as dead.  Valgrind has still to do
  the cleanup, the endof run report, etc  but otherwise should not let
  any more user code to run.  So, signal should not be handled anymore
  once the 'exit syscall' has marked all threads as VgSrc_ExitProcess.

The hang scenario:
  The main thread sends a signal 9 (KILL) to itself.
  When running natively, this directly kills the process,
  without giving any opportunity to run some user code.
  Valgrind intercepts the kill syscall, and detects that this is
  a fatal signal.  The main thread was then dying, but was
  not getting the other threads out of their syscall (to let them die).

  The fix for this is to have the 'handling' of the signal 9 sent to a
  thread of the process to directly make the process die, by getting
  all threads out of syscall.
  Note that the previous code was trying to have this action done by
  the thread to which the signal 9 was sent.  This was too tricky to
  keep (causing other race conditions between the main thread sending
  the signal 9 e.g. exiting and the other thread supposed to die).
  As it is not particularly critical to have the signal 9 'handled'
  by a specific thread, the thread that is sending the signal 9 is
  the one doing the work to cleanup and terminate the process.

6 years agoHook up preadv2 and pwritev2 correctly for arm64.
Mark Wielaard [Wed, 3 Jul 2019 08:27:17 +0000 (10:27 +0200)] 
Hook up preadv2 and pwritev2 correctly for arm64.

Use the correct generic linux sys wrapper.

Followup for https://bugs.kde.org/408414

6 years agoAdd support for preadv2 and pwritev2 syscalls
Alexandra Hájková [Tue, 4 Jun 2019 11:47:14 +0000 (13:47 +0200)] 
Add support for preadv2 and pwritev2 syscalls

Support for amd64, x86 - 64 and 32 bit, arm64, ppc64, ppc64le,
s390x, mips64. This should work identically on all
arches, tested on x86 32bit and 64bit one, but enabled on all.

Refactor the code to be reusable between old/new syscalls. Resolve TODO
items in the code. Add the testcase for the preadv2/pwritev2 and also
add the (similar) testcase for the older preadv/pwritev syscalls.

Trying to test handling an uninitialized flag argument for the v2 syscalls
does not work because the flag always comes out as defined zero.
Turns out glibc does this deliberately on 64bit architectures because
the kernel does actually have a low_offset and high_offset argument, but
ignores the high_offset/assumes it is zero.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=601cc11d054ae4b5e9b5babec3d8e4667a2cb9b5

https://bugs.kde.org/408414

6 years agoAdd support for the Linux io_uring system calls
Bart Van Assche [Mon, 1 Jul 2019 22:09:04 +0000 (15:09 -0700)] 
Add support for the Linux io_uring system calls

Man pages and test code are available in the following git repository:

http://git.kernel.dk/cgit/liburing/

6 years agoUpdate Linux x86 system call number definitions
Bart Van Assche [Mon, 1 Jul 2019 22:01:59 +0000 (15:01 -0700)] 
Update Linux x86 system call number definitions

Introduce new header files for the system call numbers that are shared
across all Linux architectures and also for the system call numbers that
are shared across all 32-bit architectures.

6 years agoReplace 'error' by 'warning' when a signal cannot be translated to the gdb nr.
Philippe Waroquiers [Tue, 25 Jun 2019 20:49:29 +0000 (22:49 +0200)] 
Replace 'error' by 'warning' when a signal cannot be translated to the gdb nr.

As 'error' is supposed to be called only to go back at gdbserver toplevel,
and such signal translations can be called during tracing, when
gdbserver is not active : 'error' then tries to longjmp using a
not initialised longjmp buffer.

(reproduced by activating the trace with the test case attached in
bug 409141 - Valgrind hangs when SIGKILLed).

6 years agoFix makefile consistency check
Petar Jovanovic [Fri, 14 Jun 2019 14:14:05 +0000 (14:14 +0000)] 
Fix makefile consistency check

Add ecag.stdout.exp-z14 to EXTRA_DIST.

6 years agomips: fix compiler warnings about unused variables
Petar Jovanovic [Fri, 14 Jun 2019 14:11:54 +0000 (14:11 +0000)] 
mips: fix compiler warnings about unused variables

Patch by Mark Wielaard.

6 years agoFix memcheck/tests/leak_cpp_interior failure on 32-bit platforms
Petar Jovanovic [Fri, 14 Jun 2019 10:09:19 +0000 (10:09 +0000)] 
Fix memcheck/tests/leak_cpp_interior failure on 32-bit platforms

Update expected file for 32-bit platforms.
This is a follow up to:

commit bc758374a25e5cfb1a7c11f3ac3b0e31217746a5
Author: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date:   Sat May 18 12:10:40 2019 +0200

    Add a test for the new gdbserver adddress[length] syntax.

6 years agoBug 404406 - s390x: test z14 miscellaneous instructions
Ilya Leoshkevich [Thu, 16 May 2019 10:34:38 +0000 (12:34 +0200)] 
Bug 404406 - s390x: test z14 miscellaneous instructions

Reuse the existing infrastructure for add, sub and mul.
Add cc checks to all mul tests.
Write a new test for bic.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
6 years agoBug 404406 - s390x: implement z14 miscellaneous instructions
Ilya Leoshkevich [Thu, 16 May 2019 10:34:37 +0000 (12:34 +0200)] 
Bug 404406 - s390x: implement z14 miscellaneous instructions

(from bug 404406 comment 0):
Valgrind on s390x currently lacks support for the miscellaneous
instruction extensions facility 2.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
6 years agos390x: Clean up s390-check-opcodes.pl
Andreas Arnez [Tue, 14 May 2019 15:19:34 +0000 (17:19 +0200)] 
s390x: Clean up s390-check-opcodes.pl

Fix false positives when invoking s390-check-opcodes.pl.  Also clean up
some code formatting issues in that script.  Add the instructions TPEI and
IRBM to guest_s390_toIR.c and s390-opcodes.csv, so they are not longer
warned about.

6 years agos390x: Add models "z14" and "z14 ZR1"
Andreas Arnez [Tue, 2 Oct 2018 11:47:50 +0000 (13:47 +0200)] 
s390x: Add models "z14" and "z14 ZR1"

Add IBM z14 and IBM z14 ZR1 to the list of known machine models.  Add an
expected output variant for z14 to the s390x-specific "ecag" test case.
In README.s390, refer to a current version of the z/Architecture
Principles of Operation that describes the instructions introduced with
IBM z14.

6 years agolinux x86 and amd64 memory protection key syscalls.
Mark Wielaard [Wed, 29 May 2019 22:29:58 +0000 (00:29 +0200)] 
linux x86 and amd64 memory protection key syscalls.

This implements minimal support for the pkey_alloc, pkey_free and
pkey_mprotect syscalls. pkey_alloc will simply indicate that pkeys
are not supported. pkey_free always fails. pkey_mprotect works just
like mprotect if the special pkey -1 is provided.

https://bugs.kde.org/show_bug.cgi?id=408091

6 years agoDocument that --xml=yes automatically activates --leak-check=full
Philippe Waroquiers [Sun, 2 Jun 2019 19:01:36 +0000 (21:01 +0200)] 
Document that --xml=yes automatically activates --leak-check=full

6 years agoHook up membarrier syscall for arm-linux.
Mark Wielaard [Fri, 31 May 2019 13:11:35 +0000 (15:11 +0200)] 
Hook up membarrier syscall for arm-linux.

6 years agoFix -Wdiscarded-qualifiers warnings in launcher-linux.c
Mark Wielaard [Thu, 30 May 2019 01:40:56 +0000 (03:40 +0200)] 
Fix -Wdiscarded-qualifiers warnings in launcher-linux.c

commit f15bee "Fix memory leak in launcher-linux.c" introduced some
warnings about passing const pointers to free.

    warning: passing argument 1 of ‘free’ discards ‘const’ qualifier from
    pointer target type [-Wdiscarded-qualifiers]

This was because that code was a little too "smart". The compiler cannot
know that we really only call free () when the pointer was dynamically
allocated. Simplify the code a little to just always allocate a new
string in find_client and always free that string in select_platform.

6 years agoExpose rdrand and f16c through cpuid also if the host only has avx.
Mark Wielaard [Mon, 27 May 2019 20:19:27 +0000 (22:19 +0200)] 
Expose rdrand and f16c through cpuid also if the host only has avx.

The amd64 CPUID dirtyhelpers are mostly static since they emulate some
existing CPU "family". The avx2 ("i7-4910MQ") CPUID variant however
can "dynamicly" enable rdrand and/or f16c if the host supports them.
Do the same for the avx_and_cx16 ("i5-2300") CPUID variant.

https://bugs.kde.org/show_bug.cgi?id=408009

6 years agoPPC64, Update testcases for vlogefp, vexptefp instructions
Carl Love [Tue, 28 May 2019 19:03:59 +0000 (14:03 -0500)] 
PPC64, Update testcases for vlogefp, vexptefp instructions

https://bugs.kde.org/show_bug.cgi?id=407340

6 years agoPPC64, Add support for vlogefp, vexptefp instructions
Carl Love [Tue, 28 May 2019 19:07:04 +0000 (14:07 -0500)] 
PPC64, Add support for vlogefp, vexptefp instructions

Add Iop_Exp2_32Fx4 to VEX/pub/libvex_ir.h to support the 2^x instruction.

Enable the existing test support for the two instructions in
none/tests/ppc64/subnormal_test.c and none/tests/ppc64/jm-insns.c.

https://bugs.kde.org/show_bug.cgi?id=407340

6 years agoPPC64, Subnormal testcase changes
Carl Love [Tue, 28 May 2019 16:33:00 +0000 (11:33 -0500)] 
PPC64, Subnormal testcase changes

VEX patch fixed issues with generating subnormal results.

This patch adds a specific test case and updates the expected values for
the existing test case.

Update jm-vmx tests, add subnormal test case.

https://bugs.kde.org/show_bug.cgi?id=406256

6 years agoPPC64, fix issues with dnormal values in the vector fp instructions.
Carl Love [Tue, 28 May 2019 16:26:13 +0000 (11:26 -0500)] 
PPC64, fix issues with dnormal values in the vector fp instructions.

The result of the floating point instructions vmaddfp, vnmsubfp,
vaddfp, vsubfp, vmaxfp, vminfp, vrefp, vrsqrtefp, vcmpeqfp, vcmpeqfp,
vcmpgefp, vcmpgtfp are controlled by the setting of the NJ bit in
the VSCR register.  If VSCR[NJ] = 0; then denormalized values are
handled as specified by Java and the IEEE standard.  If the bit is
a 1, then the denormalized element in the vector is replaced with
a zero.

Valgrind was not properly handling the denormalized case for these
instructions.  This patch fixes the issue.

https://bugs.kde.org/show_bug.cgi?id=406256

6 years agoBug 407764 - s390x: drd fails on z13 due to function wrapping issue
Andreas Arnez [Thu, 23 May 2019 15:17:43 +0000 (17:17 +0200)] 
Bug 407764 - s390x: drd fails on z13 due to function wrapping issue

The s390x-specific inline assembly macros for function wrapping in
include/valgrind.h have a few issues.

When the compiler uses vector registers, such as with "-march=z13", all
vector registers must be declared as clobbered by the callee.  Because
this is missing, many drd test failures are seen with "-march=z13".

Also, the inline assemblies write the return value into the target
register before restoring r11.  If r11 is used as the target register,
this means that the restore operation corrupts the result.  This bug
causes failures with memcheck's "wrap6" test case.

These bugs are fixed.  The clobber list is extended by the vector
registers (if appropriate), and the target register is now written at the
end, after restoring r11.

6 years agoppc64: Arguments to iselInt128Expr_to_32x4 should be initialized.
Mark Wielaard [Mon, 27 May 2019 18:31:35 +0000 (20:31 +0200)] 
ppc64: Arguments to iselInt128Expr_to_32x4 should be initialized.

Make sure to initialize the arguments to iselInt128Expr_to_32x4.
iselInt128Expr_to_32x4 will check that iselInt128Expr_to_32x4_wrk
has assigned the correct type of values to the arguments. But if
the arguments were never initialized it might not be able to when
iselInt128Expr_to_32x4_wrk was unable to assign a value.

Reviewed-by: Carl Love <cel@us.ibm.com>
6 years agoFix coding nit in x86amd64g_calculate_FXTRACT.
Mark Wielaard [Tue, 28 May 2019 15:20:31 +0000 (17:20 +0200)] 
Fix coding nit in x86amd64g_calculate_FXTRACT.

The current code "return getExp ? posInf : posInf;" looks like a typo.
But when the argument is positive infinity then both the significand
and the exponent are positive infinity (there is a fxtract testcase that
checks that). So no need to check getExp. Just always return posInf
if arg == posInf, but add a comment explaining why.

6 years agohost_amd64_defs.c don't initialize opc and subopc_imm in emit_AMD64Instr.
Mark Wielaard [Mon, 27 May 2019 18:50:02 +0000 (20:50 +0200)] 
host_amd64_defs.c don't initialize opc and subopc_imm in emit_AMD64Instr.

In the case of Ain_SseShiftN we first assign zero to opc and subopc_imm
before handling the various subops. But since we will (and must) always
assign a valid value to opc and subopc_imm we might get a compiler warning
about the values never being read before storing a different value.

So explicitly don't assign a value. Then the compiler will warn if we
would ever forget to assign it a value value later on before using it.

6 years agoCleanup GPL header address notices by using http://www.gnu.org/licenses/
Mark Wielaard [Sat, 25 May 2019 22:32:28 +0000 (00:32 +0200)] 
Cleanup GPL header address notices by using http://www.gnu.org/licenses/

Sync VEX/LICENSE.GPL with top-level COPYING file. We used 3 different
addresses for writing to the FSF to receive a copy of the GPL. Replace
all different variants with an URL <http://www.gnu.org/licenses/>.

The following files might still have some slightly different (L)GPL
copyright notice because they were derived from other programs:

- files under coregrind/m_demangle which come from libiberty:
  cplus-dem.c, d-demangle.c, demangle.h, rust-demangle.c,
  safe-ctype.c and safe-ctype.h
- coregrind/m_demangle/dyn-string.[hc] derived from GCC.
- coregrind/m_demangle/ansidecl.h derived from glibc.
- VEX files for FMA detived from glibc:
  host_generic_maddf.h and host_generic_maddf.c
- files under coregrin/m_debuginfo derived from LZO:
  lzoconf.h, lzodefs.h, minilzo-inl.c and minilzo.h
- files under coregrind/m_gdbserver detived from GDB:
  gdb/signals.h, inferiors.c, regcache.c, regcache.h,
  regdef.h, remote-utils.c, server.c, server.h, signals.c,
  target.c, target.h and utils.c

Plus the following test files:

- none/tests/ppc32/testVMX.c derived from testVMX.
- ppc tests derived from QEMU: jm-insns.c, ppc64_helpers.h
  and test_isa_3_0.c
- tests derived from bzip2 (with embedded GPL text in code):
  hackedbz2.c, origin5-bz2.c, varinfo6.c
- tests detived from glibc: str_tester.c, pth_atfork1.c
- test detived from GCC libgomp: tc17_sembar.c
- performance tests derived from bzip2 or tinycc (with embedded GPL
  text in code): bz2.c, test_input_for_tinycc.c and tinycc.c

6 years agoFix DIP instruction name typos in guest_amd64_toIR.c.
Mark Wielaard [Sat, 25 May 2019 14:38:42 +0000 (16:38 +0200)] 
Fix DIP instruction name typos in guest_amd64_toIR.c.

DIP would print the wrong instruction name for blendps, vroundpd and
vpinsrq. Which would be confusing when trying to debug the disassembly.
These were probably typos or copy/paste errors since they would print
very similar instruction names.

6 years agoFix memory leak in launcher-linux.c
Mark Wielaard [Sat, 25 May 2019 14:31:02 +0000 (16:31 +0200)] 
Fix memory leak in launcher-linux.c

When the clientname argument is not a full absolute path we reconstruct
the full path using $PATH. This reconstructed full path would be leaked.
This is small and insignificant. But valgrind should give a good example.
So free the path again when we are done and allocated the memory.
Also don't print the path twice in the debug output if we didn't need to
construct a new different path for it.

6 years agovgdb: Fix read check in report_pid.
Mark Wielaard [Sat, 25 May 2019 14:25:19 +0000 (16:25 +0200)] 
vgdb: Fix read check in report_pid.

When read fails it will return -1. In which case we might assign
cmdline[sz] = 0 and print a garbage cmdline. Fix the test to check
the return value is > 0.

6 years agoFix memcheck/tests/linux/sys-copy_file_range open call (mode).
Mark Wielaard [Fri, 24 May 2019 19:51:31 +0000 (21:51 +0200)] 
Fix memcheck/tests/linux/sys-copy_file_range open call (mode).

sys-copy_file_range.c calls open with O_CREAT flag and so must provide
a mode argument. valgrind memcheck actually caught this ommission on
some arches (fedora rawhide i686 specifically).

This is a small additional fixup for
https://bugs.kde.org/show_bug.cgi?id=407218

6 years agoMake memcheck/tests/x86-linux/scalar test work under root.
Mark Wielaard [Mon, 20 May 2019 11:08:41 +0000 (13:08 +0200)] 
Make memcheck/tests/x86-linux/scalar test work under root.

Running the testsuite as root isn't really recommended.
But lets not make tests fail unnecessarily when running as root.
Similar to the arm64-linux/scalar fixes. Plus 32bit variants that
don't exist on arm64.

Pass really invalid arguments to setuid[32], setgid[32], acct, fchown[32].
Make setresgid[32], setresuid[32], setregid[32], setreuid[32] always succeed.

6 years agoMake memcheck/tests/arm64-linux/scalar test work under root.
Mark Wielaard [Sun, 19 May 2019 22:09:59 +0000 (00:09 +0200)] 
Make memcheck/tests/arm64-linux/scalar test work under root.

Running the testsuite as root isn't really recommended.
But lets not make tests fail unnecessarily when running as root.
Pass really invalid arguments to setuid, setgid, acct and fchown.
Make setresgid, setresuid, setregid and setreuid always succeed.

6 years agoaarch64 (arm64) isn't a supported architecture for exp-sgcheck.
Mark Wielaard [Sat, 18 May 2019 12:55:50 +0000 (14:55 +0200)] 
aarch64 (arm64) isn't a supported architecture for exp-sgcheck.

exp-sgcheck/pc_main.c contains:

   #if defined(VGA_arm) || defined(VGA_arm64)
      VG_(printf)("SGCheck doesn't work on ARM yet, sorry.\n");
      VG_(exit)(1);
   #endif

But exp-sgcheck/tests/is_arch_supported checked against uname -m
which returns aarch64 (not arm64). Fix the test check so the
exp-sgcheck tests are skipped instead of producing failures.

6 years agoAdd a test for the new gdbserver adddress[length] syntax.
Philippe Waroquiers [Sat, 18 May 2019 10:10:40 +0000 (12:10 +0200)] 
Add a test for the new gdbserver adddress[length] syntax.

6 years agoHave gdbserver accepts the syntax address[length]
Philippe Waroquiers [Thu, 16 May 2019 19:34:37 +0000 (21:34 +0200)] 
Have gdbserver accepts the syntax address[length]

The syntax address[length] can be used in all the gdbserer monitor
commands that need an address and optional length argument.

This commit also fixes an error message, and removes trailing whitespaces
in m_gdbserver.c

6 years agoExplicitly make testcase variable for sys-copy_file_range undefined.
Mark Wielaard [Wed, 15 May 2019 19:30:00 +0000 (21:30 +0200)] 
Explicitly make testcase variable for sys-copy_file_range undefined.

On some systems an extra warning could occur when a variable in
the memcheck/tests/linux/sys-copy_file_range testcase was undefined,
but (accidentially) pointed to known bad memory. Fix by defining the
variable as 0, but then marking it explicitly undefined using memcheck
VALGRIND_MAKE_MEM_UNDEFINED.

Followup for https://bugs.kde.org/show_bug.cgi?id=407218

6 years agomips: hook linux copy_file_range syscall
Petar Jovanovic [Fri, 10 May 2019 16:35:02 +0000 (16:35 +0000)] 
mips: hook linux copy_file_range syscall

Allow copy_file_range syscalls on MIPS32 and MIPS64.
Update .gitignore.

Related Bugzilla issue - KDE #407218.

6 years agomips64: allow Loongson baseline
Petar Jovanovic [Wed, 8 May 2019 15:17:25 +0000 (17:17 +0200)] 
mips64: allow Loongson baseline

Allow Loongson baseline on MIPS64. This fixes KDE #406824.

6 years agoIntercept stpcpy also in ld.so for arm64
Mark Wielaard [Tue, 7 May 2019 19:20:04 +0000 (21:20 +0200)] 
Intercept stpcpy also in ld.so for arm64

On other arches stpcpy () is intercepted for both libc.so and ld.so.
But not on arm64, where it is only intercepted for libc.so.

This can cause memcheck warnings about the use of stpcpy () in ld.so
when called through dlopen () because ld.so contains its own copy of
that functions.

Fix by introducing VG_Z_LD_LINUX_AARCH64_SO_1 (the encoded name of
ld.so on arm64) and using that in vg_replace_strmem.c to intercept
stpcpy.

https://bugs.kde.org/show_bug.cgi?id=407307

6 years agoHook linux copy_file_range syscall on arm.
Mark Wielaard [Sun, 5 May 2019 14:01:41 +0000 (16:01 +0200)] 
Hook linux copy_file_range syscall on arm.

6 years agoAdd support for the copy_file_range syscall
Alexandra Hajkova [Thu, 2 May 2019 12:24:02 +0000 (08:24 -0400)] 
Add support for the copy_file_range syscall

Support amd64, x86, arm64, ppc64, ppc32 and s390x architectures.
Also add sys-copy_file_range test case.

6 years agoMake the list of horrible filter_gdb sed expressions somewhat less horrible
Philippe Waroquiers [Sat, 27 Apr 2019 16:13:45 +0000 (18:13 +0200)] 
Make the list of horrible filter_gdb sed expressions somewhat less horrible

The sed expressions and the comments of these expression were at 2 different
places, making this already horrible list of expressions even more
horrible to understand/maintain.

So, restructure to allow the comments for an expression be close
to the expression.

6 years agomips: fix file permission of guest_mips_toIR.c
Petar Jovanovic [Mon, 22 Apr 2019 22:49:48 +0000 (22:49 +0000)] 
mips: fix file permission of guest_mips_toIR.c

Revert accidentally modified file permissions back to 0644.

6 years agomips: fix mips32r6 and mips64r6 compilation issue
Petar Jovanovic [Fri, 19 Apr 2019 14:04:26 +0000 (14:04 +0000)] 
mips: fix mips32r6 and mips64r6 compilation issue

Add missing variable declarations.
Modify local_sys_write_stderr to use movn if available, and use
seleqz/selnez instructions otherwise.

6 years agofilter_gdb: add regexp to filter out names which starts with a "."
Alexandra Hájková [Mon, 15 Apr 2019 13:34:12 +0000 (15:34 +0200)] 
filter_gdb: add regexp to filter out names which starts with a "."

such names are used for "function descriptors" on ppc64

https://bugs.kde.org/show_bug.cgi?id=406561