Re: [PATCH v4 19/39] unwind_user/sframe: Add support for reading .sframe contents

Josh Poimboeuf <[email protected]>
Newsgroups org.kernel.vger.linux-toolchains,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users,org.kernel.vger.linux-trace-kernel
Message-ID <20250204194250.ihfn2iynpwckzjnn@jpoimboe>
On Thu, Jan 30, 2025 at 07:51:15PM +0000, Weinan Liu wrote:
> Nit: swap() might be a simplify way to alternate pointers between two
> fre_addr[] entries.
> 
> For example,
> 
> static __always_inline int __find_fre(struct sframe_section *sec,
> 				      struct sframe_fde *fde, unsigned long ip,
> 				      struct unwind_user_frame *frame)
> {
> 	/* intialize fres[] with invalid value */
> 	struct sframe_fre fres[2] = {0};
> 	struct sframe_fre *fre = &fres[1], *prev_fre = fres;
> 
> 	for (i = 0; i < fde->fres_num; i++) {
> 		swap(fre, next_fre);
> 		ret = __read_fre(sec, fde, fre_addr, fre);

Problem is, if it breaks out early here on the first iteration:

> 		if (fre->ip_off > ip_off)
> 			break;
> 	}
> 
> 	if (fre->size == 0)
> 		return -EINVAL;

Then fre isn't valid even though it has a nonzero size.

-- 
Josh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.