_UCD_internal.h revision d62748178383a1869b3e6c1f102cfd2e30c55371
1/* libunwind - a platform-independent unwind library 2 3This file is part of libunwind. 4 5Permission is hereby granted, free of charge, to any person obtaining 6a copy of this software and associated documentation files (the 7"Software"), to deal in the Software without restriction, including 8without limitation the rights to use, copy, modify, merge, publish, 9distribute, sublicense, and/or sell copies of the Software, and to 10permit persons to whom the Software is furnished to do so, subject to 11the following conditions: 12 13The above copyright notice and this permission notice shall be 14included in all copies or substantial portions of the Software. 15 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 23 24#ifndef _UCD_internal_h 25#define _UCD_internal_h 26 27#ifdef HAVE_CONFIG_H 28#include <config.h> 29#endif 30 31#ifdef HAVE_SYS_TYPES_H 32#include <sys/types.h> 33#endif 34#ifdef HAVE_SYS_PROCFS_H 35#include <sys/procfs.h> /* struct elf_prstatus */ 36#endif 37#include <errno.h> 38#include <string.h> 39#include <limits.h> 40#include <stdio.h> 41#include <stdlib.h> 42 43#include <libunwind-coredump.h> 44 45#include "libunwind_i.h" 46 47 48#if SIZEOF_OFF_T == 4 49typedef uint32_t uoff_t; 50#elif SIZEOF_OFF_T == 8 51typedef uint64_t uoff_t; 52#else 53# error Unknown size of off_t! 54#endif 55 56 57/* Similar to ELF phdrs. p_paddr element is absent, 58 * since it's always 0 in coredumps. 59 */ 60struct coredump_phdr 61 { 62 uint32_t p_type; 63 uint32_t p_flags; 64 uoff_t p_offset; 65 uoff_t p_vaddr; 66 uoff_t p_filesz; 67 uoff_t p_memsz; 68 uoff_t p_align; 69 /* Data for backing file. If backing_fd < 0, there is no file */ 70 uoff_t backing_filesize; 71 char *backing_filename; /* for error meesages only */ 72 int backing_fd; 73 }; 74 75typedef struct coredump_phdr coredump_phdr_t; 76 77#if defined(HAVE_STRUCT_ELF_PRSTATUS) 78#define PRSTATUS_STRUCT elf_prstatus 79#elif defined(HAVE_STRUCT_PRSTATUS) 80#define PRSTATUS_STRUCT prstatus 81#else 82#define PRSTATUS_STRUCT non_existent 83#endif 84 85struct UCD_info 86 { 87 int big_endian; /* bool */ 88 int coredump_fd; 89 char *coredump_filename; /* for error meesages only */ 90 coredump_phdr_t *phdrs; /* array, allocated */ 91 unsigned phdrs_count; 92 void *note_phdr; /* allocated or NULL */ 93 struct PRSTATUS_STRUCT *prstatus; /* points inside note_phdr */ 94 95 struct elf_dyn_info edi; 96 }; 97 98extern coredump_phdr_t * _UCD_get_elf_image(struct UCD_info *ui, unw_word_t ip); 99 100#endif 101