Commit Graph

267 Commits

Author SHA1 Message Date
Tom Hughes
61ca56765a Move the gettid system call to the linux specific section.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3493
2005-03-31 16:02:07 +00:00
Tom Hughes
21d1184fb7 Implement the gettid system call which seems to have got lost in the merge.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3490
2005-03-31 09:09:07 +00:00
Nicholas Nethercote
d5717b3e8c The two patches attached resolve the exit-hang (of OOo) bug for me. The first
fixes getppid(), and the second fixes the next bug which is revealed
once getppid() does what LinuxThreads wants;  LinuxThreads uses SIGKILL
to kill off stray threads, but if we send naked SIGKILLs to Valgrind
threads, they'll die without cleaning up or informing anyone of their
death, which means that they're waited on forever. 

ADAPTED FROM CVS HEAD



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3449
2005-03-26 20:08:06 +00:00
Julian Seward
64824ad318 More amd64 signal handling fixes (Tom Hughes)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3443
2005-03-26 13:48:19 +00:00
Nicholas Nethercote
8853545f0f Use VGP_ prefix more consistently for platform-specific exports.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3436
2005-03-26 02:42:31 +00:00
Nicholas Nethercote
f474d2e51a A modularisation + refactoring commit. vg_execontext.c has been split into
two halves: stacktrace.c, which deals with getting, traversing and printing
stack traces;  and execontext.c, which deals with storing stack traces
permanently in a way that avoids duplicates, and comparing them.

One nice outcome:  previously we were often creating ExeContexts, which live
forever, even when they were only needed temporarily.  Ie. this was a memory
leak, which has been removed.

As part of this, new headers have been created, carved off core.h and
tool.h.  Lots of function names have changed, too.

In Massif, I also changed a lot of "eip" names to "ip" to make them less
x86-specific.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3429
2005-03-25 23:35:48 +00:00
Julian Seward
43e6c44681 Various amd64 syscall improvements (Tom Hughes)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3425
2005-03-24 17:52:02 +00:00
Julian Seward
f8682ee14f PRE_(mmap2) and PRE(old_mmap): if not MAP_FIXED but addr != 0, don't
fail if we can't get addr; instead get something arbitrary.  This is
what SUSv3 requires.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3408
2005-03-23 02:53:13 +00:00
Julian Seward
f1dfcb9521 Stop sys_sigprocmask from dying with assertion failures.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3368
2005-03-16 00:40:48 +00:00
Julian Seward
d5e926ab38 Allow mmaps etc all the way down to zero. This 'fixes' as_mmap.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3366
2005-03-15 23:29:13 +00:00
Julian Seward
97fbbe4bf2 Fix another merge-related problem. I think this may resolve the
thread-hang-at-exit issues.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3360
2005-03-15 01:38:57 +00:00
Nicholas Nethercote
b4dd85ce0c Remove two malloc/free arenas:
- JITTER, which was unused, since Vex now manages its own memory
- TRANSIENT, which was barely being used;  I replaced it with usage of CORE


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3342
2005-03-13 18:11:44 +00:00
Nicholas Nethercote
05fe123a9e Update copyright notice for 2005 on all relevant files. Don't bother trying
to be selective about it.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3303
2005-03-12 16:22:54 +00:00
Julian Seward
6ddcb7dc7d Detect and reject misaligned args for mmap. This makes
none/tests/map_unaligned work.  The PRE handlers for sys_mmap and
sys_old_mmap are more convoluted than I would like, and might benefit
from a rewrite.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3284
2005-03-11 14:12:38 +00:00
Julian Seward
5fee346604 Un-break --trace-children=yes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3282
2005-03-11 12:56:56 +00:00
Nicholas Nethercote
53643ee2a6 Fix a printf formatting inconsistency.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3280
2005-03-11 05:07:16 +00:00
Julian Seward
ae8df0379b Fix PRE wrapper for sys_exit.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3268
2005-03-11 02:47:32 +00:00
Julian Seward
0356d27ca6 Merge in changes from the 2.4.0 line. This basically brings in the
overhaul of the thread support.  Many things are now probably broken,
but at least with --tool=none, simple and not-so-simple threaded and
non-thread programs work.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3265
2005-03-10 23:59:00 +00:00
Julian Seward
435d820b6d Clean up handling of socket system calls on amd64-linux, so that the
code for them is shared between amd64-linux and x86-linux.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3257
2005-03-01 19:00:30 +00:00
Julian Seward
a978be5bcb Factor out all the socket-related syscall handlers into their own
functions, so the same handlers can be used on amd64-linux as
x86-linux without tons of code duplications.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3256
2005-03-01 16:45:23 +00:00
Julian Seward
d2445e3d81 Fix more RES-is-not-set assertions, and move a couple of comments to
their correct homes.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3255
2005-02-28 20:50:29 +00:00
Julian Seward
006c9e84c3 When handling syscalls, don't try to figure out if the pre-handler set
the syscall result by inspecting RES after the pre-handler has run.
Instead, give each thread a syscall_result_set Bool, and make
SET_RESULT set it.  Inspect that Bool.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3254
2005-02-28 17:27:04 +00:00
Julian Seward
be6b72b2d3 Various cleanups to revised low-level memory manager.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3253
2005-02-28 14:39:21 +00:00
Julian Seward
f122d86dc0 Further cleanups to low-level memory management. It's still a
conceptual mess and needs a redesign, but this is a start.  Most stuff
now works again.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3247
2005-02-18 08:28:32 +00:00
Julian Seward
353c6ca6c5 Turn off tons of debug printing.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3244
2005-02-16 01:58:51 +00:00
Julian Seward
245173117c Major rewrite of the machinery which keeps track of segments:
* remove initialisation-time circularities by not using the
  skiplist mechanism and therefore not using any dynamically
  allocated memory in support of this mechanism

