hotspot/agent/src/os/bsd/libproc_impl.c
author katleman
Thu, 21 Aug 2014 14:16:14 -0700
changeset 25878 6d561031123e
parent 16351 032b310a3e2f
child 30281 b1608535e50f
permissions -rw-r--r--
Added tag jdk9-b27 for changeset 98ce0879ab4c
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
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   218
  strncpy(newlib->name, libname, sizeof(newlib->name));
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   219
  newlib->base = base;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   220
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   221
  if (fd == -1) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   222
    if ( (newlib->fd = pathmap_open(newlib->name)) < 0) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   223
      print_debug("can't open shared object %s\n", newlib->name);
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   224
      free(newlib);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   225
      return NULL;
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   226
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   227
  } else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   228
    newlib->fd = fd;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   229
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   230
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   231
#ifdef __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   232
  // check whether we have got an Macho file.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   233
  if (is_macho_file(newlib->fd) == false) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   234
    close(newlib->fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   235
    free(newlib);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   236
    print_debug("not a mach-o file\n");
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   237
    return NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   238
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   239
#else
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   240
  // 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
   241
  // 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
   242
  if (is_elf_file(newlib->fd) == false) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   243
    close(newlib->fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   244
    free(newlib);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   245
    return NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   246
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   247
#endif // __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   248
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   249
  newlib->symtab = build_symtab(newlib->fd);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   250
  if (newlib->symtab == NULL) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   251
    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
   252
  } else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   253
    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
   254
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   255
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   256
  // 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
   257
  // 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
   258
  // address read functionality. lookup_symbol checks for NULL symtab.
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   259
  if (ph->libs) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   260
    ph->lib_tail->next = newlib;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   261
    ph->lib_tail = newlib;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   262
  }  else {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   263
    ph->libs = ph->lib_tail = newlib;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   264
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   265
  ph->num_libs++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   266
  return newlib;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   267
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   268
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   269
// lookup for a specific symbol
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   270
uintptr_t lookup_symbol(struct ps_prochandle* ph,  const char* object_name,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   271
                       const char* sym_name) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   272
  // ignore object_name. search in all libraries
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   273
  // 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
   274
  // 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
   275
  // 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
   276
  // 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
   277
  // 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
   278
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   279
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   280
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   281
    if (lib->symtab) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   282
      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
   283
      if (res) return res;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   284
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   285
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   286
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   287
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   288
  print_debug("lookup failed for symbol '%s' in obj '%s'\n",
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   289
                          sym_name, object_name);
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   290
  return (uintptr_t) NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   291
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   292
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   293
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
   294
  const char* res = NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   295
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   296
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   297
    if (lib->symtab && addr >= lib->base) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   298
      res = nearest_symbol(lib->symtab, addr - lib->base, poffset);
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   299
      if (res) return res;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   300
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   301
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   302
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   303
  return NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   304
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   305
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   306
// add a thread to ps_prochandle
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   307
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
   308
  sa_thread_info* newthr;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   309
  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
   310
    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
   311
    return NULL;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   312
  }
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   313
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   314
  // initialize thread info
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   315
  newthr->pthread_id = pthread_id;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   316
  newthr->lwp_id = lwp_id;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   317
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   318
  // add new thread to the list
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   319
  newthr->next = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   320
  ph->threads = newthr;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   321
  ph->num_threads++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   322
  return newthr;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   323
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   324
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   325
#ifndef __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   326
// struct used for client data from thread_db callback
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   327
struct thread_db_client_data {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   328
  struct ps_prochandle* ph;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   329
  thread_info_callback callback;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   330
};
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   331
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   332
// callback function for libthread_db
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   333
static int thread_db_callback(const td_thrhandle_t *th_p, void *data) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   334
  struct thread_db_client_data* ptr = (struct thread_db_client_data*) data;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   335
  td_thrinfo_t ti;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   336
  td_err_e err;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   337
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   338
  memset(&ti, 0, sizeof(ti));
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   339
  err = td_thr_get_info(th_p, &ti);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   340
  if (err != TD_OK) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   341
    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
   342
    return err;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   343
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   344
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   345
  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
   346
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   347
  if (ptr->callback(ptr->ph, (pthread_t)ti.ti_tid, ti.ti_lid) != true)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   348
    return TD_ERR;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   349
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   350
  return TD_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   351
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   352
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   353
// read thread_info using libthread_db
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   354
bool read_thread_info(struct ps_prochandle* ph, thread_info_callback cb) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   355
  struct thread_db_client_data mydata;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   356
  td_thragent_t* thread_agent = NULL;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   357
  if (td_ta_new(ph, &thread_agent) != TD_OK) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   358
     print_debug("can't create libthread_db agent\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   359
     return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   360
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   361
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   362
  mydata.ph = ph;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   363
  mydata.callback = cb;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   364
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   365
  // we use libthread_db iterator to iterate thru list of threads.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   366
  if (td_ta_thr_iter(thread_agent, thread_db_callback, &mydata,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   367
                 TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   368
                 TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS) != TD_OK) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   369
     td_ta_delete(thread_agent);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   370
     return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   371
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   372
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   373
  // delete thread agent
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   374
  td_ta_delete(thread_agent);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   375
  return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   376
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   377
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   378
#endif // __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   379
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   380
// get number of threads
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   381
int get_num_threads(struct ps_prochandle* ph) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   382
   return ph->num_threads;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   383
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   384
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   385
// get lwp_id of n'th thread
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   386
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
   387
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   388
  sa_thread_info* thr = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   389
  while (thr) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   390
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   391
      return thr->lwp_id;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   392
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   393
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   394
    thr = thr->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   395
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   396
  return 0;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   397
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   398
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   399
#ifdef __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   400
// set lwp_id of n'th thread
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   401
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
   402
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   403
  sa_thread_info* thr = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   404
  while (thr) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   405
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   406
      thr->lwp_id = lwpid;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   407
      return true;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   408
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   409
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   410
    thr = thr->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   411
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   412
  return false;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   413
}
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
// 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
   416
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
   417
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   418
  sa_thread_info* thr = ph->threads;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   419
  while (thr) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   420
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   421
      break;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   422
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   423
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   424
    thr = thr->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   425
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   426
  if (thr != NULL) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   427
    memcpy(regs, &thr->regs, sizeof(struct reg));
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   428
    return true;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   429
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   430
  return false;
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
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   433
#endif // __APPLE__
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   434
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   435
// get regs for a given lwp
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   436
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
   437
  return ph->ops->get_lwp_regs(ph, lwp_id, regs);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   438
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   439
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   440
// get number of shared objects
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   441
int get_num_libs(struct ps_prochandle* ph) {
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   442
  return ph->num_libs;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   443
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   444
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   445
// get name of n'th solib
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   446
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
   447
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   448
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   449
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   450
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   451
      return lib->name;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   452
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   453
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   454
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   455
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   456
  return NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   457
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   458
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   459
// get base address of a lib
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   460
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
   461
  int count = 0;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   462
  lib_info* lib = ph->libs;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   463
  while (lib) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   464
    if (count == index) {
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   465
      return lib->base;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   466
    }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   467
    count++;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   468
    lib = lib->next;
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   469
  }
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   470
  return (uintptr_t)NULL;
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   471
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   472
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   473
bool find_lib(struct ps_prochandle* ph, const char *lib_name) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   474
  lib_info *p = ph->libs;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   475
  while (p) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   476
    if (strcmp(p->name, lib_name) == 0) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   477
      return true;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   478
    }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   479
    p = p->next;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   480
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   481
  return false;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   482
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   483
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   484
//--------------------------------------------------------------------------
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   485
// proc service functions
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   486
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   487
// ps_pglobal_lookup() looks up the symbol sym_name in the symbol table
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   488
// of the load object object_name in the target process identified by ph.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   489
// It returns the symbol's value as an address in the target process in
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   490
// *sym_addr.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   491
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   492
ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   493
                    const char *sym_name, psaddr_t *sym_addr) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   494
  *sym_addr = (psaddr_t) lookup_symbol(ph, object_name, sym_name);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   495
  return (*sym_addr ? PS_OK : PS_NOSYM);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   496
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   497
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   498
// read "size" bytes info "buf" from address "addr"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   499
ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t  addr,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   500
                  void *buf, size_t size) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   501
  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
   502
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   503
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   504
// write "size" bytes of data to debuggee at address "addr"
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   505
ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   506
                   const void *buf, size_t size) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   507
  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
   508
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   509
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   510
// fill in ptrace_lwpinfo for lid
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   511
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
   512
  return ph->ops->get_lwp_info(ph, lwp_id, linfo)? PS_OK: PS_ERR;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   513
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   514
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   515
// needed for when libthread_db is compiled with TD_DEBUG defined
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   516
void
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   517
ps_plog (const char *format, ...)
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   518
{
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   519
  va_list alist;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   520
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   521
  va_start(alist, format);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   522
  vfprintf(stderr, format, alist);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   523
  va_end(alist);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   524
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   525
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   526
#ifndef __APPLE__
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   527
// ------------------------------------------------------------------------
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   528
// Functions below this point are not yet implemented. They are here only
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   529
// to make the linker happy.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   530
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   531
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
   532
  print_debug("ps_lsetfpregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   533
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   534
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   535
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   536
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
   537
  print_debug("ps_lsetregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   538
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   539
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   540
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   541
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
   542
  print_debug("ps_lgetfpregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   543
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   544
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   545
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   546
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
   547
  print_debug("ps_lgetfpregs not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   548
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   549
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   550
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   551
ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lid) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   552
  print_debug("ps_lstop not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   553
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   554
}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   555
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   556
ps_err_e ps_pcontinue(struct ps_prochandle *ph) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   557
  print_debug("ps_pcontinue not implemented\n");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   558
  return PS_OK;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   559
}
16351
032b310a3e2f 8003348: SA can not read core file on OS
minqi
parents: 15734
diff changeset
   560
#endif // __APPLE__