Home | History | Annotate | Download | only in sys
      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 #include <sys/user.h>
     42 #include <unistd.h>
     43 
     44 #ifdef __cplusplus
     45 extern "C" {
     46 #endif  // __cplusplus
     47 
     48 #if defined(__x86_64__) || defined(__aarch64__)
     49 typedef unsigned long long elf_greg_t;
     50 #else
     51 typedef unsigned long  elf_greg_t;
     52 #endif
     53 
     54 #ifdef __arm__
     55 #define ELF_NGREG (sizeof(struct user_regs) / sizeof(elf_greg_t))
     56 #elif defined(__aarch64__)
     57 #define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(elf_greg_t))
     58 #elif defined(__mips__)
     59 #define ELF_NGREG 45
     60 #else
     61 #define ELF_NGREG (sizeof(struct user_regs_struct) / sizeof(elf_greg_t))
     62 #endif
     63 
     64 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
     65 
     66 struct elf_siginfo {
     67   int si_signo;
     68   int si_code;
     69   int si_errno;
     70 };
     71 
     72 struct elf_prstatus {
     73   struct elf_siginfo pr_info;
     74   short              pr_cursig;
     75   unsigned long      pr_sigpend;
     76   unsigned long      pr_sighold;
     77   pid_t              pr_pid;
     78   pid_t              pr_ppid;
     79   pid_t              pr_pgrp;
     80   pid_t              pd_sid;
     81   struct timeval     pr_utime;
     82   struct timeval     pr_stime;
     83   struct timeval     pr_cutime;
     84   struct timeval     pr_cstime;
     85   elf_gregset_t      pr_reg;
     86   int                pr_fpvalid;
     87 };
     88 
     89 #define ELF_PRARGSZ 80
     90 
     91 struct elf_prpsinfo {
     92   char           pr_state;
     93   char           pr_sname;
     94   char           pr_zomb;
     95   char           pr_nice;
     96   unsigned long  pr_flags;
     97 #ifdef __x86_64__
     98   unsigned int   pr_uid;
     99   unsigned int   pr_gid;
    100 #elif defined(__mips__)
    101   unsigned long  pr_uid;
    102   unsigned long  pr_gid;
    103 #else
    104   unsigned short pr_uid;
    105   unsigned short pr_gid;
    106 #endif
    107   int pr_pid;
    108   int pr_ppid;
    109   int pr_pgrp;
    110   int pr_sid;
    111   char pr_fname[16];
    112   char pr_psargs[ELF_PRARGSZ];
    113 };
    114 
    115 #ifdef __cplusplus
    116 }  // extern "C"
    117 #endif  // __cplusplus
    118 
    119 #endif  // __BIONIC_HAVE_SYS_PROCFS_H
    120 
    121 #endif  // GOOGLE_BREAKPAD_COMMON_ANDROID_SYS_PROCFS_H
    122