* Add comments about how it works (it is pretty opaque) so as
  to help future maintainers/bug-fixers

It only just works and many things are still broken.  That should
improve rapidly however.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3242
2005-02-16 01:31:37 +00:00
Julian Seward
a804b287ad Fix bug causing __NR_read on amd64-linux to always be considered to have
failed -- because __NR_read == 0.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3235
2005-02-13 10:49:58 +00:00
Julian Seward
ae638b8a3a gcc-2.96 build fixes.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3213
2004-12-31 18:09:32 +00:00
Julian Seward
49b17b8fa4 Fix segfaults caused by the impedance matches in sys_sigprocmask.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3184
2004-12-06 16:18:58 +00:00
Nicholas Nethercote
ce2585d447 Changed message at the top of files, and the startup message, and the
string in valgrind.pc.in, so that they describe Valgrind as a "dynamic
binary instrumentation framework", and don't mention platforms at all.  

I had to tweak the regtest filters a bit for this.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3178
2004-12-01 14:14:42 +00:00
Nicholas Nethercote
a470b77afd Comment change only.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3175
2004-12-01 00:38:16 +00:00
Nicholas Nethercote
61fcb2828d Gave VG_(do_syscall)() a more specific prototype:
Int VG_(do_syscall) ( UInt, UWord, UWord, UWord, UWord, UWord, UWord );

to replace the previous:
  
  Int VG_(do_syscall) ( UInt, ... )

Reason being that sometimes you could get incorrect args passed, when
passing 32-bit ints on 64-bit platforms.  I also added macros
VG_(do_syscall[123456]) to make life easier, and converted all the
relevant calls.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3143
2004-11-29 16:49:18 +00:00
Nicholas Nethercote
57ab6c1b41 Fix post-amd64-commit x86 breakage:
- remove warnings from vg_scheduler.c by using (UWord) casts rather than
  64-bit-assuming (ULong) casts.
- move deref_Addr() to x86-linux/syscalls.c, where it's now used.

Also got rid of the ancient SIGNAL_SIMULATION flag, which is a remnant of very
early days -- things now only work with signal simulation, so no point in
keeping it around.

