Valgrind Home Information Source Code Documentation Contact How to Help Gallery

Variants and Patches

Several other Valgrind tools have been created. Some of these can plug directly into an existing Valgrind installation, but some require downloading a whole Valgrind distribution which contains a specially modified core. Please note that some of these are experimental, and may not work 100%.


Back

Jeremy Fitzhardinge's Patches

http://www.goop.org/~jeremy/

I've been working on various patches for Valgrind. The complete set is rolled together as valgrind-patches.tar.bz2.

My patches are being regularly merged with the CVS head; this set represents the currently unmerged patches as of  Thu Jan 13 18:55:26 PST 2005.

Note: they are designed to be applied in the following order.

1. new-threading

Redo threading model so that we no longer emulate pthreads. Threads are done at the kernel level with clone etc. Vastly simplifies things.

 dev/null                                    | 5183 ----------------------------
 Makefile.am                                 |    2 
 addrcheck/ac_main.c                         |    8 
 cachegrind/x86/cg_arch.c                    |   39 
 configure.in                                |   44 
 corecheck/tests/pth_rwlock.stderr.exp       |    9 
 corecheck/tests/sigkill.c                   |    4 
 corecheck/tests/sigkill.stderr.exp          |   12 
 coregrind/Makefile.am                       |   21 
 coregrind/core.h                            |  455 --
 coregrind/core_asm.h                        |    2 
 coregrind/linux/Makefile.am                 |    2 
 coregrind/linux/core_os.c                   |  195 +
 coregrind/linux/core_os.h                   |   88 
 coregrind/linux/sema.c                      |  105 
 coregrind/linux/syscalls.c                  |   24 
 coregrind/vg_execontext.c                   |    5 
 coregrind/vg_intercept.c.base               |   36 
 coregrind/vg_main.c                         |  134 
 coregrind/vg_mylibc.c                       |   45 
 coregrind/vg_scheduler.c                    | 3222 ++---------------
 coregrind/vg_signals.c                      |  892 +---
 coregrind/vg_symtab2.c                      |   21 
 coregrind/vg_syscalls.c                     |  649 +--
 coregrind/vg_to_ucode.c                     |    4 
 coregrind/x86-linux/core_platform.h         |   76 
 coregrind/x86-linux/ldt.c                   |    2 
 coregrind/x86-linux/platform-private.h      |   10 
 coregrind/x86-linux/syscall.S               |  130 
 coregrind/x86-linux/syscalls.c              |  471 +-
 coregrind/x86/core_arch.h                   |   47 
 coregrind/x86/dispatch.S                    |    4 
 coregrind/x86/signal.c                      |    9 
 coregrind/x86/state.c                       |   15 
 helgrind/hg_main.c                          |   22 
 include/linux/vki.h                         |   11 
 include/tool.h.base                         |   21 
 include/x86-linux/vki_arch.h                |    9 
 memcheck/mac_leakcheck.c                    |    3 
 memcheck/mc_main.c                          |   26 
 memcheck/tests/scalar_exit_group.stderr.exp |    2 
 none/tests/Makefile.am                      |    4 
 none/tests/pending.c                        |   84 
 none/tests/pending.stderr.exp               |    2 
 none/tests/pending.stdout.exp               |    7 
 none/tests/syscall-restart1.c               |    2 
 tests/vg_regtest.in                         |    2 
 47 files changed, 2499 insertions(+), 9661 deletions(-)
2. no-fomit-framepointer

Don't use -fomit-framepointer anywhere in the core makefiles. It just makes debugging harder. We can add it back later if it really makes a performance improvement (but I'm a bit skeptical).

 coregrind/linux/Makefile.am     |    2 +-
 coregrind/x86-linux/Makefile.am |    2 +-
 coregrind/x86/Makefile.am       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
3. libpthread-warning

Warn if a program appears to be using the now-obsolete Valgrind libpthread.

 coregrind/core.h         |   55 +++++++++--------------------------------------
 coregrind/vg_scheduler.c |   47 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 44 deletions(-)
4. fix-static-exec

Fix some tiny bugs which prevented Valgrind from running static executables.

 coregrind/ume.c |    4 ++++
 1 files changed, 4 insertions(+)
5. signal-state

Allow the VCPU state to be examined and manipulated from within a signal handler. Integer state is pretty easy, but FP state requires a lot of fiddley conversion between the CPU's state and the structure passed to the signal handler.

 core.h                           |    0 
 coregrind/vg_scheduler.c         |   18 --
 coregrind/vg_signals.c           |  211 ++++++++++++++------------
 coregrind/x86/core_arch.h        |   36 ++++
 coregrind/x86/signal.c           |  305 ++++++++++++++++++++++++++++++---------
 coregrind/x86/state.c            |    4 
 none/tests/Makefile.am           |    7 
 none/tests/sigcontext.c          |   92 +++++++++++
 none/tests/sigcontext.stderr.exp |    2 
 none/tests/sigcontext.stdout.exp |    4 
 none/tests/sigcontext.vgtest     |    1 
 11 files changed, 499 insertions(+), 181 deletions(-)
6. fix-prefixes

Instruction prefixes can appear in any order.

 coregrind/vg_to_ucode.c |   49 ++++++++++++++++++++++++++++--------------------
 1 files changed, 29 insertions(+), 20 deletions(-)
7. selfrun

