hotspot/src/os/aix/vm/loadlib_aix.cpp
author attila
Mon, 08 Feb 2016 12:59:08 +0100
changeset 35725 c7a2c18529b1
parent 34647 fafb32d71489
child 35594 cc13089c6327
permissions -rw-r--r--
8149186: Don't use indy for optimistic arithmetic Reviewed-by: mhaupt, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     1
/*
34647
fafb32d71489 8143125: [aix] Further Developments for AIX
stuefe
parents: 33743
diff changeset
     2
 * Copyright 2012, 2015 SAP AG. All rights reserved.
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     4
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     8
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    13
 * accompanied this code).
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    14
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    18
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    21
 * questions.
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    22
 *
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    23
 */
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    24
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    25
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    26
// Implementation of LoadedLibraries and friends
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    27
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    28
// Ultimately this just uses loadquery()
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    29
// See:
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    30
// http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    31
//      ?topic=/com.ibm.aix.basetechref/doc/basetrf1/loadquery.htm
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    32
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    33
#ifndef __STDC_FORMAT_MACROS
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    34
#define __STDC_FORMAT_MACROS
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    35
#endif
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    36
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    37
#include "loadlib_aix.hpp"
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    38
#include "misc_aix.hpp"
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    39
#include "porting_aix.hpp"
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    40
#include "utilities/debug.hpp"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    41
#include "utilities/ostream.hpp"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    42
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    43
// For loadquery()
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    44
#include <sys/ldr.h>
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    45
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    46
// Use raw malloc instead of os::malloc - this code gets used for error reporting.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    47
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    48
// A class to "intern" eternal strings.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    49
// TODO: similar coding exists in AIX version of dladdr and potentially elsewhere: consolidate!
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    50
class StringList {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    51
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    52
  char** _list;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    53
  int _cap;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    54
  int _num;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    55
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    56
  // Enlarge list. If oom, leave old list intact and return false.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    57
  bool enlarge() {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    58
    int cap2 = _cap + 64;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    59
    char** l2 = (char**) ::realloc(_list, sizeof(char*) * cap2);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    60
    if (!l2) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    61
      return false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    62
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    63
    _list = l2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    64
    _cap = cap2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    65
    return true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    66
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    67
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    68
  // Append string to end of list.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    69
  // Returns NULL if oom.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    70
  char* append(const char* s) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    71
    if (_cap == _num) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    72
      if (!enlarge()) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    73
        return NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    74
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    75
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    76
    assert0(_cap > _num);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    77
    char* s2 = ::strdup(s);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    78
    if (!s2) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    79
      return NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    80
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    81
    _list[_num] = s2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    82
    trcVerbose("StringDir: added %s at pos %d", s2, _num);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    83
    _num ++;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    84
    return s2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    85
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    86
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    87
public:
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    88
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    89
  StringList()
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    90
    : _list(NULL)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    91
    , _cap(0)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    92
    , _num(0)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    93
  {}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    94
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    95
  // String is copied into the list; pointer to copy is returned.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    96
  // Returns NULL if oom.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    97
  char* add (const char* s) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    98
    for (int i = 0; i < _num; i++) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    99
      if (strcmp(_list[i], s) == 0) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   100
        return _list[i];
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   101
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   102
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   103
    return append(s);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   104
  }
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   105
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   106
};
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   107
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   108
static StringList g_stringlist;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   109
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   110
//////////////////////
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   111
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   112
// Entries are kept in a linked list ordered by text address. Entries are not
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   113
// eternal - this list is rebuilt on every reload.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   114
// Note that we do not hand out those entries, but copies of them.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   115
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   116
struct entry_t {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   117
  entry_t* next;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   118
  loaded_module_t info;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   119
};
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   120
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   121
static void print_entry(const entry_t* e, outputStream* os) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   122
  const loaded_module_t* const lm = &(e->info);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   123
  os->print(" %c text: " INTPTR_FORMAT " - " INTPTR_FORMAT
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   124
            ", data: " INTPTR_FORMAT " - " INTPTR_FORMAT " "
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   125
            "%s",
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   126
      (lm->is_in_vm ? '*' : ' '),
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   127
      lm->text, (uintptr_t)lm->text + lm->text_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   128
      lm->data, (uintptr_t)lm->data + lm->data_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   129
      lm->path);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   130
  if (lm->member) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   131
    os->print("(%s)", lm->member);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   132
  }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   133
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   134
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   135
static entry_t* g_first = NULL;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   136
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   137
static entry_t* find_entry_for_text_address(const void* p) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   138
  for (entry_t* e = g_first; e; e = e->next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   139
    if ((uintptr_t)p >= (uintptr_t)e->info.text &&
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   140
        (uintptr_t)p < ((uintptr_t)e->info.text + e->info.text_len)) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   141
      return e;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   142
    }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   143
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   144
  return NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   145
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   146
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   147
static entry_t* find_entry_for_data_address(const void* p) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   148
  for (entry_t* e = g_first; e; e = e->next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   149
    if ((uintptr_t)p >= (uintptr_t)e->info.data &&
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   150
        (uintptr_t)p < ((uintptr_t)e->info.data + e->info.data_len)) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   151
      return e;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   152
    }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   153
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   154
  return NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   155
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   156
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   157
// Adds a new entry to the list (ordered by text address ascending).
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   158
static void add_entry_to_list(entry_t* e, entry_t** start) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   159
  entry_t* last = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   160
  entry_t* e2 = *start;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   161
  while (e2 && e2->info.text < e->info.text) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   162
    last = e2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   163
    e2 = e2->next;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   164
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   165
  if (last) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   166
    last->next = e;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   167
  } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   168
    *start = e;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   169
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   170
  e->next = e2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   171
}
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   172
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   173
static void free_entry_list(entry_t** start) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   174
  entry_t* e = *start;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   175
  while (e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   176
    entry_t* const e2 = e->next;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   177
    ::free(e);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   178
    e = e2;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   179
  }
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   180
  *start = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   181
}
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   182
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   183
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   184
// Rebuild the internal module table. If an error occurs, old table remains
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   185
// unchanged.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   186
static bool reload_table() {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   187
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   188
  bool rc = false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   189
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   190
  trcVerbose("reload module table...");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   191
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   192
  entry_t* new_list = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   193
  const struct ld_info* ldi = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   194
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   195
  // Call loadquery(L_GETINFO..) to get a list of all loaded Dlls from AIX. loadquery
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   196
  // requires a large enough buffer.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   197
  uint8_t* buffer = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   198
  size_t buflen = 1024;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   199
  for (;;) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   200
    buffer = (uint8_t*) ::realloc(buffer, buflen);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   201
    if (loadquery(L_GETINFO, buffer, buflen) == -1) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   202
      if (errno == ENOMEM) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   203
        buflen *= 2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   204
      } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   205
        trcVerbose("loadquery failed (%d)", errno);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   206
        goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   207
      }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   208
    } else {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   209
      break;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   210
    }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   211
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   212
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   213
  trcVerbose("loadquery buffer size is %llu.", buflen);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   214
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   215
  // Iterate over the loadquery result. For details see sys/ldr.h on AIX.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   216
  ldi = (struct ld_info*) buffer;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   217
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   218
  for (;;) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   219
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   220
    entry_t* e = (entry_t*) ::malloc(sizeof(entry_t));
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   221
    if (!e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   222
      trcVerbose("OOM.");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   223
      goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   224
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   225
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   226
    memset(e, 0, sizeof(entry_t));
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   227
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   228
    e->info.text = ldi->ldinfo_textorg;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   229
    e->info.text_len = ldi->ldinfo_textsize;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   230
    e->info.data = ldi->ldinfo_dataorg;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   231
    e->info.data_len = ldi->ldinfo_datasize;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   232
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   233
    e->info.path = g_stringlist.add(ldi->ldinfo_filename);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   234
    if (!e->info.path) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   235
      trcVerbose("OOM.");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   236
      goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   237
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   238
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   239
    // Extract short name
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   240
    {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   241
      const char* p = strrchr(e->info.path, '/');
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   242
      if (p) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   243
        p ++;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   244
        e->info.shortname = p;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   245
      } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   246
        e->info.shortname = e->info.path;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   247
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   248
    }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   249
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   250
    // Do we have a member name as well (see ldr.h)?
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   251
    const char* p_mbr_name =
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   252
      ldi->ldinfo_filename + strlen(ldi->ldinfo_filename) + 1;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   253
    if (*p_mbr_name) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   254
      e->info.member = g_stringlist.add(p_mbr_name);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   255
      if (!e->info.member) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   256
        trcVerbose("OOM.");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   257
        goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   258
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   259
    } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   260
      e->info.member = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   261
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   262
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   263
    if (strcmp(e->info.shortname, "libjvm.so") == 0) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   264
      // Note that this, theoretically, is fuzzy. We may accidentally contain
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   265
      // more than one libjvm.so. But that is improbable, so lets go with this
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   266
      // solution.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   267
      e->info.is_in_vm = true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   268
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   269
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   270
    trcVerbose("entry: %p %llu, %p %llu, %s %s %s, %d",
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   271
      e->info.text, e->info.text_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   272
      e->info.data, e->info.data_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   273
      e->info.path, e->info.shortname,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   274
      (e->info.member ? e->info.member : "NULL"),
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   275
      e->info.is_in_vm
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   276
    );
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   277
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   278
    // Add to list.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   279
    add_entry_to_list(e, &new_list);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   280
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   281
    // Next entry...
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   282
    if (ldi->ldinfo_next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   283
      ldi = (struct ld_info*)(((char*)ldi) + ldi->ldinfo_next);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   284
    } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   285
      break;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   286
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   287
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   288
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   289
  // We are done. All is well. Free old list and swap to new one.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   290
  if (g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   291
    free_entry_list(&g_first);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   292
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   293
  g_first = new_list;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   294
  new_list = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   295
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   296
  rc = true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   297
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   298
cleanup:
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   299
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   300
  if (new_list) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   301
    free_entry_list(&new_list);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   302
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   303
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   304
  ::free(buffer);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   305
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   306
  return rc;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   307
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   308
} // end LoadedLibraries::reload()
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   309
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   310
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   311
///////////////////////////////////////////////////////////////////////////////
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   312
// Externals
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   313
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   314
static MiscUtils::CritSect g_cs;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   315
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   316
// Rebuild the internal module table. If an error occurs, old table remains
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   317
// unchanged.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   318
bool LoadedLibraries::reload() {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   319
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   320
  return reload_table();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   321
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   322
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   323
void LoadedLibraries::print(outputStream* os) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   324
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   325
  if (!g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   326
    reload_table();
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   327
  }
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   328
  for (entry_t* e = g_first; e; e = e->next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   329
    print_entry(e, os);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   330
    os->cr();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   331
  }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   332
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   333
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   334
bool LoadedLibraries::find_for_text_address(const void* p,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   335
                                            loaded_module_t* info) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   336
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   337
  if (!g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   338
    reload_table();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   339
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   340
  const entry_t* const e = find_entry_for_text_address(p);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   341
  if (e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   342
    if (info) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   343
      *info = e->info;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   344
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   345
    return true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   346
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   347
  return false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   348
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   349
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   350
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   351
bool LoadedLibraries::find_for_data_address (
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   352
  const void* p,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   353
  loaded_module_t* info // optional. can be NULL:
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   354
) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   355
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   356
  if (!g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   357
    reload_table();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   358
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   359
  const entry_t* const e = find_entry_for_data_address(p);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   360
  if (e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   361
    if (info) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   362
      *info = e->info;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   363
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   364
    return true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   365
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   366
  return false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   367
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   368