Also make addrcheck/tests/fprw work again now that --single-step is
dead.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3137
2004-11-29 14:24:57 +00:00
Nicholas Nethercote
10b4595add Added beginnings of an AMD64 port, so lots of new files and directories.
It compiles, but aborts immediately if you try to run it.

I didn't include ldt.c;  I'm not sure how the LDT is used on AMD64.  It can be
added later if necessary.

While doing this, did some 64-bit cleanness fixes:
- Added necessary intermediate casts to ULong to avoid warnings when converting
  ThreadId to void* and vice versa, in vg_scheduler.c.
- Fixed VALGRIND_NON_SIMD_CALL[0123] to use 'long' as the return type.
- Fixed VALGRIND_PRINTF{,BACKTRACE} to use unsigned longs instead of unsigned
  ints, as needed.
- Converted some offsets in vg_symtab2.h from "Int" to "OffT".
- Made strlen, strncat, etc, use SizeT instead of 'unsigned int' for the length
  parameter.
- Couple of other minor things.

I had to insert some "#ifdef __amd64__" and "#ifndef __amd64__" guards in
places.  In particular, in vg_mylibc.c, some of our syscall wrappers aren't
appropriate for AMD64 because the syscall numbering is a bit different in
places.  This difference will have to be abstracted out somehow.

Also rewrote the sys_fcntl and sys_fcntl64 wrappers, as required for AMD64.

Also moved the ipc wrapper into x86, since it's not applicable for
AMD64.  However, it is applicable (I think) for ARM, so it would be nice
to work out a way to share syscall wrappers between some, but not all,
archs.  Hmm.  Also now using the real IPC constants rather than magic
numbers in the wrapper.

Other non-AMD64-related fixes:
- ARM: fixed syscall table by accounting for the fact that syscall
  numbers don't start at 0, but rather at 0x900000.
- Converted a few places to use ThreadId instead of 'int' or 'Int' for
  thread IDs.
