_UCD_internal.h revision cc7c74e691032b8c694d673dc1530c26ce801736
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
78struct UCD_info
79  {
80    int big_endian;  /* bool */
81    int coredump_fd;
82    char *coredump_filename; /* for error meesages only */
83    coredump_phdr_t *phdrs; /* array, allocated */
84    unsigned phdrs_count;
85    void *note_phdr; /* allocated or NULL */
86#if defined(HAVE_STRUCT_ELF_PRSTATUS)
87    struct elf_prstatus *prstatus; /* points inside note_phdr */
88#elif defined(HAVE_STRUCT_PRSTATUS)
89    struct prstatus *prstatus; /* points inside note_phdr */
90#else
91    struct non_existent *prstatus;
92#endif
93
94    struct elf_dyn_info edi;
95  };
96
97extern coredump_phdr_t * _UCD_get_elf_image(struct UCD_info *ui, unw_word_t ip);
98
99#endif
100