/*
* 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 <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <libgen.h>
#include <dt_impl.h>
#include <dt_pid.h>
#include <dis_tables.h>
/*ARGSUSED*/
int
{
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
}
return (1);
}
static int
{
ulong_t i;
int size;
/*
* Take a pass through the function looking for a register-dependant
* jmp instruction. This could be a jump table so we have to be
* ultra conservative.
*/
dmodel);
/*
* Assume the worst if we hit an illegal instruction.
*/
if (size <= 0) {
dt_dprintf("error at %#lx (assuming jump table)\n", i);
return (1);
}
/*
* Register-dependant jmp instructions start with a 0xff byte
* and have the modrm.reg field set to 4. They can have an
* optional REX prefix on the 64-bit ISA.
*/
dt_dprintf("found a suspected jump table at %s:%lx\n",
return (1);
}
}
return (0);
}
/*ARGSUSED*/
int
{
int size;
/*
* We allocate a few extra bytes at the end so we don't have to check
* for overrunning the buffer.
*/
dt_dprintf("mr sparkle: malloc() failed\n");
return (DT_PROC_ERR);
}
dt_dprintf("mr sparkle: Pread() failed\n");
return (DT_PROC_ERR);
}
ftp->ftps_noffs = 0;
/*
* If there's a jump table in the function we're only willing to
* instrument these specific (and equivalent) instruction sequences:
* leave
* [rep] ret
* and
* movl %ebp,%esp
* popl %ebp
* [rep] ret
*
* We do this to avoid accidentally interpreting jump table
* offsets as actual instructions.
*/
/* bail if we hit an invalid opcode */
if (size <= 0)
break;
size = 2;
size = 3;
size = 4;
size = 5;
}
}
} else {
/* bail if we hit an invalid opcode */
if (size <= 0)
break;
/* ordinary ret */
goto is_ret;
/* two-byte ret */
goto is_ret;
/* ret <imm16> */
goto is_ret;
/* two-byte ret <imm16> */
goto is_ret;
/* 32-bit displacement jmp outside of the function */
goto is_ret;
/* 8-bit displacement jmp outside of the function */
goto is_ret;
/* 32-bit disp. conditional jmp outside of the func. */
goto is_ret;
/* 8-bit disp. conditional jmp outside of the func. */
goto is_ret;
continue;
dt_dprintf("return at offset %lx\n", i);
}
}
if (ftp->ftps_noffs > 0) {
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
}
}
return (ftp->ftps_noffs);
}
/*ARGSUSED*/
int
{
} else {
ulong_t i;
int size;
dt_dprintf("mr sparkle: malloc() failed\n");
return (DT_PROC_ERR);
}
dt_dprintf("mr sparkle: Pread() failed\n");
return (DT_PROC_ERR);
}
/*
* We can't instrument offsets in functions with jump tables
* as we might interpret a jump table offset as an
* instruction.
*/
return (0);
}
if (i == off) {
break;
}
/*
* If we've passed the desired offset without a
* match, then the given offset must not lie on a
* instruction boundary.
*/
if (i > off) {
return (DT_PROC_ALIGN);
}
/*
* If we hit an invalid instruction, bail as if we
* couldn't find the offset.
*/
if (size <= 0) {
return (DT_PROC_ALIGN);
}
}
}
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
}
return (ftp->ftps_noffs);
}
/*ARGSUSED*/
int
{
int size;
ftp->ftps_noffs = 0;
dt_dprintf("mr sparkle: malloc() failed\n");
return (DT_PROC_ERR);
}
dt_dprintf("mr sparkle: Pread() failed\n");
return (DT_PROC_ERR);
}
/*
* We can't instrument offsets in functions with jump tables as
* we might interpret a jump table offset as an instruction.
*/
return (0);
}
/* bail if we hit an invalid opcode */
if (size <= 0)
break;
}
} else {
/* bail if we hit an invalid opcode */
if (size <= 0)
break;
}
}
if (ftp->ftps_noffs > 0) {
dt_dprintf("fasttrap probe creation ioctl failed: %s\n",
}
}
return (ftp->ftps_noffs);
}
typedef struct dtrace_dis {
} dtrace_dis_t;
static int
{
if (ret == FASTTRAP_INSTR) {
/*
* If we hit a byte that looks like the fasttrap provider's
* trap instruction (which doubles as the breakpoint
* instruction for debuggers) we need to query the kernel
* for the real value. This may just be part of an immediate
* value so there's no need to return an error if the
* kernel doesn't know about this address.
*/
}
return (ret);
}
static int
char dmodel)
{
return (-1);
/*
* If the instruction was a single-byte breakpoint, there may be
* another debugger attached to this process. The original instruction
* can't be recovered so this must fail.
*/
return (-1);
}