On Wed, Nov 5, 2014 at 2:00 PM, Jason Ekstrand <[email protected]> wrote: > This can be very useful for trying to debug list corruptions. > > Signed-off-by: Jason Ekstrand <[email protected]> > Cc: Ian Romanick <[email protected]> > --- > src/glsl/list.h | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/src/glsl/list.h b/src/glsl/list.h > index aac13fd..1d18ec9 100644 > --- a/src/glsl/list.h > +++ b/src/glsl/list.h > @@ -521,6 +521,20 @@ exec_node_insert_list_before(struct exec_node *n, struct > exec_list *before) > exec_list_make_empty(before); > } > > +static inline void > +exec_list_validate(struct exec_list *list) > +{ > + assert(list->head->prev == (struct exec_node *) &list->head); > + assert(list->tail == NULL); > + assert(list->tail_pred->next == (struct exec_node *) &list->tail); > + > + for (struct exec_node *node = list->head; > + node->next != NULL; node = node->next) {
Just use foreach_in_list(). > + assert(node->next->prev == node); > + assert(node->prev->next == node); > + } > +} Are you intending to call this from gdb? I'm having a hard time imagining committing code that *sometimes* corrupts lists, which seems like why this function would be useful to call from real code. If you just want to call it from gdb, wrap the whole thing in #ifndef NDEBUG. I don't want to ever accidentally call this function and think it validated something when it actually did nothing. _______________________________________________ mesa-dev mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/mesa-dev
