Pisadep.c revision d9452f237f843c1321abb5810d2f9ee6cbeae43c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "Pcontrol.h"
#include "Pstack.h"
const char *
{
Elf32_Rel r;
size_t i;
fp->file_plt_base == 0 ||
return (NULL);
}
}
return (NULL);
}
int
{
sizeof (int_syscall_instr))
return (0);
return (1);
return (0);
}
int
{
int ret;
if (dst)
return (ret);
}
return (0);
}
/* ARGSUSED */
int
{
if (buflen < sizeof (int_syscall_instr))
return (0);
return (1);
return (0);
}
/*
* Given a return address, determine the likely number of arguments
* that were pushed on the stack prior to its execution. We do this by
* expecting that a typical call sequence consists of pushing arguments on
* the stack, executing a call instruction, and then performing an add
* on %esp to restore it to the value prior to pushing the arguments for
* the call. We attempt to detect such an add, and divide the addend
* by the size of a word to determine the number of pushed arguments.
*
* If we do not find such an add, this does not necessarily imply that the
* function took no arguments. It is not possible to reliably detect such a
* void function because hand-coded assembler does not always perform an add
* to %esp immediately after the "call" instruction (eg. _sys_call()).
* Because of this, we default to returning MIN(sz, TR_ARG_MAX) instead of 0
* in the absence of an add to %esp.
*/
static ulong_t
{
/*
* Read the instruction at the return location.
*/
return (max);
switch (instr[0]) {
case 0x81: /* count is a longword */
break;
case 0x83: /* count is a byte */
break;
default:
return (max);
}
count /= sizeof (long);
}
static void
{
}
int
{
int nfp = 0;
struct {
long fp;
long pc;
long args[32];
} frame;
int rv;
/*
* Type definition for a structure corresponding to an IA32
* signal frame. Refer to the comments in Pstack.c for more info
*/
typedef struct {
long fp;
long pc;
int signo;
} sf_t;
init_uclist(&ucl, P);
break;
if (fp != 0 &&
>= (ssize_t)(2* sizeof (long)))) {
/*
* One more trick for signal frames: the kernel sets
* the return pc of the signal frame to 0xffffffff on
* Intel IA32, so argcount won't work.
*/
sz -= 2* sizeof (long);
} else
} else {
argc = 0;
}
break;
/*
* In order to allow iteration over java frames (which can have
* their own frame pointers), we allow the iterator to change
* the contents of gregs. If we detect a change, then we assume
* that the new values point to the next frame.
*/
continue;
}
else
}
}
if (prevfp)
free_uclist(&ucl);
return (rv);
}
{
return (sp);
}
int
{
int i;
return (-1);
return (0);
}
int
{
int i;
!= sizeof (int) * (nargs+1))
return (-1);
return (0);
}