src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.h
author michaelm
Wed, 30 Oct 2019 11:53:07 +0000
branchunixdomainchannels
changeset 58856 b2f0339a4cad
parent 47216 71c04702a3d5
child 56109 5bf57be44328
permissions -rw-r--r--
removing unnecessary diffs from mainline
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     1
/*
15734
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     4
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     8
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    13
 * accompanied this code).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    14
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    18
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    21
 * questions.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    22
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    23
 */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    24
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    25
#ifndef _LIBPROC_IMPL_H_
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    26
#define _LIBPROC_IMPL_H_
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    27
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    28
#include <unistd.h>
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
#include <limits.h>
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    30
#include "libproc.h"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    31
#include "symtab.h"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    32
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    33
#ifdef __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    34
#include <inttypes.h>     // for PRIx64, 32, ...
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    35
#include <pthread.h>
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    36
#include <mach-o/loader.h>
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    37
#include <mach-o/nlist.h>
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    38
#include <mach-o/fat.h>
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    39
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    40
#ifndef register_t
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    41
#define register_t uint64_t
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    42
#endif
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    43
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    44
/*** registers copied from bsd/amd64 */
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    45
typedef struct reg {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    46
  register_t      r_r15;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    47
  register_t      r_r14;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    48
  register_t      r_r13;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    49
  register_t      r_r12;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    50
  register_t      r_r11;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    51
  register_t      r_r10;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    52
  register_t      r_r9;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    53
  register_t      r_r8;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    54
  register_t      r_rdi;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    55
  register_t      r_rsi;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    56
  register_t      r_rbp;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    57
  register_t      r_rbx;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    58
  register_t      r_rdx;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    59
  register_t      r_rcx;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    60
  register_t      r_rax;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    61
  uint32_t        r_trapno;      // not used
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    62
  uint16_t        r_fs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    63
  uint16_t        r_gs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    64
  uint32_t        r_err;         // not used
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    65
  uint16_t        r_es;          // not used
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    66
  uint16_t        r_ds;          // not used
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    67
  register_t      r_rip;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    68
  register_t      r_cs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    69
  register_t      r_rflags;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    70
  register_t      r_rsp;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    71
  register_t      r_ss;          // not used
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    72
} reg;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    73
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    74
// convenient defs
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    75
typedef struct mach_header_64 mach_header_64;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    76
typedef struct load_command load_command;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    77
typedef struct segment_command_64 segment_command_64;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    78
typedef struct thread_command thread_command;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    79
typedef struct dylib_command dylib_command;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    80
typedef struct symtab_command symtab_command;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    81
typedef struct nlist_64 nlist_64;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    82
#else
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    83
#include <thread_db.h>
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    84
#include "salibelf.h"
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    85
#endif //  __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    86
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    87
// data structures in this file mimic those of Solaris 8.0 - libproc's Pcontrol.h
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    88
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    89
#define BUF_SIZE     (PATH_MAX + NAME_MAX + 1)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    90
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    91
// list of shared objects
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    92
typedef struct lib_info {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    93
  char             name[BUF_SIZE];
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    94
  uintptr_t        base;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    95
  struct symtab*   symtab;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    96
  int              fd;        // file descriptor for lib
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    97
  struct lib_info* next;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    98
} lib_info;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    99
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   100
// list of threads
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   101
typedef struct sa_thread_info {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   102
   lwpid_t                  lwp_id;     // same as pthread_t
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   103
   pthread_t                pthread_id; //
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   104
   struct reg               regs;       // not for process, core uses for caching regset
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   105
   struct sa_thread_info*   next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   106
} sa_thread_info;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   107
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   108
// list of virtual memory maps
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   109
typedef struct map_info {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   110
   int              fd;       // file descriptor
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   111
   off_t            offset;   // file offset of this mapping
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   112
   uintptr_t        vaddr;    // starting virtual address
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   113
   size_t           memsz;    // size of the mapping
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   114
   struct map_info* next;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   115
} map_info;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   116
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   117
// vtable for ps_prochandle
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   118
typedef struct ps_prochandle_ops {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   119
   // "derived class" clean-up
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   120
   void (*release)(struct ps_prochandle* ph);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   121
   // read from debuggee
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   122
   bool (*p_pread)(struct ps_prochandle *ph,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   123
            uintptr_t addr, char *buf, size_t size);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   124
   // write into debuggee
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   125
   bool (*p_pwrite)(struct ps_prochandle *ph,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   126
            uintptr_t addr, const char *buf , size_t size);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   127
   // get integer regset of a thread
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   128
   bool (*get_lwp_regs)(struct ps_prochandle* ph, lwpid_t lwp_id, struct reg* regs);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   129
   // get info on thread
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   130
   bool (*get_lwp_info)(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   131
} ps_prochandle_ops;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   132
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   133
// the ps_prochandle
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   134
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   135
struct core_data {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   136
   int                core_fd;   // file descriptor of core file
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   137
   int                exec_fd;   // file descriptor of exec file
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   138
   int                interp_fd; // file descriptor of interpreter (ld-elf.so.1)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   139
   // part of the class sharing workaround
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   140
   int                classes_jsa_fd; // file descriptor of class share archive
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   141
   uintptr_t          dynamic_addr;  // address of dynamic section of a.out
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   142
   uintptr_t          ld_base_addr;  // base address of ld.so
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   143
   size_t             num_maps;  // number of maps.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   144
   map_info*          maps;      // maps in a linked list
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   145
   // part of the class sharing workaround
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   146
   map_info*          class_share_maps;// class share maps in a linked list
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   147
   map_info**         map_array; // sorted (by vaddr) array of map_info pointers
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   148
   char               exec_path[4096];  // file name java
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   149
};
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   150
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   151
struct ps_prochandle {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   152
   ps_prochandle_ops* ops;       // vtable ptr
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   153
   pid_t              pid;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   154
   int                num_libs;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   155
   lib_info*          libs;      // head of lib list
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   156
   lib_info*          lib_tail;  // tail of lib list - to append at the end
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   157
   int                num_threads;
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   158
   sa_thread_info*    threads;   // head of thread list
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   159
   struct core_data*  core;      // data only used for core dumps, NULL for process
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   160
};
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   161
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   162
int pathmap_open(const char* name);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   163
void print_debug(const char* format,...);
15734
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
   164
void print_error(const char* format,...);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   165
bool is_debug();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   166
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   167
typedef bool (*thread_info_callback)(struct ps_prochandle* ph, pthread_t pid, lwpid_t lwpid);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   168
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   169
// reads thread info using libthread_db and calls above callback for each thread
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   170
bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   171
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   172
// adds a new shared object to lib list, returns NULL on failure
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   173
lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   174
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   175
// adds a new shared object to lib list, supply open lib file descriptor as well
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   176
lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   177
                          uintptr_t base);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   178
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   179
sa_thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   180
// a test for ELF signature without using libelf
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   181
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   182
#ifdef __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   183
// a test for Mach-O signature
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   184
bool is_macho_file(int fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   185
// skip fat head to get image start offset of cpu_type_t
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   186
// return false if any error happens, else value in offset.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   187
bool get_arch_off(int fd, cpu_type_t cputype, off_t *offset);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   188
#else
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   189
bool is_elf_file(int fd);
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   190
#endif // __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   191
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   192
lwpid_t get_lwp_id(struct ps_prochandle* ph, int index);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   193
bool set_lwp_id(struct ps_prochandle* ph, int index, lwpid_t lwpid);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   194
bool get_nth_lwp_regs(struct ps_prochandle* ph, int index, struct reg* regs);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   195
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   196
// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   197
// of the load object object_name in the target process identified by ph.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   198
// It returns the symbol's value as an address in the target process in
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   199
// *sym_addr.
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   200
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   201
ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   202
                    const char *sym_name, psaddr_t *sym_addr);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   203
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   204
// read "size" bytes info "buf" from address "addr"
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   205
ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t  addr,
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   206
                  void *buf, size_t size);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   207
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   208
// write "size" bytes of data to debuggee at address "addr"
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   209
ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   210
                   const void *buf, size_t size);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   211
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   212
// fill in ptrace_lwpinfo for lid
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   213
ps_err_e ps_linfo(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   214
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   215
// needed for when libthread_db is compiled with TD_DEBUG defined
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   216
void ps_plog (const char *format, ...);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   217
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   218
// untility, tells the position in file
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   219
off_t ltell(int fd);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   220
#endif //_LIBPROC_IMPL_H_