This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Improve profiling API, add documentation
- From: Gary Thomas <gthomas at ecoscentric dot com>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: 15 Nov 2002 07:33:22 -0700
- Subject: Improve profiling API, add documentation
Index: hal/powerpc/mpc8xx/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/mpc8xx/current/ChangeLog,v
retrieving revision 1.18
diff -u -5 -p -r1.18 ChangeLog
--- hal/powerpc/mpc8xx/current/ChangeLog 14 Nov 2002 23:36:48 -0000 1.18
+++ hal/powerpc/mpc8xx/current/ChangeLog 15 Nov 2002 14:30:48 -0000
@@ -1,5 +1,9 @@
+2002-11-15 Gary Thomas <gthomas@ecoscentric.com>
+
+ * src/var_misc.c: Change in API for profile callback.
+
2002-11-14 Gary Thomas <gthomas@ecoscentric.com>
* src/var_misc.c:
* cdl/hal_powerpc_mpc8xx.cdl: Add support for profiling.
Index: hal/powerpc/mpc8xx/current/src/var_misc.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/hal/powerpc/mpc8xx/current/src/var_misc.c,v
retrieving revision 1.9
diff -u -5 -p -r1.9 var_misc.c
--- hal/powerpc/mpc8xx/current/src/var_misc.c 15 Nov 2002 00:27:22 -0000 1.9
+++ hal/powerpc/mpc8xx/current/src/var_misc.c 15 Nov 2002 12:42:25 -0000
@@ -229,11 +229,11 @@ cyg_hal_clear_MMU (void)
static cyg_uint32
isr_pit(CYG_ADDRWORD vector, CYG_ADDRWORD data, HAL_SavedRegisters *regs)
{
HAL_INTERRUPT_ACKNOWLEDGE (CYGNUM_HAL_INTERRUPT_SIU_PIT);
- profile_hit(regs->pc);
+ __profile_hit(regs->pc);
return Cyg_InterruptHANDLED;
}
void
Index: services/profile/gprof/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/services/profile/gprof/current/ChangeLog,v
retrieving revision 1.1
diff -u -5 -p -r1.1 ChangeLog
--- services/profile/gprof/current/ChangeLog 15 Nov 2002 00:27:23 -0000 1.1
+++ services/profile/gprof/current/ChangeLog 15 Nov 2002 14:31:46 -0000
@@ -1,5 +1,13 @@
+2002-11-15 Gary Thomas <gthomas@ecoscentric.com>
+
+ * src/profile.c:
+ * include/profile.h: Add proper C++ protections. Change timer
+ callback function to be __profile_hit() - less polluting.
+
+ * doc/profile.sgml: New file.
+
2002-11-14 Gary Thomas <gthomas@ecoscentric.com>
* src/profile.c:
* include/profile.h:
* include/gmon_out.h:
Index: services/profile/gprof/current/doc/profile.sgml
===================================================================
RCS file: services/profile/gprof/current/doc/profile.sgml
diff -N services/profile/gprof/current/doc/profile.sgml
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ services/profile/gprof/current/doc/profile.sgml 15 Nov 2002 14:05:36 -0000
@@ -0,0 +1,84 @@
+<PART ID="services-profile-gprof">
+<TITLE>Application profiling</TITLE>
+<PARTINTRO>
+<PARA>
+The profile_gprof package provides a mechanism to measure the
+runtime performance of an application. This is done by gathering
+an execution histogram, which can then be uploaded to a host
+and analyzed using the
+<function>gprof</function>
+utility program.
+</PARA>
+<para>
+Since the collected histogram data is volatile, some mechanism
+must be used to export the data from the target.
+Currently, this process is done using
+<emphasis>TFTP</emphasis>.
+When profiling is started on the target device, a
+<emphasis>TFTP</emphasis>
+server will be started
+which exports the single file
+<filename>PROFILE.DAT</filename>
+</para>
+</PARTINTRO>
+<CHAPTER id="profile-functions">
+<TITLE>Profiling functions</TITLE>
+<SECT1 id="services-profile-api">
+<title> API </title>
+<para>
+In order for profile data to be gathered for an application, the
+program has to initiate the process.
+Once started, execution histogram data will be collected in a
+dynamic memory buffer.
+This data can be uploaded to a host using <emphasis>TFTP</emphasis>.
+A side effect of the upload of the data is that the histogram
+is reset.
+This is useful, especially for high resolution histograms, since
+the histogram data are collected as 16-bit counters which can be quickly
+saturated.
+For example, if the histogram is being collected at a rate of 10,000
+samples per second, a hot spot in the program could saturate after
+only 6.5 seconds.
+</para>
+<para> The API for the application profiling functions can be
+found in the file <filename><cyg/profile/profile.h></filename>.
+</para>
+<sect2 id="services-profile-api-profile-on">
+<title>profile_on</title>
+<para>
+This function is used to initiate the gathering of the
+runtime execution histogram data.
+</para>
+<programlisting>
+void profile_on(void *start, void *end, int bucket_size, int resolution);
+</programlisting>
+<para>
+Calling this function will initiate execution profiling.
+An execution histogram is collected at the rate of
+<parameter>resolution</parameter> times per second.
+The area between <parameter>start</parameter> and <parameter>end</parameter>
+will be divided up into a number of buckets, each representing
+<parameter>bucket_size</parameter>
+program bytes in length. Using statistical sampling (via a high speed timer), when
+the program counter is found to be within the range
+<parameter>start</parameter>..<parameter>end</parameter>, the appropriate
+bucket (histogram entry) will be incremented.
+</para>
+<para>
+The choice of <parameter>resolution</parameter> and <parameter>bucket_size</parameter>
+control how large the data gathered will be, as well as how much overhead is
+encumbered for gathering the histogram.
+Smaller values for <parameter>bucket_size</parameter> will garner better
+results (<function>gprof</function> can more closely align the data with
+actual function names) at the expense of a larger data buffer.
+</para>
+<note><title>NOTE</title>
+<para>
+The value of <parameter>bucket_size</parameter> will be rounded up to a power of two.
+</para>
+</note>
+</sect2>
+</SECT1>
+</CHAPTER>
+</PART>
+
Index: services/profile/gprof/current/include/profile.h
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/services/profile/gprof/current/include/profile.h,v
retrieving revision 1.1
diff -u -5 -p -r1.1 profile.h
--- services/profile/gprof/current/include/profile.h 15 Nov 2002 00:27:23 -0000 1.1
+++ services/profile/gprof/current/include/profile.h 15 Nov 2002 12:42:25 -0000
@@ -48,23 +48,26 @@
// Date: 2002-11-14
// Purpose: Define profiling support
// Description:
//
// Usage:
-// #include <cyg/infra/profile.h>
+// #include <cyg/profile/profile.h>
//
//
//####DESCRIPTIONEND####
//
//==========================================================================
+#include <pkgconf/profile_gprof.h>
+#include <cyg/infra/cyg_type.h>
+
// Enable profiling
-extern void profile_on(void *start_addr, void *end_addr,
- int bucket_size, int sample_resolution);
+__externC void profile_on(void *start_addr, void *end_addr,
+ int bucket_size, int sample_resolution);
// Callback used by timer routine
-extern void profile_hit(unsigned long pc);
+__externC void __profile_hit(unsigned long pc);
// Timer setup routine, used when enabling profiling
-extern void hal_enable_profile_timer(int resolution);
+__externC void hal_enable_profile_timer(int resolution);
#endif // CYGONCE_PROFILE_H
Index: services/profile/gprof/current/src/profile.c
===================================================================
RCS file: /misc/cvsfiles/ecos/packages/services/profile/gprof/current/src/profile.c,v
retrieving revision 1.1
diff -u -5 -p -r1.1 profile.c
--- services/profile/gprof/current/src/profile.c 15 Nov 2002 00:27:23 -0000 1.1
+++ services/profile/gprof/current/src/profile.c 15 Nov 2002 12:43:37 -0000
@@ -190,11 +190,11 @@ profile_read(int fd, void *buf, int len)
fp->pos += res;
return res;
}
void
-profile_hit(unsigned long pc)
+__profile_hit(unsigned long pc)
{
int bucket;
if (enabled) {
if ((pc >= start_addr) && (pc <= end_addr)) {
bucket = (pc - start_addr) >> bucket_shift;
--
------------------------------------------------------------
Gary Thomas |
eCosCentric, Ltd. |
+1 (970) 229-1963 | eCos & RedBoot experts
gthomas@ecoscentric.com |
http://www.ecoscentric.com/ |
------------------------------------------------------------