< prev index next >
src/os/aix/vm/loadlib_aix.cpp
Print this page
rev 9422 : 8143125-Further Developments for AIX
@@ -20,11 +20,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
-
// Implementation of LoadedLibraries and friends
// Ultimately this just uses loadquery()
// See:
// http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp
@@ -33,11 +32,10 @@
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#include "loadlib_aix.hpp"
-// for CritSect
#include "misc_aix.hpp"
#include "porting_aix.hpp"
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"
@@ -45,18 +43,18 @@
#include <sys/ldr.h>
// Use raw malloc instead of os::malloc - this code gets used for error reporting.
// A class to "intern" eternal strings.
-// TODO: similar coding exists in AIX version of dladdr and potentially elsewhere: consolidate!
+// TODO: similar coding exists in AIX vcersion of dladdr and potentially elsewhere: consolidate!
class StringList {
char** _list;
int _cap;
int _num;
- // Enlarge list. If oom, leave old list intact and return false.
+ // enlarge list. If oom, leave old list intact and return false.
bool enlarge() {
int cap2 = _cap + 64;
char** l2 = (char**) ::realloc(_list, sizeof(char*) * cap2);
if (!l2) {
return false;
@@ -64,12 +62,12 @@
_list = l2;
_cap = cap2;
return true;
}
- // Append string to end of list.
- // Returns NULL if oom.
+ // append string to end of list
+ // returns NULL if oom
char* append(const char* s) {
if (_cap == _num) {
if (!enlarge()) {
return NULL;
}
@@ -91,14 +89,14 @@
: _list(NULL)
, _cap(0)
, _num(0)
{}
- // String is copied into the list; pointer to copy is returned.
- // Returns NULL if oom.
+ // string is copied into the list; pointer to copy is returned.
+ // returns NULL if oom.
char* add (const char* s) {
- for (int i = 0; i < _num; i++) {
+ for (int i = 0; i < _num; i ++) {
if (strcmp(_list[i], s) == 0) {
return _list[i];
}
}
return append(s);
@@ -129,35 +127,36 @@
lm->data, (uintptr_t)lm->data + lm->data_len,
lm->path);
if (lm->member) {
os->print("(%s)", lm->member);
}
+
}
static entry_t* g_first = NULL;
static entry_t* find_entry_for_text_address(const void* p) {
for (entry_t* e = g_first; e; e = e->next) {
- if ((uintptr_t)p >= (uintptr_t)e->info.text &&
- (uintptr_t)p < ((uintptr_t)e->info.text + e->info.text_len)) {
+ if ( (uintptr_t)p >= (uintptr_t)e->info.text &&
+ (uintptr_t)p < ((uintptr_t)e->info.text + e->info.text_len) ) {
return e;
}
}
return NULL;
}
static entry_t* find_entry_for_data_address(const void* p) {
for (entry_t* e = g_first; e; e = e->next) {
- if ((uintptr_t)p >= (uintptr_t)e->info.data &&
- (uintptr_t)p < ((uintptr_t)e->info.data + e->info.data_len)) {
+ if ( (uintptr_t)p >= (uintptr_t)e->info.data &&
+ (uintptr_t)p < ((uintptr_t)e->info.data + e->info.data_len) ) {
return e;
}
}
return NULL;
}
-// Adds a new entry to the list (ordered by text address ascending).
+// adds a new entry to the list (ordered by text address ascending)
static void add_entry_to_list(entry_t* e, entry_t** start) {
entry_t* last = NULL;
entry_t* e2 = *start;
while (e2 && e2->info.text < e->info.text) {
last = e2;
@@ -180,25 +179,30 @@
}
*start = NULL;
}
-// Rebuild the internal module table. If an error occurs, old table remains
+// rebuild the internal module table. If an error occurs, old table remains
// unchanged.
static bool reload_table() {
bool rc = false;
trcVerbose("reload module table...");
entry_t* new_list = NULL;
const struct ld_info* ldi = NULL;
- // Call loadquery(L_GETINFO..) to get a list of all loaded Dlls from AIX. loadquery
+ // call loadquery(L_GETINFO..) to get a list of all loaded Dlls from AIX. loadquery
// requires a large enough buffer.
uint8_t* buffer = NULL;
- size_t buflen = 1024;
+ size_t buflen =
+#ifdef ASSERT
+ 64;
+#else
+ 1024;
+#endif
for (;;) {
buffer = (uint8_t*) ::realloc(buffer, buflen);
if (loadquery(L_GETINFO, buffer, buflen) == -1) {
if (errno == ENOMEM) {
buflen *= 2;
@@ -211,11 +215,11 @@
}
}
trcVerbose("loadquery buffer size is %llu.", buflen);
- // Iterate over the loadquery result. For details see sys/ldr.h on AIX.
+ // iterate over the loadquery result. For details see sys/ldr.h on AIX.
ldi = (struct ld_info*) buffer;
for (;;) {
entry_t* e = (entry_t*) ::malloc(sizeof(entry_t));
@@ -235,22 +239,22 @@
if (!e->info.path) {
trcVerbose("OOM.");
goto cleanup;
}
- // Extract short name
+ // extract short name
{
const char* p = strrchr(e->info.path, '/');
if (p) {
p ++;
e->info.shortname = p;
} else {
e->info.shortname = e->info.path;
}
}
- // Do we have a member name as well (see ldr.h)?
+ // do we have a member name as well (see ldr.h)?
const char* p_mbr_name =
ldi->ldinfo_filename + strlen(ldi->ldinfo_filename) + 1;
if (*p_mbr_name) {
e->info.member = g_stringlist.add(p_mbr_name);
if (!e->info.member) {
@@ -260,11 +264,11 @@
} else {
e->info.member = NULL;
}
if (strcmp(e->info.shortname, "libjvm.so") == 0) {
- // Note that this, theoretically, is fuzzy. We may accidentally contain
+ // note that this, theoretically, is fuzzy. We may accidentally contain
// more than one libjvm.so. But that is improbable, so lets go with this
// solution.
e->info.is_in_vm = true;
}
@@ -274,22 +278,22 @@
e->info.path, e->info.shortname,
(e->info.member ? e->info.member : "NULL"),
e->info.is_in_vm
);
- // Add to list.
+ // add to list
add_entry_to_list(e, &new_list);
- // Next entry...
+ // next entry...
if (ldi->ldinfo_next) {
ldi = (struct ld_info*)(((char*)ldi) + ldi->ldinfo_next);
} else {
break;
}
}
- // We are done. All is well. Free old list and swap to new one.
+ // we are done. All is well. Free old list and swap to new one.
if (g_first) {
free_entry_list(&g_first);
}
g_first = new_list;
new_list = NULL;
@@ -312,11 +316,11 @@
///////////////////////////////////////////////////////////////////////////////
// Externals
static MiscUtils::CritSect g_cs;
-// Rebuild the internal module table. If an error occurs, old table remains
+// rebuild the internal module table. If an error occurs, old table remains
// unchanged.
bool LoadedLibraries::reload() {
MiscUtils::AutoCritSect lck(&g_cs);
return reload_table();
}
@@ -330,12 +334,14 @@
print_entry(e, os);
os->cr();
}
}
-bool LoadedLibraries::find_for_text_address(const void* p,
- loaded_module_t* info) {
+
+bool LoadedLibraries::find_for_text_address (
+ const void* p, loaded_module_t* info
+) {
MiscUtils::AutoCritSect lck(&g_cs);
if (!g_first) {
reload_table();
}
const entry_t* const e = find_entry_for_text_address(p);
@@ -365,5 +371,6 @@
return true;
}
return false;
}
+
< prev index next >