6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
26 */
27
28 #include <libdisasm.h>
29 #include <stdlib.h>
30 #ifdef DIS_STANDALONE
31 #include <mdb/mdb_modapi.h>
32 #endif
33
34 #include "libdisasm_impl.h"
35
36 static int _dis_errno;
37
38 /*
39 * If we're building the standalone library, then we only want to
40 * include support for disassembly of the native architecture.
41 * The regular shared library should include support for all
42 * architectures.
43 */
44 #if !defined(DIS_STANDALONE) || defined(__i386) || defined(__amd64)
45 extern dis_arch_t dis_arch_i386;
46 #endif
47 #if !defined(DIS_STANDALONE) || defined(__sparc)
48 extern dis_arch_t dis_arch_sparc;
49 #endif
50
51 static dis_arch_t *dis_archs[] = {
197 return (dhp->dh_arch->da_previnstr(dhp, pc, n));
198 }
199
200 int
201 dis_min_instrlen(dis_handle_t *dhp)
202 {
203 return (dhp->dh_arch->da_min_instrlen(dhp));
204 }
205
206 int
207 dis_max_instrlen(dis_handle_t *dhp)
208 {
209 return (dhp->dh_arch->da_max_instrlen(dhp));
210 }
211
212 int
213 dis_instrlen(dis_handle_t *dhp, uint64_t pc)
214 {
215 return (dhp->dh_arch->da_instrlen(dhp, pc));
216 }
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2012 Joshua M. Clulow <josh@sysmgr.org>
26 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 #include <libdisasm.h>
30 #include <stdlib.h>
31 #ifdef DIS_STANDALONE
32 #include <mdb/mdb_modapi.h>
33 #define _MDB
34 #include <mdb/mdb_io.h>
35 #else
36 #include <stdio.h>
37 #endif
38
39 #include "libdisasm_impl.h"
40
41 static int _dis_errno;
42
43 /*
44 * If we're building the standalone library, then we only want to
45 * include support for disassembly of the native architecture.
46 * The regular shared library should include support for all
47 * architectures.
48 */
49 #if !defined(DIS_STANDALONE) || defined(__i386) || defined(__amd64)
50 extern dis_arch_t dis_arch_i386;
51 #endif
52 #if !defined(DIS_STANDALONE) || defined(__sparc)
53 extern dis_arch_t dis_arch_sparc;
54 #endif
55
56 static dis_arch_t *dis_archs[] = {
202 return (dhp->dh_arch->da_previnstr(dhp, pc, n));
203 }
204
205 int
206 dis_min_instrlen(dis_handle_t *dhp)
207 {
208 return (dhp->dh_arch->da_min_instrlen(dhp));
209 }
210
211 int
212 dis_max_instrlen(dis_handle_t *dhp)
213 {
214 return (dhp->dh_arch->da_max_instrlen(dhp));
215 }
216
217 int
218 dis_instrlen(dis_handle_t *dhp, uint64_t pc)
219 {
220 return (dhp->dh_arch->da_instrlen(dhp, pc));
221 }
222
223 int
224 dis_vsnprintf(char *restrict s, size_t n, const char *restrict format,
225 va_list args)
226 {
227 #ifdef DIS_STANDALONE
228 return (mdb_iob_vsnprintf(s, n, format, args));
229 #else
230 return (vsnprintf(s, n, format, args));
231 #endif
232 }
233
234 int
235 dis_snprintf(char *restrict s, size_t n, const char *restrict format, ...)
236 {
237 va_list args;
238
239 va_start(args, format);
240 n = dis_vsnprintf(s, n, format, args);
241 va_end(args);
242
243 return (n);
244 }
|