1 /* 2 * Copyright (c) 2005, 2006, 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 "incls/_precompiled.incl" 26 # include "incls/_attachListener_windows.cpp.incl" 27 28 #include <windows.h> 29 #include <signal.h> // SIGBREAK 30 31 // The AttachListener thread services a queue of operations. It blocks in the dequeue 32 // function until an operation is enqueued. A client enqueues an operation by creating 33 // a thread in this process using the Win32 CreateRemoteThread function. That thread 34 // executes a small stub generated by the client. The stub invokes the 35 // JVM_EnqueueOperation function which checks the operation parameters and enqueues 36 // the operation to the queue serviced by the attach listener. The thread created by 37 // the client is a native thread and is restricted to a single page of stack. To keep 38 // it simple operations are pre-allocated at initialization time. An enqueue thus 39 // takes a preallocated operation, populates the operation parameters, adds it to 40 // queue and wakes up the attach listener. 41 // 42 // When an operation has completed the attach listener is required to send the 43 // operation result and any result data to the client. In this implementation the 44 // client is a pipe server. In the enqueue operation it provides the name of pipe 45 // to this process. When the operation is completed this process opens the pipe and 46 // sends the result and output back to the client. Note that writing to the pipe | 1 /* 2 * Copyright (c) 2005, 2010, 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 "runtime/interfaceSupport.hpp" 27 #include "runtime/os.hpp" 28 #include "services/attachListener.hpp" 29 #include "services/dtraceAttacher.hpp" 30 31 #include <windows.h> 32 #include <signal.h> // SIGBREAK 33 34 // The AttachListener thread services a queue of operations. It blocks in the dequeue 35 // function until an operation is enqueued. A client enqueues an operation by creating 36 // a thread in this process using the Win32 CreateRemoteThread function. That thread 37 // executes a small stub generated by the client. The stub invokes the 38 // JVM_EnqueueOperation function which checks the operation parameters and enqueues 39 // the operation to the queue serviced by the attach listener. The thread created by 40 // the client is a native thread and is restricted to a single page of stack. To keep 41 // it simple operations are pre-allocated at initialization time. An enqueue thus 42 // takes a preallocated operation, populates the operation parameters, adds it to 43 // queue and wakes up the attach listener. 44 // 45 // When an operation has completed the attach listener is required to send the 46 // operation result and any result data to the client. In this implementation the 47 // client is a pipe server. In the enqueue operation it provides the name of pipe 48 // to this process. When the operation is completed this process opens the pipe and 49 // sends the result and output back to the client. Note that writing to the pipe |