misc: tegra-profiler: add unwind reason codes
Igor Nabirushkin [Thu, 26 Feb 2015 14:49:41 +0000 (18:49 +0400)]
Add unwind reason codes for dwarf unwinding.

Bug 1611073

Change-Id: Ic7f324f526ba34505e3b9bbedae7b98c29ce097d
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/711654
(cherry picked from commit ea2a41fa9056145e3f1cbe6f97c7725f51a08f3e)
Reviewed-on: http://git-master/r/747750
GVS: Gerrit_Virtual_Submit
Reviewed-by: Andrey Trachenko <atrachenko@nvidia.com>
Reviewed-by: Winnie Hsu <whsu@nvidia.com>

drivers/misc/tegra-profiler/backtrace.c
drivers/misc/tegra-profiler/dwarf_unwind.c
drivers/misc/tegra-profiler/eh_unwind.c
drivers/misc/tegra-profiler/version.h
include/linux/tegra_profiler.h

index a249bfd..675ce85 100644 (file)
@@ -263,7 +263,7 @@ get_user_callchain_fp(struct pt_regs *regs,
                        unsigned long lr = quadd_user_link_register(regs);
 
                        nr_added = quadd_callchain_store(cc, lr,
-                                                        QUADD_UNW_TYPE_LR_FP);
+                                                        QUADD_UNW_TYPE_FP);
                        if (nr_added == 0)
                                return cc->nr;
 
@@ -450,7 +450,7 @@ get_user_callchain_fp_compat(struct pt_regs *regs,
                        u32 lr = quadd_user_link_register(regs);
 
                        nr_added = quadd_callchain_store(cc, lr,
-                                                        QUADD_UNW_TYPE_LR_FP);
+                                                        QUADD_UNW_TYPE_FP);
                        if (nr_added == 0)
                                return cc->nr;
 
index 72062e6..35409b1 100644 (file)
@@ -1765,7 +1765,6 @@ static long
 unwind_frame(struct ex_region_info *ri,
             struct stackframe *sf,
             struct vm_area_struct *vma_sp,
-            unsigned int *unw_type,
             int is_eh)
 {
        int i;
@@ -1905,7 +1904,7 @@ unwind_backtrace(struct quadd_callchain *cc,
 {
        unsigned long user_reg_size;
        struct ex_region_info ri_new;
-       unsigned int unw_type = QUADD_UNW_TYPE_UT;
+       unsigned int unw_type;
        int is_eh = 1, mode = sf->mode;
 
        cc->unw_rc = QUADD_URC_FAILURE;
@@ -1963,13 +1962,12 @@ unwind_backtrace(struct quadd_callchain *cc,
                                is_eh = 1;
                }
 
-               err = unwind_frame(ri, sf, vma_sp, &unw_type, is_eh);
+               err = unwind_frame(ri, sf, vma_sp, is_eh);
                if (err < 0) {
                        if (__is_eh && __is_debug) {
                                is_eh ^= 1;
 
-                               err = unwind_frame(ri, sf, vma_sp,
-                                                  &unw_type, is_eh);
+                               err = unwind_frame(ri, sf, vma_sp, is_eh);
                                if (err < 0) {
                                        cc->unw_rc = -err;
                                        break;
@@ -1980,10 +1978,12 @@ unwind_backtrace(struct quadd_callchain *cc,
                        }
                }
 
+               unw_type = is_eh ? QUADD_UNW_TYPE_DWARF_EH :
+                                  QUADD_UNW_TYPE_DWARF_DF;
+
                pr_debug("[%s]: function at [<%08lx>] from [<%08lx>]\n",
                         is_eh ? "eh" : "debug", where, sf->pc);
 
-
                cc->curr_sp = sf->vregs[regnum_sp(mode)];
 
                cc->curr_fp = sf->vregs[regnum_fp(mode)];
index e97ed5a..d8edc82 100644 (file)
@@ -954,8 +954,7 @@ unwind_exec_insn(struct quadd_mmap_area *mmap,
 static long
 unwind_frame(struct ex_region_info *ri,
             struct stackframe *frame,
-            struct vm_area_struct *vma_sp,
-            unsigned int *unw_type)
+            struct vm_area_struct *vma_sp)
 {
        unsigned long high, low;
        const struct unwind_idx *idx;
@@ -1037,12 +1036,8 @@ unwind_frame(struct ex_region_info *ri,
                        return -QUADD_URC_SP_INCORRECT;
        }
 
-       if (ctrl.vrs[PC] == 0) {
+       if (ctrl.vrs[PC] == 0)
                ctrl.vrs[PC] = ctrl.vrs[LR];
-               *unw_type = QUADD_UNW_TYPE_LR_UT;
-       } else {
-               *unw_type = QUADD_UNW_TYPE_UT;
-       }
 
        if (!validate_pc_addr(ctrl.vrs[PC], sizeof(u32)))
                return -QUADD_URC_PC_INCORRECT;
@@ -1064,7 +1059,6 @@ unwind_backtrace(struct quadd_callchain *cc,
                 struct vm_area_struct *vma_sp,
                 struct task_struct *task)
 {
-       unsigned int unw_type;
        struct ex_region_info ri_new;
 
        cc->unw_rc = QUADD_URC_FAILURE;
@@ -1108,7 +1102,7 @@ unwind_backtrace(struct quadd_callchain *cc,
                        ri = &ri_new;
                }
 
-               err = unwind_frame(ri, frame, vma_sp, &unw_type);
+               err = unwind_frame(ri, frame, vma_sp);
                if (err < 0) {
                        pr_debug("end unwind, urc: %ld\n", err);
                        cc->unw_rc = -err;
@@ -1123,7 +1117,8 @@ unwind_backtrace(struct quadd_callchain *cc,
                cc->curr_fp_thumb = frame->fp_thumb;
                cc->curr_pc = frame->pc;
 
-               nr_added = quadd_callchain_store(cc, frame->pc, unw_type);
+               nr_added = quadd_callchain_store(cc, frame->pc,
+                                                QUADD_UNW_TYPE_UT);
                if (nr_added == 0)
                        break;
        }
index 2798614..15e5c14 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.92"
+#define QUADD_MODULE_VERSION           "1.93"
 #define QUADD_MODULE_BRANCH            "Dev"
 
 #endif /* __QUADD_VERSION_H */
index 1aa39a4..f8042dc 100644 (file)
@@ -210,6 +210,8 @@ enum {
        QUADD_UNW_TYPE_LR_FP,
        QUADD_UNW_TYPE_LR_UT,
        QUADD_UNW_TYPE_KCTX,
+       QUADD_UNW_TYPE_DWARF_EH,
+       QUADD_UNW_TYPE_DWARF_DF,
 };
 
 struct quadd_sample_data {