toolkit/crashreporter/google-breakpad/src/third_party/libdisasm/swig/README

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 			Libdisasm SWIG README
     3 The SWIG utility (www.swig.org) can be used to generate 
     6 Building SWIG Modules
     7 ---------------------
     9 	make
    10 	make install
    12 Make and Install both build Python, Perl, Ruby, and Tcl modules. If you
    13 do not have one of these languages installed, comment out the relevant
    14 target in the main Makefile.
    16 Install uses 'sudo' to put files in the correct locations; if you
    17 do not have sudo installed, change the install targets.
    19 The Module API
    20 --------------
    22 The OOP API
    23 -----------
    26 The Python Module
    27 -----------------
    29 To test that the module loads:
    31 	bash# python
    32 	>>> import x86disasm
    33 	>>> x86disasm.version_string()
    34 	'0.21-pre'
    35 	>>>^D
    36 	bash#
    38 	>>> import x86disasm
    39 	>>> import array
    40 	>>> disasm = x86disasm.X86_Disasm( )
    41 	>>> tgt = open( "/tmp/a.out", "rb" )
    42 	>>> tgt.seek( 0, 2 )
    43 	>>> size = tgt.tell()
    44 	>>> tgt.seek( 0, 0 )
    45 	>>> buf = array.array( 'B' )
    46 	>>> buf.fromfile( tgt, size )
    47 	>>> tgt.close()
    48 	>>> data = x86disasm.byteArray( size )
    49 	>>> for i in range( size ):
    50 	...     data[i] = buf.pop(0)
    51 	...
    52 	>>> del buf
    53 	>>> del tgt
    54 	>>> insn = disasm.disasm( data, size - 1, 0, 0 )
    55 	>>> insn.format( x86disasm.att_syntax )
    56 	 'jg\t0x00000047'
    57 	>>> insn.format( x86disasm.raw_syntax )
    58 	'0x00000000|0x00000000|2|7F 45 |||controlflow|jcc|jg|80386|General Purpose|||zero_clear sign_eq_oflow |0|0|relative|sbyte|00000047|'
    59 	>>> ops = insn.operand_list()
    60 	>>> node = ops.first()
    61 	>>> while node is not None:
    62 	...     s = node.op.format(x86disasm.raw_syntax)
    63 	...     print s
    64 	...     node = ops.next()
    65 	... 
    66 	relative|sbyte|00000047|
    73 The Perl Module
    74 ---------------
    76 To test that the module loads:
    78 	bash# perl
    79 	use x86disasm;
    80 	print x86disasm::version_string() . "\n";
    81 	^D
    82 	0.21-pre
    83 	bash#
    85 The Ruby Module
    86 ---------------
    88 To test that the module loads:
    90 	bash# irb
    91 	irb(main):001:0> require 'x86disasm'
    92 	=> true
    93 	irb(main):002:0> X86disasm.version_string()
    94 	=> "0.21-pre"
    95 	irb(main):003:0> x = X86disasm::X86_Disasm.new
    96 	=> #<X86disasm::X86_Disasm:0xb7d624a4>
    97 	irb(main):004:0> x.max_register_string()
    98 	=> 8
    99 	irb(main):003:0> ^D
   100 	bash#
   102 The Tcl Module
   103 ---------------
   105 To test that the module loads:
   107 	bash# tclsh
   108 	% load /usr/lib/tcl8.3/x86disasm.so X86disasm
   109 	% version_string
   110 	0.21-pre
   111 	% ^D
   112 	bash#
   114 	% x86_init 0 NULL NULL
   115 		OR
   116 	% x86disasm dis
   117 	_486b0708_p_x86disasm
   118 	%  puts "[dis cget -last_error]"
   119 	0
   124 The Interface Files
   125 -------------------
   127 	libdisasm.i	-- interface file without shadow classes
   128 	libdisasm_oop.i	-- interface file with shadow classes

mercurial