<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 5, 2014 at 2:46 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Nov 5, 2014 at 2:00 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> This can be very useful for trying to debug list corruptions.<br>
><br>
> Signed-off-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
> Cc: Ian Romanick <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>><br>
> ---<br>
>  src/glsl/list.h | 14 ++++++++++++++<br>
>  1 file changed, 14 insertions(+)<br>
><br>
> diff --git a/src/glsl/list.h b/src/glsl/list.h<br>
> index aac13fd..1d18ec9 100644<br>
> --- a/src/glsl/list.h<br>
> +++ b/src/glsl/list.h<br>
> @@ -521,6 +521,20 @@ exec_node_insert_list_before(struct exec_node *n, struct exec_list *before)<br>
>     exec_list_make_empty(before);<br>
>  }<br>
><br>
> +static inline void<br>
> +exec_list_validate(struct exec_list *list)<br>
> +{<br>
> +   assert(list->head->prev == (struct exec_node *) &list->head);<br>
> +   assert(list->tail == NULL);<br>
> +   assert(list->tail_pred->next == (struct exec_node *) &list->tail);<br>
> +<br>
> +   for (struct exec_node *node = list->head;<br>
> +        node->next != NULL; node = node->next) {<br>
<br>
</span>Just use foreach_in_list().<br></blockquote><div><br></div><div>Sure, I can do that.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> +      assert(node->next->prev == node);<br>
> +      assert(node->prev->next == node);<br>
> +   }<br>
> +}<br>
<br>
</span>Are you intending to call this from gdb? I'm having a hard time<br>
imagining committing code that *sometimes* corrupts lists, which seems<br>
like why this function would be useful to call from real code.<br></blockquote><div><br>It is useful to call from gdb but I also call it all over nir_validate.c.  I spent most of today fighting linked list corruptions, and this was very helpful for tracking them down.  Another option would be rename it to exec_list_is_valid and make it return a bool.  Then the standard procedure would be "assert(exec_list_is_valid(list))".  Would that be better?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If you just want to call it from gdb, wrap the whole thing in #ifndef<br>
NDEBUG. I don't want to ever accidentally call this function and think<br>
it validated something when it actually did nothing.<br>
</blockquote></div><br></div></div>