- Added both AMD64 and ARM (which I'd forgotten) entries to valgrind.spec.in.
- Tweaked comments in various places.




git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3136
2004-11-29 13:54:10 +00:00
Nicholas Nethercote
f00e834c58 Use better syscall argument names for two wrappers, now that "res" and
"arg[2345]" don't clash with macros.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3128
2004-11-27 16:57:18 +00:00
Nicholas Nethercote
4e12afbac2 Moved some duplicated macros out of arch/OS/platform-specific parts,
into the core.  Renamed them with capital letters at the same time (eg.
arg1-->ARG1, res-->RES) to reduce likelihood of name conflicts, and also
it doesn't hurt to make it clearer that they're macros.  The result is a
very big diff, but conceptually it's very simple.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3126
2004-11-27 16:10:23 +00:00
Nicholas Nethercote
f23dea17b2 Factored out some stuff duplicated across all archs, to do with syscall
wrappers.  The management apologises for the excessive use of macros, but it's
hard to avoid and really does make the repetitive parts of the code (ie. the
parts that are repeated for each arch) much more concise.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3124
2004-11-27 15:22:24 +00:00
Nicholas Nethercote
4399d9700f Added beginnings of an ARM port, to the point where it compiles. It does not
run, though.  There are lots of stubs to be filled in.  (The asm ones currently
just have "swi" in them, which seems to cause seg faults.) 

Also, some of the macros are decided dubious, especially:

  ARCH_* are bogus
  SYSCALL_RET is bogus
  PLATFORM_SET_SYSCALL_RESULT is bogus
  not sure about SET_SYSCALL_RETVAL
  FIRST_STACK_FRAME et al -- bogus?
  VG_MAX_JUMPS ?

And in stage2.lds, the 0x8048000 is almost certainly wrong


This required some tweakings of the core:
- some of the vki_*.h kernel types were fixed up

- had to disable the AM_PROG_CC_C_O macro in configure.in, because automake
  (autoconf?) didn't like it...

- some "#ifdef __x86__" guards were introduced, for nasty x86 things I don't
  yet know how to factor out (trampoline page muck, sysinfo page muck).

- fixed a minor stupidity in vg_proxylwp.c.

- moved the ptrace wrapper into the x86-linux part

- had to change the intercept mangling scheme, to use 'J' instead of '$' as the
  escape char because GCC didn't like '$'.  This is all very dubious, and only
  works because none of our intercepted symbols contains a 'J'.  To be fixed up
  ASAP.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3120
2004-11-26 19:34:36 +00:00
Nicholas Nethercote
feb4fbaef5 Removed all uses of register numbers (eg. arch-specific ones like R_EAX, and
arch-neutral ones like R_STACK_PTR).  Where they were used, we now always talk
about an offset into the Vex guest state, and an offset.  As a result,
the shadow register get/set functions had to change.  They now also use
an offset and size, and in an arch-neutral way.

Also, I combined the five the post_reg_write* functions into a single one that
takes a 'CorePart' parameter (plus also a ThreadId).  Also, I added more
arguments (the CorePart, and the ThreadId) to the post_mem_write event, for
consistency with the pre_mem_* events.

Also, I reduced the number of register names that must be specified by each
arch, by factoring out duplication; and shortened their names for the core (eg.
ARCH_STACK_PTR is now STACK_PTR).

Plus some related minor cleanups in syscall wrappers.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3094
2004-11-24 16:30:22 +00:00
Nicholas Nethercote
7f0984ea02 The syscall wrappers for sys_fcntl{,64} were too simplistic -- the 3rd
arg is only used if the 2nd arg has particular values, so we were
getting false positives.  This commit makes the wrappers smarter to
account for this.  I updated the reg test too.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3080
2004-11-23 14:57:49 +00:00
Nicholas Nethercote
400cfc0311 Remove useless parameters to TL_(pre_syscall)() and TL_(post_syscall)().
Also remove Memcheck's and Addrcheck's use of syscall_wrappers,
since they didn't do anything useful.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3064
2004-11-22 19:57:39 +00:00
Nicholas Nethercote
454ab569fe Converted the SK_ prefix to TL_ everywhere.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3060
2004-11-22 18:33:15 +00:00
Nicholas Nethercote
46ea82e68a Renamed some profiling events.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3059
2004-11-22 18:10:36 +00:00
Robert Walsh
0ad76c8517 Yipes - my last checking borked the memcheck scalar test. This should
make it better.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3049
2004-11-19 02:11:56 +00:00
Robert Walsh
423bfef15b Allow readlink to handle /proc/self/exe and /proc/<pid>/exe properly.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3048
2004-11-18 22:56:09 +00:00
Nicholas Nethercote
6918dc8dc3 Convert a whole bunch of "(UWord)NULL" occurrences to 0, which is easier to
read and understand.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3038
2004-11-17 18:42:20 +00:00
Nicholas Nethercote
e2a5f870d7 Add explanatory comment to set_tid_address wrapper.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3037
2004-11-17 18:24:10 +00:00
Nicholas Nethercote
2f787498e8 Arch-abstraction:
- Moved some more syscall wrappers into linux/syscalls.c and
  x86-linux/syscalls.c.  There are still heaps of wrappers that probably aren't
  generic, but I'm not sure, so they're staying in vg_syscalls.c for now.
  Let's worry about that when we do an OS port.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3036
2004-11-17 18:22:38 +00:00
Nicholas Nethercote
05522127c4 Add coregrind/linux/ and coregrind/linux/* that was supposed to go in the last
commit.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3035
2004-11-17 17:21:12 +00:00
Nicholas Nethercote
d0ef8153b4 Arch-abstraction:
- Moved the system call table into x86-linux, since it's platform specific.

- Started moving the non-generic syscall wrappers into linux/syscalls.c and
  x86-linux/syscalls.c as appropriate.

- Added new coregrind/linux/ directory and some files in it.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3034
2004-11-17 17:11:45 +00:00