summaryrefslogtreecommitdiff
path: root/src/core_dump_handler/dlt_cdh.h
diff options
context:
space:
mode:
authorLutz Helwing <lutz_helwing@mentor.com>2015-06-23 18:32:44 +0200
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>2015-10-28 11:38:27 +0100
commitd7cea9b4df048a3b5da68710a5b62efe082fb447 (patch)
treea7e114d2bbf5814b5f221cb0273cc05fbbf52483 /src/core_dump_handler/dlt_cdh.h
parent2355ca4927cffd8307fdb78aaadeb584450bef21 (diff)
downloadDLT-daemon-d7cea9b4df048a3b5da68710a5b62efe082fb447.tar.gz
Added core dump handler code
Fixed author Doxygen tag Added licence headers Moved return value definition to new header Converted all DOS line endings to Unix Solution for CPU dependency by using CMAKE_SYSTEM_PROCESSOR cmake variable CPU specific stuff is implemented in own implementation file for each CPU architecture Added config file for sysctl. Fixed wrong parameters to open call for lockfile Added mechanism to overwrite TARGET_CPU_NAME with command line option Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Diffstat (limited to 'src/core_dump_handler/dlt_cdh.h')
-rw-r--r--src/core_dump_handler/dlt_cdh.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/core_dump_handler/dlt_cdh.h b/src/core_dump_handler/dlt_cdh.h
new file mode 100644
index 0000000..ed61560
--- /dev/null
+++ b/src/core_dump_handler/dlt_cdh.h
@@ -0,0 +1,96 @@
+/*
+ * @licence app begin@
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2011-2015, BMW AG
+ *
+ * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
+ *
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License (MPL), v. 2.0.
+ * If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ * @licence end@
+ */
+
+/*!
+ * \author Magneti Marelli http://www.magnetimarelli.com
+ * \author Lutz Helwing <lutz_helwing@mentor.com>
+ *
+ * \copyright Copyright © 2011-2015 BMW AG. \n
+ * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+ *
+ * \file dlt_cdh.h
+ */
+
+#ifndef DLT_CDH_H
+#define DLT_CDH_H
+
+#include <unistd.h>
+#include <stdint.h>
+#include <elf.h>
+#include <sys/procfs.h>
+#include <sys/user.h>
+
+#include "dlt_cdh_streamer.h"
+
+#define CORE_DIRECTORY "/var/core"
+#define CORE_TMP_DIRECTORY "/var/core_tmp"
+#define CORE_LOCK_DIRECTORY "/tmp/.core_locks"
+#define CORE_MAX_FILENAME_LENGTH 255
+#define MAX_PROC_NAME_LENGTH 32
+#define CRASH_ID_LEN 8
+#define CRASHID_FILE "/tmp/.crashid" // the file where the white screen app will read the crashid
+
+#define CORE_FILE_PATTERN "%s/core.%d.%s.%d.gz"
+#define CONTEXT_FILE_PATTERN "%s/context.%d.%s.%d.txt"
+
+#define ELF_Ehdr Elf32_Ehdr
+#define ELF_Phdr Elf32_Phdr
+#define ELF_Shdr Elf32_Shdr
+#define ELF_Nhdr Elf32_Nhdr
+
+typedef struct
+{
+ uint64_t pc;
+ uint64_t ip;
+ uint64_t lr;
+
+} cdh_registers_t;
+
+typedef struct
+{
+ char name[MAX_PROC_NAME_LENGTH];
+ char threadname[MAX_PROC_NAME_LENGTH];
+ pid_t pid;
+ uint32_t timestamp;
+ int signal;
+
+ int can_create_coredump;
+ file_streamer_t streamer;
+
+ // coredump content, for crash id generation
+ ELF_Ehdr m_Ehdr;
+ ELF_Phdr* m_pPhdr;
+ char* m_Nhdr; // buffer with all NOTE pages
+
+ unsigned int m_note_page_size;
+
+ cdh_registers_t m_registers;
+
+ pid_t m_crashed_pid;
+ uint64_t m_crashid_phase1;
+ unsigned char m_crashid[CRASH_ID_LEN];
+
+} proc_info_t;
+
+cdh_status_t get_exec_name(unsigned int p_pid_str, char* p_exec_name, int p_exec_name_maxsize);
+cdh_status_t write_proc_context(const proc_info_t*);
+cdh_status_t treat_coredump(proc_info_t* p_proc);
+cdh_status_t treat_crash_data(proc_info_t* p_proc);
+cdh_status_t move_to_core_directory(proc_info_t* p_proc);
+cdh_status_t check_core_directory();
+
+#endif // #ifndef DLT_CDH_H