[Skiboot] [PATCH] hdata: print backtraces on HDAT errors
Oliver O'Halloran
oohall at gmail.com
Thu Mar 30 11:48:51 AEDT 2017
Currently these aren't sufficently obnoxious, so make them more so. HDAT
parse errors usually mean we won't be able to generate enough of a
device-tree to boot so we want to make this much more obvious.
Suggested-by: Michael Neuling <mikey at neuling.org>
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
hdata/hdif.c | 9 +++++++++
hdata/test/stubs.c | 1 +
2 files changed, 10 insertions(+)
diff --git a/hdata/hdif.c b/hdata/hdif.c
index 62ba69f2e887..dd5e12285f32 100644
--- a/hdata/hdif.c
+++ b/hdata/hdif.c
@@ -15,6 +15,7 @@
*/
#include "hdif.h"
+#include <stack.h>
const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di,
unsigned int *size)
@@ -24,11 +25,13 @@ const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di,
if (be16_to_cpu(hdr->d1f0) != 0xd1f0) {
prerror("HDIF: Bad header format !\n");
+ backtrace();
return NULL;
}
if (di >= be16_to_cpu(hdr->idptr_count)) {
prerror("HDIF: idata index out of range !\n");
+ backtrace();
return NULL;
}
@@ -55,6 +58,7 @@ const void *HDIF_get_iarray_item(const struct HDIF_common_hdr *hdif,
if (asize < sizeof(struct HDIF_array_hdr)) {
prerror("HDIF: idata block too small for array !\n");
+ backtrace();
return NULL;
}
@@ -62,6 +66,7 @@ const void *HDIF_get_iarray_item(const struct HDIF_common_hdr *hdif,
if (ai >= be32_to_cpu(ahdr->ecnt)) {
prerror("HDIF: idata array index out of range !\n");
+ backtrace();
return NULL;
}
@@ -83,6 +88,7 @@ int HDIF_get_iarray_size(const struct HDIF_common_hdr *hdif, unsigned int di)
if (asize < sizeof(struct HDIF_array_hdr)) {
prerror("HDIF: idata block too small for array !\n");
+ backtrace();
return -1;
}
@@ -99,6 +105,7 @@ HDIF_child_arr(const struct HDIF_common_hdr *hdif, unsigned int idx)
if (idx >= be16_to_cpu(hdif->child_count)) {
prerror("HDIF: child array idx out of range!\n");
+ backtrace();
return NULL;
}
@@ -125,6 +132,7 @@ struct HDIF_common_hdr *HDIF_child(const struct HDIF_common_hdr *hdif,
if (be32_to_cpu(child->size) < sizeof(struct HDIF_common_hdr)) {
prerror("HDIF: %s child #%i too small: %u\n",
eyecatcher, idx, be32_to_cpu(child->size));
+ backtrace();
return NULL;
}
@@ -133,6 +141,7 @@ struct HDIF_common_hdr *HDIF_child(const struct HDIF_common_hdr *hdif,
if (!HDIF_check(ret, eyecatcher)) {
prerror("HDIF: #%i bad type (wanted %6s, got %6s)\n",
idx, eyecatcher, ret->id);
+ backtrace();
return NULL;
}
diff --git a/hdata/test/stubs.c b/hdata/test/stubs.c
index f513aacbf5fe..bde19e167c18 100644
--- a/hdata/test/stubs.c
+++ b/hdata/test/stubs.c
@@ -101,3 +101,4 @@ STUB(fsp_wait_lid_loaded);
STUB(fsp_adjust_lid_side);
STUB(mem_reserve_hw);
STUB(early_uart_init);
+STUB(backtrace);
--
2.9.3
More information about the Skiboot
mailing list