hotspot/agent/src/os/bsd/libproc.h
changeset 16351 032b310a3e2f
parent 10565 dc90c239f4ec
equal deleted inserted replaced
15935:50da9e5eb858 16351:032b310a3e2f
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    25 #ifndef _LIBPROC_H_
    25 #ifndef _LIBPROC_H_
    26 #define _LIBPROC_H_
    26 #define _LIBPROC_H_
    27 
    27 
    28 #include <unistd.h>
    28 #include <unistd.h>
    29 #include <stdint.h>
    29 #include <stdint.h>
       
    30 #include <stdarg.h>
       
    31 #include <stdio.h>
       
    32 #include <stdlib.h>
       
    33 #include <string.h>
       
    34 #include <fcntl.h>
       
    35 
       
    36 #ifdef __APPLE__
       
    37 typedef enum ps_err_e {
       
    38   PS_OK, PS_ERR, PS_BADPID, PS_BADLID,
       
    39   PS_BADADDR, PS_NOSYM, PS_NOFREGS
       
    40 } ps_err_e;
       
    41 
       
    42 #ifndef psaddr_t
       
    43 #define psaddr_t uintptr_t
       
    44 #endif
       
    45 
       
    46 #ifndef bool
       
    47 typedef int bool;
       
    48 #define true  1
       
    49 #define false 0
       
    50 #endif  // bool
       
    51 
       
    52 #ifndef lwpid_t
       
    53 #define lwpid_t uintptr_t
       
    54 #endif
       
    55 
       
    56 #include <mach/thread_status.h>
       
    57 #else   // __APPLE__
       
    58 #include <elf.h>
       
    59 #include <link.h>
    30 #include <machine/reg.h>
    60 #include <machine/reg.h>
    31 #include <proc_service.h>
    61 #include <proc_service.h>
    32 
       
    33 #if defined(sparc) || defined(sparcv9)
    62 #if defined(sparc) || defined(sparcv9)
    34 /*
    63 /*
    35   If _LP64 is defined ptrace.h should be taken from /usr/include/asm-sparc64
    64   If _LP64 is defined ptrace.h should be taken from /usr/include/asm-sparc64
    36   otherwise it should be from /usr/include/asm-sparc
    65   otherwise it should be from /usr/include/asm-sparc
    37   These two files define pt_regs structure differently
    66   These two files define pt_regs structure differently
    41 #else
    70 #else
    42 #include "asm-sparc/ptrace.h"
    71 #include "asm-sparc/ptrace.h"
    43 #endif
    72 #endif
    44 
    73 
    45 #endif //sparc or sparcv9
    74 #endif //sparc or sparcv9
       
    75 
       
    76 // This C bool type must be int for compatibility with BSD calls and
       
    77 // it would be a mistake to equivalence it to C++ bool on many platforms
       
    78 typedef int bool;
       
    79 #define true  1
       
    80 #define false 0
       
    81 
       
    82 #endif // __APPLE__
    46 
    83 
    47 /************************************************************************************
    84 /************************************************************************************
    48 
    85 
    49 0. This is very minimal subset of Solaris libproc just enough for current application.
    86 0. This is very minimal subset of Solaris libproc just enough for current application.
    50 Please note that the bulk of the functionality is from proc_service interface. This
    87 Please note that the bulk of the functionality is from proc_service interface. This
    70 5. for core file, we parse ELF files and read data from them. For processes we  use
   107 5. for core file, we parse ELF files and read data from them. For processes we  use
    71 combination of ptrace and /proc calls.
   108 combination of ptrace and /proc calls.
    72 
   109 
    73 *************************************************************************************/
   110 *************************************************************************************/
    74 
   111 
    75 // This C bool type must be int for compatibility with BSD calls and
   112 struct reg;
    76 // it would be a mistake to equivalence it to C++ bool on many platforms
       
    77 
       
    78 typedef int bool;
       
    79 #define true  1
       
    80 #define false 0
       
    81 
       
    82 struct ps_prochandle;
   113 struct ps_prochandle;
    83 
   114 
    84 // attach to a process
   115 // attach to a process
    85 struct ps_prochandle* Pgrab(pid_t pid);
   116 struct ps_prochandle* Pgrab(pid_t pid);
    86 
   117