summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig')
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/Makefile70
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/README128
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm.i508
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm_oop.i1114
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile-swig65
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile.PL7
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/python/Makefile-swig64
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/Makefile-swig68
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/extconf.rb4
-rw-r--r--toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/tcl/Makefile-swig63
10 files changed, 0 insertions, 2091 deletions
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/Makefile b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/Makefile
deleted file mode 100644
index 44ef486b6..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/Makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-# change these values if you need to
-SWIG = swig # apt-get install swig !
-GCC = gcc
-
-CC_FLAGS = -c -fPIC
-LD_FLAGS = -shared -L../.. -ldisasm
-
-BASE_NAME = x86disasm
-
-export INTERFACE_FILE BASE_NAME SWIG GCC CC_FLAGS LD_FLAGS
-
-#====================================================
-# TARGETS
-
-all: swig
-dummy: swig swig-python swig-ruby swig-perl swig-tcl install uninstall clean
-
-swig: swig-python swig-perl
-# swig-rub swig-tcl
-
-swig-python:
- cd python && make -f Makefile-swig
-
-swig-ruby:
- cd ruby && make -f Makefile-swig
-
-swig-perl:
- cd perl && make -f Makefile-swig
-
-swig-tcl:
- cd tcl && make -f Makefile-swig
-
-# ==================================================================
-install: install-python install-perl
-# install-ruby install-tcl
-
-install-python:
- cd python && sudo make -f Makefile-swig install
-
-install-ruby:
- cd ruby && sudo make -f Makefile-swig install
-
-install-perl:
- cd perl && sudo make -f Makefile-swig install
-
-install-tcl:
- cd tcl && sudo make -f Makefile-swig install
-
-# ==================================================================
-uninstall: uninstall-python
-#uninstall-ruby uninstall-perl uninstall-tcl
-
-uninstall-python:
- cd python && sudo make -f Makefile-swig uninstall
-
-uninstall-ruby:
- cd ruby && sudo make -f Makefile-swig uninstall
-
-uninstall-perl:
- cd perl && sudo make -f Makefile-swig uninstall
-
-uninstall-tcl:
- cd tcl && sudo make -f Makefile-swig uninstall
-
-# ==================================================================
-clean:
- cd python && make -f Makefile-swig clean
- cd ruby && make -f Makefile-swig clean
- cd perl && make -f Makefile-swig clean
- cd tcl && make -f Makefile-swig clean
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/README b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/README
deleted file mode 100644
index a9fa79ec2..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/README
+++ /dev/null
@@ -1,128 +0,0 @@
- Libdisasm SWIG README
-
-The SWIG utility (www.swig.org) can be used to generate
-
-
-Building SWIG Modules
----------------------
-
- make
- make install
-
-Make and Install both build Python, Perl, Ruby, and Tcl modules. If you
-do not have one of these languages installed, comment out the relevant
-target in the main Makefile.
-
-Install uses 'sudo' to put files in the correct locations; if you
-do not have sudo installed, change the install targets.
-
-The Module API
---------------
-
-The OOP API
------------
-
-
-The Python Module
------------------
-
-To test that the module loads:
-
- bash# python
- >>> import x86disasm
- >>> x86disasm.version_string()
- '0.21-pre'
- >>>^D
- bash#
-
- >>> import x86disasm
- >>> import array
- >>> disasm = x86disasm.X86_Disasm( )
- >>> tgt = open( "/tmp/a.out", "rb" )
- >>> tgt.seek( 0, 2 )
- >>> size = tgt.tell()
- >>> tgt.seek( 0, 0 )
- >>> buf = array.array( 'B' )
- >>> buf.fromfile( tgt, size )
- >>> tgt.close()
- >>> data = x86disasm.byteArray( size )
- >>> for i in range( size ):
- ... data[i] = buf.pop(0)
- ...
- >>> del buf
- >>> del tgt
- >>> insn = disasm.disasm( data, size - 1, 0, 0 )
- >>> insn.format( x86disasm.att_syntax )
- 'jg\t0x00000047'
- >>> insn.format( x86disasm.raw_syntax )
- '0x00000000|0x00000000|2|7F 45 |||controlflow|jcc|jg|80386|General Purpose|||zero_clear sign_eq_oflow |0|0|relative|sbyte|00000047|'
- >>> ops = insn.operand_list()
- >>> node = ops.first()
- >>> while node is not None:
- ... s = node.op.format(x86disasm.raw_syntax)
- ... print s
- ... node = ops.next()
- ...
- relative|sbyte|00000047|
-
-
-
-
-
-
-The Perl Module
----------------
-
-To test that the module loads:
-
- bash# perl
- use x86disasm;
- print x86disasm::version_string() . "\n";
- ^D
- 0.21-pre
- bash#
-
-The Ruby Module
----------------
-
-To test that the module loads:
-
- bash# irb
- irb(main):001:0> require 'x86disasm'
- => true
- irb(main):002:0> X86disasm.version_string()
- => "0.21-pre"
- irb(main):003:0> x = X86disasm::X86_Disasm.new
- => #<X86disasm::X86_Disasm:0xb7d624a4>
- irb(main):004:0> x.max_register_string()
- => 8
- irb(main):003:0> ^D
- bash#
-
-The Tcl Module
----------------
-
-To test that the module loads:
-
- bash# tclsh
- % load /usr/lib/tcl8.3/x86disasm.so X86disasm
- % version_string
- 0.21-pre
- % ^D
- bash#
-
- % x86_init 0 NULL NULL
- OR
- % x86disasm dis
- _486b0708_p_x86disasm
- % puts "[dis cget -last_error]"
- 0
-
-
-
-
-The Interface Files
--------------------
-
- libdisasm.i -- interface file without shadow classes
- libdisasm_oop.i -- interface file with shadow classes
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm.i b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm.i
deleted file mode 100644
index ec1204175..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm.i
+++ /dev/null
@@ -1,508 +0,0 @@
-%module x86disasm
-%{
-#include "../../libdis.h"
-#include "../../../config.h"
-%}
-
-%rename(version_string) x86_version_string;
-%include "../../libdis.h"
-#include "../../../config.h"
-
-%inline %{
- const char * x86_version_string( void ) {
- return PACKAGE_VERSION;
- }
-%}
-
-%rename(report_codes) x86_report_codes;
-%rename(report_error) x86_report_error;
-%rename(options) x86_options;
-%rename(init) x86_init;
-%rename(set_reporter) x86_set_reporter;
-%rename(set_options) x86_set_options;
-%rename(options) x86_get_options;
-%rename(cleanup) x86_cleanup;
-%rename(reg_type) x86_reg_type;
-%rename(reg) x86_reg_t;
-%rename(eaddr) x86_ea_t;
-%rename(op_type) x86_op_type;
-%rename(optype_is_address) x86_optype_is_address;
-%rename(optype_is_relative) x86_optype_is_relative;
-%rename(op_datatype) x86_op_datatype;
-%rename(op_access) x86_op_access;
-%rename(op_flags) x86_op_flags;
-%rename(operand) x86_op_t;
-%rename(insn_group) x86_insn_group;
-%rename(insn_type) x86_insn_type;
-%rename(insn_note) x86_insn_note ;
-%rename(flag_status) x86_flag_status;
-%rename(insn_cpu) x86_insn_cpu ;
-%rename(insn_isa) x86_insn_isa ;
-%rename(insn_prefix) x86_insn_prefix ;
-%rename(insn) x86_insn_t;
-%rename(insn_is_valid) x86_insn_is_valid;
-%rename(i_disasm) x86_disasm;
-%rename(i_disasm_range) x86_disasm_range;
-%rename(i_disasm_forward) x86_disasm_forward;
-%rename(insn_operand_count) x86_operand_count;
-%rename(insn_operand_1st) x86_operand_1st;
-%rename(insn_operand_2nd) x86_operand_2nd;
-%rename(insn_operand_3rd) x86_operand_3rd;
-%rename(insn_dest_operand) x86_get_dest_operand;
-%rename(insn_src_operand) x86_get_src_operand;
-%rename(insn_imm_operand) x86_get_imm_operand;
-%rename(operand_size) x86_operand_size;
-%rename(insn_rel_offset) x86_get_rel_offset;
-%rename(insn_branch_target) x86_get_branch_target;
-%rename(insn_imm) x86_get_imm;
-%rename(insn_raw_imm) x86_get_raw_imm;
-%rename(insn_set_addr) x86_set_insn_addr;
-%rename(insn_set_offset) x86_set_insn_offset;
-%rename(insn_set_function) x86_set_insn_function;
-%rename(insn_set_block) x86_set_insn_block;
-%rename(insn_tag) x86_tag_insn;
-%rename(insn_untag) x86_untag_insn;
-%rename(insn_is_tagged) x86_insn_is_tagged;
-%rename(asm_format) x86_asm_format;
-%rename(operand_format) x86_format_operand;
-%rename(insn_format_mnemonic) x86_format_mnemonic;
-%rename(insn_format) x86_format_insn;
-%rename(header_format) x86_format_header;
-%rename(endian) x86_endian;
-%rename(size_default_address) x86_addr_size;
-%rename(size_default_operand) x86_op_size;
-%rename(size_machine_word) x86_word_size;
-%rename(size_max_insn) x86_max_insn_size;
-%rename(reg_sp) x86_sp_reg;
-%rename(reg_fp) x86_fp_reg;
-%rename(reg_ip) x86_ip_reg;
-%rename(reg_from_id) x86_reg_from_id;
-%rename(reg_from_alias) x86_get_aliased_reg;
-%rename(invariant_op) x86_invariant_op_t;
-%rename(invariant) x86_invariant_t;
-%rename(disasm_invariant) x86_invariant_disasm;
-%rename(disasm_size) x86_size_disasm;
-
-%include "carrays.i"
-
-%array_class( unsigned char, byteArray );
-
-
-%apply (unsigned char *STRING, int LENGTH) {
- (unsigned char *buf, size_t buf_len)
-};
-
-
-%newobject x86_op_copy;
-%inline %{
- x86_op_t * x86_op_copy( x86_op_t * src ) {
- x86_op_t *op;
-
- if (! src ) {
- return NULL;
- }
-
- op = (x86_op_t *) calloc( sizeof(x86_op_t), 1 );
- if ( op ) {
- memcpy( op, src, sizeof(x86_op_t) );
- }
-
- return op;
- }
-
- typedef struct x86_op_list_node {
- x86_op_t *op;
- struct x86_op_list_node *next, *prev;
- } x86_op_list_node;
-
- typedef struct x86_op_list {
- size_t count;
- x86_op_list_node *head, *tail, *curr;
- } x86_op_list;
-
- x86_op_list * x86_op_list_new () {
- x86_op_list *list = (x86_op_list *)
- calloc( sizeof(x86_op_list), 1 );
- list->count = 0;
- return list;
- }
-
- void x86_op_list_free(x86_op_list *list) {
- x86_op_list_node *node, *next;
-
- node = list->head;
- while ( node ) {
- next = node->next;
- /* free( node->insn ); */
- free( node );
- node = next;
- }
-
- free( list );
- }
-
- x86_op_list_node * x86_op_list_first(x86_op_list *list) {
- return list->head;
- }
-
- x86_op_list_node * x86_op_list_last(x86_op_list *list) {
- return list->tail;
- }
-
- x86_op_list_node * x86_op_list_next(x86_op_list *list) {
- if (! list->curr ) {
- list->curr = list->head;
- return list->head;
- }
-
- list->curr = list->curr->next;
- return list->curr;
- }
-
- x86_op_list_node * x86_op_list_prev(x86_op_list *list) {
- if (! list->curr ) {
- list->curr = list->tail;
- return list->tail;
- }
-
- list->curr = list->curr->prev;
- return list->curr;
- }
-
-%}
-
-%newobject x86_op_list_append;
-
-%inline %{
- void x86_op_list_append( x86_op_list * list, x86_op_t *op ) {
- x86_op_list_node *node = (x86_op_list_node *)
- calloc( sizeof(x86_op_list_node) , 1 );
- if (! node ) {
- return;
- }
-
- list->count++;
- if ( ! list->tail ) {
- list->head = list->tail = node;
- } else {
- list->tail->next = node;
- node->prev = list->tail;
- list->tail = node;
- }
-
- node->op = x86_op_copy( op );
- }
-
- x86_oplist_t * x86_op_list_node_copy( x86_oplist_t * list ) {
- x86_oplist_t *ptr;
- ptr = (x86_oplist_t *) calloc( sizeof(x86_oplist_t), 1 );
- if ( ptr ) {
- memcpy( &ptr->op, &list->op, sizeof(x86_op_t) );
- }
-
- return ptr;
- }
-
- x86_insn_t * x86_insn_new() {
- x86_insn_t *insn = (x86_insn_t *)
- calloc( sizeof(x86_insn_t), 1 );
- return insn;
- }
-
- void x86_insn_free( x86_insn_t *insn ) {
- x86_oplist_free( insn );
- free( insn );
- }
-%}
-
-%newobject x86_insn_copy;
-
-%inline %{
- x86_insn_t * x86_insn_copy( x86_insn_t *src) {
- x86_oplist_t *ptr, *list, *last = NULL;
- x86_insn_t *insn = (x86_insn_t *)
- calloc( sizeof(x86_insn_t), 1 );
-
- if ( insn ) {
- memcpy( insn, src, sizeof(x86_insn_t) );
- insn->operands = NULL;
- insn->block = NULL;
- insn->function = NULL;
-
- /* copy operand list */
- for ( list = src->operands; list; list = list->next ) {
- ptr = x86_op_list_node_copy( list );
-
- if (! ptr ) {
- continue;
- }
-
- if ( insn->operands ) {
- last->next = ptr;
- } else {
- insn->operands = ptr;
- }
- last = ptr;
- }
- }
-
- return insn;
- }
-
- x86_op_list * x86_insn_op_list( x86_insn_t *insn ) {
- x86_oplist_t *list = insn->operands;
- x86_op_list *op_list = x86_op_list_new();
-
- for ( list = insn->operands; list; list = list->next ) {
- x86_op_list_append( op_list, &list->op );
- }
-
- return op_list;
- }
-
- typedef struct x86_insn_list_node {
- x86_insn_t *insn;
- struct x86_insn_list_node *next, *prev;
- } x86_insn_list_node;
-
- typedef struct x86_insn_list {
- size_t count;
- x86_insn_list_node *head, *tail, *curr;
- } x86_insn_list;
-
-%}
-
-%newobject x86_insn_list_new;
-
-%inline %{
- x86_insn_list * x86_insn_list_new () {
- x86_insn_list *list = (x86_insn_list *)
- calloc( sizeof(x86_insn_list), 1 );
- list->count = 0;
- return list;
- }
-
- void x86_insn_list_free( x86_insn_list * list ) {
- x86_insn_list_node *node, *next;
-
- if (! list ) {
- return;
- }
-
- node = list->head;
- while ( node ) {
- next = node->next;
- /* free( node->insn ); */
- free( node );
- node = next;
- }
-
- free( list );
- }
-
- x86_insn_list_node * x86_insn_list_first( x86_insn_list *list ) {
- if (! list ) {
- return NULL;
- }
- return list->head;
- }
-
- x86_insn_list_node * x86_insn_list_last( x86_insn_list *list ) {
- if (! list ) {
- return NULL;
- }
- return list->tail;
- }
-
- x86_insn_list_node * x86_insn_list_next( x86_insn_list *list ) {
- if (! list ) {
- return NULL;
- }
- if (! list->curr ) {
- list->curr = list->head;
- return list->head;
- }
-
- list->curr = list->curr->next;
- return list->curr;
- }
-
- x86_insn_list_node * x86_insn_list_prev( x86_insn_list *list ) {
- if (! list ) {
- return NULL;
- }
- if (! list->curr ) {
- list->curr = list->tail;
- return list->tail;
- }
-
- list->curr = list->curr->prev;
- return list->curr;
- }
-
-%}
-
-%newobject x86_insn_list_append;
-
-%inline %{
- void x86_insn_list_append( x86_insn_list *list, x86_insn_t *insn ) {
- x86_insn_list_node *node;
- if (! list ) {
- return;
- }
-
- node = (x86_insn_list_node *)
- calloc( sizeof(x86_insn_list_node) , 1 );
-
- if (! node ) {
- return;
- }
-
- list->count++;
- if ( ! list->tail ) {
- list->head = list->tail = node;
- } else {
- list->tail->next = node;
- node->prev = list->tail;
- list->tail = node;
- }
-
- node->insn = x86_insn_copy( insn );
- }
-
- typedef struct {
- enum x86_report_codes last_error;
- void * last_error_data;
- void * disasm_callback;
- void * disasm_resolver;
- } x86disasm;
-
- void x86_default_reporter( enum x86_report_codes code,
- void *data, void *arg ) {
- x86disasm *dis = (x86disasm *) arg;
- if ( dis ) {
- dis->last_error = code;
- dis->last_error_data = data;
- }
- }
-
- void x86_default_callback( x86_insn_t *insn, void *arg ) {
- x86_insn_list *list = (x86_insn_list *) arg;
- if ( list ) {
- x86_insn_list_append( list, insn );
- }
- }
-
- /* TODO: resolver stack, maybe a callback */
- long x86_default_resolver( x86_op_t *op, x86_insn_t *insn, void *arg ) {
- x86disasm *dis = (x86disasm *) arg;
- if ( dis ) {
- //return dis->resolver( op, insn );
- return 0;
- }
-
- return 0;
- }
-
-
-%}
-
-%newobject x86disasm_new;
-
-%inline %{
- x86disasm * x86disasm_new ( enum x86_options options ) {
- x86disasm * dis = (x86disasm *)
- calloc( sizeof( x86disasm ), 1 );
- x86_init( options, x86_default_reporter, dis );
- return dis;
- }
-
- void x86disasm_free( x86disasm * dis ) {
- x86_cleanup();
- free( dis );
- }
-%}
-
-%newobject x86_disasm;
-
-%inline %{
- x86_insn_t * disasm( unsigned char *buf, size_t buf_len,
- unsigned long buf_rva, unsigned int offset ) {
- x86_insn_t *insn = calloc( sizeof( x86_insn_t ), 1 );
- x86_disasm( buf, buf_len, buf_rva, offset, insn );
- return insn;
- }
-
- int disasm_range( unsigned char *buf, size_t buf_len,
- unsigned long buf_rva, unsigned int offset,
- unsigned int len ) {
-
- x86_insn_list *list = x86_insn_list_new();
-
- if ( len > buf_len ) {
- len = buf_len;
- }
-
- return x86_disasm_range( buf, buf_rva, offset, len,
- x86_default_callback, list );
- }
-
- int disasm_forward( unsigned char *buf, size_t buf_len,
- unsigned long buf_rva, unsigned int offset ) {
- x86_insn_list *list = x86_insn_list_new();
-
- /* use default resolver: damn SWIG callbacks! */
- return x86_disasm_forward( buf, buf_len, buf_rva, offset,
- x86_default_callback, list,
- x86_default_resolver, NULL );
- }
-
- size_t disasm_invariant( unsigned char *buf, size_t buf_len,
- x86_invariant_t *inv ) {
- return x86_invariant_disasm( buf, buf_len, inv );
- }
-
- size_t disasm_size( unsigned char *buf, size_t buf_len ) {
- return x86_size_disasm( buf, buf_len );
- }
-
- int x86_max_operand_string( enum x86_asm_format format ) {
- switch ( format ) {
- case xml_syntax:
- return MAX_OP_XML_STRING;
- break;
- case raw_syntax:
- return MAX_OP_RAW_STRING;
- break;
- case native_syntax:
- case intel_syntax:
- case att_syntax:
- case unknown_syntax:
- default:
- return MAX_OP_STRING;
- break;
- }
- }
-
-
- int x86_max_insn_string( enum x86_asm_format format ) {
- switch ( format ) {
- case xml_syntax:
- return MAX_INSN_XML_STRING;
- break;
- case raw_syntax:
- return MAX_INSN_RAW_STRING;
- break;
- case native_syntax:
- case intel_syntax:
- case att_syntax:
- case unknown_syntax:
- default:
- return MAX_INSN_STRING;
- break;
- }
- }
-
- int x86_max_num_operands( ) { return MAX_NUM_OPERANDS; }
-%}
-
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm_oop.i b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm_oop.i
deleted file mode 100644
index 973a47e27..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/libdisasm_oop.i
+++ /dev/null
@@ -1,1114 +0,0 @@
-%module x86disasm
-%{
-#ifdef _MSC_VER
- typedef __int64 qword;
-#else
- typedef long long qword;
-#endif
-
-#include <sys/types.h>
-
-#define MAX_REGNAME 8
-#define MAX_PREFIX_STR 32
-#define MAX_MNEM_STR 16
-#define MAX_INSN_SIZE 20
-#define MAX_OP_STRING 32
-#define MAX_OP_RAW_STRING 64
-#define MAX_OP_XML_STRING 256
-#define MAX_NUM_OPERANDS 8
-#define MAX_INSN_STRING 512
-#define MAX_INSN_RAW_STRING 1024
-#define MAX_INSN_XML_STRING 4096
-
-#include "../../../config.h"
-
-
-const char * version_string( void ) {
- return PACKAGE_VERSION;
-}
-
-%}
-
-const char * version_string( void );
-
-%rename(X86_Register) x86_reg_t;
-%rename(X86_EAddr) x86_ea_t;
-%rename(X86_Operand) x86_op_t;
-//%rename(X86_OpList) x86_oplist_t;
-%rename(X86_Insn) x86_insn_t;
-%rename(X86_InvOperand) x86_invariant_op_t;
-%rename(X86_Invariant) x86_invariant_t;
-
-%include "carrays.i"
-
-%array_class( unsigned char, byteArray );
-
-
-%apply (unsigned char *STRING, int LENGTH) {
- (unsigned char *buf, size_t buf_len)
-};
-
-
-%inline %{
-
-
-enum x86_asm_format {
- unknown_syntax = 0, /* never use! */
- native_syntax, /* header: 35 bytes */
- intel_syntax, /* header: 23 bytes */
- att_syntax, /* header: 23 bytes */
- xml_syntax, /* header: 679 bytes */
- raw_syntax /* header: 172 bytes */
-};
-%}
-
-/* ================================================================== */
-/* operand class */
-%inline %{
- enum x86_reg_type {
- reg_gen = 0x00001, reg_in = 0x00002,
- reg_out = 0x00004, reg_local = 0x00008,
- reg_fpu = 0x00010, reg_seg = 0x00020,
- reg_simd = 0x00040, reg_sys = 0x00080,
- reg_sp = 0x00100, reg_fp = 0x00200,
- reg_pc = 0x00400, reg_retaddr = 0x00800,
- reg_cond = 0x01000, reg_zero = 0x02000,
- reg_ret = 0x04000, reg_src = 0x10000,
- reg_dest = 0x20000, reg_count = 0x40000
- };
-
- typedef struct {
- char name[MAX_REGNAME];
- enum x86_reg_type type;
- unsigned int size;
- unsigned int id;
- unsigned int alias;
- unsigned int shift;
- } x86_reg_t;
-
- void x86_reg_from_id( unsigned int id, x86_reg_t * reg );
-
- typedef struct {
- unsigned int scale;
- x86_reg_t index, base;
- long disp;
- char disp_sign;
- char disp_size;
- } x86_ea_t;
-
- enum x86_op_type {
- op_unused = 0,
- op_register = 1,
- op_immediate = 2,
- op_relative_near = 3,
- op_relative_far = 4,
- op_absolute = 5,
- op_expression = 6,
- op_offset = 7,
- op_unknown
- };
-
- enum x86_op_datatype {
- op_byte = 1, op_word = 2,
- op_dword = 3, op_qword = 4,
- op_dqword = 5, op_sreal = 6,
- op_dreal = 7, op_extreal = 8,
- op_bcd = 9, op_ssimd = 10,
- op_dsimd = 11, op_sssimd = 12,
- op_sdsimd = 13, op_descr32 = 14,
- op_descr16 = 15, op_pdescr32 = 16,
- op_pdescr16 = 17, op_fpuenv = 18,
- op_fpregset = 19,
- };
-
- enum x86_op_access {
- op_read = 1,
- op_write = 2,
- op_execute = 4
- };
-
- enum x86_op_flags {
- op_signed = 1, op_string = 2,
- op_constant = 4, op_pointer = 8,
- op_sysref = 0x010, op_implied = 0x020,
- op_hardcode = 0x40, op_es_seg = 0x100,
- op_cs_seg = 0x200, op_ss_seg = 0x300,
- op_ds_seg = 0x400, op_fs_seg = 0x500,
- op_gs_seg = 0x600
- };
-
- typedef struct {
- enum x86_op_type type;
- enum x86_op_datatype datatype;
- enum x86_op_access access;
- enum x86_op_flags flags;
- union {
- char sbyte;
- short sword;
- long sdword;
- qword sqword;
- unsigned char byte;
- unsigned short word;
- unsigned long dword;
- qword qword;
- float sreal;
- double dreal;
- unsigned char extreal[10];
- unsigned char bcd[10];
- qword dqword[2];
- unsigned char simd[16];
- unsigned char fpuenv[28];
- void * address;
- unsigned long offset;
- x86_reg_t reg;
- char relative_near;
- long relative_far;
- x86_ea_t expression;
- } data;
- void * insn;
- } x86_op_t;
-
- unsigned int x86_operand_size( x86_op_t *op );
-
- int x86_format_operand(x86_op_t *op, char *buf, int len,
- enum x86_asm_format format);
-%}
-
-%extend x86_reg_t{
- x86_reg_t * aliased_reg( ) {
- x86_reg_t * reg = (x86_reg_t * )
- calloc( sizeof(x86_reg_t), 1 );
- x86_reg_from_id( self->id, reg );
- return reg;
- }
-}
-
-%extend x86_op_t{
- size_t size() {
- return x86_operand_size( self );
- }
- char * format( enum x86_asm_format format ) {
- char *buf, *str;
- size_t len;
-
- switch ( format ) {
- case xml_syntax:
- len = MAX_OP_XML_STRING;
- break;
- case raw_syntax:
- len = MAX_OP_RAW_STRING;
- break;
- case native_syntax:
- case intel_syntax:
- case att_syntax:
- case unknown_syntax:
- default:
- len = MAX_OP_STRING;
- break;
- }
-
- buf = (char * ) calloc( len + 1, 1 );
- x86_format_operand( self, buf, len, format );
-
- /* drop buffer down to a reasonable size */
- str = strdup( buf );
- free(buf);
- return str;
- }
-
- int is_address( ) {
- if ( self->type == op_absolute ||
- self->type == op_offset ) {
- return 1;
- }
-
- return 0;
- }
-
- int is_relative( ) {
- if ( self->type == op_relative_near ||
- self->type == op_relative_far ) {
- return 1;
- }
-
- return 0;
- }
-
- %newobject copy;
- x86_op_t * copy() {
- x86_op_t *op = (x86_op_t *) calloc( sizeof(x86_op_t), 1 );
-
- if ( op ) {
- memcpy( op, self, sizeof(x86_op_t) );
- }
-
- return op;
- }
-}
-
-/* ================================================================== */
-/* operand list class */
-%inline %{
- typedef struct X86_OpListNode {
- x86_op_t *op;
- struct X86_OpListNode *next, *prev;
- } X86_OpListNode;
-
- typedef struct X86_OpList {
- size_t count;
- X86_OpListNode *head, *tail, *curr;
- } X86_OpList;
-%}
-
-%extend X86_OpList {
- X86_OpList () {
- X86_OpList *list = (X86_OpList *)
- calloc( sizeof(X86_OpList), 1 );
- list->count = 0;
- return list;
- }
-
- ~X86_OpList() {
- X86_OpListNode *node, *next;
-
- node = self->head;
- while ( node ) {
- next = node->next;
- /* free( node->insn ); */
- free( node );
- node = next;
- }
-
- free( self );
- }
-
- X86_OpListNode * first() {
- self->curr = self->head;
- return self->head;
- }
-
- X86_OpListNode * last() {
- self->curr = self->tail;
- return self->tail;
- }
-
- X86_OpListNode * next() {
- if (! self->curr ) {
- self->curr = self->head;
- return self->head;
- }
-
- self->curr = self->curr->next;
- return self->curr;
- }
-
- X86_OpListNode * prev() {
- if (! self->curr ) {
- self->curr = self->tail;
- return self->tail;
- }
-
- self->curr = self->curr->prev;
- return self->curr;
- }
-
- %newobject append;
- void append( x86_op_t *op ) {
- X86_OpListNode *node = (X86_OpListNode *)
- calloc( sizeof(X86_OpListNode) , 1 );
- if (! node ) {
- return;
- }
-
- self->count++;
- if ( ! self->tail ) {
- self->head = self->tail = node;
- } else {
- self->tail->next = node;
- node->prev = self->tail;
- self->tail = node;
- }
-
- node->op = x86_op_t_copy( op );
- }
-}
-
-%inline %{
- typedef struct x86_operand_list {
- x86_op_t op;
- struct x86_operand_list *next;
- } x86_oplist_t;
-%}
-
-%extend x86_oplist_t {
- %newobject x86_oplist_node_copy;
-}
-
-/* ================================================================== */
-/* instruction class */
-%inline %{
- x86_oplist_t * x86_oplist_node_copy( x86_oplist_t * list ) {
- x86_oplist_t *ptr;
- ptr = (x86_oplist_t *) calloc( sizeof(x86_oplist_t), 1 );
- if ( ptr ) {
- memcpy( &ptr->op, &list->op, sizeof(x86_op_t) );
- }
-
- return ptr;
- }
-
- enum x86_insn_group {
- insn_none = 0, insn_controlflow = 1,
- insn_arithmetic = 2, insn_logic = 3,
- insn_stack = 4, insn_comparison = 5,
- insn_move = 6, insn_string = 7,
- insn_bit_manip = 8, insn_flag_manip = 9,
- insn_fpu = 10, insn_interrupt = 13,
- insn_system = 14, insn_other = 15
- };
-
- enum x86_insn_type {
- insn_invalid = 0, insn_jmp = 0x1001,
- insn_jcc = 0x1002, insn_call = 0x1003,
- insn_callcc = 0x1004, insn_return = 0x1005,
- insn_add = 0x2001, insn_sub = 0x2002,
- insn_mul = 0x2003, insn_div = 0x2004,
- insn_inc = 0x2005, insn_dec = 0x2006,
- insn_shl = 0x2007, insn_shr = 0x2008,
- insn_rol = 0x2009, insn_ror = 0x200A,
- insn_and = 0x3001, insn_or = 0x3002,
- insn_xor = 0x3003, insn_not = 0x3004,
- insn_neg = 0x3005, insn_push = 0x4001,
- insn_pop = 0x4002, insn_pushregs = 0x4003,
- insn_popregs = 0x4004, insn_pushflags = 0x4005,
- insn_popflags = 0x4006, insn_enter = 0x4007,
- insn_leave = 0x4008, insn_test = 0x5001,
- insn_cmp = 0x5002, insn_mov = 0x6001,
- insn_movcc = 0x6002, insn_xchg = 0x6003,
- insn_xchgcc = 0x6004, insn_strcmp = 0x7001,
- insn_strload = 0x7002, insn_strmov = 0x7003,
- insn_strstore = 0x7004, insn_translate = 0x7005,
- insn_bittest = 0x8001, insn_bitset = 0x8002,
- insn_bitclear = 0x8003, insn_clear_carry = 0x9001,
- insn_clear_zero = 0x9002, insn_clear_oflow = 0x9003,
- insn_clear_dir = 0x9004, insn_clear_sign = 0x9005,
- insn_clear_parity = 0x9006, insn_set_carry = 0x9007,
- insn_set_zero = 0x9008, insn_set_oflow = 0x9009,
- insn_set_dir = 0x900A, insn_set_sign = 0x900B,
- insn_set_parity = 0x900C, insn_tog_carry = 0x9010,
- insn_tog_zero = 0x9020, insn_tog_oflow = 0x9030,
- insn_tog_dir = 0x9040, insn_tog_sign = 0x9050,
- insn_tog_parity = 0x9060, insn_fmov = 0xA001,
- insn_fmovcc = 0xA002, insn_fneg = 0xA003,
- insn_fabs = 0xA004, insn_fadd = 0xA005,
- insn_fsub = 0xA006, insn_fmul = 0xA007,
- insn_fdiv = 0xA008, insn_fsqrt = 0xA009,
- insn_fcmp = 0xA00A, insn_fcos = 0xA00C,
- insn_fldpi = 0xA00D, insn_fldz = 0xA00E,
- insn_ftan = 0xA00F, insn_fsine = 0xA010,
- insn_fsys = 0xA020, insn_int = 0xD001,
- insn_intcc = 0xD002, insn_iret = 0xD003,
- insn_bound = 0xD004, insn_debug = 0xD005,
- insn_trace = 0xD006, insn_invalid_op = 0xD007,
- insn_oflow = 0xD008, insn_halt = 0xE001,
- insn_in = 0xE002, insn_out = 0xE003,
- insn_cpuid = 0xE004, insn_nop = 0xF001,
- insn_bcdconv = 0xF002, insn_szconv = 0xF003
- };
-
- enum x86_insn_note {
- insn_note_ring0 = 1,
- insn_note_smm = 2,
- insn_note_serial = 4
- };
-
- enum x86_flag_status {
- insn_carry_set = 0x1,
- insn_zero_set = 0x2,
- insn_oflow_set = 0x4,
- insn_dir_set = 0x8,
- insn_sign_set = 0x10,
- insn_parity_set = 0x20,
- insn_carry_or_zero_set = 0x40,
- insn_zero_set_or_sign_ne_oflow = 0x80,
- insn_carry_clear = 0x100,
- insn_zero_clear = 0x200,
- insn_oflow_clear = 0x400,
- insn_dir_clear = 0x800,
- insn_sign_clear = 0x1000,
- insn_parity_clear = 0x2000,
- insn_sign_eq_oflow = 0x4000,
- insn_sign_ne_oflow = 0x8000
- };
-
- enum x86_insn_cpu {
- cpu_8086 = 1, cpu_80286 = 2,
- cpu_80386 = 3, cpu_80387 = 4,
- cpu_80486 = 5, cpu_pentium = 6,
- cpu_pentiumpro = 7, cpu_pentium2 = 8,
- cpu_pentium3 = 9, cpu_pentium4 = 10,
- cpu_k6 = 16, cpu_k7 = 32,
- cpu_athlon = 48
- };
-
- enum x86_insn_isa {
- isa_gp = 1, isa_fp = 2,
- isa_fpumgt = 3, isa_mmx = 4,
- isa_sse1 = 5, isa_sse2 = 6,
- isa_sse3 = 7, isa_3dnow = 8,
- isa_sys = 9
- };
-
- enum x86_insn_prefix {
- insn_no_prefix = 0,
- insn_rep_zero = 1,
- insn_rep_notzero = 2,
- insn_lock = 4
- };
-
-
- typedef struct {
- unsigned long addr;
- unsigned long offset;
- enum x86_insn_group group;
- enum x86_insn_type type;
- enum x86_insn_note note;
- unsigned char bytes[MAX_INSN_SIZE];
- unsigned char size;
- unsigned char addr_size;
- unsigned char op_size;
- enum x86_insn_cpu cpu;
- enum x86_insn_isa isa;
- enum x86_flag_status flags_set;
- enum x86_flag_status flags_tested;
- unsigned char stack_mod;
- long stack_mod_val;
- enum x86_insn_prefix prefix;
- char prefix_string[MAX_PREFIX_STR];
- char mnemonic[MAX_MNEM_STR];
- x86_oplist_t *operands;
- size_t operand_count;
- size_t explicit_count;
- void *block;
- void *function;
- int tag;
- } x86_insn_t;
-
- typedef void (*x86_operand_fn)(x86_op_t *op, x86_insn_t *insn,
- void *arg);
-
- enum x86_op_foreach_type {
- op_any = 0,
- op_dest = 1,
- op_src = 2,
- op_ro = 3,
- op_wo = 4,
- op_xo = 5,
- op_rw = 6,
- op_implicit = 0x10,
- op_explicit = 0x20
- };
-
- size_t x86_operand_count( x86_insn_t *insn,
- enum x86_op_foreach_type type );
- x86_op_t * x86_operand_1st( x86_insn_t *insn );
- x86_op_t * x86_operand_2nd( x86_insn_t *insn );
- x86_op_t * x86_operand_3rd( x86_insn_t *insn );
- long x86_get_rel_offset( x86_insn_t *insn );
- x86_op_t * x86_get_branch_target( x86_insn_t *insn );
- x86_op_t * x86_get_imm( x86_insn_t *insn );
- unsigned char * x86_get_raw_imm( x86_insn_t *insn );
- void x86_set_insn_addr( x86_insn_t *insn, unsigned long addr );
- int x86_format_mnemonic(x86_insn_t *insn, char *buf, int len,
- enum x86_asm_format format);
- int x86_format_insn(x86_insn_t *insn, char *buf, int len,
- enum x86_asm_format);
- void x86_oplist_free( x86_insn_t *insn );
- int x86_insn_is_valid( x86_insn_t *insn );
-%}
-
-%extend x86_insn_t {
- x86_insn_t() {
- x86_insn_t *insn = (x86_insn_t *)
- calloc( sizeof(x86_insn_t), 1 );
- return insn;
- }
- ~x86_insn_t() {
- x86_oplist_free( self );
- free( self );
- }
-
- int is_valid( ) {
- return x86_insn_is_valid( self );
- }
-
- x86_op_t * operand_1st() {
- return x86_operand_1st( self );
- }
-
- x86_op_t * operand_2nd() {
- return x86_operand_2nd( self );
- }
-
- x86_op_t * operand_3rd() {
- return x86_operand_3rd( self );
- }
-
- x86_op_t * operand_dest() {
- return x86_operand_1st( self );
- }
-
- x86_op_t * operand_src() {
- return x86_operand_2nd( self );
- }
-
- size_t num_operands( enum x86_op_foreach_type type ) {
- return x86_operand_count( self, type );
- }
-
- long rel_offset() {
- return x86_get_rel_offset( self );
- }
-
- x86_op_t * branch_target() {
- return x86_get_branch_target( self );
- }
-
- x86_op_t * imm() {
- return x86_get_imm( self );
- }
-
- unsigned char * raw_imm() {
- return x86_get_raw_imm( self );
- }
-
- %newobject format;
- char * format( enum x86_asm_format format ) {
- char *buf, *str;
- size_t len;
-
- switch ( format ) {
- case xml_syntax:
- len = MAX_INSN_XML_STRING;
- break;
- case raw_syntax:
- len = MAX_INSN_RAW_STRING;
- break;
- case native_syntax:
- case intel_syntax:
- case att_syntax:
- case unknown_syntax:
- default:
- len = MAX_INSN_STRING;
- break;
- }
-
- buf = (char * ) calloc( len + 1, 1 );
- x86_format_insn( self, buf, len, format );
-
- /* drop buffer down to a reasonable size */
- str = strdup( buf );
- free(buf);
- return str;
- }
-
- %newobject format_mnemonic;
- char * format_mnemonic( enum x86_asm_format format ) {
- char *buf, *str;
- size_t len = MAX_MNEM_STR + MAX_PREFIX_STR + 4;
-
- buf = (char * ) calloc( len, 1 );
- x86_format_mnemonic( self, buf, len, format );
-
- /* drop buffer down to a reasonable size */
- str = strdup( buf );
- free(buf);
-
- return str;
- }
-
- %newobject copy;
- x86_insn_t * copy() {
- x86_oplist_t *ptr, *list, *last = NULL;
- x86_insn_t *insn = (x86_insn_t *)
- calloc( sizeof(x86_insn_t), 1 );
-
- if ( insn ) {
- memcpy( insn, self, sizeof(x86_insn_t) );
- insn->operands = NULL;
- insn->block = NULL;
- insn->function = NULL;
-
- /* copy operand list */
- for ( list = self->operands; list; list = list->next ) {
- ptr = x86_oplist_node_copy( list );
-
- if (! ptr ) {
- continue;
- }
-
- if ( insn->operands ) {
- last->next = ptr;
- } else {
- insn->operands = ptr;
- }
- last = ptr;
- }
- }
-
- return insn;
- }
-
- X86_OpList * operand_list( ) {
- x86_oplist_t *list = self->operands;
- X86_OpList *op_list = new_X86_OpList();
-
- for ( list = self->operands; list; list = list->next ) {
- X86_OpList_append( op_list, &list->op );
- }
-
- return op_list;
- }
-}
-
-/* ================================================================== */
-/* invariant instruction class */
-%inline %{
- #define X86_WILDCARD_BYTE 0xF4
-
- typedef struct {
- enum x86_op_type type;
- enum x86_op_datatype datatype;
- enum x86_op_access access;
- enum x86_op_flags flags;
- } x86_invariant_op_t;
-
- typedef struct {
- unsigned char bytes[64];
- unsigned int size;
- enum x86_insn_group group;
- enum x86_insn_type type;
- x86_invariant_op_t operands[3];
- } x86_invariant_t;
-%}
-
-%extend x86_invariant_t {
-
- x86_invariant_t() {
- x86_invariant_t *inv = (x86_invariant_t *)
- calloc( sizeof(x86_invariant_t), 1 );
- return inv;
- }
-
- ~x86_invariant_t() {
- free( self );
- }
-}
-
-/* ================================================================== */
-/* instruction list class */
-%inline %{
- typedef struct X86_InsnListNode {
- x86_insn_t *insn;
- struct X86_InsnListNode *next, *prev;
- } X86_InsnListNode;
-
- typedef struct X86_InsnList {
- size_t count;
- X86_InsnListNode *head, *tail, *curr;
- } X86_InsnList;
-%}
-
-%extend X86_InsnList {
- X86_InsnList () {
- X86_InsnList *list = (X86_InsnList *)
- calloc( sizeof(X86_InsnList), 1 );
- list->count = 0;
- return list;
- }
-
- ~X86_InsnList() {
- X86_InsnListNode *node, *next;
-
- node = self->head;
- while ( node ) {
- next = node->next;
- /* free( node->insn ); */
- free( node );
- node = next;
- }
-
- free( self );
- }
-
- X86_InsnListNode * first() { return self->head; }
-
- X86_InsnListNode * last() { return self->tail; }
-
- X86_InsnListNode * next() {
- if (! self->curr ) {
- self->curr = self->head;
- return self->head;
- }
-
- self->curr = self->curr->next;
- return self->curr;
- }
-
- X86_InsnListNode * prev() {
- if (! self->curr ) {
- self->curr = self->tail;
- return self->tail;
- }
-
- self->curr = self->curr->prev;
- return self->curr;
- }
-
- %newobject append;
- void append( x86_insn_t *insn ) {
- X86_InsnListNode *node = (X86_InsnListNode *)
- calloc( sizeof(X86_InsnListNode) , 1 );
- if (! node ) {
- return;
- }
-
- self->count++;
- if ( ! self->tail ) {
- self->head = self->tail = node;
- } else {
- self->tail->next = node;
- node->prev = self->tail;
- self->tail = node;
- }
-
- node->insn = x86_insn_t_copy( insn );
- }
-}
-
-/* ================================================================== */
-/* address table class */
-/* slight TODO */
-
-/* ================================================================== */
-/* Main disassembler class */
-%inline %{
-
- enum x86_options {
- opt_none= 0,
- opt_ignore_nulls=1,
- opt_16_bit=2
- };
- enum x86_report_codes {
- report_disasm_bounds,
- report_insn_bounds,
- report_invalid_insn,
- report_unknown
- };
-
-
- typedef struct {
- enum x86_report_codes last_error;
- void * last_error_data;
- void * disasm_callback;
- void * disasm_resolver;
- } X86_Disasm;
-
- typedef void (*DISASM_REPORTER)( enum x86_report_codes code,
- void *data, void *arg );
- typedef void (*DISASM_CALLBACK)( x86_insn_t *insn, void * arg );
- typedef long (*DISASM_RESOLVER)( x86_op_t *op,
- x86_insn_t * current_insn,
- void *arg );
-
- void x86_report_error( enum x86_report_codes code, void *data );
- int x86_init( enum x86_options options, DISASM_REPORTER reporter,
- void *arg);
- void x86_set_reporter( DISASM_REPORTER reporter, void *arg);
- void x86_set_options( enum x86_options options );
- enum x86_options x86_get_options( void );
- int x86_cleanup(void);
- int x86_format_header( char *buf, int len, enum x86_asm_format format);
- unsigned int x86_endian(void);
- unsigned int x86_addr_size(void);
- unsigned int x86_op_size(void);
- unsigned int x86_word_size(void);
- unsigned int x86_max_insn_size(void);
- unsigned int x86_sp_reg(void);
- unsigned int x86_fp_reg(void);
- unsigned int x86_ip_reg(void);
- size_t x86_invariant_disasm( unsigned char *buf, int buf_len,
- x86_invariant_t *inv );
- size_t x86_size_disasm( unsigned char *buf, unsigned int buf_len );
- int x86_disasm( unsigned char *buf, unsigned int buf_len,
- unsigned long buf_rva, unsigned int offset,
- x86_insn_t * insn );
- int x86_disasm_range( unsigned char *buf, unsigned long buf_rva,
- unsigned int offset, unsigned int len,
- DISASM_CALLBACK func, void *arg );
- int x86_disasm_forward( unsigned char *buf, unsigned int buf_len,
- unsigned long buf_rva, unsigned int offset,
- DISASM_CALLBACK func, void *arg,
- DISASM_RESOLVER resolver, void *r_arg );
-
- void x86_default_reporter( enum x86_report_codes code,
- void *data, void *arg ) {
- X86_Disasm *dis = (X86_Disasm *) arg;
- if ( dis ) {
- dis->last_error = code;
- dis->last_error_data = data;
- }
- }
-
- void x86_default_callback( x86_insn_t *insn, void *arg ) {
- X86_InsnList *list = (X86_InsnList *) arg;
- if ( list ) {
- X86_InsnList_append( list, insn );
- }
- }
-
- /* TODO: resolver stack, maybe a callback */
- long x86_default_resolver( x86_op_t *op, x86_insn_t *insn, void *arg ) {
- X86_Disasm *dis = (X86_Disasm *) arg;
- if ( dis ) {
- //return dis->resolver( op, insn );
- return 0;
- }
-
- return 0;
- }
-
-%}
-
-%extend X86_Disasm {
-
- X86_Disasm( ) {
- X86_Disasm * dis = (X86_Disasm *)
- calloc( sizeof( X86_Disasm ), 1 );
- x86_init( opt_none, x86_default_reporter, dis );
- return dis;
- }
-
- X86_Disasm( enum x86_options options ) {
- X86_Disasm * dis = (X86_Disasm *)
- calloc( sizeof( X86_Disasm ), 1 );
- x86_init( options, x86_default_reporter, dis );
- return dis;
- }
-
- X86_Disasm( enum x86_options options, DISASM_REPORTER reporter ) {
- X86_Disasm * dis = (X86_Disasm *)
- calloc( sizeof( X86_Disasm ), 1 );
- x86_init( options, reporter, NULL );
- return dis;
- }
-
- X86_Disasm( enum x86_options options, DISASM_REPORTER reporter,
- void * arg ) {
- X86_Disasm * dis = (X86_Disasm *)
- calloc( sizeof( X86_Disasm ), 1 );
- x86_init( options, reporter, arg );
- return dis;
- }
-
- ~X86_Disasm() {
- x86_cleanup();
- free( self );
- }
-
- void set_options( enum x86_options options ) {
- return x86_set_options( options );
- }
-
- enum x86_options options() {
- return x86_get_options();
- }
-
- void set_callback( void * callback ) {
- self->disasm_callback = callback;
- }
-
- void set_resolver( void * callback ) {
- self->disasm_resolver = callback;
- }
-
- void report_error( enum x86_report_codes code ) {
- x86_report_error( code, NULL );
- }
-
- %newobject disasm;
- x86_insn_t * disasm( unsigned char *buf, size_t buf_len,
- unsigned long buf_rva, unsigned int offset ) {
- x86_insn_t *insn = calloc( sizeof( x86_insn_t ), 1 );
- x86_disasm( buf, buf_len, buf_rva, offset, insn );
- return insn;
- }
-
- int disasm_range( unsigned char *buf, size_t buf_len,
- unsigned long buf_rva, unsigned int offset,
- unsigned int len ) {
-
- X86_InsnList *list = new_X86_InsnList();
-
- if ( len > buf_len ) {
- len = buf_len;
- }
-
- return x86_disasm_range( buf, buf_rva, offset, len,
- x86_default_callback, list );
- }
-
- int disasm_forward( unsigned char *buf, size_t buf_len,
- unsigned long buf_rva, unsigned int offset ) {
- X86_InsnList *list = new_X86_InsnList();
-
- /* use default resolver: damn SWIG callbacks! */
- return x86_disasm_forward( buf, buf_len, buf_rva, offset,
- x86_default_callback, list,
- x86_default_resolver, NULL );
- }
-
- size_t disasm_invariant( unsigned char *buf, size_t buf_len,
- x86_invariant_t *inv ) {
- return x86_invariant_disasm( buf, buf_len, inv );
- }
-
- size_t disasm_size( unsigned char *buf, size_t buf_len ) {
- return x86_size_disasm( buf, buf_len );
- }
-
- %newobject format_header;
- char * format_header( enum x86_asm_format format) {
- char *buf, *str;
- size_t len;
-
- switch ( format ) {
- /* these were obtained from x86_format.c */
- case xml_syntax:
- len = 679; break;
- case raw_syntax:
- len = 172; break;
- case native_syntax:
- len = 35; break;
- case intel_syntax:
- len = 23; break;
- case att_syntax:
- len = 23; break;
- case unknown_syntax:
- default:
- len = 23; break;
- }
-
- buf = (char * ) calloc( len + 1, 1 );
- x86_format_header( buf, len, format );
-
- return buf;
- }
-
- unsigned int endian() {
- return x86_endian();
- }
-
- unsigned int addr_size() {
- return x86_addr_size();
- }
-
- unsigned int op_size() {
- return x86_op_size();
- }
-
- unsigned int word_size() {
- return x86_word_size();
- }
-
- unsigned int max_insn_size() {
- return x86_max_insn_size();
- }
-
- unsigned int sp_reg() {
- return x86_sp_reg();
- }
-
- unsigned int fp_reg() {
- return x86_fp_reg();
- }
-
- unsigned int ip_reg() {
- return x86_ip_reg();
- }
-
- %newobject reg_from_id;
- x86_reg_t * reg_from_id( unsigned int id ) {
- x86_reg_t * reg = calloc( sizeof(x86_reg_t), 1 );
- x86_reg_from_id( id, reg );
- return reg;
- }
-
- unsigned char wildcard_byte() { return X86_WILDCARD_BYTE; }
-
- int max_register_string() { return MAX_REGNAME; }
-
- int max_prefix_string() { return MAX_PREFIX_STR; }
-
- int max_mnemonic_string() { return MAX_MNEM_STR; }
-
- int max_operand_string( enum x86_asm_format format ) {
- switch ( format ) {
- case xml_syntax:
- return MAX_OP_XML_STRING;
- break;
- case raw_syntax:
- return MAX_OP_RAW_STRING;
- break;
- case native_syntax:
- case intel_syntax:
- case att_syntax:
- case unknown_syntax:
- default:
- return MAX_OP_STRING;
- break;
- }
- }
-
-
- int max_insn_string( enum x86_asm_format format ) {
- switch ( format ) {
- case xml_syntax:
- return MAX_INSN_XML_STRING;
- break;
- case raw_syntax:
- return MAX_INSN_RAW_STRING;
- break;
- case native_syntax:
- case intel_syntax:
- case att_syntax:
- case unknown_syntax:
- default:
- return MAX_INSN_STRING;
- break;
- }
- }
-
- int max_num_operands( ) { return MAX_NUM_OPERANDS; }
-}
-
-/* python callback, per the manual */
-/*%typemap(python,in) PyObject *pyfunc {
- if (!PyCallable_Check($source)) {
- PyErr_SetString(PyExc_TypeError, "Need a callable object!");
- return NULL;
- }
- $target = $source;
-}*/
-
-/* python FILE * callback, per the manual */
-/*
-%typemap(python,in) FILE * {
- if (!PyFile_Check($source)) {
- PyErr_SetString(PyExc_TypeError, "Need a file!");
- return NULL;
- }
- $target = PyFile_AsFile($source);
-}*/
-
-
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile-swig b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile-swig
deleted file mode 100644
index 9f3a64573..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile-swig
+++ /dev/null
@@ -1,65 +0,0 @@
-ifndef BASE_NAME
-BASE_NAME = x86disasm
-endif
-
-ifndef SWIG
-SWIG = swig # apt-get install swig !
-endif
-
-ifndef GCC
-GCC = gcc
-endif
-
-ifndef CC_FLAGS
-CC_FLAGS = -c -fPIC
-endif
-
-ifndef LD_FLAGS
-LD_FLAGS = -shared -L.. -ldisasm
-endif
-
-INTERFACE_FILE = libdisasm_oop.i
-
-SWIG_INTERFACE = ../$(INTERFACE_FILE)
-
-# PERL rules
-PERL_MOD = blib/arch/auto/$(BASE_NAME)/$(BASE_NAME).so
-PERL_SHADOW = $(BASE_NAME)_wrap.c
-PERL_SWIG = $(BASE_NAME).pl
-PERL_OBJ = $(BASE_NAME)_wrap.o
-PERL_INC = `perl -e 'use Config; print $$Config{archlib};'`/CORE
-PERL_CC_FLAGS = `perl -e 'use Config; print $$Config{ccflags};'`
-
-#====================================================
-# TARGETS
-
-all: swig-perl
-
-dummy: swig-perl install uninstall clean
-
-swig-perl: $(PERL_MOD)
-
-$(PERL_MOD): $(PERL_OBJ)
- perl Makefile.PL
- make
- #$(GCC) $(LD_FLAGS) $(PERL_OBJ) -o $@
-
-$(PERL_OBJ): $(PERL_SHADOW)
- $(GCC) $(CC_FLAGS) $(PERL_CC_FLAGS) -I$(PERL_INC) -o $@ $<
-
-$(PERL_SHADOW): $(SWIG_INTERFACE)
- swig -perl -shadow -o $(PERL_SHADOW) -outdir . $<
-
-# ==================================================================
-install: $(PERL_MOD)
- make install
-
-# ==================================================================
-uninstall:
-
-# ==================================================================
-clean:
- rm $(PERL_MOD) $(PERL_OBJ)
- rm $(PERL_SHADOW)
- rm -rf Makefile blib pm_to_blib
-
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile.PL b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile.PL
deleted file mode 100644
index 6e625df18..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/perl/Makefile.PL
+++ /dev/null
@@ -1,7 +0,0 @@
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- 'NAME' => 'x86disasm',
- 'LIBS' => ['-ldisasm'],
- 'OBJECT' => 'x86disasm_wrap.o'
-);
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/python/Makefile-swig b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/python/Makefile-swig
deleted file mode 100644
index 544681a13..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/python/Makefile-swig
+++ /dev/null
@@ -1,64 +0,0 @@
-ifndef BASE_NAME
-BASE_NAME = x86disasm
-endif
-
-ifndef SWIG
-SWIG = swig # apt-get install swig !
-endif
-
-ifndef GCC
-GCC = gcc
-endif
-
-ifndef CC_FLAGS
-CC_FLAGS = -c -fPIC
-endif
-
-ifndef LD_FLAGS
-LD_FLAGS = -shared -L.. -ldisasm
-endif
-
-INTERFACE_FILE = libdisasm_oop.i
-
-SWIG_INTERFACE = ../$(INTERFACE_FILE)
-
-# PYTHON rules
-PYTHON_MOD = $(BASE_NAME)-python.so
-PYTHON_SHADOW = $(BASE_NAME)_wrap.c
-PYTHON_SWIG = $(BASE_NAME).py
-PYTHON_OBJ = $(BASE_NAME)_wrap.o
-PYTHON_INC = `/bin/echo -e 'import sys\nprint sys.prefix + "/include/python" + sys.version[:3]' | python`
-PYTHON_LIB = `/bin/echo -e 'import sys\nprint sys.prefix + "/lib/python" + sys.version[:3]' | python`
-PYTHON_DEST = $(PYTHON_LIB)/lib-dynload/_$(BASE_NAME).so
-
-#====================================================
-# TARGETS
-
-all: swig-python
-
-dummy: swig-python install uninstall clean
-
-swig-python: $(PYTHON_MOD)
-
-$(PYTHON_MOD): $(PYTHON_OBJ)
- $(GCC) $(LD_FLAGS) $(PYTHON_OBJ) -o $@
-
-$(PYTHON_OBJ): $(PYTHON_SHADOW)
- $(GCC) $(CC_FLAGS) -I$(PYTHON_INC) -I.. -o $@ $<
-
-$(PYTHON_SHADOW): $(SWIG_INTERFACE)
- swig -python -shadow -o $(PYTHON_SHADOW) -outdir . $<
-
-# ==================================================================
-install: $(PYTHON_MOD)
- sudo cp $(PYTHON_MOD) $(PYTHON_DEST)
- sudo cp $(PYTHON_SWIG) $(PYTHON_LIB)
-
-# ==================================================================
-uninstall:
-
-# ==================================================================
-clean:
- rm $(PYTHON_MOD) $(PYTHON_SWIG) $(PYTHON_OBJ)
- rm $(PYTHON_SHADOW)
-
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/Makefile-swig b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/Makefile-swig
deleted file mode 100644
index ee4800232..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/Makefile-swig
+++ /dev/null
@@ -1,68 +0,0 @@
-ifndef BASE_NAME
-BASE_NAME = x86disasm
-endif
-
-ifndef SWIG
-SWIG = swig # apt-get install swig !
-endif
-
-ifndef GCC
-GCC = gcc
-endif
-
-ifndef CC_FLAGS
-CC_FLAGS = -c -fPIC
-endif
-
-ifndef LD_FLAGS
-LD_FLAGS = -shared -L../.. -ldisasm
-endif
-
-LIBDISASM_DIR = ../..
-
-INTERFACE_FILE = libdisasm_oop.i
-
-SWIG_INTERFACE = ../$(INTERFACE_FILE)
-
-# RUBY rules
-RUBY_MAKEFILE = Makefile
-RUBY_MOD = $(BASE_NAME).so
-RUBY_SHADOW = $(BASE_NAME)_wrap.c
-#RUBY_SWIG = $(BASE_NAME).rb
-RUBY_OBJ = $(BASE_NAME)_wrap.o
-RUBY_INC = `ruby -e 'puts $$:.join("\n")' | tail -2 | head -1`
-#RUBY_LIB =
-#RUBY_DEST =
-
-#====================================================
-# TARGETS
-
-all: swig-ruby
-
-dummy: swig-ruby install uninstall clean
-
-swig-ruby: $(RUBY_MOD)
-
-$(RUBY_MOD): $(RUBY_MAKEFILE)
- make
-
-$(RUBY_MAKEFILE): $(RUBY_OBJ)
- ruby extconf.rb
-
-$(RUBY_OBJ):$(RUBY_SHADOW)
- $(GCC) $(CC_FLAGS) -I$(RUBY_INC) -I.. -o $@ $<
-
-$(RUBY_SHADOW): $(SWIG_INTERFACE)
- swig -ruby -o $(RUBY_SHADOW) -outdir . $<
-
-# ==================================================================
-install: $(RUBY_MOD)
- make install
-
-# ==================================================================
-uninstall:
-
-# ==================================================================
-clean:
- make clean || true
- rm $(RUBY_SHADOW) $(RUBY_MAKEFILE) $(RUBY_MOD) $(RUBY_OBJ)
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/extconf.rb b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/extconf.rb
deleted file mode 100644
index 4e7432643..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/ruby/extconf.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'mkmf'
-find_library('disasm', 'x86_init', "/usr/local/lib", "../..")
-create_makefile('x86disasm')
-
diff --git a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/tcl/Makefile-swig b/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/tcl/Makefile-swig
deleted file mode 100644
index 5145a8293..000000000
--- a/toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/tcl/Makefile-swig
+++ /dev/null
@@ -1,63 +0,0 @@
-ifndef BASE_NAME
-BASE_NAME = x86disasm
-endif
-
-ifndef SWIG
-SWIG = swig # apt-get install swig !
-endif
-
-ifndef GCC
-GCC = gcc
-endif
-
-ifndef CC_FLAGS
-CC_FLAGS = -c -fPIC
-endif
-
-ifndef LD_FLAGS
-LD_FLAGS = -shared -L../.. -ldisasm
-endif
-
-INTERFACE_FILE = libdisasm.i
-
-SWIG_INTERFACE = ../$(INTERFACE_FILE)
-
-# TCL rules
-TCL_VERSION = 8.3
-TCL_MOD = $(BASE_NAME)-tcl.so
-TCL_SHADOW = $(BASE_NAME)_wrap.c
-TCL_OBJ = $(BASE_NAME)_wrap.o
-TCL_INC = /usr/include/tcl$(TCL_VERSION)
-TCL_LIB = /usr/lib/tcl$(TCL_VERSION)
-TCL_DEST = $(TCL_LIB)/$(BASE_NAME).so
-
-#====================================================
-# TARGETS
-
-all: swig-tcl
-
-dummy: swig-tcl install uninstall clean
-
-swig-tcl: $(TCL_MOD)
-
-$(TCL_MOD): $(TCL_OBJ)
- $(GCC) $(LD_FLAGS) $(TCL_OBJ) -o $@
-
-$(TCL_OBJ): $(TCL_SHADOW)
- $(GCC) $(CC_FLAGS) -I$(TCL_INC) -I.. -o $@ $<
-
-$(TCL_SHADOW): $(SWIG_INTERFACE)
- swig -tcl -o $(TCL_SHADOW) -outdir . $<
-
-# ==================================================================
-install: $(TCL_MOD)
- sudo cp $(TCL_MOD) $(TCL_DEST)
-
-# ==================================================================
-uninstall:
-
-# ==================================================================
-clean:
- rm $(TCL_MOD) $(TCL_SWIG) $(TCL_OBJ)
- rm $(TCL_SHADOW)
-