2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * Create the /proc agent LWP for further operations. 2N/A * If not first reference, we already have the /proc agent LWP active. 2N/A * The agent is not available for use as a mortician or as an 2N/A * Create the special /proc agent LWP if it doesn't already exist. 2N/A * Give it the registers of the representative LWP. 2N/A /* refresh the process status */ 2N/A /* open the agent LWP files */ 2N/A * It is difficult to know how to recover from the two errors 2N/A * that follow. The agent LWP exists and we need to kill it, 2N/A * but we can't because we need it active in order to kill it. 2N/A * We just hope that these failures never occur. 2N/A * If the agent is currently asleep in a system call, attempt 2N/A * to abort the system call so it's ready to serve. 2N/A dprintf(
"Pcreate_agent: aborting agent syscall\n");
2N/A /* get the agent LWP status */ 2N/A /* refresh the process status */ 2N/A * Decrement the /proc agent agent reference count. 2N/A * On last reference, destroy the agent. 2N/A Psync(P);
/* Flush out any pending changes */ 2N/A * If the agent is currently asleep in a system call, attempt 2N/A * to abort the system call so we can terminate the agent. 2N/A dprintf(
"Pdestroy_agent: aborting agent syscall\n");
2N/A * The agent itself is destroyed by forcing it to execute 2N/A * the _lwp_exit(2) system call. Close our agent descriptors 2N/A * regardless of whether this is successful. 2N/A * Now that (hopefully) the agent has exited, refresh the 2N/A * status: the representative LWP is no longer the agent. 2N/A * Execute the syscall instruction. 2N/A int sentry;
/* old value of stop-on-syscall-entry */ 2N/A * If not already blocked, block all signals now. 2N/A * If there is a current signal, remember it and cancel it. 2N/A if (
washeld) {
/* restore the signal mask if we set it */ 2N/A * Perform system call in controlled process. 2N/A int i;
/* general index value */ 2N/A int Perr = 0;
/* local error number */ 2N/A int sexit;
/* old value of stop-on-syscall-exit */ 2N/A goto bad1;
/* dead processes can't perform system calls */ 2N/A /* We must be a 64-bit process to deal with a 64-bit process */ 2N/A * Create the /proc agent LWP in the process to do all the work. 2N/A * by virtue of the reference count.) 2N/A * Save agent's status to restore on exit. 2N/A * Validate arguments and compute the stack frame parameters. 2N/A * Begin with the current stack pointer. 2N/A * For each AT_BYREF argument, compute the necessary 2N/A * stack space and the object's stack address. 2N/A default:
/* programming error */ 2N/A default:
/* programming error */ 2N/A /* allocate stack space for BYREF argument */ 2N/A * Point of no return. 2N/A * Perform the system call entry, adjusting %sp. 2N/A * This moves the LWP to the stopped-on-syscall-entry state 2N/A * just before the arguments to the system call are fetched. 2N/A * Execute the syscall instruction and stop on syscall entry. 2N/A * The LWP is stopped at syscall entry. 2N/A * Copy objects to stack frame for each argument. 2N/A /* copy input byref parameter to process */ 2N/A * Complete the system call. 2N/A * This moves the LWP to the stopped-on-syscall-exit state. 2N/A * If the system call was _lwp_exit(), we expect that our last call 2N/A * to Pwait() will yield ENOENT because the LWP no longer exists. 2N/A * For each argument. 2N/A /* copy output byref parameter from process */ 2N/A * Get the return values from the syscall. 2N/A }
else {
/* normal return */ 2N/A * Destroy the /proc agent LWP now (or just bump down the ref count).