* See the License for the specific language governing permissions and
* limitations under the License.
*
- * Author: Adrian Szyndela <adrian.s@samsung.com>
- * Rafal Pietruch <r.pietruch@samsung.com>
+ * Authors: Adrian Szyndela <adrian.s@samsung.com>
+ * Rafal Pietruch <r.pietruch@samsung.com>
*/
/**
* @file crash-stack-arm.c
* @brief unwinding call stacks, functions specific for ARM
*/
#include "crash-stack.h"
-#include <libunwind-ptrace.h>
#include <string.h>
#include <sys/ptrace.h>
#define REG_PC 15
#define REG_SPSR 16
-#define MAXPROCNAMELEN 512
-
/**
* @brief Important registers for unwinding stack on ARM
*/
}
}
-void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, Callstack *callstack)
-{
- // reimplemented based on libunwind tests/test-ptrace.c file
- unw_addr_space_t as = 0;
- void *ui = 0;
- do {
- callstack->elems = 0;
-
- as = unw_create_addr_space(&_UPT_accessors, 0);
- if (!as)
- break;
-
- ui = _UPT_create(pid);
- if (!ui)
- break;
-
- unw_cursor_t cursor;
- if (unw_init_remote(&cursor, as, ui) < 0)
- break;
-
- char proc_name[MAXPROCNAMELEN];
- int n;
- // MaxDeep as proposed in libunwind tests/test-ptrace.c file
- // guard against bad unwind info in old libraries
- static const int MaxDeep = 64;
- for (n = 0; n < MaxDeep; ++n) {
-
- unw_word_t ip;
- if (unw_get_reg(&cursor, UNW_REG_IP, &ip) < 0)
- break;
- callstack->tab[callstack->elems] = ip;
-
- proc_name[0] = '\0';
- unw_word_t off;
- unw_get_proc_name(&cursor, proc_name, sizeof(proc_name), &off);
- if (strlen(proc_name) > 0)
- callstack->proc_name[callstack->elems] = strdup(proc_name);
-
- ++callstack->elems;
- if (unw_step(&cursor) <= 0)
- break;
- }
- } while (0);
-
- if (ui)
- _UPT_destroy(ui);
- if (as)
- unw_destroy_addr_space(as);
-}
-
void _crash_stack_print_regs(FILE* outputfile)
{
fprintf(outputfile, "\nRegister Information\n");
--- /dev/null
+/*
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: Rafal Pietruch <r.pietruch@samsung.com>
+ */
+/**
+ * @file crash-stack-libunw.c
+ * @brief unwinding call stacks, functions specific for archs that use only libunwind
+ */
+#include "crash-stack.h"
+#include <libunwind-ptrace.h>
+
+#include <string.h>
+
+#define MAXPROCNAMELEN 512
+
+void _create_crash_stack(Dwfl *dwfl, Elf *core, pid_t pid, Mappings *mappings, Callstack *callstack)
+{
+ // reimplemented based on libunwind tests/test-ptrace.c file
+ unw_addr_space_t as = 0;
+ void *ui = 0;
+ do {
+ callstack->elems = 0;
+
+ as = unw_create_addr_space(&_UPT_accessors, 0);
+ if (!as)
+ break;
+
+ ui = _UPT_create(pid);
+ if (!ui)
+ break;
+
+ unw_cursor_t cursor;
+ if (unw_init_remote(&cursor, as, ui) < 0)
+ break;
+
+ char proc_name[MAXPROCNAMELEN];
+ int n;
+ // MaxDeep as proposed in libunwind tests/test-ptrace.c file
+ // guard against bad unwind info in old libraries
+ static const int MaxDeep = 64;
+ for (n = 0; n < MaxDeep; ++n) {
+
+ unw_word_t ip;
+ if (unw_get_reg(&cursor, UNW_REG_IP, &ip) < 0)
+ break;
+ callstack->tab[callstack->elems] = ip;
+
+ proc_name[0] = '\0';
+ unw_word_t off;
+ unw_get_proc_name(&cursor, proc_name, sizeof(proc_name), &off);
+ if (strlen(proc_name) > 0)
+ callstack->proc_name[callstack->elems] = strdup(proc_name);
+
+ ++callstack->elems;
+ if (unw_step(&cursor) <= 0)
+ break;
+ }
+ } while (0);
+
+ if (ui)
+ _UPT_destroy(ui);
+ if (as)
+ unw_destroy_addr_space(as);
+}