instead skip the node reporting a proper error and move on
v2: add friendly error messages instead of generic readmem failures
---
tools.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/tools.c b/tools.c
index 186b703463a5..7c7f65ac558b 100644
--- a/tools.c
+++ b/tools.c
@@ -4374,8 +4374,8 @@ rbtree_iteration(ulong node_p, struct tree_data *td, char *pos)
{
int i;
uint print_radix;
- ulong struct_p, left_p, right_p;
- char left_pos[BUFSIZE], right_pos[BUFSIZE];
+ ulong struct_p, new_p, test_p;
+ char new_pos[BUFSIZE];
static struct req_entry **e;
if (!node_p)
@@ -4430,16 +4430,25 @@ rbtree_iteration(ulong node_p, struct tree_data *td, char *pos)
}
}
- readmem(node_p+OFFSET(rb_node_rb_left), KVADDR, &left_p,
- sizeof(void *), "rb_node rb_left", FAULT_ON_ERROR);
- readmem(node_p+OFFSET(rb_node_rb_right), KVADDR, &right_p,
- sizeof(void *), "rb_node rb_right", FAULT_ON_ERROR);
-
- sprintf(left_pos, "%s/l", pos);
- sprintf(right_pos, "%s/r", pos);
-
- rbtree_iteration(left_p, td, left_pos);
- rbtree_iteration(right_p, td, right_pos);
+ if ( readmem(node_p+OFFSET(rb_node_rb_left), KVADDR, &new_p,
+ sizeof(void *), "rb_node rb_left", RETURN_ON_ERROR) && new_p)
+ if (readmem(new_p+OFFSET(rb_node_rb_left), KVADDR, &test_p,
+ sizeof(void *), "rb_node rb_left", RETURN_ON_ERROR|QUIET)) {
+ sprintf(new_pos, "%s/l", pos);
+ rbtree_iteration(new_p, td, new_pos);
+ } else
+ error(INFO, "rb_node: %lx: corrupted rb_left pointer: %lx\n",
+ node_p, new_p);
+
+ if ( readmem(node_p+OFFSET(rb_node_rb_right), KVADDR, &new_p,
+ sizeof(void *), "rb_node rb_right", RETURN_ON_ERROR) && new_p)
+ if (readmem(new_p+OFFSET(rb_node_rb_left), KVADDR, &test_p,
+ sizeof(void *), "rb_node rb_left", RETURN_ON_ERROR|QUIET)) {
+ sprintf(new_pos, "%s/r", pos);
+ rbtree_iteration(new_p, td, new_pos);
+ } else
+ error(INFO, "rb_node: %lx: corrupted rb_right pointer: %lx\n",
+ node_p, new_p);
}
void
--
2.17.0