42643
|
1 |
/*
|
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include "precompiled.hpp"
|
|
26 |
#include "trace/traceStream.hpp"
|
|
27 |
#if INCLUDE_TRACE
|
|
28 |
#include "classfile/classLoaderData.hpp"
|
|
29 |
#include "classfile/javaClasses.inline.hpp"
|
|
30 |
#include "memory/resourceArea.hpp"
|
|
31 |
#include "oops/klass.hpp"
|
|
32 |
#include "oops/method.hpp"
|
|
33 |
#include "oops/symbol.hpp"
|
|
34 |
|
|
35 |
void TraceStream::print_val(const char* label, const Klass* val) const {
|
|
36 |
ResourceMark rm;
|
|
37 |
const char* description = "NULL";
|
|
38 |
if (val != NULL) {
|
|
39 |
const Symbol* name = val->name();
|
|
40 |
if (name != NULL) {
|
|
41 |
description = name->as_C_string();
|
|
42 |
}
|
|
43 |
}
|
|
44 |
tty->print("%s = %s", label, description);
|
|
45 |
}
|
|
46 |
|
|
47 |
void TraceStream::print_val(const char* label, const Method* val) const {
|
|
48 |
ResourceMark rm;
|
|
49 |
const char* description = "NULL";
|
|
50 |
if (val != NULL) {
|
|
51 |
description = val->name_and_sig_as_C_string();
|
|
52 |
}
|
|
53 |
tty->print("%s = %s", label, description);
|
|
54 |
}
|
|
55 |
|
|
56 |
void TraceStream::print_val(const char* label, const ClassLoaderData* cld) const {
|
|
57 |
ResourceMark rm;
|
|
58 |
if (cld == NULL || cld->is_anonymous()) {
|
|
59 |
tty->print("%s = NULL", label);
|
|
60 |
return;
|
|
61 |
}
|
|
62 |
const char* class_loader_name = "NULL";
|
|
63 |
const char* class_loader_type_name = "NULL";
|
|
64 |
const oop class_loader_oop = cld->class_loader();
|
|
65 |
|
|
66 |
if (class_loader_oop != NULL) {
|
|
67 |
const Klass* k = class_loader_oop->klass();
|
|
68 |
assert(k != NULL, "invariant");
|
|
69 |
const Symbol* klass_name_sym = k->name();
|
|
70 |
if (klass_name_sym != NULL) {
|
|
71 |
class_loader_type_name = klass_name_sym->as_C_string();
|
|
72 |
}
|
|
73 |
const oop class_loader_name_oop =
|
|
74 |
java_lang_ClassLoader::name(class_loader_oop);
|
|
75 |
if (class_loader_name_oop != NULL) {
|
|
76 |
const char* class_loader_name_from_oop =
|
|
77 |
java_lang_String::as_utf8_string(class_loader_name_oop);
|
|
78 |
if (class_loader_name_from_oop != NULL &&
|
|
79 |
class_loader_name_from_oop[0] != '\0') {
|
|
80 |
class_loader_name = class_loader_name_from_oop;
|
|
81 |
}
|
|
82 |
}
|
|
83 |
} else {
|
|
84 |
assert(class_loader_oop == NULL, "invariant");
|
|
85 |
// anonymous CLDs are excluded, this would be the boot loader
|
|
86 |
class_loader_name = "boot";
|
|
87 |
}
|
|
88 |
tty->print("%s = name=%s class=%s", label, class_loader_name, class_loader_type_name);
|
|
89 |
}
|
|
90 |
|
|
91 |
#endif // INCLUDE_TRACE
|