[PATCH] python: Properly initialize before trying to create disasm
Anders Waldenborg
anders at 0x63.nu
Wed Oct 9 13:36:28 PDT 2013
Hi indygreg, gottesmm,
http://llvm-reviews.chandlerc.com/D1879
Files:
bindings/python/llvm/disassembler.py
Index: bindings/python/llvm/disassembler.py
===================================================================
--- bindings/python/llvm/disassembler.py
+++ bindings/python/llvm/disassembler.py
@@ -33,6 +33,16 @@
# Constants for set_options
Option_UseMarkup = 1
+_initialized = False
+def _ensure_initialized():
+ global _initialized
+ if not _initialized:
+ lib.LLVMInitializeAllTargetInfos()
+ lib.LLVMInitializeAllTargetMCs()
+ lib.LLVMInitializeAllDisassemblers()
+ _initialized = True
+
+
class Disassembler(LLVMObject):
"""Represents a disassembler instance.
@@ -47,6 +57,9 @@
The triple argument is the triple to create the disassembler for. This
is something like 'i386-apple-darwin9'.
"""
+
+ _ensure_initialized()
+
ptr = lib.LLVMCreateDisasm(c_char_p(triple), c_void_p(None), c_int(0),
callbacks['op_info'](0), callbacks['symbol_lookup'](0))
if not ptr.contents:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1879.1.patch
Type: text/x-patch
Size: 989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131009/b9ba26cd/attachment.bin>
More information about the llvm-commits
mailing list