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 (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * Given a return address, determine the likely number of arguments 2N/A * that were pushed on the stack prior to its execution. We do this by 2N/A * expecting that a typical call sequence consists of pushing arguments on 2N/A * the stack, executing a call instruction, and then performing an add 2N/A * on %esp to restore it to the value prior to pushing the arguments for 2N/A * the call. We attempt to detect such an add, and divide the addend 2N/A * by the size of a word to determine the number of pushed arguments. 2N/A * If we do not find such an add, this does not necessarily imply that the 2N/A * function took no arguments. It is not possible to reliably detect such a 2N/A * void function because hand-coded assembler does not always perform an add 2N/A * to %esp immediately after the "call" instruction (eg. _sys_call()). 2N/A * Because of this, we default to returning MIN(sz, TR_ARG_MAX) instead of 0 2N/A * in the absence of an add to %esp. 2N/A * Read the instruction at the return location. 2N/A case 0x81:
/* count is a longword */ 2N/A case 0x83:
/* count is a byte */ 2N/A int sig;
/* ignored unless (frame_flags & PR_FOUND_SIGNAL) */ 2N/A * Type definition for a structure corresponding to an IA32 2N/A * signal frame. Refer to the comments in Pstack.c for more info 2N/A * A return PC of -1 on x86 denotes a signal frame. We 2N/A * continue to look for a ucontext as a modest 2N/A * precaution against stack corruption. 2N/A * The bogus return PC prevents us from calling 2N/A * argcount() but we know that the signal 2N/A * handler takes three arguments (the signal 2N/A * number and pointers to a siginfo_t and a 2N/A /* Locate the next frame. */ 2N/A * In order to allow iteration over java frames (which 2N/A * can have their own frame pointers), we allow the 2N/A * iterator to change the contents of gregs. If we 2N/A * detect a change, then we assume that the new values 2N/A * point to the next frame. 2N/A * If this is a signal frame then we extract the new 2N/A * registers from the saved context, thereby allowing us 2N/A * to display the interrupted frame. 2N/A int sig;
/* ignored unless (frame_flags & PR_FOUND_SIGNAL) */ 2N/A * Type definition for a structure corresponding to an IA32 2N/A * signal frame. Refer to the comments in Pstack.c for more info 2N/A * A return PC of -1 on x86 denotes a signal frame. We 2N/A * continue to look for a ucontext as a modest 2N/A * precaution against stack corruption. 2N/A * Ordinarily, function arguments are 2N/A * unavailable on amd64 without extensive DWARF 2N/A * processing. However, we may derive them for 2N/A * the special case of the signal handler since 2N/A * we know that its signature is 2N/A * sighandler(signo, sip, ucp) 2N/A * and that these data will be present in the 2N/A /* Locate the next frame. */ 2N/A * If this is a signal frame then we extract the new 2N/A * registers from the saved context, thereby allowing us 2N/A * to display the interrupted frame.