Re: [PATCH v4 11/39] unwind_user: Add user space unwinding API

Steven Rostedt <[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 <[email protected]>
On Tue, 21 Jan 2025 18:31:03 -0800
Josh Poimboeuf <[email protected]> wrote:

> +int unwind_user_next(struct unwind_user_state *state)
> +{
> +	struct unwind_user_frame _frame;
> +	struct unwind_user_frame *frame = &_frame;
> +	unsigned long cfa = 0, fp, ra = 0;
> +
> +	/* no implementation yet */
> +	-EINVAL;
> +}
> +
> +int unwind_user_start(struct unwind_user_state *state)
> +{
> +	struct pt_regs *regs = task_pt_regs(current);
> +
> +	memset(state, 0, sizeof(*state));
> +
> +	if (!current->mm || !user_mode(regs)) {
> +		state->done = true;
> +		return -EINVAL;
> +	}
> +
> +	state->type = UNWIND_USER_TYPE_NONE;
> +
> +	state->ip = instruction_pointer(regs);
> +	state->sp = user_stack_pointer(regs);
> +	state->fp = frame_pointer(regs);
> +
> +	return 0;
> +}
> +

I know this is just an introductory of the interface, but this should
really have kerneldoc attached to it, as I have no idea what these are
supposed to be doing. This patch is meaningless without it. The change log
is useless too.

-- Steve


> +int unwind_user(struct unwind_stacktrace *trace, unsigned int max_entries)
> +{
> +	struct unwind_user_state state;
> +
> +	trace->nr = 0;
> +
> +	if (!max_entries)
> +		return -EINVAL;
> +
> +	if (!current->mm)
> +		return 0;
> +
> +	for_each_user_frame(&state) {
> +		trace->entries[trace->nr++] = state.ip;
> +		if (trace->nr >= max_entries)
> +			break;
> +	}
> +
> +	return 0;
> +}
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.