This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libdw_visit_scopes: Don't recurse into imported unit children.


Hi Mark,

just when looking at it I found this issue but it is in fact unrelated minor
bug existing before this patch.


On Wed, 26 Jun 2013 18:02:26 +0200, Mark Wielaard wrote:
> --- a/libdw/libdw_visit_scopes.c
> +++ b/libdw/libdw_visit_scopes.c
> @@ -87,7 +87,7 @@ __libdw_visit_scopes (depth, root, previsit, postvisit, arg)
>  
>    child.parent = root;
>    if (INTUSE(dwarf_child) (&root->die, &child.die) != 0)
> -    return -1;
> +    return 0; // Having zero children is legal.

dwarf_child seems to return 1 on no children and -1 on error.  Here you hide
the error case.


>  
>    inline int recurse (void)
>      {
> @@ -95,63 +95,72 @@ __libdw_visit_scopes (depth, root, previsit, postvisit, arg)
[...]
> +	    Dwarf_Die orig_child_die = child.die;
> +	    Dwarf_Attribute attr_mem;
> +	    Dwarf_Attribute *attr = INTUSE(dwarf_attr) (&child.die,
> +							DW_AT_import,
> +							&attr_mem);
> +	    if (INTUSE(dwarf_formref_die) (attr, &child.die) != NULL
> +                && INTUSE(dwarf_child) (&child.die, &child.die) == 0)

Here again -1 seems to be an error, +1 no more children.

>  	      {
> -		int result = recurse ();
> +		int result = walk_children ();
>  		if (result != DWARF_CB_OK)
>  		  return result;
>  	      }
> -	    break;
>  
> -	  case imported:
> +	    /* Any "real" children left?  */
> +	    if (INTUSE(dwarf_siblingof) (&orig_child_die, &child.die) != 0)

Here again -1 seems to be an error, +1 no more children.


> +	      return 0;
> +	  };
> +
> +	child.prune = false;
[...]


Jan

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]