src/jdk.hotspot.agent/solaris/native/libsaproc/salibproc.h
author shade
Thu, 26 Apr 2018 17:59:02 +0200
branchepsilon-gc-branch
changeset 56489 016b77c3734a
parent 47216 71c04702a3d5
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
42035
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
     2
 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
#ifndef _SALIBPROC_H_
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#define _SALIBPROC_H_
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
 * The following definitions, prototypes are from Solaris libproc.h.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
 * We used to use the copy of it from Solaris 8.0. But there are
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
 * problems with that approach in building this library across Solaris
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
 * versions.  Solaris 10 has libproc.h in /usr/include. And libproc.h
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
 * varies slightly across Solaris versions. On Solaris 9, we get
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
 * 'sysret_t multiply defined' error. This is common minimum subset we
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
 * really need from libproc.h. The libproc.h in the current dir has
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
 * been left for reference and not used in build.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
#include <dlfcn.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
#include <gelf.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
#include <procfs.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
#include <proc_service.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
#include <fcntl.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
#include <unistd.h>
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
#ifdef __cplusplus
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
extern "C" {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
42035
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    49
/* extended symbol table information */
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    50
typedef struct {
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    51
        const char      *prs_object;            /* object name */
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    52
        const char      *prs_name;              /* symbol name */
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    53
        Lmid_t          prs_lmid;               /* link map id */
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    54
        uint_t          prs_id;                 /* symbol id */
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    55
        uint_t          prs_table;              /* symbol table id */
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    56
} prsyminfo_t;
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    57
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    58
typedef struct ps_prochandle ps_prochandle_t;
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    59
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
 * 'object_name' is the name of a load object obtained from an
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
 * iteration over the process's address space mappings (Pmapping_iter),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
 * or an iteration over the process's mapped objects (Pobject_iter),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
 * or else it is one of the special PR_OBJ_* values above.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
42035
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    67
extern int Plookup_by_addr(ps_prochandle_t *, uintptr_t, char *,
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    68
                           size_t, GElf_Sym *, prsyminfo_t *);
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    69
extern ps_prochandle_t *proc_arg_grab(const char *, int, int,
10e6e31dc1aa 8164383: jhsdb dumps core on Solaris 12 when loading dumped core
dsamersoff
parents: 35217
diff changeset
    70
                                      int *, const char **);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
typedef int proc_map_f(void *, const prmap_t *, const char *);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
extern int Pobject_iter(struct ps_prochandle *, proc_map_f *, void *);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
 * Utility functions for processing arguments which should be /proc files,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
 * pids, and/or core files.  The returned error code can be passed to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 * Pgrab_error() in order to convert it to an error string.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
#define PR_ARG_PIDS     0x1     /* Allow pid and /proc file arguments */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
#define PR_ARG_CORES    0x2     /* Allow core file arguments */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
#define PR_ARG_ANY      (PR_ARG_PIDS | PR_ARG_CORES)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
/* Flags accepted by Pgrab() (partial) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
#define PGRAB_FORCE     0x02    /* Open the process w/o O_EXCL */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
/* Error codes from Pgrab(), Pfgrab_core(), and Pgrab_core() */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
#define G_STRANGE       -1      /* Unanticipated error, errno is meaningful */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
#define G_NOPROC        1       /* No such process */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
#define G_NOCORE        2       /* No such core file */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
#define G_NOPROCORCORE  3       /* No such proc or core (for proc_arg_grab) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
#define G_NOEXEC        4       /* Cannot locate executable file */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
#define G_ZOMB          5       /* Zombie process */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
#define G_PERM          6       /* No permission */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
#define G_BUSY          7       /* Another process has control */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
#define G_SYS           8       /* System process */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
#define G_SELF          9       /* Process is self */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
#define G_INTR          10      /* Interrupt received while grabbing */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
#define G_LP64          11      /* Process is _LP64, self is ILP32 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
#define G_FORMAT        12      /* File is not an ELF format core file */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
#define G_ELF           13      /* Libelf error, elf_errno() is meaningful */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
#define G_NOTE          14      /* Required PT_NOTE Phdr not present in core */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
extern  const pstatus_t *Pstatus(struct ps_prochandle *);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
/* Flags accepted by Prelease (partial) */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
#define PRELEASE_CLEAR  0x10    /* Clear all tracing flags */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
extern  void    Prelease(struct ps_prochandle *, int);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
extern  int     Psetrun(struct ps_prochandle *, int, int);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
extern  int     Pstop(struct ps_prochandle *, uint_t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
 * Stack frame iteration interface.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
 */
9407
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   116
typedef int proc_stack_f(
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   117
    void *,             /* the cookie given to Pstack_iter() */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   118
    const prgregset_t,  /* the frame's registers */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   119
    uint_t,             /* argc for the frame's function */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   120
    const long *,       /* argv for the frame's function */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   121
    int,                /* bitwise flags describing the frame (see below) */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   122
    int);               /* a signal number */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   123
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   124
#define PR_SIGNAL_FRAME    1    /* called by a signal handler */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   125
#define PR_FOUND_SIGNAL    2    /* we found the corresponding signal number */
c985006c2940 7028172: 3/4 SA needs to adapt to Solaris libproc change made in 6748307
dcubed
parents: 5547
diff changeset
   126
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
extern int Pstack_iter(struct ps_prochandle *,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    const prgregset_t, proc_stack_f *, void *);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
#define PR_OBJ_EVERY    ((const char *)-1)      /* search every load object */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
#ifdef __cplusplus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
#endif /* _SALIBPROC_H_ */