unwind.h (49232773d8233ed70c4998851bc84e465fc1c788) unwind.h (49aef111e2dae176a7708b532118f33f24289248)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Most of this ideas comes from x86.
4 *
5 * Copyright (C) 2022 Loongson Technology Corporation Limited
6 */
7#ifndef _ASM_UNWIND_H
8#define _ASM_UNWIND_H
9
10#include <linux/sched.h>
11
12#include <asm/stacktrace.h>
13
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Most of this ideas comes from x86.
4 *
5 * Copyright (C) 2022 Loongson Technology Corporation Limited
6 */
7#ifndef _ASM_UNWIND_H
8#define _ASM_UNWIND_H
9
10#include <linux/sched.h>
11
12#include <asm/stacktrace.h>
13
14enum unwinder_type {
15 UNWINDER_GUESS,
16 UNWINDER_PROLOGUE,
17};
18
14struct unwind_state {
19struct unwind_state {
20 char type; /* UNWINDER_XXX */
15 struct stack_info stack_info;
16 struct task_struct *task;
17 bool first, error;
21 struct stack_info stack_info;
22 struct task_struct *task;
23 bool first, error;
18 unsigned long sp, pc;
24 unsigned long sp, pc, ra;
19};
20
21void unwind_start(struct unwind_state *state,
22 struct task_struct *task, struct pt_regs *regs);
23bool unwind_next_frame(struct unwind_state *state);
24unsigned long unwind_get_return_address(struct unwind_state *state);
25
26static inline bool unwind_done(struct unwind_state *state)
27{
28 return state->stack_info.type == STACK_TYPE_UNKNOWN;
29}
30
31static inline bool unwind_error(struct unwind_state *state)
32{
33 return state->error;
34}
35
36#endif /* _ASM_UNWIND_H */
25};
26
27void unwind_start(struct unwind_state *state,
28 struct task_struct *task, struct pt_regs *regs);
29bool unwind_next_frame(struct unwind_state *state);
30unsigned long unwind_get_return_address(struct unwind_state *state);
31
32static inline bool unwind_done(struct unwind_state *state)
33{
34 return state->stack_info.type == STACK_TYPE_UNKNOWN;
35}
36
37static inline bool unwind_error(struct unwind_state *state)
38{
39 return state->error;
40}
41
42#endif /* _ASM_UNWIND_H */