src/jdk.hotspot.agent/macosx/native/libsaproc/libproc_impl.c
author redestad
Fri, 18 Jan 2019 08:00:05 +0100
changeset 53380 c8208421a860
parent 47216 71c04702a3d5
child 56109 5bf57be44328
permissions -rw-r--r--
8217325: Enable inlining of java_lang_Class::oop_size_raw Reviewed-by: shade, coleenp, rehn, stefank
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
#include "libproc_impl.h"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    25
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    26
static const char* alt_root = NULL;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    27
static int alt_root_len = -1;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    28
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
#define SA_ALTROOT "SA_ALTROOT"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    30
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    31
off_t ltell(int fd) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    32
  return lseek(fd, 0, SEEK_CUR);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    33
}
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    34
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    35
static void init_alt_root() {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    36
  if (alt_root_len == -1) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    37
    alt_root = getenv(SA_ALTROOT);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    38
    if (alt_root) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    39
      alt_root_len = strlen(alt_root);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    40
    } else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    41
      alt_root_len = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    42
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    43
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    44
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    45
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    46
int pathmap_open(const char* name) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    47
  int fd;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    48
  char alt_path[PATH_MAX + 1];
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    49
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    50
  init_alt_root();
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    51
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    52
  if (alt_root_len > 0) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    53
    strcpy(alt_path, alt_root);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    54
    strcat(alt_path, name);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    55
    fd = open(alt_path, O_RDONLY);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    56
    if (fd >= 0) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    57
      print_debug("path %s substituted for %s\n", alt_path, name);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    58
      return fd;
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    59
    }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    60
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    61
    if (strrchr(name, '/')) {
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    62
      strcpy(alt_path, alt_root);
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    63
      strcat(alt_path, strrchr(name, '/'));
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    64
      fd = open(alt_path, O_RDONLY);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    65
      if (fd >= 0) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    66
        print_debug("path %s substituted for %s\n", alt_path, name);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    67
        return fd;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    68
      }
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    69
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    70
  } else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    71
    fd = open(name, O_RDONLY);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    72
    if (fd >= 0) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    73
      return fd;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    74
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    75
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    76
  return -1;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    77
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    78
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    79
static bool _libsaproc_debug;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    80
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    81
void print_debug(const char* format,...) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    82
  if (_libsaproc_debug) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    83
    va_list alist;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    84
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    85
    va_start(alist, format);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    86
    fputs("libsaproc DEBUG: ", stderr);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    87
    vfprintf(stderr, format, alist);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    88
    va_end(alist);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
    89
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    90
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    91
15734
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    92
void print_error(const char* format,...) {
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    93
  va_list alist;
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    94
  va_start(alist, format);
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    95
  fputs("ERROR: ", stderr);
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    96
  vfprintf(stderr, format, alist);
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    97
  va_end(alist);
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    98
}
68f78eb98356 8008088: SA can hang the VM
rbackman
parents: 10565
diff changeset
    99
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   100
bool is_debug() {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   101
  return _libsaproc_debug;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   102
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   103
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   104
#ifdef __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   105
// get arch offset in file
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   106
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
   107
  struct fat_header fatheader;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   108
  struct fat_arch fatarch;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   109
  off_t img_start = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   110
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   111
  off_t pos = ltell(fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   112
  if (read(fd, (void *)&fatheader, sizeof(struct fat_header)) != sizeof(struct fat_header)) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   113
    return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   114
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   115
  if (fatheader.magic == FAT_CIGAM) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   116
    int i;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   117
    for (i = 0; i < ntohl(fatheader.nfat_arch); i++) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   118
      if (read(fd, (void *)&fatarch, sizeof(struct fat_arch)) != sizeof(struct fat_arch)) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   119
        return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   120
      }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   121
      if (ntohl(fatarch.cputype) == cputype) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   122
        print_debug("fat offset=%x\n", ntohl(fatarch.offset));
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   123
        img_start = ntohl(fatarch.offset);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   124
        break;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   125
      }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   126
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   127
    if (img_start == 0) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   128
      return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   129
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   130
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   131
  lseek(fd, pos, SEEK_SET);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   132
  *offset = img_start;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   133
  return true;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   134
}
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   135
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   136
bool is_macho_file(int fd) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   137
  mach_header_64 fhdr;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   138
  off_t x86_64_off;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   139
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   140
  if (fd < 0) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   141
    print_debug("Invalid file handle passed to is_macho_file\n");
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   142
    return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   143
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   144
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   145
  off_t pos = ltell(fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   146
  // check fat header
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   147
  if (!get_arch_off(fd, CPU_TYPE_X86_64, &x86_64_off)) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   148
    print_debug("failed to get fat header\n");
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   149
    return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   150
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   151
  lseek(fd, x86_64_off, SEEK_SET);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   152
  if (read(fd, (void *)&fhdr, sizeof(mach_header_64)) != sizeof(mach_header_64)) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   153
     return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   154
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   155
  lseek(fd, pos, SEEK_SET);               // restore
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   156
  print_debug("fhdr.magic %x\n", fhdr.magic);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   157
  return (fhdr.magic == MH_MAGIC_64 || fhdr.magic == MH_CIGAM_64);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   158
}
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   159
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   160
#endif //__APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   161
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   162
// initialize libproc
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   163
bool init_libproc(bool debug) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   164
   _libsaproc_debug = debug;
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   165
#ifndef __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   166
   // initialize the thread_db library
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   167
   if (td_init() != TD_OK) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   168
     print_debug("libthread_db's td_init failed\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   169
     return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   170
   }
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   171
#endif // __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   172
   return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   173
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   174
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   175
void destroy_lib_info(struct ps_prochandle* ph) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   176
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   177
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   178
    lib_info* next = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   179
    if (lib->symtab) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   180
      destroy_symtab(lib->symtab);
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
    free(lib);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   183
    lib = next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   184
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   185
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   186
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   187
void destroy_thread_info(struct ps_prochandle* ph) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   188
  sa_thread_info* thr = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   189
  while (thr) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   190
    sa_thread_info* n = thr->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   191
    free(thr);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   192
    thr = n;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   193
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   194
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   195
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   196
// ps_prochandle cleanup
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   197
void Prelease(struct ps_prochandle* ph) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   198
  // do the "derived class" clean-up first
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   199
  ph->ops->release(ph);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   200
  destroy_lib_info(ph);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   201
  destroy_thread_info(ph);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   202
  free(ph);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   203
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   204
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   205
lib_info* add_lib_info(struct ps_prochandle* ph, const char* libname, uintptr_t base) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   206
  return add_lib_info_fd(ph, libname, -1, base);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   207
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   208
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   209
lib_info* add_lib_info_fd(struct ps_prochandle* ph, const char* libname, int fd, uintptr_t base) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   210
   lib_info* newlib;
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   211
  print_debug("add_lib_info_fd %s\n", libname);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   212
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   213
  if ( (newlib = (lib_info*) calloc(1, sizeof(struct lib_info))) == NULL) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   214
    print_debug("can't allocate memory for lib_info\n");
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   215
    return NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   216
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   217
30281
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 16351
diff changeset
   218
  if (strlen(libname) >= sizeof(newlib->name)) {
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 16351
diff changeset
   219
    print_debug("libname %s too long\n", libname);
35516
f0d335e847c5 8145698: Memory leak in add_lib_info_fd of libproc_impl.c:174
dsamersoff
parents: 35217
diff changeset
   220
    free(newlib);
30281
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 16351
diff changeset
   221
    return NULL;
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 16351
diff changeset
   222
  }
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 16351
diff changeset
   223
  strcpy(newlib->name, libname);
