Loading debuggerd/Android.mk +2 −2 Original line number Original line Diff line number Diff line # Copyright 2005 The Android Open Source Project # Copyright 2005 The Android Open Source Project ifeq ($(TARGET_ARCH),arm) ifneq ($(filter arm x86,$(TARGET_ARCH)),) LOCAL_PATH:= $(call my-dir) LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) include $(CLEAR_VARS) Loading Loading @@ -50,4 +50,4 @@ LOCAL_SHARED_LIBRARIES := libcutils libc include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE) endif # ARCH_ARM_HAVE_VFP == true endif # ARCH_ARM_HAVE_VFP == true endif # TARGET_ARCH == arm endif # arm or x86 in TARGET_ARCH debuggerd/arm/unwind.c +0 −1 Original line number Original line Diff line number Diff line Loading @@ -451,7 +451,6 @@ static _Unwind_Reason_Code log_function(_Unwind_Context *context, pid_t pid, * 1MB boundaries, and the library may be larger than 1MB. So for .so * 1MB boundaries, and the library may be larger than 1MB. So for .so * addresses we print the relative offset in back trace. * addresses we print the relative offset in back trace. */ */ rel_pc = pc; mi = pc_to_mapinfo(map, pc, &rel_pc); mi = pc_to_mapinfo(map, pc, &rel_pc); /* See if we can determine what symbol this stack frame resides in */ /* See if we can determine what symbol this stack frame resides in */ Loading debuggerd/debuggerd.c +7 −0 Original line number Original line Diff line number Diff line Loading @@ -286,6 +286,13 @@ void dump_crash_report(int tfd, unsigned pid, unsigned tid, bool at_fault) } } dump_stack_and_code(tfd, tid, milist, stack_depth, sp_list, at_fault); dump_stack_and_code(tfd, tid, milist, stack_depth, sp_list, at_fault); #elif __i386__ /* If stack unwinder fails, use the default solution to dump the stack * content. */ stack_depth = unwind_backtrace_with_ptrace_x86(tfd, tid, milist,at_fault); #else #error "Unsupported architecture" #endif #endif while(milist) { while(milist) { Loading debuggerd/debuggerd.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -37,4 +37,3 @@ void dump_pc_and_lr(int tfd, int pid, mapinfo *map, int unwound_level, bool at_f void dump_stack_and_code(int tfd, int pid, mapinfo *map, void dump_stack_and_code(int tfd, int pid, mapinfo *map, int unwind_depth, unsigned int sp_list[], int unwind_depth, unsigned int sp_list[], bool at_fault); bool at_fault); debuggerd/symbol_table.c +72 −19 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <sys/mman.h> #include <sys/mman.h> #include "symbol_table.h" #include "symbol_table.h" #include "utility.h" #include <linux/elf.h> #include <linux/elf.h> Loading Loading @@ -49,6 +50,7 @@ struct symbol_table *symbol_table_create(const char *filename) int length; int length; char *base; char *base; XLOG("Creating symbol table for %s\n", filename); int fd = open(filename, O_RDONLY); int fd = open(filename, O_RDONLY); if(fd < 0) { if(fd < 0) { Loading @@ -69,40 +71,70 @@ struct symbol_table *symbol_table_create(const char *filename) Elf32_Shdr *shdr = (Elf32_Shdr*)(base + hdr->e_shoff); Elf32_Shdr *shdr = (Elf32_Shdr*)(base + hdr->e_shoff); // Search for the dynamic symbols section // Search for the dynamic symbols section int sym_idx = -1; int dynsym_idx = -1; int dynsym_idx = -1; int i; int i; for(i = 0; i < hdr->e_shnum; i++) { for(i = 0; i < hdr->e_shnum; i++) { if(shdr[i].sh_type == SHT_SYMTAB ) { sym_idx = i; } if(shdr[i].sh_type == SHT_DYNSYM ) { if(shdr[i].sh_type == SHT_DYNSYM ) { dynsym_idx = i; dynsym_idx = i; } } } } if ((dynsym_idx == -1) && (sym_idx == -1)) { if(dynsym_idx == -1) { goto out_unmap; goto out_unmap; } } Elf32_Sym *dynsyms = (Elf32_Sym*)(base + shdr[dynsym_idx].sh_offset); int numsyms = shdr[dynsym_idx].sh_size / shdr[dynsym_idx].sh_entsize; table = malloc(sizeof(struct symbol_table)); table = malloc(sizeof(struct symbol_table)); if(!table) { if(!table) { goto out_unmap; goto out_unmap; } } table->name = strdup(filename); table->num_symbols = 0; table->num_symbols = 0; Elf32_Sym *dynsyms = (Elf32_Sym*)(base + shdr[dynsym_idx].sh_offset); Elf32_Sym *syms = (Elf32_Sym*)(base + shdr[sym_idx].sh_offset); int dynnumsyms = shdr[dynsym_idx].sh_size / shdr[dynsym_idx].sh_entsize; int numsyms = shdr[sym_idx].sh_size / shdr[sym_idx].sh_entsize; int dynstr_idx = shdr[dynsym_idx].sh_link; int str_idx = shdr[sym_idx].sh_link; char *dynstr = base + shdr[dynstr_idx].sh_offset; char *str = base + shdr[str_idx].sh_offset; int symbol_count = 0; int dynsymbol_count = 0; if (dynsym_idx != -1) { // Iterate through the dynamic symbol table, and count how many symbols // Iterate through the dynamic symbol table, and count how many symbols // are actually defined // are actually defined for(i = 0; i < numsyms; i++) { for(i = 0; i < dynnumsyms; i++) { if(dynsyms[i].st_shndx != SHN_UNDEF) { if(dynsyms[i].st_shndx != SHN_UNDEF) { table->num_symbols++; dynsymbol_count++; } } } } XLOG("Dynamic Symbol count: %d\n", dynsymbol_count); } int dynstr_idx = shdr[dynsym_idx].sh_link; if (sym_idx != -1) { char *dynstr = base + shdr[dynstr_idx].sh_offset; // Iterate through the symbol table, and count how many symbols // are actually defined for(i = 0; i < numsyms; i++) { if((syms[i].st_shndx != SHN_UNDEF) && (strlen(str+syms[i].st_name)) && (syms[i].st_value != 0) && (syms[i].st_size != 0)) { symbol_count++; } } XLOG("Symbol count: %d\n", symbol_count); } // Now, create an entry in our symbol table structure for each symbol... // Now, create an entry in our symbol table structure for each symbol... table->num_symbols += symbol_count + dynsymbol_count;; table->symbols = malloc(table->num_symbols * sizeof(struct symbol)); table->symbols = malloc(table->num_symbols * sizeof(struct symbol)); if(!table->symbols) { if(!table->symbols) { free(table); free(table); Loading @@ -110,16 +142,37 @@ struct symbol_table *symbol_table_create(const char *filename) goto out_unmap; goto out_unmap; } } // ...and populate them int j = 0; int j = 0; for(i = 0; i < numsyms; i++) { if (dynsym_idx != -1) { // ...and populate them for(i = 0; i < dynnumsyms; i++) { if(dynsyms[i].st_shndx != SHN_UNDEF) { if(dynsyms[i].st_shndx != SHN_UNDEF) { table->symbols[j].name = strdup(dynstr + dynsyms[i].st_name); table->symbols[j].name = strdup(dynstr + dynsyms[i].st_name); table->symbols[j].addr = dynsyms[i].st_value; table->symbols[j].addr = dynsyms[i].st_value; table->symbols[j].size = dynsyms[i].st_size; table->symbols[j].size = dynsyms[i].st_size; XLOG("name: %s, addr: %x, size: %x\n", table->symbols[j].name, table->symbols[j].addr, table->symbols[j].size); j++; j++; } } } } } if (sym_idx != -1) { // ...and populate them for(i = 0; i < numsyms; i++) { if((syms[i].st_shndx != SHN_UNDEF) && (strlen(str+syms[i].st_name)) && (syms[i].st_value != 0) && (syms[i].st_size != 0)) { table->symbols[j].name = strdup(str + syms[i].st_name); table->symbols[j].addr = syms[i].st_value; table->symbols[j].size = syms[i].st_size; XLOG("name: %s, addr: %x, size: %x\n", table->symbols[j].name, table->symbols[j].addr, table->symbols[j].size); j++; } } } // Sort the symbol table entries, so they can be bsearched later // Sort the symbol table entries, so they can be bsearched later qsort(table->symbols, table->num_symbols, sizeof(struct symbol), qcompar); qsort(table->symbols, table->num_symbols, sizeof(struct symbol), qcompar); Loading Loading
debuggerd/Android.mk +2 −2 Original line number Original line Diff line number Diff line # Copyright 2005 The Android Open Source Project # Copyright 2005 The Android Open Source Project ifeq ($(TARGET_ARCH),arm) ifneq ($(filter arm x86,$(TARGET_ARCH)),) LOCAL_PATH:= $(call my-dir) LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) include $(CLEAR_VARS) Loading Loading @@ -50,4 +50,4 @@ LOCAL_SHARED_LIBRARIES := libcutils libc include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE) endif # ARCH_ARM_HAVE_VFP == true endif # ARCH_ARM_HAVE_VFP == true endif # TARGET_ARCH == arm endif # arm or x86 in TARGET_ARCH
debuggerd/arm/unwind.c +0 −1 Original line number Original line Diff line number Diff line Loading @@ -451,7 +451,6 @@ static _Unwind_Reason_Code log_function(_Unwind_Context *context, pid_t pid, * 1MB boundaries, and the library may be larger than 1MB. So for .so * 1MB boundaries, and the library may be larger than 1MB. So for .so * addresses we print the relative offset in back trace. * addresses we print the relative offset in back trace. */ */ rel_pc = pc; mi = pc_to_mapinfo(map, pc, &rel_pc); mi = pc_to_mapinfo(map, pc, &rel_pc); /* See if we can determine what symbol this stack frame resides in */ /* See if we can determine what symbol this stack frame resides in */ Loading
debuggerd/debuggerd.c +7 −0 Original line number Original line Diff line number Diff line Loading @@ -286,6 +286,13 @@ void dump_crash_report(int tfd, unsigned pid, unsigned tid, bool at_fault) } } dump_stack_and_code(tfd, tid, milist, stack_depth, sp_list, at_fault); dump_stack_and_code(tfd, tid, milist, stack_depth, sp_list, at_fault); #elif __i386__ /* If stack unwinder fails, use the default solution to dump the stack * content. */ stack_depth = unwind_backtrace_with_ptrace_x86(tfd, tid, milist,at_fault); #else #error "Unsupported architecture" #endif #endif while(milist) { while(milist) { Loading
debuggerd/debuggerd.h +0 −1 Original line number Original line Diff line number Diff line Loading @@ -37,4 +37,3 @@ void dump_pc_and_lr(int tfd, int pid, mapinfo *map, int unwound_level, bool at_f void dump_stack_and_code(int tfd, int pid, mapinfo *map, void dump_stack_and_code(int tfd, int pid, mapinfo *map, int unwind_depth, unsigned int sp_list[], int unwind_depth, unsigned int sp_list[], bool at_fault); bool at_fault);
debuggerd/symbol_table.c +72 −19 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <sys/mman.h> #include <sys/mman.h> #include "symbol_table.h" #include "symbol_table.h" #include "utility.h" #include <linux/elf.h> #include <linux/elf.h> Loading Loading @@ -49,6 +50,7 @@ struct symbol_table *symbol_table_create(const char *filename) int length; int length; char *base; char *base; XLOG("Creating symbol table for %s\n", filename); int fd = open(filename, O_RDONLY); int fd = open(filename, O_RDONLY); if(fd < 0) { if(fd < 0) { Loading @@ -69,40 +71,70 @@ struct symbol_table *symbol_table_create(const char *filename) Elf32_Shdr *shdr = (Elf32_Shdr*)(base + hdr->e_shoff); Elf32_Shdr *shdr = (Elf32_Shdr*)(base + hdr->e_shoff); // Search for the dynamic symbols section // Search for the dynamic symbols section int sym_idx = -1; int dynsym_idx = -1; int dynsym_idx = -1; int i; int i; for(i = 0; i < hdr->e_shnum; i++) { for(i = 0; i < hdr->e_shnum; i++) { if(shdr[i].sh_type == SHT_SYMTAB ) { sym_idx = i; } if(shdr[i].sh_type == SHT_DYNSYM ) { if(shdr[i].sh_type == SHT_DYNSYM ) { dynsym_idx = i; dynsym_idx = i; } } } } if ((dynsym_idx == -1) && (sym_idx == -1)) { if(dynsym_idx == -1) { goto out_unmap; goto out_unmap; } } Elf32_Sym *dynsyms = (Elf32_Sym*)(base + shdr[dynsym_idx].sh_offset); int numsyms = shdr[dynsym_idx].sh_size / shdr[dynsym_idx].sh_entsize; table = malloc(sizeof(struct symbol_table)); table = malloc(sizeof(struct symbol_table)); if(!table) { if(!table) { goto out_unmap; goto out_unmap; } } table->name = strdup(filename); table->num_symbols = 0; table->num_symbols = 0; Elf32_Sym *dynsyms = (Elf32_Sym*)(base + shdr[dynsym_idx].sh_offset); Elf32_Sym *syms = (Elf32_Sym*)(base + shdr[sym_idx].sh_offset); int dynnumsyms = shdr[dynsym_idx].sh_size / shdr[dynsym_idx].sh_entsize; int numsyms = shdr[sym_idx].sh_size / shdr[sym_idx].sh_entsize; int dynstr_idx = shdr[dynsym_idx].sh_link; int str_idx = shdr[sym_idx].sh_link; char *dynstr = base + shdr[dynstr_idx].sh_offset; char *str = base + shdr[str_idx].sh_offset; int symbol_count = 0; int dynsymbol_count = 0; if (dynsym_idx != -1) { // Iterate through the dynamic symbol table, and count how many symbols // Iterate through the dynamic symbol table, and count how many symbols // are actually defined // are actually defined for(i = 0; i < numsyms; i++) { for(i = 0; i < dynnumsyms; i++) { if(dynsyms[i].st_shndx != SHN_UNDEF) { if(dynsyms[i].st_shndx != SHN_UNDEF) { table->num_symbols++; dynsymbol_count++; } } } } XLOG("Dynamic Symbol count: %d\n", dynsymbol_count); } int dynstr_idx = shdr[dynsym_idx].sh_link; if (sym_idx != -1) { char *dynstr = base + shdr[dynstr_idx].sh_offset; // Iterate through the symbol table, and count how many symbols // are actually defined for(i = 0; i < numsyms; i++) { if((syms[i].st_shndx != SHN_UNDEF) && (strlen(str+syms[i].st_name)) && (syms[i].st_value != 0) && (syms[i].st_size != 0)) { symbol_count++; } } XLOG("Symbol count: %d\n", symbol_count); } // Now, create an entry in our symbol table structure for each symbol... // Now, create an entry in our symbol table structure for each symbol... table->num_symbols += symbol_count + dynsymbol_count;; table->symbols = malloc(table->num_symbols * sizeof(struct symbol)); table->symbols = malloc(table->num_symbols * sizeof(struct symbol)); if(!table->symbols) { if(!table->symbols) { free(table); free(table); Loading @@ -110,16 +142,37 @@ struct symbol_table *symbol_table_create(const char *filename) goto out_unmap; goto out_unmap; } } // ...and populate them int j = 0; int j = 0; for(i = 0; i < numsyms; i++) { if (dynsym_idx != -1) { // ...and populate them for(i = 0; i < dynnumsyms; i++) { if(dynsyms[i].st_shndx != SHN_UNDEF) { if(dynsyms[i].st_shndx != SHN_UNDEF) { table->symbols[j].name = strdup(dynstr + dynsyms[i].st_name); table->symbols[j].name = strdup(dynstr + dynsyms[i].st_name); table->symbols[j].addr = dynsyms[i].st_value; table->symbols[j].addr = dynsyms[i].st_value; table->symbols[j].size = dynsyms[i].st_size; table->symbols[j].size = dynsyms[i].st_size; XLOG("name: %s, addr: %x, size: %x\n", table->symbols[j].name, table->symbols[j].addr, table->symbols[j].size); j++; j++; } } } } } if (sym_idx != -1) { // ...and populate them for(i = 0; i < numsyms; i++) { if((syms[i].st_shndx != SHN_UNDEF) && (strlen(str+syms[i].st_name)) && (syms[i].st_value != 0) && (syms[i].st_size != 0)) { table->symbols[j].name = strdup(str + syms[i].st_name); table->symbols[j].addr = syms[i].st_value; table->symbols[j].size = syms[i].st_size; XLOG("name: %s, addr: %x, size: %x\n", table->symbols[j].name, table->symbols[j].addr, table->symbols[j].size); j++; } } } // Sort the symbol table entries, so they can be bsearched later // Sort the symbol table entries, so they can be bsearched later qsort(table->symbols, table->num_symbols, sizeof(struct symbol), qcompar); qsort(table->symbols, table->num_symbols, sizeof(struct symbol), qcompar); Loading