hotspot/src/os/aix/vm/loadlib_aix.cpp
author psadhukhan
Tue, 08 Dec 2015 11:25:47 +0300
changeset 34802 f8f0def6f107
parent 33743 e21d93a9e062
child 34647 fafb32d71489
permissions -rw-r--r--
7160052: GlyphVector.setGlyphPosition can throw an exception on valid input Reviewed-by: jdv, serb
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
/*
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
     2
 * Copyright 2012, 2013 SAP AG. All rights reserved.
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
// for CritSect
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    39
#include "misc_aix.hpp"
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    40
#include "porting_aix.hpp"
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    41
#include "utilities/debug.hpp"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    42
#include "utilities/ostream.hpp"
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    43
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    44
// For loadquery()
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    45
#include <sys/ldr.h>
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    46
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    47
// 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
    48
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    49
// A class to "intern" eternal strings.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    50
// TODO: similar coding exists in AIX version of dladdr and potentially elsewhere: consolidate!
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    51
class StringList {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    52
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    53
  char** _list;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    54
  int _cap;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    55
  int _num;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    56
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    57
  // Enlarge list. If oom, leave old list intact and return false.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    58
  bool enlarge() {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    59
    int cap2 = _cap + 64;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    60
    char** l2 = (char**) ::realloc(_list, sizeof(char*) * cap2);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    61
    if (!l2) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    62
      return false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    63
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    64
    _list = l2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    65
    _cap = cap2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    66
    return true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    67
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    68
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    69
  // Append string to end of list.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    70
  // Returns NULL if oom.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    71
  char* append(const char* s) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    72
    if (_cap == _num) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    73
      if (!enlarge()) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    74
        return NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    75
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    76
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    77
    assert0(_cap > _num);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    78
    char* s2 = ::strdup(s);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    79
    if (!s2) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    80
      return NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    81
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    82
    _list[_num] = s2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    83
    trcVerbose("StringDir: added %s at pos %d", s2, _num);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    84
    _num ++;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    85
    return s2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    86
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    87
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    88
public:
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
    89
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    90
  StringList()
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    91
    : _list(NULL)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    92
    , _cap(0)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    93
    , _num(0)
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    94
  {}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    95
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    96
  // String is copied into the list; pointer to copy is returned.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    97
  // Returns NULL if oom.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    98
  char* add (const char* s) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
    99
    for (int i = 0; i < _num; i++) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   100
      if (strcmp(_list[i], s) == 0) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   101
        return _list[i];
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   102
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   103
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   104
    return append(s);
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   105
  }
33743
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
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   109
static StringList g_stringlist;
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
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   113
// 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
   114
// eternal - this list is rebuilt on every reload.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   115
// Note that we do not hand out those entries, but copies of them.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   116
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   117
struct entry_t {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   118
  entry_t* next;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   119
  loaded_module_t info;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   120
};
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   121
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   122
static void print_entry(const entry_t* e, outputStream* os) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   123
  const loaded_module_t* const lm = &(e->info);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   124
  os->print(" %c text: " INTPTR_FORMAT " - " INTPTR_FORMAT
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   125
            ", data: " INTPTR_FORMAT " - " INTPTR_FORMAT " "
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   126
            "%s",
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   127
      (lm->is_in_vm ? '*' : ' '),
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   128
      lm->text, (uintptr_t)lm->text + lm->text_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   129
      lm->data, (uintptr_t)lm->data + lm->data_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   130
      lm->path);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   131
  if (lm->member) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   132
    os->print("(%s)", lm->member);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   133
  }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   134
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   135
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   136
static entry_t* g_first = NULL;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   137
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   138
static entry_t* find_entry_for_text_address(const void* p) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   139
  for (entry_t* e = g_first; e; e = e->next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   140
    if ((uintptr_t)p >= (uintptr_t)e->info.text &&
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   141
        (uintptr_t)p < ((uintptr_t)e->info.text + e->info.text_len)) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   142
      return e;
22831
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
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   145
  return NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   146
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   147
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   148
static entry_t* find_entry_for_data_address(const void* p) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   149
  for (entry_t* e = g_first; e; e = e->next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   150
    if ((uintptr_t)p >= (uintptr_t)e->info.data &&
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   151
        (uintptr_t)p < ((uintptr_t)e->info.data + e->info.data_len)) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   152
      return e;
22831
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
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   155
  return NULL;
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   156
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   157
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   158
// Adds a new entry to the list (ordered by text address ascending).
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   159
static void add_entry_to_list(entry_t* e, entry_t** start) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   160
  entry_t* last = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   161
  entry_t* e2 = *start;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   162
  while (e2 && e2->info.text < e->info.text) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   163
    last = e2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   164
    e2 = e2->next;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   165
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   166
  if (last) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   167
    last->next = e;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   168
  } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   169
    *start = e;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   170
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   171
  e->next = e2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   172
}
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   173
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   174
static void free_entry_list(entry_t** start) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   175
  entry_t* e = *start;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   176
  while (e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   177
    entry_t* const e2 = e->next;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   178
    ::free(e);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   179
    e = e2;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   180
  }
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   181
  *start = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   182
}
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   183
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   184
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   185
// Rebuild the internal module table. If an error occurs, old table remains
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   186
// unchanged.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   187
static bool reload_table() {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   188
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   189
  bool rc = false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   190
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   191
  trcVerbose("reload module table...");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   192
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   193
  entry_t* new_list = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   194
  const struct ld_info* ldi = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   195
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   196
  // 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
   197
  // requires a large enough buffer.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   198
  uint8_t* buffer = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   199
  size_t buflen = 1024;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   200
  for (;;) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   201
    buffer = (uint8_t*) ::realloc(buffer, buflen);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   202
    if (loadquery(L_GETINFO, buffer, buflen) == -1) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   203
      if (errno == ENOMEM) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   204
        buflen *= 2;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   205
      } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   206
        trcVerbose("loadquery failed (%d)", errno);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   207
        goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   208
      }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   209
    } else {
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   210
      break;
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
  }
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   213
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   214
  trcVerbose("loadquery buffer size is %llu.", buflen);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   215
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   216
  // Iterate over the loadquery result. For details see sys/ldr.h on AIX.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   217
  ldi = (struct ld_info*) buffer;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   218
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   219
  for (;;) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   220
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   221
    entry_t* e = (entry_t*) ::malloc(sizeof(entry_t));
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   222
    if (!e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   223
      trcVerbose("OOM.");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   224
      goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   225
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   226
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   227
    memset(e, 0, sizeof(entry_t));
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   228
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   229
    e->info.text = ldi->ldinfo_textorg;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   230
    e->info.text_len = ldi->ldinfo_textsize;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   231
    e->info.data = ldi->ldinfo_dataorg;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   232
    e->info.data_len = ldi->ldinfo_datasize;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   233
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   234
    e->info.path = g_stringlist.add(ldi->ldinfo_filename);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   235
    if (!e->info.path) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   236
      trcVerbose("OOM.");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   237
      goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   238
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   239
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   240
    // Extract short name
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   241
    {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   242
      const char* p = strrchr(e->info.path, '/');
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   243
      if (p) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   244
        p ++;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   245
        e->info.shortname = p;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   246
      } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   247
        e->info.shortname = e->info.path;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   248
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   249
    }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   250
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   251
    // Do we have a member name as well (see ldr.h)?
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   252
    const char* p_mbr_name =
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   253
      ldi->ldinfo_filename + strlen(ldi->ldinfo_filename) + 1;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   254
    if (*p_mbr_name) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   255
      e->info.member = g_stringlist.add(p_mbr_name);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   256
      if (!e->info.member) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   257
        trcVerbose("OOM.");
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   258
        goto cleanup;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   259
      }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   260
    } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   261
      e->info.member = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   262
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   263
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   264
    if (strcmp(e->info.shortname, "libjvm.so") == 0) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   265
      // Note that this, theoretically, is fuzzy. We may accidentally contain
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   266
      // 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
   267
      // solution.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   268
      e->info.is_in_vm = true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   269
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   270
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   271
    trcVerbose("entry: %p %llu, %p %llu, %s %s %s, %d",
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   272
      e->info.text, e->info.text_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   273
      e->info.data, e->info.data_len,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   274
      e->info.path, e->info.shortname,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   275
      (e->info.member ? e->info.member : "NULL"),
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   276
      e->info.is_in_vm
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   277
    );
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   278
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   279
    // Add to list.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   280
    add_entry_to_list(e, &new_list);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   281
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   282
    // Next entry...
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   283
    if (ldi->ldinfo_next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   284
      ldi = (struct ld_info*)(((char*)ldi) + ldi->ldinfo_next);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   285
    } else {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   286
      break;
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
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   290
  // 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
   291
  if (g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   292
    free_entry_list(&g_first);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   293
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   294
  g_first = new_list;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   295
  new_list = NULL;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   296
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   297
  rc = true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   298
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   299
cleanup:
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   300
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   301
  if (new_list) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   302
    free_entry_list(&new_list);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   303
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   304
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   305
  ::free(buffer);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   306
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   307
  return rc;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   308
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   309
} // end LoadedLibraries::reload()
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   310
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   311
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   312
///////////////////////////////////////////////////////////////////////////////
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   313
// Externals
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   314
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   315
static MiscUtils::CritSect g_cs;
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   316
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   317
// Rebuild the internal module table. If an error occurs, old table remains
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   318
// unchanged.
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   319
bool LoadedLibraries::reload() {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   320
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   321
  return reload_table();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   322
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   323
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   324
void LoadedLibraries::print(outputStream* os) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   325
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   326
  if (!g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   327
    reload_table();
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   328
  }
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   329
  for (entry_t* e = g_first; e; e = e->next) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   330
    print_entry(e, os);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   331
    os->cr();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   332
  }
22831
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   333
}
1e2ba1d62103 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
   334
33743
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   335
bool LoadedLibraries::find_for_text_address(const void* p,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   336
                                            loaded_module_t* info) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   337
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   338
  if (!g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   339
    reload_table();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   340
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   341
  const entry_t* const e = find_entry_for_text_address(p);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   342
  if (e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   343
    if (info) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   344
      *info = e->info;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   345
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   346
    return true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   347
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   348
  return false;
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
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   352
bool LoadedLibraries::find_for_data_address (
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   353
  const void* p,
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   354
  loaded_module_t* info // optional. can be NULL:
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   355
) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   356
  MiscUtils::AutoCritSect lck(&g_cs);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   357
  if (!g_first) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   358
    reload_table();
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   359
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   360
  const entry_t* const e = find_entry_for_data_address(p);
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   361
  if (e) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   362
    if (info) {
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   363
      *info = e->info;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   364
    }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   365
    return true;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   366
  }
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   367
  return false;
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   368
}
e21d93a9e062 8140645: Recent Developments for AIX
stuefe
parents: 22831
diff changeset
   369