Pisadep.c revision d51e90740114c60620c0febffd4d3ce6e280a107
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "Pcontrol.h"
#include "Pstack.h"
const char *
{
size_t i;
fp->file_plt_base == 0 ||
return (NULL);
}
Elf64_Rela r;
}
} else {
Elf32_Rel r;
}
}
return (NULL);
}
int
{
sizeof (syscall_instr) ||
return (0);
else
return (1);
}
sizeof (int_syscall_instr))
return (0);
return (1);
return (0);
}
int
{
int ret;
if (dst)
return (1);
}
return (0);
}
if (dst)
return (ret);
}
return (0);
}
int
{
if (buflen >= sizeof (syscall_instr) &&
return (1);
else
return (0);
}
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);
return (max);
switch (instr[0]) {
case 0x81: /* count is a longword */
break;
case 0x83: /* count is a byte */
break;
default:
return (max);
}
}
static void
{
}
static int
{
int nfp = 0;
struct {
} frame;
long args[32];
int rv;
int i;
/*
* Type definition for a structure corresponding to an IA32
* signal frame. Refer to the comments in Pstack.c for more info
*/
typedef struct {
int signo;
} sf_t;
init_uclist(&ucl, P);
break;
if (fp != 0 &&
/*
* 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.
*/
} else
} else {
argc = 0;
}
for (i = 0; i < argc; i++)
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);
}
static void
{
}
int
{
struct {
} frame;
int nfp = 0;
int rv = 0;
int argc;
/*
* Type definition for a structure corresponding to an IA32
* signal frame. Refer to the comments in Pstack.c for more info
*/
typedef struct {
} sigframe_t;
init_uclist(&ucl, P);
break;
if (fp != 0 &&
sizeof (frame)) {
/*
* Function arguments are not available on
* amd64 without extensive DWARF processing.
*/
argc = 0;
} else {
argc = 3;
2 * sizeof (prgreg_t))
argc = 0;
}
} else {
argc = 0;
}
break;
== sizeof (uc)) {
}
}
}
if (prevfp)
free_uclist(&ucl);
return (rv);
}
{
} else {
}
return (sp);
}
int
{
int i;
return (-1);
} else {
int i;
switch (i) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
break;
}
}
return (-1);
}
return (0);
}
int
{
int i;
return (-1);
} else {
int i;
if (pusharg > 0 &&
return (-1);
switch (i) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
default:
break;
}
}
return (0);
}
return (0);
}