Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/os/solaris/vm/attachListener_solaris.cpp
+++ new/src/os/solaris/vm/attachListener_solaris.cpp
1 1 /*
2 2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 20 * or visit www.oracle.com if you need additional information or have any
21 21 * questions.
22 22 *
23 23 */
24 24
25 25 #include "precompiled.hpp"
26 26 #include "runtime/interfaceSupport.hpp"
27 27 #include "runtime/os.hpp"
28 28 #include "services/attachListener.hpp"
29 29 #include "services/dtraceAttacher.hpp"
30 30
31 31 #include <door.h>
32 32 #include <string.h>
33 33 #include <signal.h>
34 34 #include <sys/types.h>
35 35 #include <sys/socket.h>
36 36 #include <sys/stat.h>
37 37
38 38 // stropts.h uses STR in stream ioctl defines
39 39 #undef STR
40 40 #include <stropts.h>
41 41 #undef STR
42 42 #define STR(a) #a
43 43
44 44 // The attach mechanism on Solaris is implemented using the Doors IPC
45 45 // mechanism. The first tool to attempt to attach causes the attach
46 46 // listener thread to startup. This thread creats a door that is
47 47 // associated with a function that enqueues an operation to the attach
48 48 // listener. The door is attached to a file in the file system so that
49 49 // client (tools) can locate it. To enqueue an operation to the VM the
50 50 // client calls through the door which invokes the enqueue function in
51 51 // this process. The credentials of the client are checked and if the
52 52 // effective uid matches this process then the operation is enqueued.
53 53 // When an operation completes the attach listener is required to send the
54 54 // operation result and any result data to the client. In this implementation
55 55 // the result is returned via a UNIX domain socket. A pair of connected
56 56 // sockets (socketpair) is created in the enqueue function and the file
57 57 // descriptor for one of the sockets is returned to the client as the
58 58 // return from the door call. The other end is retained in this process.
59 59 // When the operation completes the result is sent to the client and
60 60 // the socket is closed.
61 61
62 62 // forward reference
63 63 class SolarisAttachOperation;
64 64
65 65 class SolarisAttachListener: AllStatic {
66 66 private:
67 67
68 68 // the path to which we attach the door file descriptor
69 69 static char _door_path[PATH_MAX+1];
70 70 static volatile bool _has_door_path;
71 71
72 72 // door descriptor returned by door_create
73 73 static int _door_descriptor;
74 74
75 75 static void set_door_path(char* path) {
76 76 if (path == NULL) {
77 77 _has_door_path = false;
78 78 } else {
79 79 strncpy(_door_path, path, PATH_MAX);
80 80 _door_path[PATH_MAX] = '\0'; // ensure it's nul terminated
81 81 _has_door_path = true;
82 82 }
83 83 }
84 84
85 85 static void set_door_descriptor(int dd) { _door_descriptor = dd; }
86 86
87 87 // mutex to protect operation list
88 88 static mutex_t _mutex;
89 89
90 90 // semaphore to wakeup listener thread
91 91 static sema_t _wakeup;
92 92
93 93 static mutex_t* mutex() { return &_mutex; }
94 94 static sema_t* wakeup() { return &_wakeup; }
95 95
96 96 // enqueued operation list
97 97 static SolarisAttachOperation* _head;
98 98 static SolarisAttachOperation* _tail;
99 99
100 100 static SolarisAttachOperation* head() { return _head; }
101 101 static void set_head(SolarisAttachOperation* head) { _head = head; }
102 102
103 103 static SolarisAttachOperation* tail() { return _tail; }
104 104 static void set_tail(SolarisAttachOperation* tail) { _tail = tail; }
105 105
106 106 // create the door
107 107 static int create_door();
108 108
109 109 public:
110 110 enum {
111 111 ATTACH_PROTOCOL_VER = 1 // protocol version
112 112 };
113 113 enum {
114 114 ATTACH_ERROR_BADREQUEST = 100, // error code returned by
115 115 ATTACH_ERROR_BADVERSION = 101, // the door call
116 116 ATTACH_ERROR_RESOURCE = 102,
117 117 ATTACH_ERROR_INTERNAL = 103,
118 118 ATTACH_ERROR_DENIED = 104
119 119 };
120 120
121 121 // initialize the listener
122 122 static int init();
123 123
124 124 static bool has_door_path() { return _has_door_path; }
125 125 static char* door_path() { return _door_path; }
126 126 static int door_descriptor() { return _door_descriptor; }
127 127
128 128 // enqueue an operation
129 129 static void enqueue(SolarisAttachOperation* op);
130 130
131 131 // dequeue an operation
132 132 static SolarisAttachOperation* dequeue();
133 133 };
134 134
135 135
136 136 // SolarisAttachOperation is an AttachOperation that additionally encapsulates
137 137 // a socket connection to the requesting client/tool. SolarisAttachOperation
138 138 // can additionally be held in a linked list.
139 139
140 140 class SolarisAttachOperation: public AttachOperation {
141 141 private:
142 142 friend class SolarisAttachListener;
143 143
144 144 // connection to client
145 145 int _socket;
146 146
147 147 // linked list support
148 148 SolarisAttachOperation* _next;
149 149
150 150 SolarisAttachOperation* next() { return _next; }
151 151 void set_next(SolarisAttachOperation* next) { _next = next; }
152 152
153 153 public:
154 154 void complete(jint res, bufferedStream* st);
155 155
156 156 int socket() const { return _socket; }
157 157 void set_socket(int s) { _socket = s; }
158 158
159 159 SolarisAttachOperation(char* name) : AttachOperation(name) {
160 160 set_socket(-1);
161 161 set_next(NULL);
162 162 }
163 163 };
164 164
165 165 // statics
166 166 char SolarisAttachListener::_door_path[PATH_MAX+1];
167 167 volatile bool SolarisAttachListener::_has_door_path;
168 168 int SolarisAttachListener::_door_descriptor = -1;
169 169 mutex_t SolarisAttachListener::_mutex;
170 170 sema_t SolarisAttachListener::_wakeup;
171 171 SolarisAttachOperation* SolarisAttachListener::_head = NULL;
172 172 SolarisAttachOperation* SolarisAttachListener::_tail = NULL;
173 173
174 174 // Supporting class to help split a buffer into individual components
175 175 class ArgumentIterator : public StackObj {
176 176 private:
177 177 char* _pos;
178 178 char* _end;
179 179 public:
180 180 ArgumentIterator(char* arg_buffer, size_t arg_size) {
181 181 _pos = arg_buffer;
182 182 _end = _pos + arg_size - 1;
183 183 }
184 184 char* next() {
185 185 if (*_pos == '\0') {
186 186 return NULL;
187 187 }
188 188 char* res = _pos;
189 189 char* next_pos = strchr(_pos, '\0');
190 190 if (next_pos < _end) {
191 191 next_pos++;
192 192 }
193 193 _pos = next_pos;
194 194 return res;
195 195 }
196 196 };
197 197
198 198 // Calls from the door function to check that the client credentials
199 199 // match this process. Returns 0 if credentials okay, otherwise -1.
200 200 static int check_credentials() {
201 201 door_cred_t cred_info;
202 202
203 203 // get client credentials
204 204 if (door_cred(&cred_info) == -1) {
205 205 return -1; // unable to get them
206 206 }
207 207
208 208 // get our euid/eguid (probably could cache these)
209 209 uid_t euid = geteuid();
210 210 gid_t egid = getegid();
211 211
212 212 // check that the effective uid/gid matches - discuss this with Jeff.
213 213 if (cred_info.dc_euid == euid && cred_info.dc_egid == egid) {
214 214 return 0; // okay
215 215 } else {
216 216 return -1; // denied
217 217 }
218 218 }
219 219
220 220
221 221 // Parses the argument buffer to create an AttachOperation that we should
222 222 // enqueue to the attach listener.
223 223 // The buffer is expected to be formatted as follows:
224 224 // <ver>0<cmd>0<arg>0<arg>0<arg>0
225 225 // where <ver> is the version number (must be "1"), <cmd> is the command
226 226 // name ("load, "datadump", ...) and <arg> is an argument.
227 227 //
228 228 static SolarisAttachOperation* create_operation(char* argp, size_t arg_size, int* err) {
229 229 // assume bad request until parsed
230 230 *err = SolarisAttachListener::ATTACH_ERROR_BADREQUEST;
231 231
232 232 if (arg_size < 2 || argp[arg_size-1] != '\0') {
233 233 return NULL; // no ver or not null terminated
234 234 }
235 235
236 236 // Use supporting class to iterate over the buffer
237 237 ArgumentIterator args(argp, arg_size);
238 238
239 239 // First check the protocol version
240 240 char* ver = args.next();
241 241 if (ver == NULL) {
242 242 return NULL;
243 243 }
244 244 if (atoi(ver) != SolarisAttachListener::ATTACH_PROTOCOL_VER) {
245 245 *err = SolarisAttachListener::ATTACH_ERROR_BADVERSION;
246 246 return NULL;
247 247 }
248 248
249 249 // Get command name and create the operation
250 250 char* name = args.next();
251 251 if (name == NULL || strlen(name) > AttachOperation::name_length_max) {
252 252 return NULL;
253 253 }
254 254 SolarisAttachOperation* op = new SolarisAttachOperation(name);
255 255
256 256 // Iterate over the arguments
257 257 for (int i=0; i<AttachOperation::arg_count_max; i++) {
258 258 char* arg = args.next();
259 259 if (arg == NULL) {
260 260 op->set_arg(i, NULL);
261 261 } else {
262 262 if (strlen(arg) > AttachOperation::arg_length_max) {
263 263 delete op;
264 264 return NULL;
265 265 }
266 266 op->set_arg(i, arg);
267 267 }
268 268 }
269 269
270 270 // return operation
271 271 *err = 0;
272 272 return op;
273 273 }
274 274
275 275 // create special operation to indicate all clients have detached
276 276 static SolarisAttachOperation* create_detachall_operation() {
277 277 return new SolarisAttachOperation(AttachOperation::detachall_operation_name());
278 278 }
279 279
280 280 // This is door function which the client executes via a door_call.
281 281 extern "C" {
282 282 static void enqueue_proc(void* cookie, char* argp, size_t arg_size,
283 283 door_desc_t* dt, uint_t n_desc)
284 284 {
285 285 int return_fd = -1;
286 286 SolarisAttachOperation* op = NULL;
287 287
288 288 // no listener
289 289 jint res = 0;
290 290 if (!AttachListener::is_initialized()) {
291 291 // how did we get here?
292 292 debug_only(warning("door_call when not enabled"));
293 293 res = (jint)SolarisAttachListener::ATTACH_ERROR_INTERNAL;
294 294 }
295 295
296 296 // check client credentials
297 297 if (res == 0) {
298 298 if (check_credentials() != 0) {
299 299 res = (jint)SolarisAttachListener::ATTACH_ERROR_DENIED;
300 300 }
301 301 }
302 302
303 303 // if we are stopped at ShowMessageBoxOnError then maybe we can
304 304 // load a diagnostic library
305 305 if (res == 0 && is_error_reported()) {
306 306 if (ShowMessageBoxOnError) {
307 307 // TBD - support loading of diagnostic library here
308 308 }
309 309
310 310 // can't enqueue operation after fatal error
311 311 res = (jint)SolarisAttachListener::ATTACH_ERROR_RESOURCE;
312 312 }
313 313
314 314 // create the operation
315 315 if (res == 0) {
316 316 int err;
317 317 op = create_operation(argp, arg_size, &err);
318 318 res = (op == NULL) ? (jint)err : 0;
319 319 }
320 320
321 321 // create a pair of connected sockets. Store the file descriptor
322 322 // for one end in the operation and enqueue the operation. The
323 323 // file descriptor for the other end wil be returned to the client.
324 324 if (res == 0) {
325 325 int s[2];
326 326 if (socketpair(PF_UNIX, SOCK_STREAM, 0, s) < 0) {
327 327 delete op;
328 328 res = (jint)SolarisAttachListener::ATTACH_ERROR_RESOURCE;
↓ open down ↓ |
328 lines elided |
↑ open up ↑ |
329 329 } else {
330 330 op->set_socket(s[0]);
331 331 return_fd = s[1];
332 332 SolarisAttachListener::enqueue(op);
333 333 }
334 334 }
335 335
336 336 // Return 0 (success) + file descriptor, or non-0 (error)
337 337 if (res == 0) {
338 338 door_desc_t desc;
339 - desc.d_attributes = DOOR_DESCRIPTOR;
339 + desc.d_attributes = DOOR_DESCRIPTOR | DOOR_RELEASE;
340 340 desc.d_data.d_desc.d_descriptor = return_fd;
341 341 door_return((char*)&res, sizeof(res), &desc, 1);
342 342 } else {
343 343 door_return((char*)&res, sizeof(res), NULL, 0);
344 344 }
345 345 }
346 346 }
347 347
348 348 // atexit hook to detach the door and remove the file
349 349 extern "C" {
350 350 static void listener_cleanup() {
351 351 static int cleanup_done;
352 352 if (!cleanup_done) {
353 353 cleanup_done = 1;
354 354 int dd = SolarisAttachListener::door_descriptor();
355 355 if (dd >= 0) {
356 356 ::close(dd);
357 357 }
358 358 if (SolarisAttachListener::has_door_path()) {
359 359 char* path = SolarisAttachListener::door_path();
360 360 ::fdetach(path);
361 361 ::unlink(path);
362 362 }
363 363 }
364 364 }
365 365 }
366 366
367 367 // Create the door
368 368 int SolarisAttachListener::create_door() {
369 369 char door_path[PATH_MAX+1];
370 370 char initial_path[PATH_MAX+1];
371 371 int fd, res;
372 372
373 373 // register exit function
374 374 ::atexit(listener_cleanup);
375 375
376 376 // create the door descriptor
377 377 int dd = ::door_create(enqueue_proc, NULL, 0);
378 378 if (dd < 0) {
379 379 return -1;
380 380 }
381 381
382 382 // create initial file to attach door descriptor
383 383 snprintf(door_path, sizeof(door_path), "%s/.java_pid%d",
384 384 os::get_temp_directory(), os::current_process_id());
385 385 snprintf(initial_path, sizeof(initial_path), "%s.tmp", door_path);
386 386 RESTARTABLE(::creat(initial_path, S_IRUSR | S_IWUSR), fd);
387 387 if (fd == -1) {
388 388 debug_only(warning("attempt to create %s failed", initial_path));
389 389 ::door_revoke(dd);
390 390 return -1;
391 391 }
392 392 assert(fd >= 0, "bad file descriptor");
393 393 RESTARTABLE(::close(fd), res);
394 394
395 395 // attach the door descriptor to the file
396 396 if ((res = ::fattach(dd, initial_path)) == -1) {
397 397 // if busy then detach and try again
398 398 if (errno == EBUSY) {
399 399 ::fdetach(initial_path);
400 400 res = ::fattach(dd, initial_path);
401 401 }
402 402 if (res == -1) {
403 403 ::door_revoke(dd);
404 404 dd = -1;
405 405 }
406 406 }
407 407
408 408 // rename file so that clients can attach
409 409 if (dd >= 0) {
410 410 if (::rename(initial_path, door_path) == -1) {
411 411 RESTARTABLE(::close(dd), res);
412 412 ::fdetach(initial_path);
413 413 dd = -1;
414 414 }
415 415 }
416 416 if (dd >= 0) {
417 417 set_door_descriptor(dd);
418 418 set_door_path(door_path);
419 419 } else {
420 420 // unable to create door, attach it to file, or rename file into place
421 421 ::unlink(initial_path);
422 422 return -1;
423 423 }
424 424
425 425 return 0;
426 426 }
427 427
428 428 // Initialization - create the door, locks, and other initialization
429 429 int SolarisAttachListener::init() {
430 430 if (create_door()) {
431 431 return -1;
432 432 }
433 433
434 434 int status = os::Solaris::mutex_init(&_mutex);
435 435 assert_status(status==0, status, "mutex_init");
436 436
437 437 status = ::sema_init(&_wakeup, 0, NULL, NULL);
438 438 assert_status(status==0, status, "sema_init");
439 439
440 440 set_head(NULL);
441 441 set_tail(NULL);
442 442
443 443 return 0;
444 444 }
445 445
446 446 // Dequeue an operation
447 447 SolarisAttachOperation* SolarisAttachListener::dequeue() {
448 448 for (;;) {
449 449 int res;
450 450
451 451 // wait for somebody to enqueue something
452 452 while ((res = ::sema_wait(wakeup())) == EINTR)
453 453 ;
454 454 if (res) {
455 455 warning("sema_wait failed: %s", strerror(res));
456 456 return NULL;
457 457 }
458 458
459 459 // lock the list
460 460 res = os::Solaris::mutex_lock(mutex());
461 461 assert(res == 0, "mutex_lock failed");
462 462
463 463 // remove the head of the list
464 464 SolarisAttachOperation* op = head();
465 465 if (op != NULL) {
466 466 set_head(op->next());
467 467 if (head() == NULL) {
468 468 set_tail(NULL);
469 469 }
470 470 }
471 471
472 472 // unlock
473 473 os::Solaris::mutex_unlock(mutex());
474 474
475 475 // if we got an operation when return it.
476 476 if (op != NULL) {
477 477 return op;
478 478 }
479 479 }
480 480 }
481 481
482 482 // Enqueue an operation
483 483 void SolarisAttachListener::enqueue(SolarisAttachOperation* op) {
484 484 // lock list
485 485 int res = os::Solaris::mutex_lock(mutex());
486 486 assert(res == 0, "mutex_lock failed");
487 487
488 488 // enqueue at tail
489 489 op->set_next(NULL);
490 490 if (head() == NULL) {
491 491 set_head(op);
492 492 } else {
493 493 tail()->set_next(op);
494 494 }
495 495 set_tail(op);
496 496
497 497 // wakeup the attach listener
498 498 RESTARTABLE(::sema_post(wakeup()), res);
499 499 assert(res == 0, "sema_post failed");
500 500
501 501 // unlock
502 502 os::Solaris::mutex_unlock(mutex());
503 503 }
504 504
505 505
506 506 // support function - writes the (entire) buffer to a socket
507 507 static int write_fully(int s, char* buf, int len) {
508 508 do {
509 509 int n = ::write(s, buf, len);
510 510 if (n == -1) {
511 511 if (errno != EINTR) return -1;
512 512 } else {
513 513 buf += n;
514 514 len -= n;
515 515 }
516 516 }
517 517 while (len > 0);
518 518 return 0;
519 519 }
520 520
521 521 // Complete an operation by sending the operation result and any result
522 522 // output to the client. At this time the socket is in blocking mode so
523 523 // potentially we can block if there is a lot of data and the client is
524 524 // non-responsive. For most operations this is a non-issue because the
525 525 // default send buffer is sufficient to buffer everything. In the future
526 526 // if there are operations that involves a very big reply then it the
527 527 // socket could be made non-blocking and a timeout could be used.
528 528
529 529 void SolarisAttachOperation::complete(jint res, bufferedStream* st) {
530 530 if (this->socket() >= 0) {
531 531 JavaThread* thread = JavaThread::current();
532 532 ThreadBlockInVM tbivm(thread);
533 533
534 534 thread->set_suspend_equivalent();
535 535 // cleared by handle_special_suspend_equivalent_condition() or
536 536 // java_suspend_self() via check_and_wait_while_suspended()
537 537
538 538 // write operation result
539 539 char msg[32];
540 540 sprintf(msg, "%d\n", res);
541 541 int rc = write_fully(this->socket(), msg, strlen(msg));
542 542
543 543 // write any result data
544 544 if (rc == 0) {
545 545 write_fully(this->socket(), (char*) st->base(), st->size());
546 546 ::shutdown(this->socket(), 2);
547 547 }
548 548
549 549 // close socket and we're done
550 550 RESTARTABLE(::close(this->socket()), rc);
551 551
552 552 // were we externally suspended while we were waiting?
553 553 thread->check_and_wait_while_suspended();
554 554 }
555 555 delete this;
556 556 }
557 557
558 558
559 559 // AttachListener functions
560 560
561 561 AttachOperation* AttachListener::dequeue() {
562 562 JavaThread* thread = JavaThread::current();
563 563 ThreadBlockInVM tbivm(thread);
564 564
565 565 thread->set_suspend_equivalent();
566 566 // cleared by handle_special_suspend_equivalent_condition() or
567 567 // java_suspend_self() via check_and_wait_while_suspended()
568 568
569 569 AttachOperation* op = SolarisAttachListener::dequeue();
570 570
571 571 // were we externally suspended while we were waiting?
572 572 thread->check_and_wait_while_suspended();
573 573
574 574 return op;
575 575 }
576 576
577 577 int AttachListener::pd_init() {
578 578 JavaThread* thread = JavaThread::current();
579 579 ThreadBlockInVM tbivm(thread);
580 580
581 581 thread->set_suspend_equivalent();
582 582 // cleared by handle_special_suspend_equivalent_condition() or
583 583 // java_suspend_self()
584 584
585 585 int ret_code = SolarisAttachListener::init();
586 586
587 587 // were we externally suspended while we were waiting?
588 588 thread->check_and_wait_while_suspended();
589 589
590 590 return ret_code;
591 591 }
592 592
593 593 // Attach Listener is started lazily except in the case when
594 594 // +ReduseSignalUsage is used
595 595 bool AttachListener::init_at_startup() {
596 596 if (ReduceSignalUsage) {
597 597 return true;
598 598 } else {
599 599 return false;
600 600 }
601 601 }
602 602
603 603 // If the file .attach_pid<pid> exists in the working directory
604 604 // or /tmp then this is the trigger to start the attach mechanism
605 605 bool AttachListener::is_init_trigger() {
606 606 if (init_at_startup() || is_initialized()) {
607 607 return false; // initialized at startup or already initialized
608 608 }
609 609 char fn[PATH_MAX+1];
610 610 sprintf(fn, ".attach_pid%d", os::current_process_id());
611 611 int ret;
612 612 struct stat64 st;
613 613 RESTARTABLE(::stat64(fn, &st), ret);
614 614 if (ret == -1) {
615 615 snprintf(fn, sizeof(fn), "%s/.attach_pid%d",
616 616 os::get_temp_directory(), os::current_process_id());
617 617 RESTARTABLE(::stat64(fn, &st), ret);
618 618 }
619 619 if (ret == 0) {
620 620 // simple check to avoid starting the attach mechanism when
621 621 // a bogus user creates the file
622 622 if (st.st_uid == geteuid()) {
623 623 init();
624 624 return true;
625 625 }
626 626 }
627 627 return false;
628 628 }
629 629
630 630 // if VM aborts then detach/cleanup
631 631 void AttachListener::abort() {
632 632 listener_cleanup();
633 633 }
634 634
635 635 void AttachListener::pd_data_dump() {
636 636 os::signal_notify(SIGQUIT);
637 637 }
638 638
639 639 static jint enable_dprobes(AttachOperation* op, outputStream* out) {
640 640 const char* probe = op->arg(0);
641 641 if (probe == NULL || probe[0] == '\0') {
642 642 out->print_cr("No probe specified");
643 643 return JNI_ERR;
644 644 } else {
645 645 int probe_typess = atoi(probe);
646 646 if (errno) {
647 647 out->print_cr("invalid probe type");
648 648 return JNI_ERR;
649 649 } else {
650 650 DTrace::enable_dprobes(probe_typess);
651 651 return JNI_OK;
652 652 }
653 653 }
654 654 }
655 655
656 656 // platform specific operations table
657 657 static AttachOperationFunctionInfo funcs[] = {
658 658 { "enabledprobes", enable_dprobes },
659 659 { NULL, NULL }
660 660 };
661 661
662 662 AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* name) {
663 663 int i;
664 664 for (i = 0; funcs[i].name != NULL; i++) {
665 665 if (strcmp(funcs[i].name, name) == 0) {
666 666 return &funcs[i];
667 667 }
668 668 }
669 669 return NULL;
670 670 }
671 671
672 672 // Solaris specific global flag set. Currently, we support only
673 673 // changing ExtendedDTraceProbes flag.
674 674 jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) {
675 675 const char* name = op->arg(0);
676 676 assert(name != NULL, "flag name should not be null");
677 677 bool flag = true;
678 678 const char* arg1;
679 679 if ((arg1 = op->arg(1)) != NULL) {
680 680 flag = (atoi(arg1) != 0);
681 681 if (errno) {
682 682 out->print_cr("flag value has to be an integer");
683 683 return JNI_ERR;
684 684 }
685 685 }
686 686
687 687 if (strcmp(name, "ExtendedDTraceProbes") == 0) {
688 688 DTrace::set_extended_dprobes(flag);
689 689 return JNI_OK;
690 690 }
691 691
692 692 if (strcmp(name, "DTraceMonitorProbes") == 0) {
693 693 DTrace::set_monitor_dprobes(flag);
694 694 return JNI_OK;
695 695 }
696 696
697 697 out->print_cr("flag '%s' cannot be changed", name);
698 698 return JNI_ERR;
699 699 }
700 700
701 701 void AttachListener::pd_detachall() {
702 702 DTrace::detach_all_clients();
703 703 }
↓ open down ↓ |
354 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX