mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-13 06:33:56 +00:00
which is a sorted set with no duplicates. This is derived from m_skiplist, which it will hopefully replace. The interface has the following improvements: - Avoided all mention of how the data structure is implemented in the interface, so it could be replaced with another data structure without changing external code. - Two kinds of comparison: fast -- use the first word of each element for comparison; slow -- use a custom function. The custom function compares a key with an element, so non-overlapping interval lists can be supported easily. m_skiplist only supports the slow variant, and it makes things almost 2x faster. - Users pass in malloc() and free() functions, so m_oset.c it doesn't rely on any particular allocator. - It has a Destroy() function which will deallocate all the nodes. - It allows variable-sized nodes. - No static constructor; I needed the flexibility of being able to execute arbitrary code in the constructor. This also means no type internals are exposed. No part of Valgrind actually uses OSet yet, although I've privately converted several data structures, and so I'm confident that the interface is basically sound. Some functions may be added later. The implementation uses AVL trees, and has the following characteristics: - Lookup is much faster than for skiplists -- around 3x. This is because the inner lookup loop is much tighter. - Insertion and removal is similar speed to skiplists, maybe a little slower, but there's still some fat to be trimmed. - The code is a bit longer and more complex than the skiplist code. This was intended to replace the need for the VgHashTable type. But my experiments have shown that VgHashTable is really fast, faster than both AVL trees and skiplists in all but extreme cases (eg. if the hashtable becomes way too full): insertion takes constant time, because you always prepend to chains; lookup depends on chain length, but the inner loop is so tight that you need about 20 elements per chain before it gets worse than the AVL tree; removal is similar to lookup. And because insertion uses prepending, any locality in accesses will help things. If VgHashTable had its interface cleaned up to look like OSet's, and was made to auto-resize when it got too full, it might be a better OSet (although it's not sorted). So, it's currently unclear exactly how the AVL tree OSet will be used. The skiplist could be converted to the new interface (I have a 90% complete version which I used in the comparison experiments). If VgHashTable was converted to the same interface (or as close as possible) it would make direct comparison of important places (eg. Memcheck's malloc_lists) simple. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4410
219 lines
5.0 KiB
Makefile
219 lines
5.0 KiB
Makefile
include $(top_srcdir)/Makefile.all.am
|
|
include $(top_srcdir)/Makefile.core-AM_CPPFLAGS.am
|
|
|
|
MODULES = \
|
|
m_aspacemgr \
|
|
m_debuginfo \
|
|
m_demangle \
|
|
m_dispatch \
|
|
m_replacemalloc \
|
|
m_scheduler \
|
|
m_sigframe \
|
|
m_syswrap
|
|
|
|
## When building, we are only interested in the current arch/OS/platform.
|
|
## But when doing 'make dist', we are interested in every arch/OS/platform.
|
|
## That's what DIST_SUBDIRS specifies.
|
|
SUBDIRS = $(MODULES) .
|
|
|
|
DIST_SUBDIRS = $(MODULES) .
|
|
|
|
AM_CPPFLAGS += -DVG_LIBDIR="\"$(valdir)"\" \
|
|
-DKICKSTART_BASE=@KICKSTART_BASE@
|
|
|
|
default.supp: $(SUPP_FILES)
|
|
|
|
bin_PROGRAMS = \
|
|
valgrind
|
|
|
|
val_PROGRAMS = \
|
|
stage2 \
|
|
vg_preload_core.so
|
|
|
|
noinst_HEADERS = \
|
|
coregrind.h \
|
|
pub_core_aspacemgr.h \
|
|
pub_core_basics.h \
|
|
pub_core_cpuid.h \
|
|
pub_core_debuginfo.h \
|
|
pub_core_debugger.h \
|
|
pub_core_debuglog.h \
|
|
pub_core_demangle.h \
|
|
pub_core_dispatch.h \
|
|
pub_core_dispatch_asm.h \
|
|
pub_core_errormgr.h \
|
|
pub_core_execontext.h \
|
|
pub_core_hashtable.h \
|
|
pub_core_libcbase.h \
|
|
pub_core_libcassert.h \
|
|
pub_core_libcfile.h \
|
|
pub_core_libcmman.h \
|
|
pub_core_libcprint.h \
|
|
pub_core_libcproc.h \
|
|
pub_core_libcsignal.h \
|
|
pub_core_machine.h \
|
|
pub_core_main.h \
|
|
pub_core_mallocfree.h \
|
|
pub_core_options.h \
|
|
pub_core_oset.h \
|
|
pub_core_profile.h \
|
|
pub_core_pthreadmodel.h \
|
|
pub_core_redir.h \
|
|
pub_core_replacemalloc.h\
|
|
pub_core_scheduler.h \
|
|
pub_core_sigframe.h \
|
|
pub_core_signals.h \
|
|
pub_core_skiplist.h \
|
|
pub_core_stacks.h \
|
|
pub_core_stacktrace.h \
|
|
pub_core_syscall.h \
|
|
pub_core_syswrap.h \
|
|
pub_core_threadmodel.h \
|
|
pub_core_threadstate.h \
|
|
pub_core_tooliface.h \
|
|
pub_core_trampoline.h \
|
|
pub_core_translate.h \
|
|
pub_core_transtab.h \
|
|
pub_core_transtab_asm.h \
|
|
pub_core_ume.h \
|
|
vki_unistd.h \
|
|
vki_unistd-amd64-linux.h\
|
|
vki_unistd-ppc32-linux.h\
|
|
vki_unistd-x86-linux.h
|
|
|
|
BUILT_SOURCES = stage2.lds
|
|
CLEANFILES = stage2.lds
|
|
|
|
valgrind_SOURCES = \
|
|
stage1.c \
|
|
m_debuglog.c \
|
|
m_ume.c
|
|
valgrind_DEPENDENCIES =
|
|
valgrind_LDFLAGS=-static -g
|
|
valgrind_LDADD=
|
|
|
|
stage2_SOURCES = \
|
|
m_cpuid.S \
|
|
m_debugger.c \
|
|
m_debuglog.c \
|
|
m_errormgr.c \
|
|
m_execontext.c \
|
|
m_hashtable.c \
|
|
m_libcbase.c \
|
|
m_libcassert.c \
|
|
m_libcfile.c \
|
|
m_libcmman.c \
|
|
m_libcprint.c \
|
|
m_libcproc.c \
|
|
m_libcsignal.c \
|
|
m_machine.c \
|
|
m_main.c \
|
|
m_mallocfree.c \
|
|
m_options.c \
|
|
m_oset.c \
|
|
m_profile.c \
|
|
m_pthreadmodel.c \
|
|
m_redir.c \
|
|
m_signals.c \
|
|
m_skiplist.c \
|
|
m_stacks.c \
|
|
m_stacktrace.c \
|
|
m_syscall.c \
|
|
m_threadmodel.c \
|
|
m_threadstate.c \
|
|
m_tooliface.c \
|
|
m_trampoline.S \
|
|
m_translate.c \
|
|
m_transtab.c \
|
|
m_ume.c
|
|
|
|
## Nb: libscheduler.a must precede libdispatch.a in this list.
|
|
stage2_extra= \
|
|
m_debuginfo/libdebuginfo.a \
|
|
m_demangle/libdemangle.a \
|
|
m_scheduler/libscheduler.a \
|
|
m_dispatch/libdispatch.a \
|
|
m_aspacemgr/libaspacemgr.a \
|
|
m_sigframe/libsigframe.a \
|
|
m_syswrap/libsyswrap.a \
|
|
@VEX_DIR@/libvex.a
|
|
|
|
## These ones must be linked in with the --whole-archive flag, because they
|
|
## wouldn't get pulled into stage2 otherwise (because they contain symbols
|
|
## only referred to by tool shared objects).
|
|
stage2_extra2 = \
|
|
m_replacemalloc/libreplacemalloc_core.a
|
|
|
|
## Nb: older versions of automake don't seem to like having += within an
|
|
## if-then-else, so we have to use these variables for the common parts.
|
|
st2_DEPS_common = \
|
|
$(stage2_extra) \
|
|
$(stage2_extra2)
|
|
|
|
st2_LDFLAGS_common = \
|
|
-Wl,--export-dynamic -g \
|
|
-Wl,--whole-archive $(stage2_extra2) -Wl,--no-whole-archive
|
|
|
|
if USE_PIE
|
|
stage2_DEPENDENCIES = $(st2_DEPS_common)
|
|
stage2_LDFLAGS = \
|
|
$(st2_LDFLAGS_common) \
|
|
-pie
|
|
else
|
|
stage2_DEPENDENCIES = $(st2_DEPS_common) stage2.lds
|
|
stage2_LDFLAGS = \
|
|
$(st2_LDFLAGS_common) \
|
|
-Wl,-defsym,kickstart_base=@KICKSTART_BASE@ -Wl,-T,stage2.lds
|
|
endif
|
|
|
|
stage2_LDADD= $(stage2_extra) \
|
|
-ldl
|
|
|
|
vg_preload_core_so_SOURCES = vg_preloaded.c
|
|
vg_preload_core_so_CFLAGS = $(AM_CFLAGS) -fpic
|
|
vg_preload_core_so_LDADD = -ldl
|
|
vg_preload_core_so_LDFLAGS = \
|
|
-shared \
|
|
-Wl,--soname,vg_preload_core.so \
|
|
-Wl,-z,initfirst
|
|
|
|
# Extract ld's default linker script and hack it to our needs.
|
|
# First we cut everything above and below the "=====..." lines at the top
|
|
# and bottom.
|
|
# Then we have to replace the load address with "kickstart_base".
|
|
# The line to replace in has one of the following two forms:
|
|
#
|
|
# . = 0x08048000 + SIZEOF_HEADERS;
|
|
#
|
|
# or
|
|
# PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS;
|
|
#
|
|
# So we search for the line with a hex value "+ SIZEOF_HEADERS", and replace
|
|
# all the hex values in that line with "kickstart_base".
|
|
stage2.lds: Makefile
|
|
$(CC) -Wl,--verbose -nostdlib 2>&1 | sed \
|
|
-e '1,/^=====\+$$/d' \
|
|
-e '/^=====\+$$/d' \
|
|
-e '/\. = 0x[0-9A-Fa-f]\+ + SIZEOF_HEADERS/s/0x[0-9A-Fa-f]\+/kickstart_base/g' > $@ \
|
|
|| rm -f $@
|
|
|
|
@VEX_DIR@/libvex.a: @VEX_DIR@/priv/main/vex_svnversion.h
|
|
$(MAKE) -C @VEX_DIR@ libvex.a EXTRA_CFLAGS="@PIE_AM_CFLAGS@"
|
|
|
|
@VEX_DIR@/priv/main/vex_svnversion.h:
|
|
$(MAKE) -C @VEX_DIR@ version
|
|
|
|
clean-local:
|
|
$(MAKE) -C @VEX_DIR@ clean
|
|
|
|
MANUAL_DEPS = $(noinst_HEADERS) $(include_HEADERS)
|
|
|
|
all-local:
|
|
mkdir -p $(inplacedir)
|
|
for i in $(val_PROGRAMS); do \
|
|
to=$(inplacedir)/$$i; \
|
|
rm -f $$$to; \
|
|
ln -sf ../$(subdir)/$$i $$to; \
|
|
done
|
|
|