Misc changes needed so that Valgrind can run itself.

 coregrind/core.h             |    4 ++
 coregrind/linux/core_os.c    |   16 +++++++-
 coregrind/stage1.c           |    4 +-
 coregrind/vg_main.c          |   14 +------
 coregrind/vg_messages.c      |    6 ++-
 coregrind/vg_procselfmaps.c  |    7 ++-
 coregrind/vg_scheduler.c     |   10 ++++-
 coregrind/vg_signals.c       |   78 +++++++++++++++++++++++++++++--------------
 coregrind/vg_symtab2.c       |   14 ++++++-
 coregrind/vg_syscalls.c      |   26 +++++++++-----
 coregrind/vg_transtab.c      |   43 ++++++++++++-----------
 include/x86-linux/vki_arch.h |    8 ++--
 12 files changed, 149 insertions(+), 81 deletions(-)
8. signal-queue

What started as a simple signal queueing patch turned into an omnibus signal rework. Lots of details changed, but the big picture is the same.

 tests/blockfault.stdout.exp      |    0 
 coregrind/core.h                 |   48 ++++--
 coregrind/linux/core_os.c        |   14 -
 coregrind/vg_main.c              |   13 +
 coregrind/vg_mylibc.c            |    6 
 coregrind/vg_scheduler.c         |  123 +++++++--------
 coregrind/vg_signals.c           |  301 ++++++++++++++++++++++++++++++++-------
 coregrind/vg_syscalls.c          |   14 +
 coregrind/x86-linux/ldt.c        |    9 -
 coregrind/x86-linux/syscalls.c   |    7 
 coregrind/x86/signal.c           |   71 ++++++++-
 include/tool.h.base              |    6 
 none/tests/Makefile.am           |    4 
 none/tests/blockfault.c          |   31 ++++
 none/tests/blockfault.stderr.exp |    6 
 none/tests/blockfault.vgtest     |    1 
 none/tests/x86/badseg.c          |    2 
 17 files changed, 493 insertions(+), 163 deletions(-)
9. as-stabs

Generate stabs debugging info for .S files.

 Makefile.core-AM_CPPFLAGS.am |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
10. update-regtest

Little updates to quiet down 'make regtest'. Oh, and a revamp of the syscall args checking so that Valgrind should be much more immune to segfaulting itself.

 corecheck/tests/as_mmap.stderr.exp     |    2 
 corecheck/tests/fdleak_cmsg.c          |    4 
 corecheck/tests/fdleak_cmsg.stderr.exp |   14 
 coregrind/core.h                       |   33 +
 coregrind/linux/syscalls.c             |  105 ++-
 coregrind/vg_memory.c                  |   59 --
 coregrind/vg_scheduler.c               |    8 
 coregrind/vg_signals.c                 |   40 +
 coregrind/vg_symtab2.c                 |   11 
 coregrind/vg_syscalls.c                |  904 +++++++++++++++++----------------
 coregrind/vg_translate.c               |    2 
 coregrind/x86-linux/syscalls.c         |   48 +
 coregrind/x86/signal.c                 |   46 -
 glibc-2.3.supp                         |   71 ++
 include/tool.h.base                    |    2 
 massif/ms_main.c                       |    1 
 memcheck/tests/scalar.c                |    2 
 memcheck/tests/scalar.stderr.exp       |   13 
 memcheck/tests/zeropage.stderr.exp     |    3 
 memcheck/tests/zeropage.stdout.exp     |    3 
 none/tests/cmdline1.stdout.exp         |    1 
 none/tests/cmdline2.stdout.exp         |    2 
 none/tests/exec-sigmask.c              |   68 ++
 none/tests/exec-sigmask.stderr.exp     |    1 
 none/tests/exec-sigmask.stdout.exp     |    1 
 none/tests/pth_blockedsig.c            |    3 
 none/tests/yield.c                     |   36 -
 tests/toobig-allocs.c                  |    2 
 28 files changed, 852 insertions(+), 633 deletions(-)
11. fix-exit-race

Fix up a nasty little race on thread exit. After the thread sets the status to Empty and releases run_sema, it could get recycled. Since there's a little bit of code which needs to run after unlocking, there's a chance that it could get its stack stolen from under it.

The solution it to use a temporary Zombie state, which prevents the thread structure from being reallocated. The thread exit code then sets the state to Empty and exits without touching the stack in the meantime.

 coregrind/core.h               |    3 ++-
 coregrind/linux/core_os.c      |    6 ------
 coregrind/vg_main.c            |    2 ++
 coregrind/vg_scheduler.c       |   19 +++++++++++++++----
 coregrind/x86-linux/syscalls.c |   24 +++++++++++++++---------
 5 files changed, 34 insertions(+), 20 deletions(-)
12. sigreturn-syscall

Use sigreturn/rt_sigreturn to finish a signal handler rather than using a client request. This allows clients to use SA_RESTORER, and it helps gdb understand the signal stack frames Valgrind generates.

 coregrind/core.h               |    8 
 coregrind/vg_scheduler.c       |    9 
 coregrind/vg_signals.c         |   26 --
 coregrind/x86-linux/syscalls.c |   34 ++-
 coregrind/x86/core_arch.h      |    5 
 coregrind/x86/helpers.S        |   33 +-
 coregrind/x86/signal.c         |  456 ++++++++++++++++++++++++-----------------
 7 files changed, 333 insertions(+), 238 deletions(-)
13. fix-tracking

Add a missing thread-creation track.

 coregrind/linux/core_os.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
14. segment-sanity

Add an expensive sanity check to make sure that the Segment list is consistent with the contents of /proc/self/maps at all times.es

 coregrind/core.h            |    6 
 coregrind/vg_main.c         |   44 ++++++
 coregrind/vg_memory.c       |  278 ++++++++++++++++++++++++++++++++++++++++++--
 coregrind/vg_procselfmaps.c |    3 
 4 files changed, 315 insertions(+), 16 deletions(-)


Bad, Bad Bug!

Copyright © 2000-2024 Valgrind™ Developers

Hosting kindly provided by sourceware.org