r9623 jmb - in /trunk/tools/trace: ./ Makefile build/ src/ src/Makefile src/shim.s src/trace.c

netsurf at semichrome.net netsurf at semichrome.net
Mon Oct 12 15:52:37 BST 2009


Author: jmb
Date: Mon Oct 12 09:52:35 2009
New Revision: 9623

URL: http://source.netsurf-browser.org?rev=9623&view=rev
Log:
First cut at a call tracing library

Added:
    trunk/tools/trace/
    trunk/tools/trace/Makefile
    trunk/tools/trace/build/   (with props)
    trunk/tools/trace/src/
    trunk/tools/trace/src/Makefile
    trunk/tools/trace/src/shim.s
    trunk/tools/trace/src/trace.c

Added: trunk/tools/trace/Makefile
URL: http://source.netsurf-browser.org/trunk/tools/trace/Makefile?rev=9623&view=auto
==============================================================================
--- trunk/tools/trace/Makefile (added)
+++ trunk/tools/trace/Makefile Mon Oct 12 09:52:35 2009
@@ -1,0 +1,29 @@
+# Component settings
+COMPONENT := trace
+COMPONENT_VERSION := 0.0.1
+# Default to a static library
+COMPONENT_TYPE ?= lib-static
+
+# Setup the tooling
+include build/makefiles/Makefile.tools
+
+# Toolchain flags
+WARNFLAGS := -Wall -Wundef -Wpointer-arith -Wcast-align \
+	-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
+	-Wmissing-declarations -Wnested-externs -Werror -pedantic
+ifneq ($(GCCVER),2)
+  WARNFLAGS := $(WARNFLAGS) -Wextra
+endif
+CFLAGS := -D_BSD_SOURCE -I$(CURDIR)/include/ \
+	-I$(CURDIR)/src $(WARNFLAGS) $(CFLAGS)
+ifneq ($(GCCVER),2)
+  CFLAGS := $(CFLAGS) -std=c99
+else
+  # __inline__ is a GCCism
+  CFLAGS := $(CFLAGS) -Dinline="__inline__"
+endif
+
+include build/makefiles/Makefile.top
+
+# Extra installation rules
+INSTALL_ITEMS := $(INSTALL_ITEMS) /lib:$(OUTPUT)

Propchange: trunk/tools/trace/build/
------------------------------------------------------------------------------
--- svn:externals (added)
+++ svn:externals Mon Oct 12 09:52:35 2009
@@ -1,0 +1,1 @@
+makefiles svn://svn.netsurf-browser.org/trunk/tools/buildsystem/makefiles

Added: trunk/tools/trace/src/Makefile
URL: http://source.netsurf-browser.org/trunk/tools/trace/src/Makefile?rev=9623&view=auto
==============================================================================
--- trunk/tools/trace/src/Makefile (added)
+++ trunk/tools/trace/src/Makefile Mon Oct 12 09:52:35 2009
@@ -1,0 +1,4 @@
+# Sources
+DIR_SOURCES := shim.s trace.s
+
+include build/makefiles/Makefile.subdir

Added: trunk/tools/trace/src/shim.s
URL: http://source.netsurf-browser.org/trunk/tools/trace/src/shim.s?rev=9623&view=auto
==============================================================================
--- trunk/tools/trace/src/shim.s (added)
+++ trunk/tools/trace/src/shim.s Mon Oct 12 09:52:35 2009
@@ -1,0 +1,26 @@
+#if !defined(__aof__)
+		.section	".text"
+
+		.global	image__ro__base
+		.global	image__ro__limit
+
+image__ro__base:
+		.word	Image$$RO$$Base
+image__ro__limit:
+		.word	Image$$RO$$Limit
+#else
+		AREA	|ARM$$Code|, CODE, READONLY
+
+		IMPORT	|Image$$RO$$Base|
+		IMPORT	|Image$$RO$$Limit|
+
+		EXPORT	image__ro__base
+		EXPORT	image__ro__limit
+
+image__ro__base
+		DCD	|Image$$RO$$Base|
+image__ro__limit
+		DCD	|Image$$RO$$Limit|
+
+		END
+#endif

Added: trunk/tools/trace/src/trace.c
URL: http://source.netsurf-browser.org/trunk/tools/trace/src/trace.c?rev=9623&view=auto
==============================================================================
--- trunk/tools/trace/src/trace.c (added)
+++ trunk/tools/trace/src/trace.c Mon Oct 12 09:52:35 2009
@@ -1,0 +1,55 @@
+#include <stdint.h>
+#include <stdio.h>
+
+extern uint32_t image__ro__base;
+extern uint32_t image__ro__limit;
+
+static uint32_t depth;
+
+static void print_function_name(uint32_t fn_address)
+{
+	uint32_t *offaddr = ((uint32_t *) address) - 1;
+	uint32_t offset = *offaddr;
+
+	if ((offset >> 24) == 0xff) {
+		fprintf(stderr, "%s\n", (const char *) (offaddr - 
+				((offset & ~0xff000000) / 4)));
+	} else {
+		fprintf(stderr, "(unknown)\n");
+	}
+}
+
+void __cyg_profile_enter(uint32_t fn_address, uint32_t call_site)
+{
+	uint32_t i = depth;
+
+	/* Ignore if address is out of bounds */
+	if (fn_address < image__ro__base || image__ro__limit < fn_address)
+		return;
+
+	while (i-- > 0)
+		fputc(' ', stderr);
+
+	fprintf(stderr, "Entering ");
+	print_function_name(fn_address);
+
+	depth++;
+}
+
+void __cyg_profile_exit(uint32_t fn_address, uint32_t call_site)
+{
+	uint32_t i = depth;
+
+	/* Ignore if address is out of bounds */
+	if (fn_address < image__ro__base || image__ro__limit < fn_address)
+		return;
+
+	while (i-- > 0)
+		fputc(' ', stderr);
+
+	fprintf(stderr, "Leaving ");
+	print_function_name(fn_address);
+
+	depth--;
+}
+




More information about the netsurf-commits mailing list