summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/profiling
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2005-05-06 02:43:04 +0000
committerPascal Rigaux <pixel@mandriva.com>2005-05-06 02:43:04 +0000
commit4e506c9aefe5b89970ae6894d05ad53c81af0d83 (patch)
tree2fac98df209e72eaba773cad2d7b90c99d9d9249 /mdk-stage1/dietlibc/profiling
parent793707b39bf2e9df40a6d2d60b83b3061088ae9e (diff)
downloaddrakx-4e506c9aefe5b89970ae6894d05ad53c81af0d83.tar
drakx-4e506c9aefe5b89970ae6894d05ad53c81af0d83.tar.gz
drakx-4e506c9aefe5b89970ae6894d05ad53c81af0d83.tar.bz2
drakx-4e506c9aefe5b89970ae6894d05ad53c81af0d83.tar.xz
drakx-4e506c9aefe5b89970ae6894d05ad53c81af0d83.zip
use installed dietlibc, not our forked cvs version
Diffstat (limited to 'mdk-stage1/dietlibc/profiling')
-rw-r--r--mdk-stage1/dietlibc/profiling/PORTING25
-rw-r--r--mdk-stage1/dietlibc/profiling/README37
-rw-r--r--mdk-stage1/dietlibc/profiling/__mcount.c24
-rw-r--r--mdk-stage1/dietlibc/profiling/monitor.c93
-rw-r--r--mdk-stage1/dietlibc/profiling/profil.c75
5 files changed, 0 insertions, 254 deletions
diff --git a/mdk-stage1/dietlibc/profiling/PORTING b/mdk-stage1/dietlibc/profiling/PORTING
deleted file mode 100644
index c3fc5eba7..000000000
--- a/mdk-stage1/dietlibc/profiling/PORTING
+++ /dev/null
@@ -1,25 +0,0 @@
- Porting to other platforms
-
- ... is easy. Just create an mcount.S in the $ARCH
- directory (eg. dietlibc/i386) which includes a
- function (called "mcount") that:
-
- 1.) saves ALL registers that are freely usable
- and which might be used by __mcount().
- 2.) loads the instruction pointer (PC) from the
- function that called mcount, and the function
- which called the function, that called mcount
- into the first two argument registers (or push
- them on the stack - depending on the processor-
- architecture).
- 3.) call __mcount.
- 4.) restore the registers saved in 1)
-
- Then You need a macro called PC in <asm/sigcontext.h>
- which extracts the (instruction pointer / program
- counter) from a sigcontext structure (eg. on i386 this
- would be ctx.eip).
-
- $ARCH/start.S must also be modified to call monitor
- with the offset of .text and _etext as parameters.
-
diff --git a/mdk-stage1/dietlibc/profiling/README b/mdk-stage1/dietlibc/profiling/README
deleted file mode 100644
index 0a0293073..000000000
--- a/mdk-stage1/dietlibc/profiling/README
+++ /dev/null
@@ -1,37 +0,0 @@
-
- Notes on profiling support for dietlibc
-
- 1.) A big problem when doing profiling on statically linked
- programs, is that the internal profiling functions (mcount
- and friends) will be included in the call graph although
- they would not if the program would have been dynamically
- linked. This is because every symbol between .text and
- _etext is included in the call-graph. If a program is
- dynamically linked, then mcount and friends are not between
- .text and _etext, so they are not included. A workaround
- for this, would be to put mcount, __mcount, monitor and
- profiler into another section (eg. ".profile"), but this
- creates some strange problems, I'm currently not aware of.
- If you want to debug this: Putting a function into a specific
- section works like this (with gcc):
-
- void foo (int bar) __attribute__ ((section(".foobar")))
-
- 2.) _start may randomly be found in the callgraph. I don't
- know why. May be a bug in gprof.
-
- 3.) The profiling is a complete rewrite, though I looked at
- the glibc Version for inspiration. Please note that this
- version might not be as portable as the glibc version but
- its much smaller (although this is not a really important
- argument, as profiled binaries seldom get shipped) and
- hopefully easier to understand.
-
- 4.) all objects that should be profiled mustn't be compiled
- with -fomit-frame-pointer (as with glibc). Add
- -fno-fomit-frame-pointer to $CFLAGS if you're encountering
- weird problems.
-
- 5.) There is currently no basic-block statistic support.
-
-Please send comments and bug reports to: tom@rhadamanthys.org
diff --git a/mdk-stage1/dietlibc/profiling/__mcount.c b/mdk-stage1/dietlibc/profiling/__mcount.c
deleted file mode 100644
index b1955f370..000000000
--- a/mdk-stage1/dietlibc/profiling/__mcount.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <unistd.h>
-#include <sys/gmon.h>
-
-extern struct monparam mparam;
-
-void __mcount (unsigned long, unsigned long) PROF_SECTION;
-
-void
-__mcount (unsigned long frompc, unsigned long selfpc)
-{
- struct rawarc *arc = mparam.arcs, thisarc;
- unsigned long num;
- /* If arc already exists, increment count */
- for (num = 0; num < mparam.arcnum; num++)
- if (arc[num].raw_frompc == frompc && arc[num].raw_selfpc == selfpc) {
- arc[num].raw_count++;
- return;
- }
- if (selfpc < mparam.lowpc || selfpc > mparam.highpc) return;
- thisarc.raw_frompc = frompc;
- thisarc.raw_selfpc = selfpc;
- thisarc.raw_count = 1;
- arc[mparam.arcnum++] = thisarc;
-}
diff --git a/mdk-stage1/dietlibc/profiling/monitor.c b/mdk-stage1/dietlibc/profiling/monitor.c
deleted file mode 100644
index cc06e3465..000000000
--- a/mdk-stage1/dietlibc/profiling/monitor.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/**************************************************************
- Copyright (C) 2001, 2002 Thomas M. Ogrisegg
-
- This is free software. You can redistribute and modify
- it under the terms of the GNU General Public License.
-
- This file is part of the profiling support for dietlibc
-
- monitor(3) interface
-
- *************************************************************/
-#include <sys/uio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <sys/gmon.h>
-
-typedef unsigned short u_short;
-
-struct monparam mparam;
-
-void monitor (unsigned long, unsigned long) PROF_SECTION;
-void _stop_monitor (void) PROF_SECTION;
-
-/*
- monitor is called by _start, to start profiling
- lowpc -> lowest valid program counter (normally .text)
- highpc -> highest valid program counter (normally _etext)
-*/
-void
-monitor (unsigned long lowpc, unsigned long highpc)
-{
- mparam.highpc = highpc;
- mparam.lowpc = lowpc;
- mparam.kcountsize = (mparam.textsize = highpc-lowpc) << 1;
- mparam.kcount = (u_short *) malloc (mparam.kcountsize);
- mparam.arcs = (struct rawarc *) malloc (MAXARCS*sizeof (struct rawarc));
- if (!mparam.kcount || !mparam.arcs)
- exit (42);
- mparam.arcnum = 0;
- /* start profiling */
- profil (mparam.kcount, highpc-lowpc, lowpc, 10000);
-}
-
-/*
- write_gmon - write all data collected by the helper routines
- to gmon.out
-*/
-static void
-write_gmon (void)
-{
- struct gmon_hdr ghdr = { "gmon", 1, "" };
- int fd = open ("gmon.out", O_CREAT | O_RDWR | O_TRUNC, 0666);
-
- if (fd < 0) return;
- write (fd, &ghdr, sizeof (ghdr));
- if (mparam.kcountsize)
- {
- char tag = GMON_TAG_TIME_HIST;
- struct gmon_hist_hdr ghdr = {
- mparam.lowpc, mparam.highpc,
- (mparam.kcountsize >> 1), 100, "seconds", 's'
- };
- struct iovec iov[3] = {
- { &tag, sizeof (tag) },
- { &ghdr, sizeof (ghdr) },
- { mparam.kcount, mparam.kcountsize >> 1 << 1 }
- };
- writev (fd, iov, 3);
- }
- if (mparam.arcnum)
- {
- char tag = GMON_TAG_CG_ARC;
- struct iovec iov[mparam.arcnum*2];
- unsigned long l;
- for (l=0;l<mparam.arcnum;l++) {
- iov[l*2].iov_base = &tag;
- iov[l*2].iov_len = sizeof (tag);
- iov[l*2+1].iov_base = &mparam.arcs[l];
- iov[l*2+1].iov_len = sizeof (mparam.arcs[l]);
- }
- writev (fd, iov, mparam.arcnum*2);
- }
- close (fd);
-}
-
-/* called by _start before exit */
-void
-_stop_monitor (void)
-{
- profil (NULL, 0, 0, 0);
- write_gmon ();
-}
diff --git a/mdk-stage1/dietlibc/profiling/profil.c b/mdk-stage1/dietlibc/profiling/profil.c
deleted file mode 100644
index fa9a0ef2b..000000000
--- a/mdk-stage1/dietlibc/profiling/profil.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/******************************************************
- Copyright (C) 2001, 2002 Thomas M. Ogrisegg
-
- This is free software. You can redistribute and modify
- it under the terms of the GNU General Public License.
-
- This file is part of the profiling support for dietlibc
-
- profil (3) generic implementation
-
- *************************************************************/
-
-#include <asm/sigcontext.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <signal.h>
-
-#define SHORT_SIZE sizeof (short)
-#define MAX_SHORT 65536
-
-#ifdef DEBUG
-# include <stdio.h>
-# define debug printf
-#else
-# define debug
-#endif
-
-#ifndef u_short
-# define u_short unsigned short
-#endif
-
-#ifndef u_int
-# define u_int unsigned int
-#endif
-
-static unsigned short *buffer = NULL;
-static size_t maxhits = 0;
-static unsigned long low_pc = 0;
-static unsigned long pscale = 0;
-
-/* profiler - helper function for profil(3) */
-static void
-profiler (int signal, struct sigcontext ctx)
-{
- size_t s = PC(ctx)-low_pc;
- (void)signal;
- if ((PC(ctx)) < low_pc) return;
- s >>= 1;
- if (s < maxhits)
- ++buffer[s];
-}
-
-/* profil(3) - start or stop the profiling timer */
-int
-profil (u_short *buf, size_t bufsiz, size_t offset, u_int scale)
-{
- struct itimerval itv = { { 0, 1 }, { 0, 1 } };
- struct sigaction sa;
- if (!buf) {
- sigaction (SIGPROF, NULL, NULL);
- setitimer (ITIMER_PROF, NULL, NULL);
- return (0);
- }
- sa.sa_handler = (sighandler_t)&profiler;
- sa.sa_flags = SA_RESTART;
- sigfillset (&sa.sa_mask);
- sigaction (SIGPROF, &sa, NULL);
- pscale = scale;
- buffer = buf;
- low_pc = offset;
- maxhits = bufsiz/SHORT_SIZE;
-
- return (setitimer (ITIMER_PROF, &itv, &itv));
-}