### Build Oprofile ###
1) Get source package
http://oprofile.sourceforge.net/download/
oprofile-0.9.7.tar.gz
http://www.gnu.org/s/libiconv/#downloading
libiconv-1.13.1.tar.gz
http://www.gnu.org/s/gettext/#downloading
gettext-0.18.1.1.tar.gz
http://www.gnu.org/software/binutils/
binutils-2.22.tar.bz2
http://freecode.com/projects/popt
popt-1.14.tar.gz
# Note that we should build (and application would check) dynamic link library
2) Build libiconv-1.13.1
tar zxvf libiconv-1.13.1.tar.gz
mkdir build_libiconv
cd build_libiconv
../libiconv-1.13.1/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --with-gnu-ld --prefix=/home/user/mingfeng_wu/installed/arm-uc-libiconv
make all install
3) Build gettext-0.18.1.1
tar zxvf gettext-0.18.1.1.tar.gz
cd gettext-0.18.1.1
patch -p1 < ../oprofile/gettext-spawn.patch
cd ..
mkdir build_gettext
cd build_gettext
../gettext-0.18.1.1/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --with-gnu-ld --prefix=/home/user/mingfeng_wu/installed/arm-uc-gettext --with-libiconv-prefix=/home/user/mingfeng_wu/installed/arm-uc-libiconv
make
make install
4) Copy the libiconv.so library to GCC toolchain library (or certain path in LD_LIBRARY_PATH)
cp /home/user/mingfeng_wu/installed/arm-uc-libiconv/lib/libiconv.so.2.5.0 /home/user/mingfeng_wu/installed/crosstool-4.5.2/arm-unknown-linux-uclibcgnueabi/sysroot/lib/libiconv.so.2
5) Build binutils-2.22
tar xvjf /home/user/mingfeng_wu/src/GCC/binutils-2.22.tar.bz2
mkdir build_binutils
cd build_binutils
# need to --enable-shared, oprofile use libbfd.so
../binutils-2.22/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --with-gnu-ld --enable-install-libbfd --prefix=/home/user/mingfeng_wu/installed/arm-uc-binutils
make
make install
6) Build popt-1.14
tar zxvf popt-1.14.tar.gz
cd popt-1.14
patch -p0 < popt_fix_va_copy.patch
mkdir build_popt
cd build_popt
ac_cv_va_copy=C99 ../popt-1.14/configure --host=arm-unknown-linux-uclibcgnueabi --enable-shared --disable-nls --with-gnu-ld --with-libiconv-prefix=/home/user/mingfeng_wu/installed/arm-uc-libiconv --prefix=/home/user/mingfeng_wu/installed/arm-uc-popt
make all install
7) Build oprofile
tar xvjf oprofile-0.9.7.tar.gz
cd oprofile-0.9.7
patch -p1 < ../oprofile/oprofile_remove_linux24_support.patch
cd ..
mkdir build_oprofile
cd build_oprofile
../oprofile-0.9.7/configure --host=arm-unknown-linux-uclibcgnueabi --with-binutils=/home/user/mingfeng_wu/installed/arm-uc-binutils --enable-dependency-tracking --enable-pch --enable-gcov --with-gnu-ld --with-kernel-support --with-linux=/home/user/mingfeng_wu/work/trunk/kernel/linux-2.6.35.12 --prefix=/home/user/mingfeng_wu/installed/arm-uc-oprofile --with-extra-libs=/home/user/mingfeng_wu/installed/arm-uc-popt/lib:/home/user/mingfeng_wu/installed/arm-uc-zlib/lib:/home/user/mingfeng_wu/installed/arm-uc-libiconv/lib:/home/user/mingfeng_wu/installed/arm-uc-gettext/lib:/home/user/mingfeng_wu/installed/arm-uc-binutils/lib --with-extra-includes=/home/user/mingfeng_wu/installed/arm-uc-binutils/include:/home/user/mingfeng_wu/installed/arm-uc-libiconv/include:/home/user/mingfeng_wu/installed/arm-uc-gettext/include:/home/user/mingfeng_wu/src/binutils-2.22/include:/home/user/mingfeng_wu/installed/arm-uc-popt/include
make
make install
### Build stage OK now, the following gives the patch ###
1) gettext-spawn.patch
--- a/gettext-tools/gnulib-lib/spawn.in.h 2010-11-18 19:49:42.424350565 +0300
+++ b/gettext-tools/gnulib-lib/spawn.in.h 2010-11-18 19:49:10.392349526 +0300
@@ -37,6 +37,10 @@
# include <signal.h>
#endif
+#ifdef __UCLIBC__
+# include <sched.h>
+#endif
+
#include <sys/types.h>
#ifndef __THROW
2) oprofile_remove_linux24_support.patch
diff -uNr oprofile-0.9.7/daemon.orig/Makefile.am oprofile-0.9.7/daemon/Makefile.am
--- oprofile-0.9.7/daemon.orig/Makefile.am 2011-12-12 09:56:12.513861000 +0800
+++ oprofile-0.9.7/daemon/Makefile.am 2011-12-12 09:57:06.264055000 +0800
@@ -1,4 +1,4 @@
-SUBDIRS = liblegacy .
+SUBDIRS = .
oprofiled_SOURCES = \
init.c \
@@ -49,7 +49,6 @@
bin_PROGRAMS = oprofiled
oprofiled_LDADD = \
- liblegacy/liblegacy.a \
../libabi/libabi.a \
../libdb/libodb.a \
../libop/libop.a \
diff -uNr oprofile-0.9.7/daemon.orig/Makefile.in oprofile-0.9.7/daemon/Makefile.in
--- oprofile-0.9.7/daemon.orig/Makefile.in 2011-12-12 09:56:12.402971000 +0800
+++ oprofile-0.9.7/daemon/Makefile.in 2011-12-12 09:57:29.143153000 +0800
@@ -70,7 +70,7 @@
opd_extended.$(OBJEXT) opd_ibs.$(OBJEXT) \
opd_ibs_trans.$(OBJEXT)
oprofiled_OBJECTS = $(am_oprofiled_OBJECTS)
-oprofiled_DEPENDENCIES = liblegacy/liblegacy.a ../libabi/libabi.a \
+oprofiled_DEPENDENCIES = ../libabi/libabi.a \
../libdb/libodb.a ../libop/libop.a ../libutil/libutil.a
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -285,7 +285,7 @@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
topdir = @topdir@
-SUBDIRS = liblegacy .
+SUBDIRS = .
oprofiled_SOURCES = \
init.c \
oprofiled.c \
@@ -331,7 +331,6 @@
# -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 \
diff -uNr oprofile-0.9.7/daemon.orig/oprofiled.c oprofile-0.9.7/daemon/oprofiled.c
--- oprofile-0.9.7/daemon.orig/oprofiled.c 2011-12-12 09:56:12.388988000 +0800
+++ oprofile-0.9.7/daemon/oprofiled.c 2011-12-12 09:58:06.699559000 +0800
@@ -77,7 +77,6 @@
static char * ext_feature;
static int showvers;
static struct oprofiled_ops * opd_ops;
-extern struct oprofiled_ops opd_24_ops;
extern struct oprofiled_ops opd_26_ops;
#define OPD_IMAGE_FILTER_HASH_SIZE 32
@@ -477,9 +476,6 @@
static struct oprofiled_ops * get_ops(void)
{
switch (op_get_interface()) {
- case OP_INTERFACE_24:
- printf("Using 2.4 OProfile kernel interface.\n");
- return &opd_24_ops;
case OP_INTERFACE_26:
printf("Using 2.6+ OProfile kernel interface.\n");
return &opd_26_ops;
3) popt_fix_va_copy.patch
--- configure.ac.orig 2011-12-08 17:16:11.092076000 +0800
+++ configure.ac 2011-12-08 17:16:17.376785000 +0800
@@ -43,7 +43,6 @@
AC_ISC_POSIX
AM_C_PROTOTYPES
-AC_CHECK_VA_COPY
AC_CHECK_HEADERS(float.h glob.h langinfo.h libintl.h mcheck.h unistd.h)
### Below shows how to run OProfile on target system ###
# In host Linux
1) Modify .config file of Linux kernel. Add:
CONFIG_PROFILING=y
CONFIG_OPROFILE=y
CONFIG_HAVE_OPROFILE=y
and add "oprofile.timer=1" to CMDLINE, like the following:
CONFIG_CMDLINE="mem=64M console=ttyS0,115200 init=/init oprofile.timer=1"
# In target platform
1) Create the mtab file to /etc/mtab with the following contents
nodev /dev/oprofile oprofilefs rw 0 0
cp /mnt/arm-uc-oprofile/mtab /etc
1) Set binary and library path
export PATH=/mnt/arm-uc-oprofile/bin:$PATH
export LD_LIBRARY_PATH=/mnt/arm-uc-oprofile/lib:$LD_LIBRARY_PATH
2) Setup /dev/oprofile/*
mv /etc/mtab /etc/mtab1
/mnt/arm-uc-oprofile/bin/opcontrol --init
mv /etc/mtab1 /etc/mtab
/mnt/arm-uc-oprofile/bin/opcontrol --init
3) Set up path to Linux kernel image
/mnt/arm-uc-oprofile/bin/opcontrol --vmlinux=/mnt/trunk_ST58200/kernel/linux-2.6.35.12/vmlinux
4) Start profiling
/mnt/arm-uc-oprofile/bin/opcontrol --start
5) Do any thing you want to profile
6) Stop profiling
/mnt/arm-uc-oprofile/bin/opcontrol --stop
7) Read report
/mnt/arm-uc-oprofile/bin/opreport -l
2011年12月13日 星期二
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言