Skip to contentSkip to conversation

Provide more useful debugging when an initcall fails

PATCH New Simon Glass 2 participants 3 messages Apr 13, 2013 – Apr 16, 2013 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Provide more useful debugging when an initcall fails

The debug() which prints out the current call is not very useful, since if it is called early enough (such as before the console is ready in the pre-relocation board_init_f() sequence) it can hang the board.

It is more useful to print a message when a call fails, and in this case the non-relocated symbol address provides a way for the offending function to be located in System.map.

Adjust the initcall to provide this.

---
 lib/initcall.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
lib/initcall.c +7 -2
index fc91bf6..ace285d 100644
@@ -23,15 +23,20 @@
 #include <common.h>
 #include <initcall.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 int initcall_run_list(init_fnc_t init_sequence[])
 {
 	init_fnc_t *init_fnc_ptr;
 
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
-		debug("initcall: %p\n", *init_fnc_ptr);
 		if ((*init_fnc_ptr)()) {
+			unsigned long reloc_ofs = 0;
+
+			if (gd->flags & GD_FLG_RELOC)
+				reloc_ofs = gd->reloc_off;
 			debug("initcall sequence %p failed at call %p\n",
-			      init_sequence, *init_fnc_ptr);
+			      init_sequence, (char *)*init_fnc_ptr - reloc_ofs);
 			return -1;
 		}
 	}
Signature · 1 line
1.8.1.3
#1 lore raw

PATCH 1/1 Provide more useful debugging when an initcall fails

Dear Simon Glass,

Quoted 3 lines · In message <[email protected]> you wrote:

The debug() which prints out the current call is not very useful, since if it is called early enough (such as before the console is ready in the pre-relocation board_init_f() sequence) it can hang the board.

This should not happen (and if it does, that wouldbe a bug that needs fixing).

Quoted 3 lines

It is more useful to print a message when a call fails, and in this case the non-relocated symbol address provides a way for the offending function to be located in System.map.

No. it is a long styanding rule that for this tyoe of actions the begin of the message gets printed before even attempting to call the respective function, so if the systemn hangs you can see the last operation which was about to be run. I think we should follow this principle here, too.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Love is an ideal thing, marriage a real thing; a  confusion  of  the
real with the ideal never goes unpunished."                  - Goethe
#2 lore raw

PATCH 1/1 Provide more useful debugging when an initcall fails

Hi Wolfgang,

Quoted 9 lines · Wolfgang Denk

Dear Simon Glass,

Quoted 3 lines · In message <[email protected]> you wrote:

The debug() which prints out the current call is not very useful, since if it is called early enough (such as before the console is ready in the pre-relocation board_init_f() sequence) it can hang the board.

This should not happen (and if it does, that wouldbe a bug that needs fixing).

Yes.

Quoted 10 lines
Quoted 4 lines

It is more useful to print a message when a call fails, and in this case the non-relocated symbol address provides a way for the offending function to be located in System.map.

No. it is a long styanding rule that for this tyoe of actions the begin of the message gets printed before even attempting to call the respective function, so if the systemn hangs you can see the last operation which was about to be run. I think we should follow this principle here, too.

OK fair enough, makes sense. I think. It is certainly true that any of these calls could hang the board.

Let's drop this patch.

Quoted 11 lines

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "Love is an ideal thing, marriage a real thing; a confusion of the
real with the ideal never goes unpunished." - Goethe

Regards,
Simon