Re: [PATCH v2 dwarves 3/5] btf_encoder: collect elf_functions in pre_cus__load_module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2024-10-14 at 23:08 +0000, Ihor Solodrai wrote:

[...]

> +static inline void elf_functions__delete_all()
> +{
> +	struct list_head *pos, *tmp;
> +
> +	list_for_each_safe(pos, tmp, &elf_functions_list) {
> +		struct elf_functions *funcs = list_entry(pos, struct elf_functions, node);
> +		elf_functions__delete(funcs);
> +	}
> +}
> +
>  static int elf_functions__collect(struct elf_functions *functions);
>  
>  int btf_encoder__pre_load_module(Dwfl_Module *mod, Elf *elf)
> @@ -2136,8 +2146,7 @@ int btf_encoder__encode(struct btf_encoder *encoder)
>  		err = btf_encoder__write_elf(encoder, encoder->btf, BTF_ELF_SEC);
>  	}
>  
> -	elf_functions__delete(elf_functions__get(encoder->functions.elf));
> +	elf_functions__delete_all();
> 
>         return err;
>  }

Right, this should work.

> Can't think of a better place to call elf_functions__delete_all(). On
> this patch, btf_encoder__add_saved_funcs() is still called at the
> entry into btf_encoder__encode().

This is a bit ugly, tbh, as it makes the lifespan of this global data
not really obvious. I'd put a call to elf_functions__delete_all()
somewhere at the 'out' label of the pahole.c:main(), but I do not insist.

[...]






[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux