/* * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2019 SAP SE. All rights reserved. * Copyright (c) 2022, IBM Corp. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// 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! class StringList {
char** _list; int _cap; int _num;
// 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) { returnfalse;
}
_list = l2;
_cap = cap2; returntrue;
}
// Append string to end of list. // Returns NULL if oom. char* append(constchar* s) { if (_cap == _num) { if (!enlarge()) { return NULL;
}
}
assert0(_cap > _num); char* s2 = ::strdup(s); if (!s2) { return NULL;
}
_list[_num] = s2;
trcVerbose("StringDir: added %s at pos %d", s2, _num);
_num ++; return s2;
}
public:
StringList()
: _list(NULL)
, _cap(0)
, _num(0)
{}
// String is copied into the list; pointer to copy is returned. // Returns NULL if oom. char* add (constchar* s) { for (int i = 0; i < _num; i++) { if (strcmp(_list[i], s) == 0) { return _list[i];
}
} return append(s);
}
};
static StringList g_stringlist;
//////////////////////
// Entries are kept in a linked list ordered by text address. Entries are not // eternal - this list is rebuilt on every reload. // Note that we do not hand out those entries, but copies of them.
lm->path = g_stringlist.add(ldi->ldinfo_filename); if (!lm->path) {
trcVerbose("OOM."); goto cleanup;
}
// Extract short name
{ constchar* p = strrchr(lm->path, '/'); if (p) {
p ++;
lm->shortname = p;
} else {
lm->shortname = lm->path;
}
}
// Do we have a member name as well (see ldr.h)? constchar* p_mbr_name =
ldi->ldinfo_filename + strlen(ldi->ldinfo_filename) + 1; if (*p_mbr_name) {
lm->member = g_stringlist.add(p_mbr_name); if (!lm->member) {
trcVerbose("OOM."); goto cleanup;
}
} else {
lm->member = NULL;
}
if (strcmp(lm->shortname, "libjvm.so") == 0) { // 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.
lm->is_in_vm = true;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.