5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <ctype.h>
32 #include <fcntl.h>
33 #include <string.h>
34 #include <memory.h>
35 #include <errno.h>
36 #include <dirent.h>
37 #include <limits.h>
38 #include <signal.h>
39 #include <sys/types.h>
40 #include <sys/uio.h>
41 #include <sys/stat.h>
42 #include <sys/resource.h>
43 #include <sys/param.h>
44 #include <sys/stack.h>
45 #include <sys/fault.h>
46 #include <sys/syscall.h>
47 #include <sys/sysmacros.h>
335 /*
336 * Save agent's status to restore on exit.
337 */
338 agent_created = TRUE;
339 save_pstatus = P->status;
340
341 if (P->state != PS_STOP || /* check state of LWP */
342 (P->status.pr_flags & PR_ASLEEP))
343 goto bad2;
344
345 if (Pscantext(P)) /* bad text ? */
346 goto bad3;
347
348 /*
349 * Validate arguments and compute the stack frame parameters.
350 * Begin with the current stack pointer.
351 */
352 #ifdef _LP64
353 if (model == PR_MODEL_LP64) {
354 sp = P->status.pr_lwp.pr_reg[R_SP] + STACK_BIAS;
355 sp = PSTACK_ALIGN64(sp);
356 } else {
357 #endif
358 sp = (uint32_t)P->status.pr_lwp.pr_reg[R_SP];
359 sp = PSTACK_ALIGN32(sp);
360 #ifdef _LP64
361 }
362 #endif
363
364 /*
365 * For each AT_BYREF argument, compute the necessary
366 * stack space and the object's stack address.
367 */
368 for (i = 0, adp = argp; i < nargs; i++, adp++) {
369 rval->sys_rval1 = i; /* in case of error */
370 switch (adp->arg_type) {
371 default: /* programming error */
372 goto bad4;
373 case AT_BYVAL: /* simple argument */
374 break;
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25 /*
26 * Copyright (c) 2013, Joyent Inc. All rights reserved.
27 */
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <unistd.h>
32 #include <ctype.h>
33 #include <fcntl.h>
34 #include <string.h>
35 #include <memory.h>
36 #include <errno.h>
37 #include <dirent.h>
38 #include <limits.h>
39 #include <signal.h>
40 #include <sys/types.h>
41 #include <sys/uio.h>
42 #include <sys/stat.h>
43 #include <sys/resource.h>
44 #include <sys/param.h>
45 #include <sys/stack.h>
46 #include <sys/fault.h>
47 #include <sys/syscall.h>
48 #include <sys/sysmacros.h>
336 /*
337 * Save agent's status to restore on exit.
338 */
339 agent_created = TRUE;
340 save_pstatus = P->status;
341
342 if (P->state != PS_STOP || /* check state of LWP */
343 (P->status.pr_flags & PR_ASLEEP))
344 goto bad2;
345
346 if (Pscantext(P)) /* bad text ? */
347 goto bad3;
348
349 /*
350 * Validate arguments and compute the stack frame parameters.
351 * Begin with the current stack pointer.
352 */
353 #ifdef _LP64
354 if (model == PR_MODEL_LP64) {
355 sp = P->status.pr_lwp.pr_reg[R_SP] + STACK_BIAS;
356 #if defined(__amd64)
357 /*
358 * To offset the expense of computerised subtraction, the AMD64
359 * ABI allows a process the use of a 128-byte area beyond the
360 * location pointed to by %rsp. We must advance the agent's
361 * stack pointer by at least the size of this region or else it
362 * may corrupt this temporary storage.
363 */
364 sp -= STACK_RESERVE64;
365 #endif
366 sp = PSTACK_ALIGN64(sp);
367 } else {
368 #endif
369 sp = (uint32_t)P->status.pr_lwp.pr_reg[R_SP];
370 sp = PSTACK_ALIGN32(sp);
371 #ifdef _LP64
372 }
373 #endif
374
375 /*
376 * For each AT_BYREF argument, compute the necessary
377 * stack space and the object's stack address.
378 */
379 for (i = 0, adp = argp; i < nargs; i++, adp++) {
380 rval->sys_rval1 = i; /* in case of error */
381 switch (adp->arg_type) {
382 default: /* programming error */
383 goto bad4;
384 case AT_BYVAL: /* simple argument */
385 break;
|