/*
* 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.
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/privregs.h>
#include <mdb/mdb_ia32util.h>
#include <mdb/mdb_target_impl.h>
#include <mdb/mdb_kreg_impl.h>
#include <mdb/mdb_debug.h>
#include <mdb/mdb_modapi.h>
/*
* We also define an array of register names and their corresponding
* array indices. This is used by the getareg and putareg entry points,
* and also by our register variable discipline.
*/
{ NULL, 0, 0 }
};
void
{
mdb_printf("%%cs = 0x%04x\t\t%%eax = 0x%0?p %A\n",
mdb_printf("%%ds = 0x%04x\t\t%%ebx = 0x%0?p %A\n",
mdb_printf("%%ss = 0x%04x\t\t%%ecx = 0x%0?p %A\n",
mdb_printf("%%es = 0x%04x\t\t%%edx = 0x%0?p %A\n",
mdb_printf("%%fs = 0x%04x\t\t%%esi = 0x%0?p %A\n",
mdb_printf("%%gs = 0x%04x\t\t%%edi = 0x%0?p %A\n\n",
mdb_printf(" id=%u vip=%u vif=%u ac=%u vm=%u rf=%u nt=%u iopl=0x%x\n",
mdb_printf(" status=<%s,%s,%s,%s,%s,%s,%s,%s,%s>\n\n",
#ifndef _KMDB
#endif
}
/*
* Given a return address (%eip), 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.
*/
static uint_t
{
ulong_t n;
enum {
};
return (0);
return (0);
switch (ins[0]) {
case M_ADD_IMM32:
break;
case M_ADD_IMM8:
n = ins[2];
break;
default:
n = 0;
}
}
int
{
int err;
struct fr {
} fr;
int detect_exception_frames = 0;
#ifndef _KMDB
int xp;
#endif
while (fp != 0) {
err = EMDB_STKALIGN;
goto badfp;
}
} else {
err = EMDB_NOMAP;
goto badfp;
}
if (tortoise_fp == 0) {
tortoise_fp = fp;
} else {
/*
* Advance tortoise_fp every other frame, so we detect
*/
if (advance_tortoise != 0) {
tortoise_fp) != sizeof (tfr)) {
err = EMDB_NOMAP;
goto badfp;
}
}
if (fp == tortoise_fp) {
err = EMDB_STKFRAME;
goto badfp;
}
}
break;
/*
* The Xen hypervisor marks a stack frame as belonging to
* an exception by inverting the bits of the pointer to
* that frame. We attempt to identify these frames by
* inverting the pointer and seeing if it is within 0xfff
* bytes of the last frame.
*/
}
return (0);
}
/*
* Determine the return address for the current frame. Typically this is the
* fr_savpc value from the current frame, but we also perform some special
* handling to see if we are stopped on one of the first two instructions of a
* typical function prologue, in which case %ebp will not be set up yet.
*/
int
{
GElf_Sym s;
enum {
};
}
return (0);
}
return (-1); /* errno is set for us */
}
/*
* Return the address of the next instruction following a call, or return -1
* and set errno to EAGAIN if the target should just single-step. We perform
* a bit of disassembly on the current instruction in order to determine if it
* is a call and how many bytes should be skipped, depending on the exact form
* of the call instruction that is being used.
*/
int
{
uint8_t m;
enum {
};
/*
* If the opcode is a near call with relative displacement, assume the
* displacement is a rel32 from the next instruction.
*/
if (curinstr == M_CALL_REL) {
return (0);
}
/*
* If the opcode is a call near indirect or call far register opcode,
*/
if (curinstr == M_CALL_REG) {
return (-1); /* errno is set for us */
/*
* call, then skip the appropriate number of additional
* bytes depending on the addressing form that is used.
*/
if ((m & M_MODRM_OP) == M_OP_IND) {
switch (m & M_MODRM_MD) {
case M_MD_DSP8:
break;
case M_MD_DSP32:
break;
case M_MD_IND:
if ((m & M_MODRM_RM) == M_RM_DSP32) {
*p = pc + 6;
break; /* skip pr_instr, m, disp32 */
}
/* FALLTHRU */
case M_MD_REG:
break;
}
return (0);
}
}
}
/*ARGSUSED*/
int
const mdb_tgt_gregset_t *gregs)
{
if (argc != 0) {
}
mdb_printf(")\n");
return (0);
}
int
const mdb_tgt_gregset_t *gregs)
{
if (argc != 0) {
}
mdb_printf(")\n");
return (0);
}