oprofile 0.9.6
Copy in the rest of the oprofile 0.9.6 tree so we have a source
copy to match the prebuilt binaries that are checked into
external/.
Change-Id: Iaac327571d5d583594a4194973bf256569061048
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
new file mode 100644
index 0000000..043cfd6
--- /dev/null
+++ b/daemon/Makefile.am
@@ -0,0 +1,58 @@
+SUBDIRS = liblegacy .
+
+oprofiled_SOURCES = \
+ init.c \
+ oprofiled.c \
+ oprofiled.h \
+ opd_stats.c \
+ opd_pipe.c \
+ opd_pipe.h \
+ opd_sfile.c \
+ opd_sfile.h \
+ opd_kernel.c \
+ opd_kernel.h \
+ opd_trans.c \
+ opd_trans.h \
+ opd_printf.h \
+ opd_stats.h \
+ opd_cookie.c \
+ opd_cookie.h \
+ opd_events.c \
+ opd_events.h \
+ opd_interface.h \
+ opd_mangling.c \
+ opd_mangling.h \
+ opd_perfmon.h \
+ opd_perfmon.c \
+ opd_anon.h \
+ opd_anon.c \
+ opd_spu.c \
+ opd_extended.h \
+ opd_extended.c \
+ opd_ibs.h \
+ opd_ibs.c \
+ opd_ibs_macro.h \
+ opd_ibs_trans.h \
+ opd_ibs_trans.c
+
+LIBS=@POPT_LIBS@ @LIBERTY_LIBS@
+
+AM_CPPFLAGS = \
+ -I ${top_srcdir}/libabi \
+ -I ${top_srcdir}/libutil \
+ -I ${top_srcdir}/libop \
+ -I ${top_srcdir}/libdb
+
+# -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
+AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
+
+bin_PROGRAMS = oprofiled
+
+oprofiled_LDADD = \
+ liblegacy/liblegacy.a \
+ ../libabi/libabi.a \
+ ../libdb/libodb.a \
+ ../libop/libop.a \
+ ../libutil/libutil.a
+
+oprofiled_LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
diff --git a/daemon/Makefile.in b/daemon/Makefile.in
new file mode 100644
index 0000000..2f0f0ef
--- /dev/null
+++ b/daemon/Makefile.in
@@ -0,0 +1,686 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = oprofiled$(EXEEXT)
+subdir = daemon
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \
+ $(top_srcdir)/m4/builtinexpect.m4 \
+ $(top_srcdir)/m4/cellspubfdsupport.m4 \
+ $(top_srcdir)/m4/compileroption.m4 \
+ $(top_srcdir)/m4/configmodule.m4 \
+ $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \
+ $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \
+ $(top_srcdir)/m4/kerneloption.m4 \
+ $(top_srcdir)/m4/kernelversion.m4 \
+ $(top_srcdir)/m4/mallocattribute.m4 \
+ $(top_srcdir)/m4/poptconst.m4 \
+ $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \
+ $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \
+ $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_oprofiled_OBJECTS = init.$(OBJEXT) oprofiled.$(OBJEXT) \
+ opd_stats.$(OBJEXT) opd_pipe.$(OBJEXT) opd_sfile.$(OBJEXT) \
+ opd_kernel.$(OBJEXT) opd_trans.$(OBJEXT) opd_cookie.$(OBJEXT) \
+ opd_events.$(OBJEXT) opd_mangling.$(OBJEXT) \
+ opd_perfmon.$(OBJEXT) opd_anon.$(OBJEXT) opd_spu.$(OBJEXT) \
+ opd_extended.$(OBJEXT) opd_ibs.$(OBJEXT) \
+ opd_ibs_trans.$(OBJEXT)
+oprofiled_OBJECTS = $(am_oprofiled_OBJECTS)
+oprofiled_DEPENDENCIES = liblegacy/liblegacy.a ../libabi/libabi.a \
+ ../libdb/libodb.a ../libop/libop.a ../libutil/libutil.a
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(oprofiled_SOURCES)
+DIST_SOURCES = $(oprofiled_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-exec-recursive install-info-recursive \
+ install-recursive installcheck-recursive installdirs-recursive \
+ pdf-recursive ps-recursive uninstall-info-recursive \
+ uninstall-recursive
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BFD_LIBS = @BFD_LIBS@
+BUILD_JVMPI_AGENT_FALSE = @BUILD_JVMPI_AGENT_FALSE@
+BUILD_JVMPI_AGENT_TRUE = @BUILD_JVMPI_AGENT_TRUE@
+BUILD_JVMTI_AGENT_FALSE = @BUILD_JVMTI_AGENT_FALSE@
+BUILD_JVMTI_AGENT_TRUE = @BUILD_JVMTI_AGENT_TRUE@
+CAT_ENTRY_END = @CAT_ENTRY_END@
+CAT_ENTRY_START = @CAT_ENTRY_START@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DOCBOOK_ROOT = @DOCBOOK_ROOT@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAVA_HOMEDIR = @JAVA_HOMEDIR@
+KINC = @KINC@
+KSRC = @KSRC@
+KVERS = @KVERS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBERTY_LIBS = @LIBERTY_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @POPT_LIBS@ @LIBERTY_LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MOC = @MOC@
+MODINSTALLDIR = @MODINSTALLDIR@
+OBJEXT = @OBJEXT@
+OPROFILE_DIR = @OPROFILE_DIR@
+OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@
+OP_CFLAGS = @OP_CFLAGS@
+OP_CXXFLAGS = @OP_CXXFLAGS@
+OP_DOCDIR = @OP_DOCDIR@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POPT_LIBS = @POPT_LIBS@
+PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@
+QT_INCLUDES = @QT_INCLUDES@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LIB = @QT_LIB@
+QT_VERSION = @QT_VERSION@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZE_T_TYPE = @SIZE_T_TYPE@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+XML_CATALOG = @XML_CATALOG@
+XSLTPROC = @XSLTPROC@
+XSLTPROC_FLAGS = @XSLTPROC_FLAGS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+have_qt_FALSE = @have_qt_FALSE@
+have_qt_TRUE = @have_qt_TRUE@
+have_xsltproc_FALSE = @have_xsltproc_FALSE@
+have_xsltproc_TRUE = @have_xsltproc_TRUE@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+kernel_support_FALSE = @kernel_support_FALSE@
+kernel_support_TRUE = @kernel_support_TRUE@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+topdir = @topdir@
+SUBDIRS = liblegacy .
+oprofiled_SOURCES = \
+ init.c \
+ oprofiled.c \
+ oprofiled.h \
+ opd_stats.c \
+ opd_pipe.c \
+ opd_pipe.h \
+ opd_sfile.c \
+ opd_sfile.h \
+ opd_kernel.c \
+ opd_kernel.h \
+ opd_trans.c \
+ opd_trans.h \
+ opd_printf.h \
+ opd_stats.h \
+ opd_cookie.c \
+ opd_cookie.h \
+ opd_events.c \
+ opd_events.h \
+ opd_interface.h \
+ opd_mangling.c \
+ opd_mangling.h \
+ opd_perfmon.h \
+ opd_perfmon.c \
+ opd_anon.h \
+ opd_anon.c \
+ opd_spu.c \
+ opd_extended.h \
+ opd_extended.c \
+ opd_ibs.h \
+ opd_ibs.c \
+ opd_ibs_macro.h \
+ opd_ibs_trans.h \
+ opd_ibs_trans.c
+
+AM_CPPFLAGS = \
+ -I ${top_srcdir}/libabi \
+ -I ${top_srcdir}/libutil \
+ -I ${top_srcdir}/libop \
+ -I ${top_srcdir}/libdb
+
+
+# -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
+AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
+oprofiled_LDADD = \
+ liblegacy/liblegacy.a \
+ ../libabi/libabi.a \
+ ../libdb/libodb.a \
+ ../libop/libop.a \
+ ../libutil/libutil.a
+
+oprofiled_LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+all: all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign daemon/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign daemon/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+oprofiled$(EXEEXT): $(oprofiled_OBJECTS) $(oprofiled_DEPENDENCIES)
+ @rm -f oprofiled$(EXEEXT)
+ $(oprofiled_LINK) $(oprofiled_LDFLAGS) $(oprofiled_OBJECTS) $(oprofiled_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_anon.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_cookie.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_events.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_extended.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_ibs.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_ibs_trans.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_kernel.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_mangling.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_perfmon.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_pipe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_sfile.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_spu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_stats.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_trans.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oprofiled.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+ list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(mkdir_p) "$(distdir)/$$subdir" \
+ || exit 1; \
+ distdir=`$(am__cd) $(distdir) && pwd`; \
+ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+ (cd $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(PROGRAMS)
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-info: install-info-recursive
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-info-am
+
+uninstall-info: uninstall-info-recursive
+
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
+ clean clean-binPROGRAMS clean-generic clean-libtool \
+ clean-recursive ctags ctags-recursive distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-recursive distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-exec install-exec-am \
+ install-info install-info-am install-man install-strip \
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic \
+ maintainer-clean-recursive mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
+ pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
+ uninstall-binPROGRAMS uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/daemon/liblegacy/Makefile.am b/daemon/liblegacy/Makefile.am
new file mode 100644
index 0000000..51078a6
--- /dev/null
+++ b/daemon/liblegacy/Makefile.am
@@ -0,0 +1,28 @@
+noinst_LIBRARIES = liblegacy.a
+
+# -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
+AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
+
+AM_CPPFLAGS = \
+ -I ${top_srcdir}/libutil \
+ -I ${top_srcdir}/libop \
+ -I ${top_srcdir}/libdb \
+ -I ${top_srcdir}/daemon
+
+liblegacy_a_SOURCES = \
+ opd_24_stats.c \
+ opd_24_stats.h \
+ opd_kernel.c \
+ opd_proc.c \
+ opd_image.c \
+ opd_mapping.c \
+ opd_parse_proc.c \
+ opd_image.h \
+ opd_mapping.h \
+ p_module.h \
+ opd_kernel.h \
+ opd_parse_proc.h \
+ opd_proc.h \
+ opd_sample_files.c \
+ opd_sample_files.h \
+ init.c
diff --git a/daemon/liblegacy/Makefile.in b/daemon/liblegacy/Makefile.in
new file mode 100644
index 0000000..519f855
--- /dev/null
+++ b/daemon/liblegacy/Makefile.in
@@ -0,0 +1,510 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = daemon/liblegacy
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/binutils.m4 \
+ $(top_srcdir)/m4/builtinexpect.m4 \
+ $(top_srcdir)/m4/cellspubfdsupport.m4 \
+ $(top_srcdir)/m4/compileroption.m4 \
+ $(top_srcdir)/m4/configmodule.m4 \
+ $(top_srcdir)/m4/copyifchange.m4 $(top_srcdir)/m4/docbook.m4 \
+ $(top_srcdir)/m4/extradirs.m4 $(top_srcdir)/m4/findkernel.m4 \
+ $(top_srcdir)/m4/kerneloption.m4 \
+ $(top_srcdir)/m4/kernelversion.m4 \
+ $(top_srcdir)/m4/mallocattribute.m4 \
+ $(top_srcdir)/m4/poptconst.m4 \
+ $(top_srcdir)/m4/precompiledheader.m4 $(top_srcdir)/m4/qt.m4 \
+ $(top_srcdir)/m4/resultyn.m4 $(top_srcdir)/m4/sstream.m4 \
+ $(top_srcdir)/m4/typedef.m4 $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+liblegacy_a_AR = $(AR) $(ARFLAGS)
+liblegacy_a_LIBADD =
+am_liblegacy_a_OBJECTS = opd_24_stats.$(OBJEXT) opd_kernel.$(OBJEXT) \
+ opd_proc.$(OBJEXT) opd_image.$(OBJEXT) opd_mapping.$(OBJEXT) \
+ opd_parse_proc.$(OBJEXT) opd_sample_files.$(OBJEXT) \
+ init.$(OBJEXT)
+liblegacy_a_OBJECTS = $(am_liblegacy_a_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(liblegacy_a_SOURCES)
+DIST_SOURCES = $(liblegacy_a_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BFD_LIBS = @BFD_LIBS@
+BUILD_JVMPI_AGENT_FALSE = @BUILD_JVMPI_AGENT_FALSE@
+BUILD_JVMPI_AGENT_TRUE = @BUILD_JVMPI_AGENT_TRUE@
+BUILD_JVMTI_AGENT_FALSE = @BUILD_JVMTI_AGENT_FALSE@
+BUILD_JVMTI_AGENT_TRUE = @BUILD_JVMTI_AGENT_TRUE@
+CAT_ENTRY_END = @CAT_ENTRY_END@
+CAT_ENTRY_START = @CAT_ENTRY_START@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DATE = @DATE@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DOCBOOK_ROOT = @DOCBOOK_ROOT@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+EXTRA_CFLAGS_MODULE = @EXTRA_CFLAGS_MODULE@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JAVA_HOMEDIR = @JAVA_HOMEDIR@
+KINC = @KINC@
+KSRC = @KSRC@
+KVERS = @KVERS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBERTY_LIBS = @LIBERTY_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MOC = @MOC@
+MODINSTALLDIR = @MODINSTALLDIR@
+OBJEXT = @OBJEXT@
+OPROFILE_DIR = @OPROFILE_DIR@
+OPROFILE_MODULE_ARCH = @OPROFILE_MODULE_ARCH@
+OP_CFLAGS = @OP_CFLAGS@
+OP_CXXFLAGS = @OP_CXXFLAGS@
+OP_DOCDIR = @OP_DOCDIR@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POPT_LIBS = @POPT_LIBS@
+PTRDIFF_T_TYPE = @PTRDIFF_T_TYPE@
+QT_INCLUDES = @QT_INCLUDES@
+QT_LDFLAGS = @QT_LDFLAGS@
+QT_LIB = @QT_LIB@
+QT_VERSION = @QT_VERSION@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZE_T_TYPE = @SIZE_T_TYPE@
+STRIP = @STRIP@
+UIC = @UIC@
+VERSION = @VERSION@
+XML_CATALOG = @XML_CATALOG@
+XSLTPROC = @XSLTPROC@
+XSLTPROC_FLAGS = @XSLTPROC_FLAGS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+have_qt_FALSE = @have_qt_FALSE@
+have_qt_TRUE = @have_qt_TRUE@
+have_xsltproc_FALSE = @have_xsltproc_FALSE@
+have_xsltproc_TRUE = @have_xsltproc_TRUE@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+kernel_support_FALSE = @kernel_support_FALSE@
+kernel_support_TRUE = @kernel_support_TRUE@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+topdir = @topdir@
+noinst_LIBRARIES = liblegacy.a
+
+# -fno-omit-frame-pointer needed for daemon build: see ChangeLog-2004 02-23
+AM_CFLAGS = @OP_CFLAGS@ -fno-omit-frame-pointer
+AM_CPPFLAGS = \
+ -I ${top_srcdir}/libutil \
+ -I ${top_srcdir}/libop \
+ -I ${top_srcdir}/libdb \
+ -I ${top_srcdir}/daemon
+
+liblegacy_a_SOURCES = \
+ opd_24_stats.c \
+ opd_24_stats.h \
+ opd_kernel.c \
+ opd_proc.c \
+ opd_image.c \
+ opd_mapping.c \
+ opd_parse_proc.c \
+ opd_image.h \
+ opd_mapping.h \
+ p_module.h \
+ opd_kernel.h \
+ opd_parse_proc.h \
+ opd_proc.h \
+ opd_sample_files.c \
+ opd_sample_files.h \
+ init.c
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign daemon/liblegacy/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign daemon/liblegacy/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+liblegacy.a: $(liblegacy_a_OBJECTS) $(liblegacy_a_DEPENDENCIES)
+ -rm -f liblegacy.a
+ $(liblegacy_a_AR) liblegacy.a $(liblegacy_a_OBJECTS) $(liblegacy_a_LIBADD)
+ $(RANLIB) liblegacy.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_24_stats.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_image.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_kernel.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_mapping.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_parse_proc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_proc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opd_sample_files.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/daemon/liblegacy/init.c b/daemon/liblegacy/init.c
new file mode 100644
index 0000000..b2cd013
--- /dev/null
+++ b/daemon/liblegacy/init.c
@@ -0,0 +1,387 @@
+/**
+ * @file daemon/liblegacy/init.c
+ * Daemon set up and main loop for 2.4
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include "config.h"
+
+#include "opd_proc.h"
+#include "opd_mapping.h"
+#include "opd_24_stats.h"
+#include "opd_sample_files.h"
+#include "opd_image.h"
+#include "opd_parse_proc.h"
+#include "opd_kernel.h"
+#include "opd_printf.h"
+#include "oprofiled.h"
+
+#include "op_sample_file.h"
+#include "op_config_24.h"
+#include "op_interface.h"
+#include "op_libiberty.h"
+#include "op_deviceio.h"
+#include "op_events.h"
+#include "op_get_time.h"
+#include "op_fileio.h"
+
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+fd_t hashmapdevfd;
+
+int cpu_number;
+
+static fd_t devfd;
+static fd_t notedevfd;
+static struct op_buffer_head * sbuf;
+static size_t s_buf_bytesize;
+static struct op_note * nbuf;
+static size_t n_buf_bytesize;
+
+static void opd_sighup(void);
+static void opd_alarm(void);
+static void opd_sigterm(void);
+
+
+/**
+ * op_open_files - open necessary files
+ *
+ * Open the device files and the log file,
+ * and mmap() the hash map.
+ */
+static void op_open_files(void)
+{
+ hashmapdevfd = op_open_device(op_hash_device);
+ if (hashmapdevfd == -1) {
+ perror("Failed to open hash map device");
+ exit(EXIT_FAILURE);
+ }
+
+ notedevfd = op_open_device(op_note_device);
+ if (notedevfd == -1) {
+ if (errno == EINVAL)
+ fprintf(stderr, "Failed to open note device. Possibly you have passed incorrect\n"
+ "parameters. Check /var/log/messages.");
+ else
+ perror("Failed to open note device");
+ exit(EXIT_FAILURE);
+ }
+
+ devfd = op_open_device(op_device);
+ if (devfd == -1) {
+ if (errno == EINVAL)
+ fprintf(stderr, "Failed to open device. Possibly you have passed incorrect\n"
+ "parameters. Check /var/log/messages.");
+ else
+ perror("Failed to open profile device");
+ exit(EXIT_FAILURE);
+ }
+
+ opd_init_hash_map();
+
+ /* give output before re-opening stdout as the logfile */
+ printf("Using log file %s\n", op_log_file);
+
+ /* set up logfile */
+ close(0);
+ close(1);
+
+ if (open("/dev/null", O_RDONLY) == -1) {
+ perror("oprofiled: couldn't re-open stdin as /dev/null: ");
+ exit(EXIT_FAILURE);
+ }
+
+ opd_open_logfile();
+
+ printf("oprofiled started %s", op_get_time());
+ fflush(stdout);
+}
+
+
+static void opd_do_samples(struct op_buffer_head const * buf);
+static void opd_do_notes(struct op_note const * opd_buf, size_t count);
+
+/**
+ * do_shutdown - shutdown cleanly, reading as much remaining data as possible.
+ * @param buf sample buffer area
+ * @param size size of sample buffer
+ * @param nbuf note buffer area
+ * @param nsize size of note buffer
+ */
+static void opd_shutdown(struct op_buffer_head * buf, size_t size, struct op_note * nbuf, size_t nsize)
+{
+ ssize_t count = -1;
+ ssize_t ncount = -1;
+
+ /* the dump may have added no samples, so we must set
+ * non-blocking */
+ if (fcntl(devfd, F_SETFL, fcntl(devfd, F_GETFL) | O_NONBLOCK) < 0) {
+ perror("Failed to set non-blocking read for device: ");
+ exit(EXIT_FAILURE);
+ }
+
+ /* it's always OK to read the note device */
+ while (ncount < 0)
+ ncount = op_read_device(notedevfd, nbuf, nsize);
+
+ if (ncount > 0)
+ opd_do_notes(nbuf, ncount);
+
+ /* read as much as we can until we have exhausted the data
+ * (EAGAIN is returned).
+ *
+ * This will not livelock as the profiler has been partially
+ * shut down by now.
+ */
+ while (1) {
+ count = op_read_device(devfd, buf, size);
+ if (count < 0 && errno == EAGAIN)
+ break;
+ verbprintf(vmisc, "Shutting down, state %d\n", buf->state);
+ opd_do_samples(buf);
+ }
+}
+
+
+/**
+ * opd_do_read - enter processing loop
+ * @param buf buffer to read into
+ * @param size size of buffer
+ * @param nbuf note buffer
+ * @param nsize size of note buffer
+ *
+ * Read some of a buffer from the device and process
+ * the contents.
+ */
+static void opd_do_read(struct op_buffer_head * buf, size_t size, struct op_note * nbuf, size_t nsize)
+{
+ while (1) {
+ ssize_t count = -1;
+ ssize_t ncount = -1;
+
+ /* loop to handle EINTR */
+ while (count < 0)
+ count = op_read_device(devfd, buf, size);
+
+ while (ncount < 0)
+ ncount = op_read_device(notedevfd, nbuf, nsize);
+
+ opd_do_notes(nbuf, ncount);
+ opd_do_samples(buf);
+
+ // we can lost a signal alarm or a signal hup but we don't
+ // take care.
+ if (signal_alarm) {
+ signal_alarm = 0;
+ opd_alarm();
+ }
+
+ if (signal_hup) {
+ signal_hup = 0;
+ opd_sighup();
+ }
+
+ if (signal_term)
+ opd_sigterm();
+
+ /* request to stop arrived */
+ if (buf->state == STOPPING) {
+ verbprintf(vmisc, "Shutting down by request.\n");
+ opd_shutdown(buf, size, nbuf, nsize);
+ return;
+ }
+ }
+}
+
+/**
+ * opd_do_notes - process a notes buffer
+ * @param opd_buf buffer to process
+ * @param count number of bytes in buffer
+ *
+ * Process a buffer of notes.
+ */
+static void opd_do_notes(struct op_note const * opd_buf, size_t count)
+{
+ uint i;
+ struct op_note const * note;
+
+ for (i = 0; i < count/sizeof(struct op_note); i++) {
+ note = &opd_buf[i];
+
+ opd_24_stats[OPD_NOTIFICATIONS]++;
+
+ switch (note->type) {
+ case OP_MAP:
+ case OP_EXEC:
+ if (note->type == OP_EXEC)
+ opd_handle_exec(note->pid, note->tgid);
+ opd_handle_mapping(note);
+ break;
+
+ case OP_FORK:
+ opd_handle_fork(note);
+ break;
+
+ case OP_DROP_MODULES:
+ opd_clear_module_info();
+ break;
+
+ case OP_EXIT:
+ opd_handle_exit(note);
+ break;
+
+ default:
+ fprintf(stderr, "Received unknown notification type %u\n", note->type);
+ abort();
+ break;
+ }
+ }
+}
+
+/**
+ * opd_do_samples - process a sample buffer
+ * @param opd_buf buffer to process
+ *
+ * Process a buffer of samples.
+ * The signals specified by the global variable maskset are
+ * masked.
+ *
+ * If the sample could be processed correctly, it is written
+ * to the relevant sample file. Additionally mapping and
+ * process notifications are handled here.
+ */
+static void opd_do_samples(struct op_buffer_head const * opd_buf)
+{
+ uint i;
+ struct op_sample const * buffer = opd_buf->buffer;
+
+ opd_24_stats[OPD_DUMP_COUNT]++;
+
+ verbprintf(vmisc, "Read buffer of %d entries for cpu %d.\n",
+ (unsigned int)opd_buf->count, opd_buf->cpu_nr);
+
+ if (separate_cpu)
+ cpu_number = opd_buf->cpu_nr;
+ for (i = 0; i < opd_buf->count; i++) {
+ verbprintf(vsamples, "%.6u: EIP: 0x%.8lx pid: %.6d\n",
+ i, buffer[i].eip, buffer[i].pid);
+ opd_put_sample(&buffer[i]);
+ }
+}
+
+
+/**
+ * opd_alarm - clean up old procs, msync, and report stats
+ */
+static void opd_alarm(void)
+{
+ opd_sync_samples_files();
+
+ opd_age_procs();
+
+ opd_print_24_stats();
+
+ alarm(60 * 10);
+}
+
+
+/* re-open logfile for logrotate */
+static void opd_sighup(void)
+{
+ printf("Received SIGHUP.\n");
+ close(1);
+ close(2);
+ opd_open_logfile();
+ /* We just close them, and re-open them lazily as usual. */
+ opd_for_each_image(opd_close_image_samples_files);
+}
+
+
+static void clean_exit(void)
+{
+ opd_cleanup_hash_name();
+ op_free_events();
+ unlink(op_lock_file);
+}
+
+
+static void opd_sigterm(void)
+{
+ opd_print_24_stats();
+ printf("oprofiled stopped %s", op_get_time());
+ exit(EXIT_FAILURE);
+}
+
+
+static void opd_24_init(void)
+{
+ size_t i;
+ int opd_buf_size = OP_DEFAULT_BUF_SIZE;
+ int opd_note_buf_size = OP_DEFAULT_NOTE_SIZE;
+
+ if (!no_vmlinux)
+ opd_parse_kernel_range(kernel_range);
+ opd_buf_size = opd_read_fs_int(OP_MOUNT, "bufsize", 1);
+ opd_note_buf_size = opd_read_fs_int(OP_MOUNT, "notesize", 1);
+
+ s_buf_bytesize = sizeof(struct op_buffer_head) + opd_buf_size * sizeof(struct op_sample);
+
+ sbuf = xmalloc(s_buf_bytesize);
+
+ n_buf_bytesize = opd_note_buf_size * sizeof(struct op_note);
+ nbuf = xmalloc(n_buf_bytesize);
+
+ opd_init_images();
+ opd_init_procs();
+ opd_init_kernel_image();
+
+ for (i = 0; i < OPD_MAX_STATS; i++)
+ opd_24_stats[i] = 0;
+
+ if (atexit(clean_exit)) {
+ perror("oprofiled: couldn't set exit cleanup: ");
+ exit(EXIT_FAILURE);
+ }
+}
+
+
+static void opd_24_start(void)
+{
+ op_open_files();
+
+ /* yes, this is racey. */
+ opd_get_ascii_procs();
+
+ /* simple sleep-then-process loop */
+ opd_do_read(sbuf, s_buf_bytesize, nbuf, n_buf_bytesize);
+}
+
+
+static void opd_24_exit(void)
+{
+ opd_print_24_stats();
+ printf("oprofiled stopped %s", op_get_time());
+
+ free(sbuf);
+ free(nbuf);
+ opd_clear_module_info();
+ opd_proc_cleanup();
+ /* kernel/module image are not owned by a proc, we must cleanup them */
+ opd_for_each_image(opd_delete_image);
+}
+
+
+struct oprofiled_ops opd_24_ops = {
+ .init = opd_24_init,
+ .start = opd_24_start,
+ .exit = opd_24_exit
+};
diff --git a/daemon/liblegacy/opd_24_stats.c b/daemon/liblegacy/opd_24_stats.c
new file mode 100644
index 0000000..52425c4
--- /dev/null
+++ b/daemon/liblegacy/opd_24_stats.c
@@ -0,0 +1,62 @@
+/**
+ * @file opd_24_stats.c
+ * Management of daemon statistics
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include "opd_24_stats.h"
+#include "opd_proc.h"
+#include "opd_image.h"
+#include "oprofiled.h"
+
+#include "op_get_time.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+unsigned long opd_24_stats[OPD_MAX_STATS];
+
+void opd_print_24_stats(void)
+{
+ printf("\n%s\n", op_get_time());
+ printf("Nr. proc struct: %d\n", opd_get_nr_procs());
+ printf("Nr. image struct: %d\n", opd_get_nr_images());
+ printf("Nr. kernel samples: %lu\n", opd_24_stats[OPD_KERNEL]);
+ printf("Nr. modules samples: %lu\n", opd_24_stats[OPD_MODULE]);
+ printf("Nr. modules samples lost: %lu\n", opd_24_stats[OPD_LOST_MODULE]);
+ printf("Nr. samples lost due to no process information: %lu\n",
+ opd_24_stats[OPD_LOST_PROCESS]);
+ printf("Nr. samples lost due to sample file open failure: %lu\n",
+ opd_24_stats[OPD_LOST_SAMPLEFILE]);
+ printf("Nr. process samples in user-space: %lu\n", opd_24_stats[OPD_PROCESS]);
+ printf("Nr. samples lost due to no map information: %lu\n",
+ opd_24_stats[OPD_LOST_MAP_PROCESS]);
+ if (opd_24_stats[OPD_PROC_QUEUE_ACCESS]) {
+ printf("Average depth of search of proc queue: %f\n",
+ (double)opd_24_stats[OPD_PROC_QUEUE_DEPTH]
+ / (double)opd_24_stats[OPD_PROC_QUEUE_ACCESS]);
+ }
+ if (opd_24_stats[OPD_MAP_ARRAY_ACCESS]) {
+ printf("Average depth of iteration through mapping array: %f\n",
+ (double)opd_24_stats[OPD_MAP_ARRAY_DEPTH]
+ / (double)opd_24_stats[OPD_MAP_ARRAY_ACCESS]);
+ }
+ if (opd_24_stats[OPD_IMAGE_HASH_ACCESS]) {
+ printf("Average depth of iteration through image hash array: %f\n",
+ (double)opd_24_stats[OPD_IMAGE_HASH_DEPTH]
+ / (double)opd_24_stats[OPD_IMAGE_HASH_ACCESS]);
+ }
+ printf("Nr. sample dumps: %lu\n", opd_24_stats[OPD_DUMP_COUNT]);
+ printf("Nr. samples total: %lu\n", opd_24_stats[OPD_SAMPLES]);
+ printf("Nr. notifications: %lu\n", opd_24_stats[OPD_NOTIFICATIONS]);
+ printf("Nr. kernel note buffer overflow: %u\n",
+ opd_read_fs_int(OP_MOUNT, "note_buffer_overflow", 0));
+ printf("Nr. kernel samples buffer overflow: %u\n",
+ opd_read_fs_int(OP_MOUNT, "buffer_overflow", 0));
+ fflush(stdout);
+}
diff --git a/daemon/liblegacy/opd_24_stats.h b/daemon/liblegacy/opd_24_stats.h
new file mode 100644
index 0000000..4acd860
--- /dev/null
+++ b/daemon/liblegacy/opd_24_stats.h
@@ -0,0 +1,39 @@
+/**
+ * @file opd_24_stats.h
+ * Management of daemon statistics
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#ifndef OPD_24_STATS_H
+#define OPD_24_STATS_H
+
+extern unsigned long opd_24_stats[];
+
+enum { OPD_KERNEL, /**< nr kernel samples */
+ OPD_MODULE, /**< nr module samples */
+ OPD_LOST_MODULE, /**< nr samples in module for which modules can not be located */
+ OPD_LOST_PROCESS, /**< nr samples for which process info couldn't be accessed */
+ OPD_PROCESS, /**< nr userspace samples */
+ OPD_LOST_MAP_PROCESS, /**< nr samples for which map info couldn't be accessed */
+ OPD_LOST_SAMPLEFILE, /**< nr samples for which sample file can't be opened */
+ OPD_PROC_QUEUE_ACCESS, /**< nr accesses of proc queue */
+ OPD_PROC_QUEUE_DEPTH, /**< cumulative depth of proc queue accesses */
+ OPD_DUMP_COUNT, /**< nr of times buffer is read */
+ OPD_MAP_ARRAY_ACCESS, /**< nr accesses of map array */
+ OPD_MAP_ARRAY_DEPTH, /**< cumulative depth of map array accesses */
+ OPD_IMAGE_HASH_ACCESS, /**< nr opd_find_image() */
+ OPD_IMAGE_HASH_DEPTH, /**< cumulative depth of image search */
+ OPD_SAMPLES, /**< nr distinct samples */
+ OPD_NOTIFICATIONS, /**< nr notifications */
+ OPD_MAX_STATS /**< end of stats */
+ };
+
+/** opd_print_24_stats - print out latest statistics */
+void opd_print_24_stats(void);
+
+#endif /* OPD_24_STATS_H */
diff --git a/daemon/liblegacy/opd_image.c b/daemon/liblegacy/opd_image.c
new file mode 100644
index 0000000..ac6b5a2
--- /dev/null
+++ b/daemon/liblegacy/opd_image.c
@@ -0,0 +1,264 @@
+/**
+ * @file opd_image.c
+ * Management of binary images
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include "opd_image.h"
+#include "opd_printf.h"
+#include "opd_sample_files.h"
+#include "opd_24_stats.h"
+#include "oprofiled.h"
+
+#include "op_file.h"
+#include "op_config_24.h"
+#include "op_libiberty.h"
+#include "op_string.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* maintained for statistics purpose only */
+static int nr_images;
+
+/* list of images */
+#define OPD_IMAGE_HASH_SIZE 2048
+static struct list_head opd_images[OPD_IMAGE_HASH_SIZE];
+
+
+void opd_init_images(void)
+{
+ int i;
+ for (i = 0; i < OPD_IMAGE_HASH_SIZE; ++i)
+ list_init(&opd_images[i]);
+}
+
+
+int opd_get_nr_images(void)
+{
+ return nr_images;
+}
+
+
+void opd_delete_image(struct opd_image * image)
+{
+ verbprintf(vmisc, "Deleting image: name %s app_name %s, kernel %d, "
+ "tid %d, tgid %d ref count %u\n",
+ image->name, image->app_name, image->kernel,
+ image->tid, image->tgid, (int)image->ref_count);
+
+ if (image->ref_count <= 0) {
+ printf("image->ref_count < 0 for image: name %s app_name %s, "
+ "kernel %d, tid %d, tgid %d ref count %u\n",
+ image->name, image->app_name, image->kernel,
+ image->tid, image->tgid, image->ref_count);
+ abort();
+ }
+
+ if (--image->ref_count != 0)
+ return;
+
+ if (image->name)
+ free(image->name);
+ if (image->app_name)
+ free(image->app_name);
+ list_del(&image->hash_next);
+ opd_close_image_samples_files(image);
+ free(image);
+
+ nr_images--;
+}
+
+
+void opd_for_each_image(opd_image_cb image_cb)
+{
+ struct list_head * pos;
+ struct list_head * pos2;
+ int i;
+
+ for (i = 0; i < OPD_IMAGE_HASH_SIZE; ++i) {
+ list_for_each_safe(pos, pos2, &opd_images[i]) {
+ struct opd_image * image =
+ list_entry(pos, struct opd_image, hash_next);
+ image_cb(image);
+ }
+ }
+}
+
+
+/**
+ * opd_hash_image - hash an image
+ * @param hash hash of image name
+ * @param tid thread id
+ * @param tgid thread group id
+ *
+ * return the hash code for the passed parameters
+ */
+static size_t opd_hash_image(char const * name, pid_t tid, pid_t tgid)
+{
+ size_t hash = op_hash_string(name);
+ if (separate_thread)
+ hash += tid + tgid;
+ return hash % OPD_IMAGE_HASH_SIZE;
+}
+
+
+/**
+ * opd_new_image - create an image sample file
+ * @param app_name the application name where belongs this image
+ * @param name name of the image to add
+ * @param kernel is the image a kernel/module image
+ * @param tid thread id
+ * @param tgid thread group id
+ *
+ * image at funtion entry is uninitialised
+ * name is copied i.e. should be GC'd separately from the
+ * image structure if appropriate.
+ *
+ * Initialise an opd_image struct for the image image
+ * without opening the associated samples files. At return
+ * the image is fully initialized.
+ */
+static struct opd_image *
+opd_new_image(char const * name, char const * app_name, int kernel,
+ pid_t tid, pid_t tgid)
+{
+ size_t hash_image;
+ struct opd_image * image;
+
+ verbprintf(vmisc, "Creating image: %s %s, kernel %d, tid %d, "
+ "tgid %d\n", name, app_name, kernel, tid, tgid);
+
+ image = xmalloc(sizeof(struct opd_image));
+
+ list_init(&image->hash_next);
+ image->name = xstrdup(name);
+ image->kernel = kernel;
+ image->tid = tid;
+ image->tgid = tgid;
+ image->ref_count = 0;
+ image->app_name = app_name ? xstrdup(app_name) : NULL;
+ image->mtime = op_get_mtime(image->name);
+
+ image->ignored = 1;
+ if (separate_lib && app_name)
+ image->ignored = is_image_ignored(app_name);
+ if (image->ignored)
+ image->ignored = is_image_ignored(name);
+
+ memset(image->sfiles, '\0', NR_CPUS * sizeof(struct opd_24_sfile **));
+
+ hash_image = opd_hash_image(name, tid, tgid);
+ list_add(&image->hash_next, &opd_images[hash_image]);
+
+ nr_images++;
+
+ return image;
+}
+
+
+/**
+ * is_same_image - check for identical image
+ * @param image image to compare
+ * @param name name of image
+ * @param app_name image must belong to this application name
+ * @param tid thread id
+ * @param tgid thread group id
+ *
+ * on entry caller have checked than strcmp(image->name, name) == 0
+ * return 0 if the couple (name, app_name) refers to same image
+ */
+static int is_same_image(struct opd_image const * image, char const * app_name,
+ pid_t tid, pid_t tgid)
+{
+ /* correctness is really important here, if we fail to recognize
+ * identical image we will open/mmap multiple time the same samples
+ * files which is not supported by the kernel, strange assertion
+ * failure in libfd is a typical symptom of that */
+
+ if (separate_thread) {
+ if (image->tid != tid || image->tgid != tgid)
+ return 1;
+ }
+
+ /* if !separate_lib, the comparison made by caller is enough */
+ if (!separate_lib)
+ return 0;
+
+ if (image->app_name == NULL && app_name == NULL)
+ return 0;
+
+ if (image->app_name != NULL && app_name != NULL &&
+ !strcmp(image->app_name, app_name))
+ return 0;
+
+ /* /proc parsed image come with a non null app_name but notification
+ * for application itself come with a null app_name, in this case
+ * the test above fail so check for this case. */
+ if (image->app_name && !app_name && !strcmp(image->app_name, image->name))
+ return 0;
+
+ return 1;
+}
+
+
+/**
+ * opd_find_image - find an image
+ * @param name name of image to find
+ * @param hash hash of image to find
+ * @param app_name the application name where belongs this image
+ * @param tid thread id
+ * @param tgid thread group id
+ *
+ * Returns the image pointer for the file specified by name, or %NULL.
+ */
+static struct opd_image * opd_find_image(char const * name,
+ char const * app_name, pid_t tid, pid_t tgid)
+{
+ /* suppress uninitialized use warning */
+ struct opd_image * image = 0;
+ struct list_head * pos;
+ size_t bucket;
+
+ opd_24_stats[OPD_IMAGE_HASH_ACCESS]++;
+ bucket = opd_hash_image(name, tid, tgid);
+ list_for_each(pos, &opd_images[bucket]) {
+ opd_24_stats[OPD_IMAGE_HASH_DEPTH]++;
+ image = list_entry(pos, struct opd_image, hash_next);
+
+ if (!strcmp(image->name, name)) {
+ if (!is_same_image(image, app_name, tid, tgid))
+ break;
+ }
+ }
+
+ if (pos == &opd_images[bucket])
+ return NULL;
+
+ /* The app_name field is always valid */
+ return image;
+}
+
+
+struct opd_image * opd_get_image(char const * name, char const * app_name,
+ int kernel, pid_t tid, pid_t tgid)
+{
+ struct opd_image * image;
+ if ((image = opd_find_image(name, app_name, tid, tgid)) == NULL)
+ image = opd_new_image(name, app_name, kernel, tid, tgid);
+
+ return image;
+}
+
+
+struct opd_image * opd_get_kernel_image(char const * name,
+ char const * app_name, pid_t tid, pid_t tgid)
+{
+ return opd_get_image(name, app_name, 1, tid, tgid);
+}
diff --git a/daemon/liblegacy/opd_image.h b/daemon/liblegacy/opd_image.h
new file mode 100644
index 0000000..5d55270
--- /dev/null
+++ b/daemon/liblegacy/opd_image.h
@@ -0,0 +1,111 @@
+/**
+ * @file opd_image.h
+ * Management of binary images
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#ifndef OPD_IMAGE_H
+#define OPD_IMAGE_H
+
+#include "op_list.h"
+#include "op_config_24.h"
+#include "op_types.h"
+
+#include <time.h>
+
+struct opd_24_sfile;
+
+/**
+ * A binary (library, application, kernel or module)
+ * is represented by a struct opd_image.
+ */
+struct opd_image {
+ /** used by container of opd_images */
+ struct list_head hash_next;
+ /** how many time this opd_image is referenced */
+ int ref_count;
+ /** all samples files belonging to this image */
+ struct opd_24_sfile ** sfiles[NR_CPUS];
+ /** name of this image */
+ char * name;
+ /** the application name where belongs this image, NULL if image has
+ * no owner (such as vmlinux or module) */
+ char * app_name;
+ /** thread id, on 2.2 kernel always == to tgid */
+ pid_t tid;
+ /** thread group id */
+ pid_t tgid;
+ /** time of last modification */
+ time_t mtime;
+ /** kernel image or not */
+ int kernel;
+ /** non zero if this image must be profiled */
+ int ignored;
+};
+
+/** callback function passed to opd_for_each_image() */
+typedef void (*opd_image_cb)(struct opd_image *);
+
+/**
+ * @param imagecb callback to apply onto each existing image struct
+ *
+ * the callback receive a struct opd_image * (not a const struct) and is
+ * allowed to freeze the image struct itself.
+ */
+void opd_for_each_image(opd_image_cb imagecb);
+
+/**
+ * initialize opd_image container
+ */
+void opd_init_images(void);
+
+/**
+ * @param image the image pointer
+ *
+ * Decrement reference count of image, if reference count is zero flush and
+ * close the samples files then freeze all memory belonging to this image.
+ */
+void opd_delete_image(struct opd_image * image);
+
+/**
+ * opd_get_kernel_image - get a kernel image
+ * @param name of image
+ * @param app_name application owner of this kernel image. non-null only
+ * when separate_kernel_sample != 0
+ * @param tid thread id
+ * @param tgid thread group id
+ *
+ * Create and initialise an image adding it to the image lists and to image
+ * hash list. Note than at creation reference count is zero, it's caller
+ * responsabilities to incr this count.
+ */
+struct opd_image * opd_get_kernel_image(char const * name,
+ char const * app_name, pid_t tid, pid_t tgid);
+
+/**
+ * opd_get_image - get an image from the image structure
+ * @param name name of image
+ * @param app_name the application name where belongs this image
+ * @param kernel is the image a kernel/module image
+ * @param tid thread id
+ * @param tgid thread group id
+ *
+ * Get the image specified by the file name name from the
+ * image structure. If it is not present, the image is
+ * added to the structure. In either case, the image number
+ * is returned.
+ */
+struct opd_image * opd_get_image(char const * name, char const * app_name,
+ int kernel, pid_t tid, pid_t tgid);
+
+/**
+ * opd_get_nr_images - return number of images
+ */
+int opd_get_nr_images(void);
+
+#endif /* OPD_IMAGE_H */
diff --git a/daemon/liblegacy/opd_kernel.c b/daemon/liblegacy/opd_kernel.c
new file mode 100644
index 0000000..1131aa7
--- /dev/null
+++ b/daemon/liblegacy/opd_kernel.c
@@ -0,0 +1,464 @@
+/**
+ * @file daemon/liblegacy/opd_kernel.c
+ * Dealing with the kernel and kernel module samples
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include "opd_kernel.h"
+#include "opd_proc.h"
+#include "opd_image.h"
+#include "opd_mapping.h"
+#include "opd_printf.h"
+#include "opd_24_stats.h"
+#include "oprofiled.h"
+
+#include "op_fileio.h"
+#include "op_config_24.h"
+#include "op_libiberty.h"
+
+#include "p_module.h"
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+/* kernel module */
+struct opd_module {
+ char * name;
+ struct opd_image * image;
+ unsigned long start;
+ unsigned long end;
+ struct list_head module_list;
+};
+
+static struct opd_image * kernel_image;
+
+/* kernel and module support */
+static unsigned long kernel_start;
+static unsigned long kernel_end;
+static struct list_head opd_modules = { &opd_modules, &opd_modules };
+static unsigned int nr_modules=0;
+
+void opd_init_kernel_image(void)
+{
+ /* for no vmlinux */
+ if (!vmlinux)
+ vmlinux = "no-vmlinux";
+ kernel_image = opd_get_kernel_image(vmlinux, NULL, 0, 0);
+ kernel_image->ref_count++;
+}
+
+
+void opd_parse_kernel_range(char const * arg)
+{
+ sscanf(arg, "%lx,%lx", &kernel_start, &kernel_end);
+
+ verbprintf(vmisc, "OPD_PARSE_KERNEL_RANGE: kernel_start = %lx, kernel_end = %lx\n",
+ kernel_start, kernel_end);
+
+ if (!kernel_start && !kernel_end) {
+ fprintf(stderr,
+ "Warning: mis-parsed kernel range: %lx-%lx\n",
+ kernel_start, kernel_end);
+ fprintf(stderr, "kernel profiles will be wrong.\n");
+ }
+}
+
+
+/**
+ * opd_create_module - allocate and initialise a module description
+ * @param name module name
+ * @param start start address
+ * @param end end address
+ */
+static struct opd_module *
+opd_create_module(char * name, unsigned long start, unsigned long end)
+{
+ struct opd_module * module = xmalloc(sizeof(struct opd_module));
+
+ module->name = xstrdup(name);
+ module->image = NULL;
+ module->start = start;
+ module->end = end;
+ list_add(&module->module_list, &opd_modules);
+
+ return module;
+}
+
+
+/**
+ * opd_find_module_by_name - find a module by name, ccreating a new once if
+ * search fail
+ * @param name module name
+ */
+static struct opd_module * opd_find_module_by_name(char * name)
+{
+ struct list_head * pos;
+ struct opd_module * module;
+
+ list_for_each(pos, &opd_modules) {
+ module = list_entry(pos, struct opd_module, module_list);
+ if (!strcmp(name, module->name))
+ return module;
+ }
+
+ return opd_create_module(name, 0, 0);
+}
+
+
+void opd_clear_module_info(void)
+{
+ struct list_head * pos;
+ struct list_head * pos2;
+ struct opd_module * module;
+
+ verbprintf(vmodule, "Removing module list\n");
+ list_for_each_safe(pos, pos2, &opd_modules) {
+ module = list_entry(pos, struct opd_module, module_list);
+ free(module->name);
+ free(module);
+ }
+
+ list_init(&opd_modules);
+
+ opd_clear_kernel_mapping();
+}
+
+
+/**
+ * opd_get_module_info - parse mapping information for kernel modules
+ *
+ * Parse the file /proc/ksyms to read in mapping information for
+ * all kernel modules. The modutils package adds special symbols
+ * to this file which allows determination of the module image
+ * and mapping addresses of the form :
+ *
+ * __insmod_modulename_Oobjectfile_Mmtime_Vversion
+ * __insmod_modulename_Ssectionname_Llength
+ *
+ * Currently the image file "objectfile" is stored, and details of
+ * ".text" sections.
+ *
+ * There is no query_module API that allow to get directly the pathname
+ * of a module so we need to parse all the /proc/ksyms.
+ */
+static void opd_get_module_info(void)
+{
+ char * line;
+ char * cp, * cp2, * cp3;
+ FILE * fp;
+ struct opd_module * mod;
+ char * modname;
+ char * filename;
+
+ nr_modules=0;
+
+ fp = op_try_open_file("/proc/ksyms", "r");
+
+ if (!fp) {
+ printf("oprofiled: /proc/ksyms not readable, can't process module samples.\n");
+ return;
+ }
+
+ verbprintf(vmodule, "Read module info.\n");
+
+ while (1) {
+ line = op_get_line(fp);
+
+ if (!line)
+ break;
+
+ if (!strcmp("", line)) {
+ free(line);
+ continue;
+ }
+
+ if (strlen(line) < 9) {
+ printf("oprofiled: corrupt /proc/ksyms line \"%s\"\n", line);
+ break;
+ }
+
+ if (strncmp("__insmod_", line + 9, 9)) {
+ free(line);
+ continue;
+ }
+
+ cp = line + 18;
+ cp2 = cp;
+ while ((*cp2) && !!strncmp("_S", cp2+1, 2) && !!strncmp("_O", cp2+1, 2))
+ cp2++;
+
+ if (!*cp2) {
+ printf("oprofiled: corrupt /proc/ksyms line \"%s\"\n", line);
+ break;
+ }
+
+ cp2++;
+
+ modname = xmalloc((size_t)((cp2-cp) + 1));
+ strncpy(modname, cp, (size_t)((cp2-cp)));
+ modname[cp2-cp] = '\0';
+
+ mod = opd_find_module_by_name(modname);
+
+ free(modname);
+
+ switch (*(++cp2)) {
+ case 'O':
+ /* get filename */
+ cp2++;
+ cp3 = cp2;
+
+ while ((*cp3) && !!strncmp("_M", cp3+1, 2))
+ cp3++;
+
+ if (!*cp3) {
+ free(line);
+ continue;
+ }
+
+ cp3++;
+ filename = xmalloc((size_t)(cp3 - cp2 + 1));
+ strncpy(filename, cp2, (size_t)(cp3 - cp2));
+ filename[cp3-cp2] = '\0';
+
+ mod->image = opd_get_kernel_image(filename, NULL, 0, 0);
+ mod->image->ref_count++;
+ free(filename);
+ break;
+
+ case 'S':
+ /* get extent of .text section */
+ cp2++;
+ if (strncmp(".text_L", cp2, 7)) {
+ free(line);
+ continue;
+ }
+
+ cp2 += 7;
+ sscanf(line, "%lx", &mod->start);
+ sscanf(cp2, "%lu", &mod->end);
+ mod->end += mod->start;
+ break;
+ }
+
+ free(line);
+ }
+
+ if (line)
+ free(line);
+ op_close_file(fp);
+}
+
+
+/**
+ * opd_drop_module_sample - drop a module sample efficiently
+ * @param eip eip of sample
+ *
+ * This function is called to recover from failing to put a samples even
+ * after re-reading /proc/ksyms. It's either a rogue sample, or from a module
+ * that didn't create symbols (like in some initrd setups). So we check with
+ * query_module() if we can place it in a symbol-less module, and if so create
+ * a negative entry for it, to quickly ignore future samples.
+ *
+ * Problem uncovered by Bob Montgomery <bobm@fc.hp.com>
+ *
+ */
+static void opd_drop_module_sample(unsigned long eip)
+{
+ char * module_names;
+ char * name;
+ size_t size = 1024;
+ size_t ret;
+ uint nr_mods;
+ uint mod = 0;
+
+ opd_24_stats[OPD_LOST_MODULE]++;
+
+ module_names = xmalloc(size);
+ while (query_module(NULL, QM_MODULES, module_names, size, &ret)) {
+ if (errno != ENOSPC) {
+ verbprintf(vmodule, "query_module failed: %s\n", strerror(errno));
+ return;
+ }
+ size = ret;
+ module_names = xrealloc(module_names, size);
+ }
+
+ nr_mods = ret;
+ name = module_names;
+
+ while (mod < nr_mods) {
+ struct module_info info;
+ if (!query_module(name, QM_INFO, &info, sizeof(info), &ret)) {
+ if (eip >= info.addr && eip < info.addr + info.size) {
+ verbprintf(vmodule, "Sample from unprofilable module %s\n", name);
+ opd_create_module(name, info.addr, info.addr + info.size);
+ break;
+ }
+ }
+ mod++;
+ name += strlen(name) + 1;
+ }
+
+ if (module_names)
+ free(module_names);
+}
+
+
+/**
+ * opd_find_module_by_eip - find a module by its eip
+ * @param eip EIP value
+ *
+ * find in the modules container the module which
+ * contain this eip return %NULL if not found.
+ * caller must check than the module image is valid
+ */
+static struct opd_module * opd_find_module_by_eip(unsigned long eip)
+{
+ struct list_head * pos;
+ struct opd_module * module;
+
+ list_for_each(pos, &opd_modules) {
+ module = list_entry(pos, struct opd_module, module_list);
+ if (module->start <= eip && module->end > eip)
+ return module;
+ }
+
+ return NULL;
+}
+
+
+/**
+ * opd_handle_module_sample - process a module sample
+ * @param eip EIP value
+ * @param counter counter number
+ *
+ * Process a sample in module address space. The sample eip
+ * is matched against module information. If the search was
+ * successful, the sample is output to the relevant file.
+ *
+ * Note that for modules and the kernel, the offset will be
+ * wrong in the file, as it is not a file offset, but the offset
+ * from the text section. This is fixed up in pp.
+ *
+ * If the sample could not be located in a module, it is treated
+ * as a kernel sample.
+ */
+static void opd_handle_module_sample(unsigned long eip, u32 counter)
+{
+ struct opd_module * module;
+
+ module = opd_find_module_by_eip(eip);
+ if (!module) {
+ /* not found in known modules, re-read our info and retry */
+ opd_clear_module_info();
+ opd_get_module_info();
+
+ module = opd_find_module_by_eip(eip);
+ }
+
+ if (module) {
+ if (module->image != NULL) {
+ opd_24_stats[OPD_MODULE]++;
+ opd_put_image_sample(module->image,
+ eip - module->start, counter);
+ } else {
+ opd_24_stats[OPD_LOST_MODULE]++;
+ verbprintf(vmodule, "No image for sampled module %s\n",
+ module->name);
+ }
+ } else {
+ opd_drop_module_sample(eip);
+ }
+}
+
+
+void opd_handle_kernel_sample(unsigned long eip, u32 counter)
+{
+ if (no_vmlinux || eip < kernel_end) {
+ opd_24_stats[OPD_KERNEL]++;
+ opd_put_image_sample(kernel_image, eip - kernel_start, counter);
+ return;
+ }
+
+ /* in a module */
+ opd_handle_module_sample(eip, counter);
+}
+
+
+int opd_eip_is_kernel(unsigned long eip)
+{
+#ifdef __i386
+#define KERNEL_OFFSET 0xC0000000
+ /*
+ * kernel_start == 0 when using --no-vmlinux.
+ * This is wrong, wrong, wrong, wrong, but we don't have much
+ * choice. It obviously breaks for IA64.
+ */
+ if (!kernel_start)
+ return eip >= KERNEL_OFFSET;
+#endif
+
+ return eip >= kernel_start;
+}
+
+
+void opd_add_kernel_map(struct opd_proc * proc, unsigned long eip)
+{
+ struct opd_module * module;
+ struct opd_image * image;
+ char const * app_name;
+
+ app_name = proc->name;
+ if (!app_name) {
+ verbprintf(vmisc, "un-named proc for tid %d\n", proc->tid);
+ return;
+ }
+
+
+ if (eip < kernel_end) {
+ image = opd_get_kernel_image(vmlinux, app_name, proc->tid, proc->tgid);
+ if (!image) {
+ verbprintf(vmisc, "Can't create image for %s %s\n", vmlinux, app_name);
+ return;
+ }
+
+ opd_add_mapping(proc, image, kernel_start, 0, kernel_end);
+ return;
+ }
+
+ module = opd_find_module_by_eip(eip);
+ if (!module) {
+ /* not found in known modules, re-read our info and retry */
+ opd_clear_module_info();
+ opd_get_module_info();
+
+ module = opd_find_module_by_eip(eip);
+ }
+
+ if (module) {
+ /* module->name is only the module name not the full path */
+ char const * module_name = 0;
+ if (module->image)
+ module_name = module->image->name;
+ if (!module_name) {
+ verbprintf(vmodule, "unable to get path name for module %s\n",
+ module->name);
+ module_name = module->name;
+ }
+ image = opd_get_kernel_image(module_name, app_name, proc->tid, proc->tgid);
+ if (!image) {
+ verbprintf(vmodule, "Can't create image for %s %s\n",
+ module->name, app_name);
+ return;
+ }
+ opd_add_mapping(proc, image, module->start, 0, module->end);
+ } else {
+ opd_drop_module_sample(eip);
+ }
+}
diff --git a/daemon/liblegacy/opd_kernel.h b/daemon/liblegacy/opd_kernel.h
new file mode 100644
index 0000000..f854ae0
--- /dev/null
+++ b/daemon/liblegacy/opd_kernel.h
@@ -0,0 +1,67 @@
+/**
+ * @file daemon/liblegacy/opd_kernel.h
+ * Dealing with the kernel and kernel module samples
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#ifndef OPD_KERNEL_H
+#define OPD_KERNEL_H
+
+#include "op_types.h"
+
+struct opd_proc;
+
+/**
+ * opd_init_kernel_image - initialise the kernel image
+ */
+void opd_init_kernel_image(void);
+
+/**
+ * opd_parse_kernel_range - parse the kernel range values
+ */
+void opd_parse_kernel_range(char const * arg);
+
+/**
+ * opd_clear_module_info - clear kernel module information
+ *
+ * Clear and free all kernel module information and reset
+ * values.
+ */
+void opd_clear_module_info(void);
+
+/**
+ * opd_handle_kernel_sample - process a kernel sample
+ * @param eip EIP value of sample
+ * @param counter counter number
+ *
+ * Handle a sample in kernel address space or in a module. The sample is
+ * output to the relevant image file.
+ */
+void opd_handle_kernel_sample(unsigned long eip, u32 counter);
+
+/**
+ * opd_eip_is_kernel - is the sample from kernel/module space
+ * @param eip EIP value
+ *
+ * Returns %1 if eip is in the address space starting at
+ * kernel_start, %0 otherwise.
+ */
+int opd_eip_is_kernel(unsigned long eip);
+
+/**
+ * opd_add_kernel_map - add a module or kernel maps to a proc struct
+ *
+ * @param proc owning proc of the new mapping
+ * @param eip eip inside the new mapping
+ *
+ * We assume than eip >= kernel_start
+ *
+ */
+void opd_add_kernel_map(struct opd_proc * proc, unsigned long eip);
+
+#endif /* OPD_KERNEL_H */
diff --git a/daemon/liblegacy/opd_mapping.c b/daemon/liblegacy/opd_mapping.c
new file mode 100644
index 0000000..699c475
--- /dev/null
+++ b/daemon/liblegacy/opd_mapping.c
@@ -0,0 +1,170 @@
+/**
+ * @file opd_mapping.c
+ * Management of process mappings
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include "opd_mapping.h"
+#include "opd_proc.h"
+#include "opd_image.h"
+#include "opd_printf.h"
+
+#include "op_interface.h"
+#include "op_config_24.h"
+#include "op_libiberty.h"
+
+#include <sys/mman.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/* hash map device mmap */
+static struct op_hash_index * hashmap;
+/* already seen mapping name */
+static char const * hash_name[OP_HASH_MAP_NR];
+
+
+void opd_cleanup_hash_name(void)
+{
+ int i;
+ for (i = 0; i < OP_HASH_MAP_NR; ++i)
+ free((char *)hash_name[i]);
+
+}
+
+
+void opd_init_hash_map(void)
+{
+ extern fd_t hashmapdevfd;
+
+ hashmap = mmap(0, OP_HASH_MAP_SIZE, PROT_READ, MAP_SHARED, hashmapdevfd, 0);
+ if ((long)hashmap == -1) {
+ perror("oprofiled: couldn't mmap hash map");
+ exit(EXIT_FAILURE);
+ }
+
+}
+
+
+void opd_kill_maps(struct opd_proc * proc)
+{
+ struct list_head * pos, * pos2;
+
+ list_for_each_safe(pos, pos2, &proc->maps) {
+ struct opd_map * map = list_entry(pos, struct opd_map, next);
+ list_del(pos);
+ opd_delete_image(map->image);
+ free(map);
+ }
+}
+
+
+void opd_add_mapping(struct opd_proc * proc, struct opd_image * image,
+ unsigned long start, unsigned long offset, unsigned long end)
+{
+ struct opd_map * map;
+
+ verbprintf(vmisc, "Adding mapping for process %d: 0x%.8lx-0x%.8lx, off 0x%.8lx, \"%s\"\n",
+ proc->tid, start, end, offset, image->name);
+
+ map = malloc(sizeof(struct opd_map));
+
+ /* first map is the primary image */
+ if (list_empty(&proc->maps)) {
+ if (proc->name)
+ free((char *)proc->name);
+ proc->name = xstrdup(image->name);
+ }
+
+ image->ref_count++;
+
+ map->image = image;
+ map->start = start;
+ map->offset = offset;
+ map->end = end;
+ list_add_tail(&map->next, &proc->maps);
+}
+
+
+/**
+ * get_from_pool - retrieve string from hash map pool
+ * @param ind index into pool
+ */
+inline static char * get_from_pool(uint ind)
+{
+ return ((char *)(hashmap + OP_HASH_MAP_NR) + ind);
+}
+
+
+/**
+ * opg_get_hash_name - find a mapping name from a hash
+ * @param hash hash value for this name
+ */
+static char const * opd_get_hash_name(int hash)
+{
+ char file[PATH_MAX];
+ char * c = &file[PATH_MAX-1];
+ int orighash = hash;
+
+ if (hash_name[hash])
+ return hash_name[hash];
+
+ *c = '\0';
+ while (hash) {
+ char * name = get_from_pool(hashmap[hash].name);
+
+ if (strlen(name) + 1 + strlen(c) >= PATH_MAX) {
+ fprintf(stderr, "String \"%s\" too large.\n", c);
+ exit(EXIT_FAILURE);
+ }
+
+ c -= strlen(name) + 1;
+ *c = '/';
+ strncpy(c + 1, name, strlen(name));
+
+ /* move onto parent */
+ hash = hashmap[hash].parent;
+ }
+
+ return hash_name[orighash] = xstrdup(c);
+}
+
+
+void opd_handle_mapping(struct op_note const * note)
+{
+ struct opd_proc * proc;
+ struct opd_image * image;
+ int hash;
+ char const * name;
+
+ proc = opd_get_proc(note->pid, note->tgid);
+
+ if (!proc) {
+ verbprintf(vmisc, "Told about mapping for non-existent process %u.\n", note->pid);
+ proc = opd_new_proc(note->pid, note->tgid);
+ }
+
+ hash = note->hash;
+
+ if (hash == -1) {
+ /* possibly deleted file */
+ return;
+ }
+
+ if (hash < 0 || hash >= OP_HASH_MAP_NR) {
+ fprintf(stderr, "hash value %u out of range.\n", hash);
+ return;
+ }
+
+ name = opd_get_hash_name(hash);
+ image = opd_get_image(name, proc->name, 0, note->pid, note->tgid);
+
+ opd_add_mapping(proc, image, note->addr, note->offset,
+ note->addr + note->len);
+}
diff --git a/daemon/liblegacy/opd_mapping.h b/daemon/liblegacy/opd_mapping.h
new file mode 100644
index 0000000..f10b0c8
--- /dev/null
+++ b/daemon/liblegacy/opd_mapping.h
@@ -0,0 +1,111 @@
+/**
+ * @file opd_mapping.h
+ * Management of process mappings
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#ifndef OPD_MAPPING_H
+#define OPD_MAPPING_H
+
+#include "op_list.h"
+
+struct opd_image;
+struct opd_proc;
+struct op_note;
+
+/**
+ * represent a mmap'ed area, we create such area only for vma area with exec
+ * access right
+ */
+struct opd_map {
+ /** next mapping for this image */
+ struct list_head next;
+ /** owning image */
+ struct opd_image * image;
+ /** mapping start vma */
+ unsigned long start;
+ /** mapping offset */
+ unsigned long offset;
+ /** mapping end vma */
+ unsigned long end;
+};
+
+/**
+ * opd_init_hash_map - initialise the hashmap
+ */
+void opd_init_hash_map(void);
+
+/**
+ * op_cleanup_hash_name
+ *
+ * release resource owned by hash_name array
+ */
+void opd_cleanup_hash_name(void);
+
+/**
+ * opd_handle_mapping - deal with mapping notification
+ * @param note mapping notification
+ *
+ * Deal with one notification that a process has mapped
+ * in a new executable file. The mapping information is
+ * added to the process structure.
+ */
+void opd_handle_mapping(struct op_note const * note);
+
+/**
+ * opd_put_mapping - add a mapping to a process
+ * @param proc process to add map to
+ * @param image mapped image pointer
+ * @param start start of mapping
+ * @param offset file offset of mapping
+ * @param end end of mapping
+ *
+ * Add the mapping specified to the process proc growing the maps array
+ * if necessary.
+ */
+void opd_add_mapping(struct opd_proc * proc, struct opd_image * image,
+ unsigned long start, unsigned long offset, unsigned long end);
+
+/**
+ * opd_kill_maps - delete mapping information for a process
+ * @param proc process to work on
+ *
+ * Frees structures holding mapping information
+ */
+void opd_kill_maps(struct opd_proc * proc);
+
+/**
+ * opd_is_in_map - check whether an EIP is within a mapping
+ * @param map map to check
+ * @param eip EIP value
+ *
+ * Return %1 if the EIP value @eip is within the boundaries
+ * of the map @map, %0 otherwise.
+ */
+inline static int opd_is_in_map(struct opd_map * map, unsigned long eip)
+{
+ return (eip >= map->start && eip < map->end);
+}
+
+
+/*
+ * opd_map_offset - return offset of sample against map
+ * @param map map to use
+ * @param eip EIP value to use
+ *
+ * Returns the offset of the EIP value @eip into
+ * the map @map, which is the same as the file offset
+ * for the relevant binary image.
+ */
+inline static unsigned long opd_map_offset(struct opd_map * map,
+ unsigned long eip)
+{
+ return (eip - map->start) + map->offset;
+}
+
+#endif /* OPD_MAPPING_H */
diff --git a/daemon/liblegacy/opd_parse_proc.c b/daemon/liblegacy/opd_parse_proc.c
new file mode 100644
index 0000000..8a2d4e8
--- /dev/null
+++ b/daemon/liblegacy/opd_parse_proc.c
@@ -0,0 +1,223 @@
+/**
+ * @file opd_parse_proc.c
+ * Parsing of /proc/#pid
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include "op_libiberty.h"
+
+#include "opd_parse_proc.h"
+#include "opd_proc.h"
+#include "opd_mapping.h"
+#include "opd_image.h"
+#include "opd_printf.h"
+
+#include "op_file.h"
+#include "op_fileio.h"
+
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * opd_add_ascii_map - parse an ASCII map string for a process
+ * @param proc process to add map to
+ * @param line 0-terminated ASCII string
+ * @param image_name the binary application name
+ *
+ * Attempt to parse the string @line for map information
+ * and add the info to the process @proc. Returns %1
+ * on success, %0 otherwise.
+ *
+ * The parsing is based on Linux 2.4 format, which looks like this :
+ *
+ * 4001e000-400fc000 r-xp 00000000 03:04 31011 /lib/libc-2.1.2.so
+ */
+/* FIXME: handle (deleted) */
+static int opd_add_ascii_map(struct opd_proc * proc, char const * line,
+ char * const image_name)
+{
+ unsigned long offset, start, end;
+ struct opd_image * image;
+ char const * cp = line;
+
+ /* skip to protection field */
+ while (*cp && *cp != ' ')
+ cp++;
+
+ /* handle rwx */
+ if (!*cp || (!*(++cp)) || (!*(++cp)) || (*(++cp) != 'x'))
+ return 0;
+
+ /* get start and end from "40000000-4001f000" */
+ if (sscanf(line, "%lx-%lx", &start, &end) != 2)
+ return 0;
+
+ /* "p " */
+ cp += 2;
+
+ /* read offset */
+ if (sscanf(cp, "%lx", &offset) != 1)
+ return 0;
+
+ while (*cp && *cp != '/')
+ cp++;
+
+ if (!*cp)
+ return 0;
+
+ image = opd_get_image(cp, image_name, 0, proc->tid, proc->tgid);
+ if (!image)
+ return 0;
+
+ opd_add_mapping(proc, image, start, offset, end);
+
+ return 1;
+}
+
+
+/**
+ * opd_get_ascii_maps - read all maps for a process
+ * @param proc process to work on
+ *
+ * Read the /proc/<pid>/maps file and add all
+ * mapping information found to the process @proc.
+ */
+static void opd_get_ascii_maps(struct opd_proc * proc)
+{
+ FILE * fp;
+ char mapsfile[20] = "/proc/";
+ char * line;
+ char exe_name[20];
+ char * image_name;
+ struct list_head * pos;
+
+ snprintf(mapsfile + 6, 6, "%hu", proc->tid);
+
+ strcpy(exe_name, mapsfile);
+
+ strcat(mapsfile, "/maps");
+
+ fp = op_try_open_file(mapsfile, "r");
+ if (!fp)
+ return;
+
+ strcat(exe_name, "/exe");
+ image_name = xmalloc(PATH_MAX);
+ if (!realpath(exe_name, image_name))
+ /* kernel thread are invalid symlink */
+ strcpy(image_name, exe_name);
+
+ verbprintf(vmisc, "image name %s for pid %u %u\n", image_name, proc->tid, proc->tgid);
+
+ while (1) {
+ line = op_get_line(fp);
+ if (!line)
+ break;
+
+ opd_add_ascii_map(proc, line, image_name);
+ free(line);
+ }
+
+ /* dae assume than the first map added is the primary image name, this
+ * is always true at exec time but not for /proc/pid so restore
+ * the primary image name
+ */
+ list_for_each(pos, &proc->maps) {
+ struct opd_map * map = list_entry(pos, struct opd_map, next);
+ if (!strcmp(map->image->name, image_name)) {
+ if (pos != proc->maps.next) {
+ fprintf(stderr, "swap map for image %s from %s to %s\n", image_name, proc->name, map->image->name);
+ free((char *)proc->name);
+ proc->name = xstrdup(map->image->name);
+ }
+ break;
+ }
+ }
+
+ if (list_empty(&proc->maps)) {
+ /* we always need a valid proc->maps[0], we artificially give
+ * a map of length zero so on no samples will never go to this
+ * map. This is used only with --separate-samples and kernel
+ * thread when adding vmlinux and module maps to proc->maps[]
+ */
+ /* FIXME: use the first field of /proc/pid/status as proc name
+ * for now we use /proc/%pid/exe as name */
+ struct opd_image * image = opd_get_image(image_name,
+ image_name, 0, proc->tid, proc->tgid);
+ if (image)
+ opd_add_mapping(proc, image, 0, 0, 0);
+ }
+
+ if (image_name)
+ free(image_name);
+
+ op_close_file(fp);
+}
+
+
+static u32 read_tgid(u32 tid)
+{
+ char status_file[30] = "/proc/";
+ char * line;
+ FILE * fp;
+ u32 tgid;
+
+ snprintf(status_file + 6, 6, "%hu", tid);
+
+ strcat(status_file, "/status");
+
+ fp = op_try_open_file(status_file, "r");
+ if (!fp)
+ return 0;
+
+ while (1) {
+ line = op_get_line(fp);
+ if (!line)
+ break;
+
+ if (sscanf(line, "Tgid: %u", &tgid) == 1) {
+ free(line);
+ op_close_file(fp);
+ return tgid;
+ }
+ free(line);
+ }
+
+ op_close_file(fp);
+
+ return 0;
+}
+
+
+void opd_get_ascii_procs(void)
+{
+ DIR * dir;
+ struct dirent * dirent;
+ struct opd_proc * proc;
+ u32 pid;
+
+ if (!(dir = opendir("/proc"))) {
+ perror("oprofiled: /proc directory could not be opened. ");
+ exit(EXIT_FAILURE);
+ }
+
+ while ((dirent = readdir(dir))) {
+ if (sscanf(dirent->d_name, "%u", &pid) == 1) {
+ u32 tgid = read_tgid(pid);
+ verbprintf(vmisc, "ASCII added %u %u\n", pid, tgid);
+ proc = opd_get_proc(pid, tgid);
+ if (!proc)
+ proc = opd_new_proc(pid, tgid);
+ opd_get_ascii_maps(proc);
+ }
+ }
+
+ closedir(dir);
+}
diff --git a/daemon/liblegacy/opd_parse_proc.h b/daemon/liblegacy/opd_parse_proc.h
new file mode 100644
index 0000000..a224be4
--- /dev/null
+++ b/daemon/liblegacy/opd_parse_proc.h
@@ -0,0 +1,23 @@
+/**
+ * @file opd_parse_proc.h
+ * Parsing of /proc/#pid
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#ifndef OPD_PARSE_PROC_H
+#define OPD_PARSE_PROC_H
+
+/**
+ * opd_get_ascii_procs - read process and mapping information from /proc
+ *
+ * Read information on each process and its mappings from the /proc
+ * filesystem.
+ */
+void opd_get_ascii_procs(void);
+
+#endif /* OPD_PARSE_PROC_H */
diff --git a/daemon/liblegacy/opd_proc.c b/daemon/liblegacy/opd_proc.c
new file mode 100644
index 0000000..2f9b38c
--- /dev/null
+++ b/daemon/liblegacy/opd_proc.c
@@ -0,0 +1,432 @@
+/**
+ * @file opd_proc.c
+ * Management of processes
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include "op_hw_config.h"
+#include "opd_proc.h"
+#include "opd_image.h"
+#include "opd_mapping.h"
+#include "opd_sample_files.h"
+#include "opd_kernel.h"
+#include "opd_24_stats.h"
+#include "opd_printf.h"
+#include "oprofiled.h"
+
+#include "op_interface.h"
+#include "op_libiberty.h"
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* size of process hash table */
+#define OPD_MAX_PROC_HASH 1024
+
+extern int cpu_number;
+
+/* hash of process lists */
+static struct list_head opd_procs[OPD_MAX_PROC_HASH];
+
+/* statistics purpose */
+static int nr_procs;
+
+
+void opd_init_procs(void)
+{
+ int i;
+ for (i = 0; i < OPD_MAX_PROC_HASH; i++)
+ list_init(&opd_procs[i]);
+}
+
+
+int opd_get_nr_procs(void)
+{
+ return nr_procs;
+}
+
+
+/**
+ * proc_hash - hash pid value
+ * @param tid pid value to hash
+ *
+ */
+inline static uint proc_hash(pid_t tid)
+{
+ /* FIXME: hash tgid too! */
+ return ((tid >> 4) ^ (tid)) % OPD_MAX_PROC_HASH;
+}
+
+
+struct opd_proc * opd_new_proc(pid_t tid, pid_t tgid)
+{
+ struct opd_proc * proc;
+
+ nr_procs++;
+ proc = xmalloc(sizeof(struct opd_proc));
+ list_init(&proc->maps);
+ proc->name = NULL;
+ proc->tid = tid;
+ proc->tgid = tgid;
+ proc->dead = 0;
+ proc->accessed = 0;
+ list_add(&proc->next, &opd_procs[proc_hash(tid)]);
+ return proc;
+}
+
+
+struct opd_proc * opd_get_proc(pid_t tid, pid_t tgid)
+{
+ struct opd_proc * proc;
+ uint hash = proc_hash(tid);
+ struct list_head * pos, *pos2;
+
+ opd_24_stats[OPD_PROC_QUEUE_ACCESS]++;
+ list_for_each_safe(pos, pos2, &opd_procs[hash]) {
+ opd_24_stats[OPD_PROC_QUEUE_DEPTH]++;
+ proc = list_entry(pos, struct opd_proc, next);
+ if (tid == proc->tid && tgid == proc->tgid) {
+ /* LRU to head */
+ list_del(&proc->next);
+ list_add(&proc->next, &opd_procs[hash]);
+ return proc;
+ }
+ }
+
+ return NULL;
+}
+
+
+/**
+ * verb_show_sample - print the sample out to the log
+ * @param offset the offset value
+ * @param map map to print
+ */
+inline static void
+verb_show_sample(unsigned long offset, struct opd_map * map)
+{
+ verbprintf(vsamples, "DO_PUT_SAMPLE : calc offset 0x%.8lx, "
+ "map start 0x%.8lx, end 0x%.8lx, offset 0x%.8lx, name \"%s\"\n",
+ offset, map->start, map->end, map->offset,
+ map->image->name);
+}
+
+
+void opd_put_image_sample(struct opd_image * image, unsigned long offset,
+ u32 counter)
+{
+ struct opd_24_sfile * sfile;
+ int err;
+
+ if (image->ignored)
+ return;
+
+ if (!image->sfiles[cpu_number]) {
+ image->sfiles[cpu_number] =
+ xcalloc(OP_MAX_COUNTERS, sizeof(struct op_24_sfile *));
+ }
+ sfile = image->sfiles[cpu_number][counter];
+
+ if (!sfile || !odb_open_count(&sfile->sample_file)) {
+ if (opd_open_24_sample_file(image, counter, cpu_number)) {
+ /* opd_open_24_sample_file output an error message */
+ opd_24_stats[OPD_LOST_SAMPLEFILE]++;
+ return;
+ }
+ sfile = image->sfiles[cpu_number][counter];
+ }
+
+ err = odb_update_node(&sfile->sample_file, offset);
+ if (err) {
+ fprintf(stderr, "%s\n", strerror(err));
+ abort();
+ }
+
+ opd_24_sfile_lru(sfile);
+}
+
+
+/**
+ * opd_lookup_maps - lookup a proc mappings for a sample
+ * @param proc proc to lookup
+ * @param sample sample to lookup
+ *
+ * iterate through the proc maps searching the mapping which owns sample
+ * if sucessful sample count will be updated and we return non-zero
+ */
+static int opd_lookup_maps(struct opd_proc * proc,
+ struct op_sample const * sample)
+{
+ struct list_head * pos;
+
+ proc->accessed = 1;
+
+ opd_24_stats[OPD_MAP_ARRAY_ACCESS]++;
+ list_for_each(pos, &proc->maps) {
+ struct opd_map * map = list_entry(pos, struct opd_map, next);
+ if (opd_is_in_map(map, sample->eip)) {
+ unsigned long offset = opd_map_offset(map, sample->eip);
+ if (map->image != NULL) {
+ verb_show_sample(offset, map);
+ opd_put_image_sample(map->image, offset, sample->counter);
+ }
+ opd_24_stats[OPD_PROCESS]++;
+ return 1;
+ }
+ opd_24_stats[OPD_MAP_ARRAY_DEPTH]++;
+ }
+
+ return 0;
+}
+
+
+void opd_put_sample(struct op_sample const * sample)
+{
+ struct opd_proc * proc;
+ int in_kernel_eip = opd_eip_is_kernel(sample->eip);
+
+ opd_24_stats[OPD_SAMPLES]++;
+
+ verbprintf(vsamples, "DO_PUT_SAMPLE: c%d, EIP 0x%.8lx, tgid %.6d pid %.6d\n",
+ sample->counter, sample->eip, sample->tgid, sample->pid);
+
+ if (!separate_kernel && in_kernel_eip) {
+ opd_handle_kernel_sample(sample->eip, sample->counter);
+ return;
+ }
+
+ if (!(proc = opd_get_proc(sample->pid, sample->tgid))) {
+ if (in_kernel_eip || no_vmlinux) {
+ /* idle task get a 0 pid and is hidden we can never get
+ * a proc so on we fall back to put sample in vmlinux
+ * or module samples files. Here we will catch also
+ * sample for newly created kernel thread, currently
+ * we can handle properly only kenel thread created
+ * at daemon startup time */
+ opd_handle_kernel_sample(sample->eip, sample->counter);
+ } else {
+ verbprintf(vmisc, "No proc info for tgid %.6d pid %.6d.\n",
+ sample->tgid, sample->pid);
+ opd_24_stats[OPD_LOST_PROCESS]++;
+ }
+ return;
+ }
+
+ if (opd_lookup_maps(proc, sample))
+ return;
+
+ if (in_kernel_eip) {
+ opd_add_kernel_map(proc, sample->eip);
+ if (opd_lookup_maps(proc, sample))
+ return;
+ }
+
+ /* couldn't locate it */
+ verbprintf(vsamples, "Couldn't find map for pid %.6d, EIP 0x%.8lx.\n",
+ sample->pid, sample->eip);
+ opd_24_stats[OPD_LOST_MAP_PROCESS]++;
+}
+
+
+void opd_handle_fork(struct op_note const * note)
+{
+ struct opd_proc * old;
+ struct opd_proc * proc;
+ struct list_head * pos;
+
+ verbprintf(vmisc, "DO_FORK: from %d, %d to %ld, %ld\n", note->pid, note->tgid,
+ note->addr, note->len);
+
+ old = opd_get_proc(note->pid, note->tgid);
+
+ /* we can quite easily get a fork() after the execve() because the
+ * notifications are racy. In particular, the fork notification is
+ * done on parent return (so we know the pid), but this will often be
+ * after the execve is done by the child.
+ *
+ * So we only create a new setup if it doesn't exist already, allowing
+ * both the clone() and the execve() cases to work.
+ */
+ if (opd_get_proc(note->addr, note->len))
+ return;
+
+ /* eip/len is actually tid/tgid of new process */
+ proc = opd_new_proc(note->addr, note->len);
+
+ if (!old)
+ return;
+
+ /* copy the maps */
+ list_for_each(pos, &old->maps) {
+ struct opd_map * map = list_entry(pos, struct opd_map, next);
+ if (!separate_thread) {
+ opd_add_mapping(proc, map->image, map->start,
+ map->offset, map->end);
+ } else {
+ /* when separating thread we can't create blindly a new
+ * image e.g. pid re-use, multiple mapping with the
+ * same mapping name etc. */
+ struct opd_image * image =
+ opd_get_image(map->image->name, old->name,
+ map->image->kernel, note->addr, note->len);
+ opd_add_mapping(proc, image, map->start, map->offset,
+ map->end);
+ }
+ }
+}
+
+
+void opd_handle_exec(pid_t tid, pid_t tgid)
+{
+ struct opd_proc * proc;
+
+ verbprintf(vmisc, "DO_EXEC: pid %u %u\n", tid, tgid);
+
+ /* There is a race for samples received between fork/exec sequence.
+ * These samples belong to the old mapping but we can not say if
+ * samples has been received before the exec or after. This explains
+ * the message "Couldn't find map for ..." in verbose mode.
+ *
+ * Unhappily, it is difficult to get an estimation of these misplaced
+ * samples, the error message can count only out of mapping samples but
+ * not samples between the race and inside the mapping of the exec'ed
+ * process :/.
+ *
+ * Trying to save old mapping is not correct due the above reason. The
+ * only manner to handle this is to flush the module samples hash table
+ * after each fork which is unacceptable for performance reasons */
+ proc = opd_get_proc(tid, tgid);
+ if (proc) {
+ opd_kill_maps(proc);
+ /* proc->name will be set when the next mapping occurs */
+ free((char *)proc->name);
+ proc->name = NULL;
+ } else {
+ opd_new_proc(tid, tgid);
+ }
+}
+
+
+void opd_handle_exit(struct op_note const * note)
+{
+ struct opd_proc * proc;
+
+ verbprintf(vmisc, "DO_EXIT: process %d\n", note->pid);
+
+ proc = opd_get_proc(note->pid, note->tgid);
+ if (proc) {
+ proc->dead = 1;
+ proc->accessed = 1;
+ } else {
+ verbprintf(vmisc, "unknown proc %u just exited.\n", note->pid);
+ }
+}
+
+
+typedef void (*opd_proc_cb)(struct opd_proc *);
+
+/**
+ * @param proc_cb callback to apply onto each existing proc struct
+ *
+ * the callback receive a struct opd_proc * (not a const struct) and is
+ * allowed to freeze the proc struct itself.
+ */
+static void opd_for_each_proc(opd_proc_cb proc_cb)
+{
+ struct list_head * pos;
+ struct list_head * pos2;
+ int i;
+
+ for (i = 0; i < OPD_MAX_PROC_HASH; ++i) {
+ list_for_each_safe(pos, pos2, &opd_procs[i]) {
+ struct opd_proc * proc =
+ list_entry(pos, struct opd_proc, next);
+ proc_cb(proc);
+ }
+ }
+}
+
+
+/**
+ * opd_delete_proc - delete a process
+ * @param proc process to delete
+ *
+ * Remove the process proc from the process list and free
+ * the associated structures.
+ */
+static void opd_delete_proc(struct opd_proc * proc)
+{
+ --nr_procs;
+ list_del(&proc->next);
+ opd_kill_maps(proc);
+ if (proc->name)
+ free((char *)proc->name);
+ free(proc);
+}
+
+
+void opd_proc_cleanup(void)
+{
+ opd_for_each_proc(opd_delete_proc);
+}
+
+
+/**
+ * opd_age_proc - age a struct opd_proc
+ * @param proc proc to age
+ *
+ * age dead proc in such way if a proc doesn't receive any samples
+ * between two age_proc the opd_proc struct is deleted
+ */
+static void opd_age_proc(struct opd_proc * proc)
+{
+ // delay death whilst its still being accessed
+ if (proc->dead) {
+ proc->dead += proc->accessed;
+ proc->accessed = 0;
+ if (--proc->dead == 0)
+ opd_delete_proc(proc);
+ }
+}
+
+
+void opd_age_procs(void)
+{
+ opd_for_each_proc(opd_age_proc);
+}
+
+
+/**
+ * opd_remove_kernel_mapping - remove all kernel mapping for an opd_proc
+ * @param proc proc where mappings must be updated.
+ *
+ * invalidate (by removing them) all kernel mapping. This function do nothing
+ * when separate_kernel == 0 because we don't add mapping for kernel
+ * sample in proc struct.
+ */
+static void opd_remove_kernel_mapping(struct opd_proc * proc)
+{
+ struct list_head * pos, * pos2;
+
+ list_for_each_safe(pos, pos2, &proc->maps) {
+ struct opd_map * map = list_entry(pos, struct opd_map, next);
+ if (opd_eip_is_kernel(map->start + map->offset)) {
+ list_del(pos);
+ opd_delete_image(map->image);
+ free(map);
+ }
+ }
+}
+
+
+void opd_clear_kernel_mapping(void)
+{
+ opd_for_each_proc(opd_remove_kernel_mapping);
+}
diff --git a/daemon/liblegacy/opd_proc.h b/daemon/liblegacy/opd_proc.h
new file mode 100644
index 0000000..8140a46
--- /dev/null
+++ b/daemon/liblegacy/opd_proc.h
@@ -0,0 +1,151 @@
+/**
+ * @file opd_proc.h
+ * Management of processes
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#ifndef OPD_PROC_H
+#define OPD_PROC_H
+
+#include "op_types.h"
+#include "op_list.h"
+
+struct opd_map;
+struct opd_image;
+struct op_note;
+struct op_sample;
+
+/**
+ * track process, created either by a fork or an exec notification.
+ */
+struct opd_proc {
+ /** maps are always added to the end of head, so search will be done
+ * from the newest map to the oldest which mean we don't care about
+ * munmap. First added map must be the primary image */
+ struct list_head maps;
+ /** process name */
+ char const * name;
+ /** thread id for this process, always equal to tgid for 2.2 kernel */
+ pid_t tid;
+ /** thread group id for this process */
+ pid_t tgid;
+ /** non-zero if this process receive any samples, this field
+ * is used with dead field to defer opd_proc deletion */
+ int accessed;
+ /** Set to non-zero when an exit notification occur for this process */
+ int dead;
+ /** used by container of opd_proc */
+ struct list_head next;
+};
+
+/**
+ * initialize opd_proc container
+ */
+void opd_init_procs(void);
+
+/**
+ * opd_put_sample - process a sample
+ * @param sample sample to process
+ *
+ * Write out the sample to the appropriate sample file. This
+ * routine handles kernel and module samples as well as ordinary ones.
+ */
+void opd_put_sample(struct op_sample const * sample);
+
+/**
+ * opd_put_image_sample - write sample to file
+ * @param image image for sample
+ * @param offset (file) offset to write to
+ * @param counter counter number
+ *
+ * Add to the count stored at position offset in the
+ * image file. Overflow pins the count at the maximum
+ * value.
+ */
+void opd_put_image_sample(struct opd_image * image, unsigned long offset, u32 counter);
+
+/**
+ * opd_handle_fork - deal with fork notification
+ * @param note note to handle
+ *
+ * Deal with a fork() notification by creating a new process
+ * structure, and copying mapping information from the old process.
+ *
+ * sample->pid contains the process id of the old process.
+ * sample->eip contains the process id of the new process.
+ */
+void opd_handle_fork(struct op_note const * note);
+
+/**
+ * opd_handle_exec - deal with notification of execve()
+ * @param tid tid for this process
+ * @param tgid tgid for this process
+ *
+ * Drop all mapping information for the process.
+ */
+void opd_handle_exec(pid_t tid, pid_t tgid);
+
+/**
+ * opd_handle_exit - deal with exit notification
+ * @param note note to handle
+ *
+ * Deal with an exit() notification by setting the flag "dead"
+ * on a process. These will be later cleaned up by the %SIGALRM
+ * handler.
+ *
+ * sample->pid contains the process id of the exited process.
+ */
+void opd_handle_exit(struct op_note const * note);
+
+/**
+ * opd_get_proc - get process from process list
+ * @param tid tid for this process
+ * @param tgid tgid for this process
+ *
+ * A process with pid tid is searched on the process list,
+ * maintaining LRU order. If it is not found, %NULL is returned,
+ * otherwise the process structure is returned.
+ */
+struct opd_proc * opd_get_proc(pid_t tid, pid_t tgid);
+
+/**
+ * opd_new_proc - create a new process structure
+ * @param tid tid for this process
+ * @param tgid tgid for this process
+ *
+ * Allocate and initialise a process structure and insert
+ * it into the procs hash table.
+ */
+struct opd_proc * opd_new_proc(pid_t tid, pid_t tgid);
+
+/**
+ * opd_get_nr_procs - return number of processes tracked
+ */
+int opd_get_nr_procs(void);
+
+/**
+ * opd_age_procs - age all dead process preparing them for a deletion
+ */
+void opd_age_procs(void);
+
+/**
+ * freeze all resource used by opd_procs managment
+ */
+void opd_proc_cleanup(void);
+
+/**
+ * opd_clear_kernel_mapping - remove all kernel mapping for all opd_proc
+ *
+ * invalidate (by removing them) all kernel mapping. This function do nothing
+ * when separate_kernel == 0 because we don't add mapping for kernel
+ * sample in proc struct. As side effect decrease reference count of
+ * associated with these mapping which eventually close this image
+ */
+void opd_clear_kernel_mapping(void);
+
+#endif /* OPD_PROC_H */
diff --git a/daemon/liblegacy/opd_sample_files.c b/daemon/liblegacy/opd_sample_files.c
new file mode 100644
index 0000000..126ba99
--- /dev/null
+++ b/daemon/liblegacy/opd_sample_files.c
@@ -0,0 +1,179 @@
+/**
+ * @file opd_sample_files.c
+ * Management of sample files
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include <sys/types.h>
+
+#include "opd_sample_files.h"
+#include "opd_image.h"
+#include "opd_printf.h"
+#include "opd_events.h"
+#include "oprofiled.h"
+
+#include "op_sample_file.h"
+#include "op_file.h"
+#include "op_config.h"
+#include "op_mangle.h"
+#include "op_events.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+/** All sfiles are on this list. */
+static LIST_HEAD(lru_list);
+
+/* this value probably doesn't matter too much */
+#define LRU_AMOUNT 1000
+static int opd_24_sfile_lru_clear(void)
+{
+ struct list_head * pos;
+ struct list_head * pos2;
+ struct opd_24_sfile * sfile;
+ int amount = LRU_AMOUNT;
+
+ verbprintf(vsfile, "image lru clear\n");
+
+ if (list_empty(&lru_list))
+ return 1;
+
+ list_for_each_safe(pos, pos2, &lru_list) {
+ if (!--amount)
+ break;
+ sfile = list_entry(pos, struct opd_24_sfile, lru_next);
+ odb_close(&sfile->sample_file);
+ list_del_init(&sfile->lru_next);
+ }
+
+ return 0;
+}
+
+
+void opd_24_sfile_lru(struct opd_24_sfile * sfile)
+{
+ list_del(&sfile->lru_next);
+ list_add_tail(&sfile->lru_next, &lru_list);
+}
+
+
+static char * opd_mangle_filename(struct opd_image const * image, int counter,
+ int cpu_nr)
+{
+ char * mangled;
+ struct mangle_values values;
+ struct opd_event * event = find_counter_event(counter);
+
+ values.flags = 0;
+ if (image->kernel)
+ values.flags |= MANGLE_KERNEL;
+
+ if (separate_thread) {
+ values.flags |= MANGLE_TGID | MANGLE_TID;
+ values.tid = image->tid;
+ values.tgid = image->tgid;
+ }
+
+ if (separate_cpu) {
+ values.flags |= MANGLE_CPU;
+ values.cpu = cpu_nr;
+ }
+
+ values.event_name = event->name;
+ values.count = event->count;
+ values.unit_mask = event->um;
+
+ values.image_name = image->name;
+ values.dep_name = separate_lib && image->app_name
+ ? image->app_name : image->name;
+
+ mangled = op_mangle_filename(&values);
+
+ return mangled;
+}
+
+
+int opd_open_24_sample_file(struct opd_image * image, int counter, int cpu_nr)
+{
+ char * mangled;
+ struct opd_24_sfile * sfile;
+ int err;
+
+ mangled = opd_mangle_filename(image, counter, cpu_nr);
+
+ verbprintf(vsfile, "Opening \"%s\"\n", mangled);
+
+ create_path(mangled);
+
+ sfile = image->sfiles[cpu_nr][counter];
+ if (!sfile) {
+ sfile = malloc(sizeof(struct opd_24_sfile));
+ list_init(&sfile->lru_next);
+ odb_init(&sfile->sample_file);
+ image->sfiles[cpu_nr][counter] = sfile;
+ }
+
+ list_del(&sfile->lru_next);
+ list_add_tail(&sfile->lru_next, &lru_list);
+
+retry:
+ err = odb_open(&sfile->sample_file, mangled, ODB_RDWR,
+ sizeof(struct opd_header));
+
+ /* This can naturally happen when racing against opcontrol --reset. */
+ if (err) {
+ if (err == EMFILE) {
+ if (opd_24_sfile_lru_clear()) {
+ printf("LRU cleared but odb_open() fails for %s.\n", mangled);
+ abort();
+ }
+ goto retry;
+ }
+
+ fprintf(stderr, "oprofiled: open of %s failed: %s\n",
+ mangled, strerror(err));
+ goto out;
+ }
+
+ fill_header(odb_get_data(&sfile->sample_file), counter, 0, 0,
+ image->kernel, 0, 0, 0, image->mtime);
+
+out:
+ free(mangled);
+ return err;
+}
+
+
+void opd_sync_samples_files(void)
+{
+ struct list_head * pos;
+ struct opd_24_sfile * sfile;
+
+ list_for_each(pos, &lru_list) {
+ sfile = list_entry(pos, struct opd_24_sfile, lru_next);
+ odb_sync(&sfile->sample_file);
+ }
+}
+
+
+void opd_close_image_samples_files(struct opd_image * image)
+{
+ uint i, j;
+ for (i = 0 ; i < op_nr_counters ; ++i) {
+ for (j = 0; j < NR_CPUS; ++j) {
+ if (image->sfiles[j] && image->sfiles[j][i]) {
+ odb_close(&image->sfiles[j][i]->sample_file);
+ list_del(&image->sfiles[j][i]->lru_next);
+ free(image->sfiles[j][i]);
+ image->sfiles[j][i] = 0;
+ }
+ }
+ }
+}
diff --git a/daemon/liblegacy/opd_sample_files.h b/daemon/liblegacy/opd_sample_files.h
new file mode 100644
index 0000000..20555a9
--- /dev/null
+++ b/daemon/liblegacy/opd_sample_files.h
@@ -0,0 +1,63 @@
+/**
+ * @file opd_sample_files.h
+ * Management of sample files
+ *
+ * @remark Copyright 2002 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#ifndef OPD_SAMPLE_FILES_H
+#define OPD_SAMPLE_FILES_H
+
+#include "op_list.h"
+#include "odb.h"
+
+struct opd_image;
+
+/** one samples file when profiling on a 2.2/2.4 kernel */
+struct opd_24_sfile {
+ /** lru list of sample file */
+ struct list_head lru_next;
+ /** the sample file itself */
+ odb_t sample_file;
+};
+
+/**
+ * sync all samples files
+ */
+void opd_sync_samples_files(void);
+
+/**
+ * @param image the image pointer to work on
+ *
+ * close all samples files belonging to this image
+ */
+void opd_close_image_samples_files(struct opd_image * image);
+
+/**
+ * opd_open_24_sample_file - open an image sample file
+ * @param image image to open file for
+ * @param counter counter number
+ * @param cpu_nr cpu number
+ *
+ * Open image sample file for the image, counter
+ * counter and set up memory mappings for it.
+ * image->kernel and image->name must have meaningful
+ * values.
+ *
+ * Returns 0 on success.
+ */
+int opd_open_24_sample_file(struct opd_image * image, int counter, int cpu_nr);
+
+/**
+ * @param sfile sample file to act on
+ *
+ * put sfile at the head of samples files lru list
+ */
+void opd_24_sfile_lru(struct opd_24_sfile * sfile);
+
+
+#endif /* OPD_SAMPLE_FILES_H */
diff --git a/daemon/liblegacy/p_module.h b/daemon/liblegacy/p_module.h
new file mode 100644
index 0000000..9367508
--- /dev/null
+++ b/daemon/liblegacy/p_module.h
@@ -0,0 +1,207 @@
+/* Definitions for the Linux module syscall interface.
+ Copyright 1996, 1997 Linux International.
+
+ Contributed by Richard Henderson <rth@tamu.edu>
+
+ This file is part of the Linux modutils.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef MODUTILS_MODULE_H
+#define MODUTILS_MODULE_H 1
+
+/* This file contains the structures used by the 2.0 and 2.1 kernels.
+ We do not use the kernel headers directly because we do not wish
+ to be dependant on a particular kernel version to compile insmod. */
+
+
+/*======================================================================*/
+/* The structures used by Linux 2.0. */
+
+/* The symbol format used by get_kernel_syms(2). */
+struct old_kernel_sym
+{
+ unsigned long value;
+ char name[60];
+};
+
+struct old_module_ref
+{
+ unsigned long module; /* kernel addresses */
+ unsigned long next;
+};
+
+struct old_module_symbol
+{
+ unsigned long addr;
+ unsigned long name;
+};
+
+struct old_symbol_table
+{
+ int size; /* total, including string table!!! */
+ int n_symbols;
+ int n_refs;
+ struct old_module_symbol symbol[0]; /* actual size defined by n_symbols */
+ struct old_module_ref ref[0]; /* actual size defined by n_refs */
+};
+
+struct old_mod_routines
+{
+ unsigned long init;
+ unsigned long cleanup;
+};
+
+struct old_module
+{
+ unsigned long next;
+ unsigned long ref; /* the list of modules that refer to me */
+ unsigned long symtab;
+ unsigned long name;
+ int size; /* size of module in pages */
+ unsigned long addr; /* address of module */
+ int state;
+ unsigned long cleanup; /* cleanup routine */
+};
+
+/* Sent to init_module(2) or'ed into the code size parameter. */
+#define OLD_MOD_AUTOCLEAN 0x40000000 /* big enough, but no sign problems... */
+
+int get_kernel_syms(struct old_kernel_sym *);
+int old_sys_init_module(char const * name, char *code, unsigned codesize,
+ struct old_mod_routines *, struct old_symbol_table *);
+
+/*======================================================================*/
+/* For sizeof() which are related to the module platform and not to the
+ environment isnmod is running in, use sizeof_xx instead of sizeof(xx). */
+
+#define tgt_sizeof_char sizeof(char)
+#define tgt_sizeof_short sizeof(short)
+#define tgt_sizeof_int sizeof(int)
+#define tgt_sizeof_long sizeof(long)
+#define tgt_sizeof_char_p sizeof(char *)
+#define tgt_sizeof_void_p sizeof(void *)
+#define tgt_long long
+#define tgt_long_fmt "l"
+
+/* This assumes that long long on a 32 bit system is equivalent to long on the
+ * equivalent 64 bit system. Also that void and char pointers are 8 bytes on
+ * all 64 bit systems. Add per system tweaks if it ever becomes necessary.
+ */
+#if defined(COMMON_3264) && defined(ONLY_64)
+#undef tgt_long
+#undef tgt_long_fmt
+#undef tgt_sizeof_long
+#undef tgt_sizeof_char_p
+#undef tgt_sizeof_void_p
+#define tgt_long long long
+#define tgt_long_fmt "ll"
+#define tgt_sizeof_long 8
+#define tgt_sizeof_char_p 8
+#define tgt_sizeof_void_p 8
+#endif
+
+/*======================================================================*/
+/* The structures used in Linux 2.1 onwards. */
+
+/* Note: module_symbol does not use tgt_long intentionally */
+struct module_symbol
+{
+ unsigned long value;
+ unsigned long name;
+};
+
+struct module_ref
+{
+ unsigned tgt_long dep; /* kernel addresses */
+ unsigned tgt_long ref;
+ unsigned tgt_long next_ref;
+};
+
+struct module
+{
+ unsigned tgt_long size_of_struct; /* == sizeof(module) */
+ unsigned tgt_long next;
+ unsigned tgt_long name;
+ unsigned tgt_long size;
+
+ tgt_long usecount;
+ unsigned tgt_long flags; /* AUTOCLEAN et al */
+
+ unsigned nsyms;
+ unsigned ndeps;
+
+ unsigned tgt_long syms;
+ unsigned tgt_long deps;
+ unsigned tgt_long refs;
+ unsigned tgt_long init;
+ unsigned tgt_long cleanup;
+ unsigned tgt_long ex_table_start;
+ unsigned tgt_long ex_table_end;
+#ifdef __alpha__
+ unsigned tgt_long gp;
+#endif
+ /* Everything after here is extension. */
+ unsigned tgt_long read_start; /* Read data from existing module */
+ unsigned tgt_long read_end;
+ unsigned tgt_long can_unload;
+ unsigned tgt_long runsize;
+ unsigned tgt_long kallsyms_start;
+ unsigned tgt_long kallsyms_end;
+ unsigned tgt_long archdata_start;
+ unsigned tgt_long archdata_end;
+ unsigned tgt_long kernel_data;
+};
+
+struct module_info
+{
+ unsigned long addr;
+ unsigned long size;
+ unsigned long flags;
+ long usecount;
+};
+
+/* Bits of module.flags. */
+#define NEW_MOD_RUNNING 1
+#define NEW_MOD_DELETED 2
+#define NEW_MOD_AUTOCLEAN 4
+#define NEW_MOD_VISITED 8
+#define NEW_MOD_USED_ONCE 16
+#define NEW_MOD_INITIALIZING 64
+
+int sys_init_module(char const * name, const struct module *);
+int query_module(char const * name, int which, void *buf, size_t bufsize,
+ size_t *ret);
+
+/* Values for query_module's which. */
+
+#define QM_MODULES 1
+#define QM_DEPS 2
+#define QM_REFS 3
+#define QM_SYMBOLS 4
+#define QM_INFO 5
+
+/*======================================================================*/
+/* The system calls unchanged between 2.0 and 2.1. */
+
+unsigned long create_module(const char *, size_t);
+int delete_module(const char *);
+
+/* In safe mode the last parameter is forced to be a module name and meta
+ * expansion is not allowed on that name.
+ */
+extern unsigned int safemode;
+
+#endif /* module.h */