/** Validation function to check that a fr_value_box_t is correctly initialised
*
*/
-void value_box_verify(char const *file, int line, fr_value_box_t const *vb, bool talloced)
+void fr_value_box_verify(char const *file, int line, fr_value_box_t const *vb, bool talloced)
{
DIAG_OFF(nonnull-compare)
/*
break;
case FR_TYPE_GROUP:
- value_box_list_verify(file, line, &vb->vb_group, talloced);
+ fr_value_box_list_verify(file, line, &vb->vb_group, talloced);
break;
default:
}
}
-void value_box_list_verify(char const *file, int line, FR_DLIST_HEAD(fr_value_box_list) const *list, bool talloced)
+void fr_value_box_list_verify(char const *file, int line, FR_DLIST_HEAD(fr_value_box_list) const *list, bool talloced)
{
- fr_value_box_t const *vb = NULL;
-
- while ((vb = fr_value_box_list_next(list, vb))) value_box_verify(file, line, vb, talloced);
+ fr_value_box_list_foreach(list, vb) fr_value_box_verify(file, line, vb, talloced);
}
return box.vb_bool;
}
}
+
+#define INFO_INDENT(_fmt, ...) FR_FAULT_LOG("%*s"_fmt, depth * 2, " ", ## __VA_ARGS__)
+
+static void _fr_value_box_debug(fr_value_box_t const *vb, int depth, int idx);
+static void _fr_value_box_list_debug(FR_DLIST_HEAD(fr_value_box_list) const *head, int depth)
+{
+ int i = 0;
+
+ INFO_INDENT("{");
+ fr_value_box_list_foreach(head, vb) _fr_value_box_debug(vb, depth + 1, i++);
+ INFO_INDENT("}");
+}
+
+/** Print a list of value boxes as info messages
+ *
+ * @note Call directly from the debugger
+ */
+void fr_value_box_list_debug(FR_DLIST_HEAD(fr_value_box_list) const *head)
+{
+ _fr_value_box_list_debug(head, 0);
+}
+
+static void _fr_value_box_debug(fr_value_box_t const *vb, int depth, int idx)
+{
+ char *value;
+
+ if (fr_type_is_structural(vb->type)) {
+ _fr_value_box_list_debug(&vb->vb_group, depth + 1);
+ return;
+ }
+
+ fr_value_box_aprint(NULL, &value, vb, NULL);
+ if (idx >= 0) {
+ INFO_INDENT("[%d] %s", idx, value);
+ } else {
+ INFO_INDENT("%s", value);
+ }
+ talloc_free(value);
+}
+
+/** Print the value of a box as info messages
+ *
+ * @note Call directly from the debugger
+ */
+void fr_value_box_debug(fr_value_box_t const *vb)
+{
+ _fr_value_box_debug(vb, 0, -1);
+}
+
+
#define fr_value_box_list_foreach(_list_head, _iter) fr_dlist_foreach(fr_value_box_list_dlist_head(_list_head), fr_value_box_t, _iter)
#define fr_value_box_list_foreach_safe(_list_head, _iter) fr_dlist_foreach_safe(fr_value_box_list_dlist_head(_list_head), fr_value_box_t, _iter)
-#define fr_value_box_list_verify(_list_head) _fr_value_box_list_verify(__FILE__, __LINE__, _list_head)
FR_DCURSOR_FUNCS(fr_value_box_dcursor, fr_value_box_list, fr_value_box_t)
/** @} */
/** @} */
-void value_box_verify(char const *file, int line, fr_value_box_t const *vb, bool talloced)
+void fr_value_box_verify(char const *file, int line, fr_value_box_t const *vb, bool talloced)
CC_HINT(nonnull(3));
-void value_box_list_verify(char const *file, int line, FR_DLIST_HEAD(fr_value_box_list) const *list, bool talloced)
+void fr_value_box_list_verify(char const *file, int line, FR_DLIST_HEAD(fr_value_box_list) const *list, bool talloced)
CC_HINT(nonnull(3));
#ifdef WITH_VERIFY_PTR
-# define VALUE_BOX_VERIFY(_x) value_box_verify(__FILE__, __LINE__, _x, false)
-# define VALUE_BOX_LIST_VERIFY(_x) value_box_list_verify(__FILE__, __LINE__, _x, false)
-# define VALUE_BOX_TALLOC_VERIFY(_x) value_box_verify(__FILE__, __LINE__, _x, true)
-# define VALUE_BOX_TALLOC_LIST_VERIFY(_x) value_box_list_verify(__FILE__, __LINE__, _x, true)
+# define VALUE_BOX_VERIFY(_x) fr_value_box_verify(__FILE__, __LINE__, _x, false)
+# define VALUE_BOX_LIST_VERIFY(_x) fr_value_box_list_verify(__FILE__, __LINE__, _x, false)
+# define VALUE_BOX_TALLOC_VERIFY(_x) fr_value_box_verify(__FILE__, __LINE__, _x, true)
+# define VALUE_BOX_TALLOC_LIST_VERIFY(_x) fr_value_box_list_verify(__FILE__, __LINE__, _x, true)
#else
/*
* Even if were building without WITH_VERIFY_PTR
# define VALUE_BOX_TALLOC_LIST_VERIFY(_x) fr_assert(_x)
#endif
+/** @name Debug functions
+ *
+ * @{
+ */
+void fr_value_box_list_debug(FR_DLIST_HEAD(fr_value_box_list) const *head);
+void fr_value_box_debug(fr_value_box_t const *vb);
+/** @} */
+
#undef _CONST
#ifdef __cplusplus