30 #include <sys/procfs.h> 35 #include <asm/prctl.h> 63 for (i = 0; i < p_proc->
m_Ehdr.e_phnum; i++)
65 if (p_proc->
m_pPhdr[i].p_vaddr < p_address
66 && p_proc->
m_pPhdr[i].p_vaddr + p_proc->
m_pPhdr[i].p_memsz > p_address)
79 #define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL)) 80 #define NOTE_SIZE(_hdr) (sizeof (_hdr) + ALIGN((_hdr).n_namesz, 4) + (_hdr).n_descsz) 85 unsigned int offset = 0;
89 while (found !=
CDH_OK && offset < p_proc->m_note_page_size)
94 if (ptr_note->n_type == NT_PRSTATUS)
97 prstatus_t* prstatus = (prstatus_t*) ((
char*) ptr_note +
sizeof(
ELF_Nhdr) +
ALIGN(ptr_note->n_namesz, 4));
111 #ifdef HAS_CITYHASH_C 115 #define CRASHID_BUF_SIZE MAX_PROC_NAME_LENGTH+sizeof(uint64_t) 117 char cityhash_in[CRASHID_BUF_SIZE];
118 uint64_t cityhash_result=0;
122 cityhash_result =
CityHash64(cityhash_in, CRASHID_BUF_SIZE);
123 memcpy(p_proc->
m_crashid, &cityhash_result,
sizeof(uint64_t));
126 #undef CRASHID_BUF_SIZE 129 #endif // HAS_CITYHASH_C 133 uint32_t final_lr = 0;
134 uint32_t final_pc = 0;
139 #define ADDRESS_REBASE(__x, __phdr_num) (__x - p_proc->m_pPhdr[__phdr_num].p_vaddr) 141 #define READ_STACK_VALUE(__offset, __type) (*(__type*)(stack_page+__offset-sizeof(__type))) 156 #ifdef HAS_CITYHASH_C 157 crashid_cityhash(p_proc);
163 "Crash in \"%s\", thread=\"%s\", pid=%d, crashID=%"PRIx64
", based on signal=%d, PC=0x%x, caller=0x%x",
177 FILE* crashid_file =
NULL;
181 syslog(LOG_ERR,
"(pid=%d) cannot write crashid to %s: %s", p_proc->
pid,
CRASHID_FILE, strerror(errno));
185 fprintf(crashid_file,
"%"PRIx64, *(uint64_t*) p_proc->
m_crashid);
186 fclose(crashid_file);
195 syslog(LOG_ERR,
"registers not found in notes");
201 syslog(LOG_ERR,
"crashid not generated");
char name[MAX_PROC_NAME_LENGTH]
unsigned char m_crashid[CRASH_ID_LEN]
uint64_t m_crashid_phase1
void get_registers(prstatus_t *prstatus, cdh_registers_t *registers)
int write_crashid_to_filesystem(proc_info_t *p_proc)
uint64 CityHash64(const char *s, size_t len)
#define MAX_PROC_NAME_LENGTH
cdh_status_t create_crashid(proc_info_t *p_proc)
cdh_status_t get_crashed_registers(proc_info_t *p_proc)
cdh_registers_t m_registers
cdh_status_t get_phdr_num(proc_info_t *p_proc, unsigned int p_address, int *phdr_num)
char threadname[MAX_PROC_NAME_LENGTH]
cdh_status_t treat_crash_data(proc_info_t *p_proc)
#define ADDRESS_REBASE(__x, __phdr_num)