summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRafal Pietruch <r.pietruch@samsung.com>2016-12-14 13:11:12 +0100
committerKarol Lewandowski <k.lewandowsk@samsung.com>2016-12-14 16:52:49 +0100
commit753d359c44f4f61aa894fdc3a842c750a09f08bd (patch)
tree9c8b57bd35895fcf3ec2a2a2b93a0ed824ff4154 /src
parent0e18422b1add2247554b57bbbb28c93bd3b16670 (diff)
downloadcrash-worker-753d359c44f4f61aa894fdc3a842c750a09f08bd.tar.gz
crash-worker-753d359c44f4f61aa894fdc3a842c750a09f08bd.tar.bz2
crash-worker-753d359c44f4f61aa894fdc3a842c750a09f08bd.zip
crash-stack: reformat callstack output
Change-Id: Ica727d63de389d8a4a2f1ff7cfced2a463630282
Diffstat (limited to 'src')
-rw-r--r--src/crash-stack/crash-stack-libunw.c1
-rw-r--r--src/crash-stack/crash-stack.c49
-rw-r--r--src/crash-stack/crash-stack.h1
3 files changed, 32 insertions, 19 deletions
diff --git a/src/crash-stack/crash-stack-libunw.c b/src/crash-stack/crash-stack-libunw.c
index ba0b245..23e3df3 100644
--- a/src/crash-stack/crash-stack-libunw.c
+++ b/src/crash-stack/crash-stack-libunw.c
@@ -64,6 +64,7 @@ void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, C
unw_get_proc_name(&cursor, proc_name, sizeof(proc_name), &off);
if (strlen(proc_name) > 0)
callstack->proc[callstack->elems].name = strdup(proc_name);
+ callstack->proc[callstack->elems].offset = off;
++callstack->elems;
if (unw_step(&cursor) <= 0)
diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c
index e1cabf9..07cdb46 100644
--- a/src/crash-stack/crash-stack.c
+++ b/src/crash-stack/crash-stack.c
@@ -732,6 +732,29 @@ static void __resolve_symbols(ProcInfo *proc_info, Dwfl *dwfl, Elf *core, Elf_Da
}
/**
+ * @brief Prints call stack element to the global outputfile.
+ *
+ * @param proc_info gathered call stack element
+ */
+static void __print_proc_info(ProcInfo *proc_info)
+{
+ if (proc_info->name) {
+ fprintf(outputfile, "%s ", proc_info->name);
+ if (proc_info->offset >= 0)
+ fprintf(outputfile, "+ 0x%x ", proc_info->offset);
+ }
+ if (sizeof(proc_info->addr) > 4)
+ fprintf(outputfile, "(0x%016llx)", (long long)proc_info->addr);
+ else
+ fprintf(outputfile, "(0x%08x)", (int32_t)proc_info->addr);
+
+ if (proc_info->module_name != 0)
+ fprintf(outputfile, " [%s]", proc_info->module_name);
+
+ fprintf(outputfile, "\n");
+}
+
+/**
* @brief Prints call stack to the global outputfile.
*
* @param callstack gathered call stack database
@@ -740,29 +763,16 @@ static void __resolve_symbols(ProcInfo *proc_info, Dwfl *dwfl, Elf *core, Elf_Da
static void __print_callstack(Callstack *callstack, pid_t pid)
{
fprintf(outputfile, "\nCallstack Information");
- if (pid > 1) fprintf(outputfile, " (PID:%d)", pid);
- fprintf(outputfile, "\n");
- fprintf(outputfile, "Call Stack Count: %d\n", (int)callstack->elems);
+ if (pid > 1)
+ fprintf(outputfile, " (PID:%d)", pid);
+ fprintf(outputfile, "\nCall Stack Count: %zu\n", callstack->elems);
size_t it;
for (it = 0; it != callstack->elems; ++it) {
- if (sizeof(callstack->proc[0].addr) > 4)
- fprintf(outputfile, "0x%016llx: ", (long long)callstack->proc[it].addr);
- else
- fprintf(outputfile, "0x%08x: ", (int32_t)callstack->proc[it].addr);
-
- const char *symbol = callstack->proc[it].name;
- if (symbol != 0)
- fprintf(outputfile, "%s()", symbol);
- else
- fprintf(outputfile, "<unknown>");
-
- const char *module_name = callstack->proc[it].module_name;
- if (module_name != 0)
- fprintf(outputfile, " from %s", module_name);
-
- fprintf(outputfile, "\n");
+ fprintf(outputfile, "%2zu: ", it);
+ __print_proc_info(&callstack->proc[it]);
}
+ fprintf(outputfile, "End of Call Stack\n");
}
void callstack_constructor(Callstack *callstack)
@@ -770,6 +780,7 @@ void callstack_constructor(Callstack *callstack)
size_t it;
callstack->elems = 0;
for (it = 0; it < (int)sizeof(callstack->proc)/sizeof(callstack->proc[0]); ++it) {
+ callstack->proc[it].offset = -1;
callstack->proc[it].name = 0;
callstack->proc[it].module_name = 0;
}
diff --git a/src/crash-stack/crash-stack.h b/src/crash-stack/crash-stack.h
index 142e0ac..385a31d 100644
--- a/src/crash-stack/crash-stack.h
+++ b/src/crash-stack/crash-stack.h
@@ -32,6 +32,7 @@
*/
struct ProcInfo {
uintptr_t addr; ///< procedure address
+ int offset; ///< procedure offset
char *name; ///< procedure name
char *module_name; ///< module name
};