]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - drivers/misc/tegra-profiler/backtrace.h
misc: tegra-profiler: add unwind information
[sojka/nv-tegra/linux-3.10.git] / drivers / misc / tegra-profiler / backtrace.h
1 /*
2  * drivers/misc/tegra-profiler/backtrace.h
3  *
4  * Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  */
16
17 #ifndef __QUADD_BACKTRACE_H
18 #define __QUADD_BACKTRACE_H
19
20 #include <linux/mm.h>
21 #include <linux/bitops.h>
22
23 #define QUADD_MAX_STACK_DEPTH           64
24
25 #define QUADD_UNW_TYPES_SIZE \
26         DIV_ROUND_UP(QUADD_MAX_STACK_DEPTH * 4, sizeof(u32) * BITS_PER_BYTE)
27
28 struct quadd_callchain {
29         int nr;
30
31         union {
32                 u32 ip_32[QUADD_MAX_STACK_DEPTH];
33                 u64 ip_64[QUADD_MAX_STACK_DEPTH];
34         };
35
36         u32 types[QUADD_UNW_TYPES_SIZE];
37
38         int cs_64;
39
40         unsigned int unw_method;
41         unsigned int unw_rc;
42
43         unsigned long curr_sp;
44         unsigned long curr_fp;
45 };
46
47 struct quadd_ctx;
48 struct pt_regs;
49
50 unsigned int
51 quadd_get_user_callchain(struct pt_regs *regs,
52                          struct quadd_callchain *cc_data,
53                          struct quadd_ctx *ctx,
54                          struct task_struct *task);
55
56 int
57 quadd_callchain_store(struct quadd_callchain *cc,
58                       unsigned long ip, unsigned int type);
59
60 unsigned long
61 quadd_user_stack_pointer(struct pt_regs *regs);
62
63 unsigned long
64 quadd_user_link_register(struct pt_regs *regs);
65
66 static inline int
67 is_vma_addr(unsigned long addr, struct vm_area_struct *vma,
68             unsigned long nbytes)
69 {
70         return  vma &&
71                 addr >= vma->vm_start &&
72                 addr < vma->vm_end - nbytes;
73 }
74
75
76 #endif  /* __QUADD_BACKTRACE_H */