annotate src/share/vm/services/attachListener.hpp @ 1721:413ad0331a0c

6977924: Changes for 6975078 produce build error with certain gcc versions Summary: The changes introduced for 6975078 assign badHeapOopVal to the _allocation field in the ResourceObj class. In 32 bit linux builds with certain versions of gcc this assignment will be flagged as an error while compiling allocation.cpp. In 32 bit builds the constant value badHeapOopVal (which is cast to an intptr_t) is negative. The _allocation field is typed as an unsigned intptr_t and gcc catches this as an error. Reviewed-by: jcoomes, ysr, phh
author johnc
date Wed, 18 Aug 2010 10:59:06 -0700
parents c18cbe5936b8
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // The AttachListener thread services a queue of operations that are enqueued
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // by client tools. Each operation is identified by a name and has up to 3
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // arguments. The operation name is mapped to a function which performs the
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // operation. The function is called with an outputStream which is can use to
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // write any result data (for examples the properties command serializes
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // properties names and values to the output stream). When the function
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // complets the result value and any result data is returned to the client
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // tool.
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 #ifndef SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class AttachOperation;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 typedef jint (*AttachOperationFunction)(AttachOperation* op, outputStream* out);
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 struct AttachOperationFunctionInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 const char* name;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 AttachOperationFunction func;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 };
a61af66fc99e Initial load
duke
parents:
diff changeset
44 #endif // SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 class AttachListener: AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 static void init() KERNEL_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 static void abort() KERNEL_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // invoke to perform clean-up tasks when all clients detach
a61af66fc99e Initial load
duke
parents:
diff changeset
52 static void detachall() KERNEL_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // indicates if the Attach Listener needs to be created at startup
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static bool init_at_startup() KERNEL_RETURN_(return false;);
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // indicates if we have a trigger to start the Attach Listener
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static bool is_init_trigger() KERNEL_RETURN_(return false;);
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #ifdef SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
61 static bool is_attach_supported() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 #else // SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
64 static volatile bool _initialized;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static bool is_initialized() { return _initialized; }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 static void set_initialized() { _initialized = true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // indicates if this VM supports attach-on-demand
a61af66fc99e Initial load
duke
parents:
diff changeset
71 static bool is_attach_supported() { return !DisableAttachMechanism; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // platform specific initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
74 static int pd_init();
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // platform specific operation
a61af66fc99e Initial load
duke
parents:
diff changeset
77 static AttachOperationFunctionInfo* pd_find_operation(const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // platform specific flag change
a61af66fc99e Initial load
duke
parents:
diff changeset
80 static jint pd_set_flag(AttachOperation* op, outputStream* out);
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // platform specific detachall
a61af66fc99e Initial load
duke
parents:
diff changeset
83 static void pd_detachall();
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // platform specific data dump
a61af66fc99e Initial load
duke
parents:
diff changeset
86 static void pd_data_dump();
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // dequeue the next operation
a61af66fc99e Initial load
duke
parents:
diff changeset
89 static AttachOperation* dequeue();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 #endif // SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
91 };
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 #ifndef SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
94 class AttachOperation: public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 name_length_max = 16, // maximum length of name
a61af66fc99e Initial load
duke
parents:
diff changeset
98 arg_length_max = 1024, // maximum length of argument
a61af66fc99e Initial load
duke
parents:
diff changeset
99 arg_count_max = 3 // maximum number of arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
100 };
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // name of special operation that can be enqueued when all
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // clients detach
a61af66fc99e Initial load
duke
parents:
diff changeset
104 static char* detachall_operation_name() { return (char*)"detachall"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
107 char _name[name_length_max+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
108 char _arg[arg_count_max][arg_length_max+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
111 const char* name() const { return _name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // set the operation name
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void set_name(char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 assert(strlen(name) <= name_length_max, "exceeds maximum name length");
a61af66fc99e Initial load
duke
parents:
diff changeset
116 strcpy(_name, name);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // get an argument value
a61af66fc99e Initial load
duke
parents:
diff changeset
120 const char* arg(int i) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 assert(i>=0 && i<arg_count_max, "invalid argument index");
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return _arg[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // set an argument value
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void set_arg(int i, char* arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 assert(i>=0 && i<arg_count_max, "invalid argument index");
a61af66fc99e Initial load
duke
parents:
diff changeset
128 if (arg == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 _arg[i][0] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
130 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 assert(strlen(arg) <= arg_length_max, "exceeds maximum argument length");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 strcpy(_arg[i], arg);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // create an operation of a given name
a61af66fc99e Initial load
duke
parents:
diff changeset
137 AttachOperation(char* name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 set_name(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
139 for (int i=0; i<arg_count_max; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 set_arg(i, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // complete operation by sending result code and any result data to the client
a61af66fc99e Initial load
duke
parents:
diff changeset
145 virtual void complete(jint result, bufferedStream* result_stream) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 };
a61af66fc99e Initial load
duke
parents:
diff changeset
147 #endif // SERVICES_KERNEL