1 // Copyright (c) 2012, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 //     * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //     * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 //     * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef GOOGLE_BREAKPAD_COMMON_ANDROID_SYS_PROCFS_H
31 #define GOOGLE_BREAKPAD_COMMON_ANDROID_SYS_PROCFS_H
32 
33 #ifdef __BIONIC_HAVE_SYS_PROCFS_H
34 
35 #include_next <sys/procfs.h>
36 
37 #else
38 
39 #include <asm/ptrace.h>
40 #include <sys/cdefs.h>
41 #if defined (__mips__)
42 #include <sys/types.h>
43 #endif
44 #include <sys/user.h>
45 #include <unistd.h>
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif  // __cplusplus
50 
51 #if defined(__x86_64__) || defined(__aarch64__)
52 typedef unsigned long long elf_greg_t;
53 #else
54 typedef unsigned long  elf_greg_t;
55 #endif
56 
57 #ifdef __arm__
58 #define ELF_NGREG (sizeof(struct user_regs) / sizeof(elf_greg_t))
59 #elif defined(__aarch64__)
60 #define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(elf_greg_t))
61 #elif defined(__mips__)
62 #define ELF_NGREG 45
63 #else
64 #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
65 #endif
66 
67 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
68 
69 struct elf_siginfo {
70   int si_signo;
71   int si_code;
72   int si_errno;
73 };
74 
75 struct elf_prstatus {
76   struct elf_siginfo pr_info;
77   short              pr_cursig;
78   unsigned long      pr_sigpend;
79   unsigned long      pr_sighold;
80   pid_t              pr_pid;
81   pid_t              pr_ppid;
82   pid_t              pr_pgrp;
83   pid_t              pd_sid;
84   struct timeval     pr_utime;
85   struct timeval     pr_stime;
86   struct timeval     pr_cutime;
87   struct timeval     pr_cstime;
88   elf_gregset_t      pr_reg;
89   int                pr_fpvalid;
90 };
91 
92 #define ELF_PRARGSZ 80
93 
94 struct elf_prpsinfo {
95   char           pr_state;
96   char           pr_sname;
97   char           pr_zomb;
98   char           pr_nice;
99   unsigned long  pr_flags;
100 #ifdef __x86_64__
101   unsigned int   pr_uid;
102   unsigned int   pr_gid;
103 #elif defined(__mips__)
104   __kernel_uid_t pr_uid;
105   __kernel_gid_t pr_gid;
106 #else
107   unsigned short pr_uid;
108   unsigned short pr_gid;
109 #endif
110   int pr_pid;
111   int pr_ppid;
112   int pr_pgrp;
113   int pr_sid;
114   char pr_fname[16];
115   char pr_psargs[ELF_PRARGSZ];
116 };
117 
118 #ifdef __cplusplus
119 }  // extern "C"
120 #endif  // __cplusplus
121 
122 #endif  // __BIONIC_HAVE_SYS_PROCFS_H
123 
124 #endif  // GOOGLE_BREAKPAD_COMMON_ANDROID_SYS_PROCFS_H
125