diff mbox

[U-Boot,2/7] Add macros for recording init calls during UBoot execution

Message ID 1314829261-13996-3-git-send-email-amurray@theiet.org
State Superseded
Headers show

Commit Message

Andrew Murray Aug. 31, 2011, 10:20 p.m. UTC
From: Andrew Murray <amurray@mpcdata.com>

This patch adds macros which allow for the instrumentation of UBoot boot
time. The macros can be used to call existing initialisation functions during
start up. Each macro adds printf statements before and after the initialisation
call.

Signed-off-by: Andrew Murray <amurray@theiet.org>
---
 include/common.h |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

Comments

Mike Frysinger Aug. 31, 2011, 10:50 p.m. UTC | #1
On Wednesday, August 31, 2011 18:20:56 Andrew Murray wrote:
> +#if defined(CONFIG_BOOT_TRACE)
> +#define DO_INITCALL(x, ...) \
> +	do { \
> +		printf("calling  0x%pF\n", x); \
> +		(x)(__VA_ARGS__); \
> +		printf("initcall 0x%pF returned\n", x); \
> +	} while (0)

are there any void initcalls ?  or just ones where you ignore the value ?  
otherwise we can simply rename DO_INITCALL_RET() to DO_INITCALL().

> +#define DO_INITCALL_RET(x, ret, ...) \
> +	do { \
> +		printf("calling  0x%pF\n", x); \
> +		ret = (x)(__VA_ARGS__); \
> +		printf("initcall 0x%pF returned\n", x); \
> +	} while (0)

#define DO_INITCALL_RET(x, ...) \
	({ \
		int __ret; \
		printf("calling  0x%pF\n", x); \
		__ret = (x)(__VA_ARGS__); \
		printf("initcall 0x%pF returned\n", x); \
		__ret; \
	})
-mike
Andrew Murray Aug. 31, 2011, 11:40 p.m. UTC | #2
On 31 August 2011 23:50, Mike Frysinger <vapier@gentoo.org> wrote:
> On Wednesday, August 31, 2011 18:20:56 Andrew Murray wrote:
>> +#if defined(CONFIG_BOOT_TRACE)
>> +#define DO_INITCALL(x, ...) \
>> +     do { \
>> +             printf("calling  0x%pF\n", x); \
>> +             (x)(__VA_ARGS__); \
>> +             printf("initcall 0x%pF returned\n", x); \
>> +     } while (0)
>
> are there any void initcalls ?  or just ones where you ignore the value ?
> otherwise we can simply rename DO_INITCALL_RET() to DO_INITCALL().

I guess it depends what you define as an initcall. A lot of functions
called during startup (e.g. arch/arm/lib/board.c) return int and in
most cases that value is ignored - but there are occasions where void
is returned - e.g. env_relocate.

For simplicity you could limit the use cases for this macro to those
which just return int and take your proposed approach?

Andrew Murray
diff mbox

Patch

diff --git a/include/common.h b/include/common.h
index 1e21b7a..aa21b10 100644
--- a/include/common.h
+++ b/include/common.h
@@ -176,6 +176,29 @@  typedef void (interrupt_handler_t)(void *);
 
 #endif /* CONFIG_SERIAL_MULTI */
 
+#if defined(CONFIG_BOOT_TRACE)
+#define DO_INITCALL(x, ...) \
+	do { \
+		printf("calling  0x%pF\n", x); \
+		(x)(__VA_ARGS__); \
+		printf("initcall 0x%pF returned\n", x); \
+	} while (0)
+#define DO_INITCALL_RET(x, ret, ...) \
+	do { \
+		printf("calling  0x%pF\n", x); \
+		ret = (x)(__VA_ARGS__); \
+		printf("initcall 0x%pF returned\n", x); \
+	} while (0)
+#define DO_INITCALL_END(x) \
+	printf("initcall 0x%pF returned\n", x)
+#else
+#define DO_INITCALL(x, ...) \
+	(x)(__VA_ARGS__)
+#define DO_INITCALL_RET(x, ret, ...) \
+	ret = (x)(__VA_ARGS__)
+#define DO_INITCALL_END(x)
+#endif
+
 /*
  * General Purpose Utilities
  */