Commit Graph

17 Commits

Author SHA1 Message Date
Julian Seward
cd529fcc23 Remove unused variable.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14402
2014-09-01 08:41:43 +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
Julian Seward
32cf31c0d8 Enable sys_fchmodat.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13997
2014-06-04 23:22:29 +00:00
Julian Seward
e5d979564f arm64-linux: enable sys_sched_setaffinity, sys_linkat.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13974
2014-05-16 15:02:09 +00:00
Julian Seward
8b72a31ca9 Enable: sys_add_key, sys_keyctl, apparently needed by glibc-2.19.90 on
arm64-linux.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13972
2014-05-15 16:47:56 +00:00
Julian Seward
20f47d4181 Enable syscalls:
sys_readv sys_signalfd4 sys_utimensat sys_timerfd_create
sys_timerfd_settime sys_timerfd_gettime sys_capget sys_syslog
sys_sched_yield sys_sigaltstack sys_rt_sigqueueinfo
sys_mq_timedsend sys_mq_timedreceive sys_mq_notify
sys_mq_getsetattr sys_mremap



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13892
2014-04-07 14:47:23 +00:00
Julian Seward
da3d709fb7 Enable syscalls: sys_inotify_init1 sys_inotify_add_watch
sys_inotify_rm_watch sys_fallocate sys_quotactl sys_pwrite64
sys_sysinfo sys_shmctl wrap_sys_shmat sys_shmdt



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13857
2014-03-08 20:34:45 +00:00
Julian Seward
a6f3590485 Enable the following syscalls: sys_eventfd2 sys_symlinkat sys_renameat
sys_fstatfs sys_fsync sys_clock_getres sys_sched_getaffinity
sys_shmget sys_fadvise64


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13855
2014-03-07 22:48:50 +00:00
Julian Seward
12f983e5dc Enable sys_epoll_create1, sys_epoll_ctl, sys_epoll_pwait, sys_prctl.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13849
2014-03-02 12:49:52 +00:00
Julian Seward
1ffe03c510 Enable the following syscalls, which are needed to make regtests
in none/ work:
sys_ftruncate
sys_setitimer
sys_rt_sigsuspend
sys_rt_sigtimedwait
sys_mq_open
sys_mq_unlink
sys_semget
sys_semctl
sys_semtimedop
sys_semop
sys_listen
sys_accept
sys_process_vm_readv
sys_process_vm_writev



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13845
2014-03-01 11:24:42 +00:00
Julian Seward
686ec53b47 Enable a few more syscalls:
sys_setpriority, sys_getpriority, sys_getresuid,
sys_getresgid, sys_recvfrom, sys_readahead


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13840
2014-02-27 11:14:19 +00:00
Julian Seward
b1b41a45d8 * fix a bug in sys_clone that was causing threads to hang at exit
* enable enough syscalls to be able to run ssh and bash


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13826
2014-02-21 14:51:14 +00:00
Julian Seward
40469b7085 Enable sys_ppoll, sys_kill, sys_socketpair.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13824
2014-02-20 23:20:08 +00:00
Julian Seward
c1cd47aae4 First attempt at supporting sys_clone.
Also enable: sys_exit, sys_nanosleep, sys_madvise.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13822
2014-02-20 17:36:56 +00:00
Tom Hughes
6ef2cbe59d Add support for the clock_adjtime system call.
Based on a patch from Stefan Sørensen on BZ#330469.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13785
2014-01-30 22:33:02 +00:00
Tom Hughes
f1c82feda5 Both eventfd and eventfd2 have post handlers that we were failing
to call on most platforms. Fixes BZ #330459.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13784
2014-01-30 21:47:30 +00:00
Julian Seward
3f6d211236 Add support for ARMv8 AArch64 (the 64 bit ARM instruction set).
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13770
2014-01-12 12:54:00 +00:00