/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
#include <libdisasm.h>
#include <stdlib.h>
#ifdef DIS_STANDALONE
#include <mdb/mdb_modapi.h>
#define _MDB
#else
#include <stdio.h>
#endif
#include "libdisasm_impl.h"
static int _dis_errno;
/*
* If we're building the standalone library, then we only want to
* include support for disassembly of the native architecture.
* The regular shared library should include support for all
* architectures.
*/
extern dis_arch_t dis_arch_i386;
#endif
#if !defined(DIS_STANDALONE) || defined(__sparc)
extern dis_arch_t dis_arch_sparc;
#endif
extern dis_arch_t dis_arch_s390;
#endif
#endif
#if !defined(DIS_STANDALONE) || defined(__sparc)
#endif
#endif
};
/*
*/
#ifdef DIS_STANDALONE
void *
{
}
void
{
}
#else
void *
{
}
/*ARGSUSED*/
void
{
}
#endif
int
{
_dis_errno = error;
return (-1);
}
int
dis_errno(void)
{
return (_dis_errno);
}
const char *
{
switch (error) {
case E_DIS_NOMEM:
return ("out of memory");
case E_DIS_INVALFLAG:
return ("invalid flags for this architecture");
case E_DIS_UNSUPARCH:
return ("unsupported machine architecture");
default:
return ("unknown error");
}
}
void
{
}
void
{
}
void
{
}
void
{
}
{
int i;
/* Select an architecture based on flags */
break;
}
}
(void) dis_seterrno(E_DIS_UNSUPARCH);
return (NULL);
}
(void) dis_seterrno(E_DIS_NOMEM);
return (NULL);
}
/*
* Allow the architecture-specific code to allocate
* its private data.
*/
/* dis errno already set */
return (NULL);
}
return (dhp);
}
int
{
}
/*
* On some instruction sets (e.g., x86), we have no choice except to
* disassemble everything from the start of the symbol, and stop when we
* have reached our instruction address. If we're not in the middle of a
* known symbol, then we return the same address to indicate failure.
*/
static uint64_t
{
if (n <= 0)
return (pc);
return (res);
nseen++;
/* if we cannot make forward progress, give up */
goto done;
}
/*
* We scanned past %pc, but didn't find an instruction that
* started at %pc. This means that either the caller specified
* an invalid address, or we ran into something other than code
* during our scan. Virtually any combination of bytes can be
* construed as a valid Intel instruction, so any non-code bytes
* we encounter will have thrown off the scan.
*/
goto done;
}
done:
return (res);
}
/*
* Return the nth previous instruction's address. Return the same address
* to indicate failure.
*/
{
}
int
{
}
int
{
}
static int
{
return (-1);
}
int
{
}
int
{
#ifdef DIS_STANDALONE
#else
#endif
}
int
{
return (n);
}