b1608535e50f 8076475: Misuses of strncpy/strncat
stuefe
parents: 16351
diff changeset
   224
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   225
  newlib->base = base;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   226
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   227
  if (fd == -1) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   228
    if ( (newlib->fd = pathmap_open(newlib->name)) < 0) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   229
      print_debug("can't open shared object %s\n", newlib->name);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   230
      free(newlib);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   231
      return NULL;
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   232
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   233
  } else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   234
    newlib->fd = fd;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   235
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   236
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   237
#ifdef __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   238
  // check whether we have got an Macho file.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   239
  if (is_macho_file(newlib->fd) == false) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   240
    close(newlib->fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   241
    free(newlib);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   242
    print_debug("not a mach-o file\n");
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   243
    return NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   244
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   245
#else
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   246
  // check whether we have got an ELF file. /proc/<pid>/map
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   247
  // gives out all file mappings and not just shared objects
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   248
  if (is_elf_file(newlib->fd) == false) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   249
    close(newlib->fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   250
    free(newlib);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   251
    return NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   252
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   253
#endif // __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   254
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   255
  newlib->symtab = build_symtab(newlib->fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   256
  if (newlib->symtab == NULL) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   257
    print_debug("symbol table build failed for %s\n", newlib->name);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   258
  } else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   259
    print_debug("built symbol table for %s\n", newlib->name);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   260
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   261
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   262
  // even if symbol table building fails, we add the lib_info.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   263
  // This is because we may need to read from the ELF file or MachO file for core file
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   264
  // address read functionality. lookup_symbol checks for NULL symtab.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   265
  if (ph->libs) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   266
    ph->lib_tail->next = newlib;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   267
    ph->lib_tail = newlib;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   268
  }  else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   269
    ph->libs = ph->lib_tail = newlib;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   270
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   271
  ph->num_libs++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   272
  return newlib;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   273
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   274
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   275
// lookup for a specific symbol
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   276
uintptr_t lookup_symbol(struct ps_prochandle* ph,  const char* object_name,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   277
                       const char* sym_name) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   278
  // ignore object_name. search in all libraries
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   279
  // FIXME: what should we do with object_name?? The library names are obtained
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   280
  // by parsing /proc/<pid>/maps, which may not be the same as object_name.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   281
  // What we need is a utility to map object_name to real file name, something
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   282
  // dlopen() does by looking at LD_LIBRARY_PATH and /etc/ld.so.cache. For
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   283
  // now, we just ignore object_name and do a global search for the symbol.
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   284
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   285
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   286
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   287
    if (lib->symtab) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   288
      uintptr_t res = search_symbol(lib->symtab, lib->base, sym_name, NULL);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   289
      if (res) return res;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   290
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   291
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   292
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   293
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   294
  print_debug("lookup failed for symbol '%s' in obj '%s'\n",
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   295
                          sym_name, object_name);
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   296
  return (uintptr_t) NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   297
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   298
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   299
const char* symbol_for_pc(struct ps_prochandle* ph, uintptr_t addr, uintptr_t* poffset) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   300
  const char* res = NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   301
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   302
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   303
    if (lib->symtab && addr >= lib->base) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   304
      res = nearest_symbol(lib->symtab, addr - lib->base, poffset);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   305
      if (res) return res;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   306
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   307
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   308
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   309
  return NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   310
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   311
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   312
// add a thread to ps_prochandle
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   313
sa_thread_info* add_thread_info(struct ps_prochandle* ph, pthread_t pthread_id, lwpid_t lwp_id) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   314
  sa_thread_info* newthr;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   315
  if ( (newthr = (sa_thread_info*) calloc(1, sizeof(sa_thread_info))) == NULL) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   316
    print_debug("can't allocate memory for thread_info\n");
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   317
    return NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   318
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   319
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   320
  // initialize thread info
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   321
  newthr->pthread_id = pthread_id;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   322
  newthr->lwp_id = lwp_id;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   323
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   324
  // add new thread to the list
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   325
  newthr->next = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   326
  ph->threads = newthr;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   327
  ph->num_threads++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   328
  return newthr;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   329
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   330
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   331
#ifndef __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   332
// struct used for client data from thread_db callback
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   333
struct thread_db_client_data {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   334
  struct ps_prochandle* ph;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   335
  thread_info_callback callback;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   336
};
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   337
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   338
// callback function for libthread_db
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   339
static int thread_db_callback(const td_thrhandle_t *th_p, void *data) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   340
  struct thread_db_client_data* ptr = (struct thread_db_client_data*) data;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   341
  td_thrinfo_t ti;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   342
  td_err_e err;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   343
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   344
  memset(&ti, 0, sizeof(ti));
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   345
  err = td_thr_get_info(th_p, &ti);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   346
  if (err != TD_OK) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   347
    print_debug("libthread_db : td_thr_get_info failed, can't get thread info\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   348
    return err;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   349
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   350
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   351
  print_debug("thread_db : pthread %d (lwp %d)\n", ti.ti_tid, ti.ti_lid);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   352
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   353
  if (ptr->callback(ptr->ph, (pthread_t)ti.ti_tid, ti.ti_lid) != true)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   354
    return TD_ERR;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   355
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   356
  return TD_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   357
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   358
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   359
// read thread_info using libthread_db
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   360
bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   361
  struct thread_db_client_data mydata;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   362
  td_thragent_t* thread_agent = NULL;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   363
  if (td_ta_new(ph, &thread_agent) != TD_OK) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   364
     print_debug("can't create libthread_db agent\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   365
     return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   366
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   367
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   368
  mydata.ph = ph;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   369
  mydata.callback = cb;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   370
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   371
  // we use libthread_db iterator to iterate thru list of threads.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   372
  if (td_ta_thr_iter(thread_agent, thread_db_callback, &mydata,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   373
                 TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   374
                 TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS) != TD_OK) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   375
     td_ta_delete(thread_agent);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   376
     return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   377
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   378
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   379
  // delete thread agent
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   380
  td_ta_delete(thread_agent);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   381
  return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   382
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   383
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   384
#endif // __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   385
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   386
// get number of threads
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   387
int get_num_threads(struct ps_prochandle* ph) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   388
   return ph->num_threads;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   389
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   390
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   391
// get lwp_id of n'th thread
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   392
lwpid_t get_lwp_id(struct ps_prochandle* ph, int index) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   393
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   394
  sa_thread_info* thr = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   395
  while (thr) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   396
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   397
      return thr->lwp_id;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   398
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   399
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   400
    thr = thr->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   401
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   402
  return 0;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   403
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   404
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   405
#ifdef __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   406
// set lwp_id of n'th thread
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   407
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
   408
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   409
  sa_thread_info* thr = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   410
  while (thr) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   411
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   412
      thr->lwp_id = lwpid;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   413
      return true;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   414
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   415
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   416
    thr = thr->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   417
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   418
  return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   419
}
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   420
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   421
// get regs of n-th thread, only used in fillThreads the first time called
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   422
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
   423
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   424
  sa_thread_info* thr = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   425
  while (thr) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   426
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   427
      break;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   428
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   429
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   430
    thr = thr->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   431
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   432
  if (thr != NULL) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   433
    memcpy(regs, &thr->regs, sizeof(struct reg));
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   434
    return true;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   435
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   436
  return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   437
}
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   438
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   439
#endif // __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   440
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   441
// get regs for a given lwp
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   442
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
   443
  return ph->ops->get_lwp_regs(ph, lwp_id, regs);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   444
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   445
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   446
// get number of shared objects
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   447
int get_num_libs(struct ps_prochandle* ph) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   448
  return ph->num_libs;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   449
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   450
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   451
// get name of n'th solib
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   452
const char* get_lib_name(struct ps_prochandle* ph, int index) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   453
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   454
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   455
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   456
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   457
      return lib->name;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   458
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   459
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   460
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   461
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   462
  return NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   463
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   464
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   465
// get base address of a lib
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   466
uintptr_t get_lib_base(struct ps_prochandle* ph, int index) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   467
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   468
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   469
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   470
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   471
      return lib->base;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   472
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   473
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   474
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   475
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   476
  return (uintptr_t)NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   477
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   478
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   479
bool find_lib(struct ps_prochandle* ph, const char *lib_name) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   480
  lib_info *p = ph->libs;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   481
  while (p) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   482
    if (strcmp(p->name, lib_name) == 0) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   483
      return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   484
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   485
    p = p->next;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   486
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   487
  return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   488
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   489
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   490
//--------------------------------------------------------------------------
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   491
// proc service functions
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   492
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   493
// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   494
// of the load object object_name in the target process identified by ph.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   495
// It returns the symbol's value as an address in the target process in
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   496
// *sym_addr.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   497
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   498
ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   499
                    const char *sym_name, psaddr_t *sym_addr) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   500
  *sym_addr = (psaddr_t) lookup_symbol(ph, object_name, sym_name);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   501
  return (*sym_addr ? PS_OK : PS_NOSYM);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   502
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   503
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   504
// read "size" bytes info "buf" from address "addr"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   505
ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t  addr,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   506
                  void *buf, size_t size) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   507
  return ph->ops->p_pread(ph, (uintptr_t) addr, buf, size)? PS_OK: PS_ERR;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   508
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   509
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   510
// write "size" bytes of data to debuggee at address "addr"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   511
ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   512
                   const void *buf, size_t size) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   513
  return ph->ops->p_pwrite(ph, (uintptr_t)addr, buf, size)? PS_OK: PS_ERR;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   514
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   515
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   516
// fill in ptrace_lwpinfo for lid
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   517
ps_err_e ps_linfo(struct ps_prochandle *ph, lwpid_t lwp_id, void *linfo) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   518
  return ph->ops->get_lwp_info(ph, lwp_id, linfo)? PS_OK: PS_ERR;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   519
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   520
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   521
// needed for when libthread_db is compiled with TD_DEBUG defined
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   522
void
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   523
ps_plog (const char *format, ...)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   524
{
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   525
  va_list alist;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   526
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   527
  va_start(alist, format);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   528
  vfprintf(stderr, format, alist);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   529
  va_end(alist);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   530
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   531
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   532
#ifndef __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   533
// ------------------------------------------------------------------------
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   534
// Functions below this point are not yet implemented. They are here only
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   535
// to make the linker happy.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   536
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   537
ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lid, const prfpregset_t *fpregs) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   538
  print_debug("ps_lsetfpregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   539
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   540
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   541
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   542
ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lid, const prgregset_t gregset) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   543
  print_debug("ps_lsetregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   544
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   545
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   546
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   547
ps_err_e  ps_lgetfpregs(struct  ps_prochandle  *ph,  lwpid_t lid, prfpregset_t *fpregs) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   548
  print_debug("ps_lgetfpregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   549
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   550
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   551
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   552
ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lid, prgregset_t gregset) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   553
  print_debug("ps_lgetfpregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   554
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   555
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   556
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   557
ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lid) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   558
  print_debug("ps_lstop not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   559
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   560
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   561
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   562
ps_err_e ps_pcontinue(struct ps_prochandle *ph) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   563
  print_debug("ps_pcontinue not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   564
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   565
}
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   566
#endif // __APPLE__