/thirdparty/breakpad/third_party/libdisasm/swig/README

http://github.com/tomahawk-player/tomahawk · #! · 128 lines · 95 code · 33 blank · 0 comment · 0 complexity · 412f3d710aab128d3a784845402dc19c MD5 · raw file

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