aboutsummaryrefslogtreecommitdiff
path: root/lib/System/Disassembler.cpp
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-07-13 17:19:57 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-07-13 17:19:57 +0000
commit66e41e3c6e8b8fbc48d5d3b4d2bd9ce0be4ecb75 (patch)
tree9de1c5f67a98cd0e73c60838396486c984f63ac2 /lib/System/Disassembler.cpp
parentabdf259d487163e72081a8cf4991b1617206b41e (diff)
downloadsrc-66e41e3c6e8b8fbc48d5d3b4d2bd9ce0be4ecb75.tar.gz
src-66e41e3c6e8b8fbc48d5d3b4d2bd9ce0be4ecb75.zip
Notes
Diffstat (limited to 'lib/System/Disassembler.cpp')
-rw-r--r--lib/System/Disassembler.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/System/Disassembler.cpp b/lib/System/Disassembler.cpp
index bad427a58d8c..139e3be1aaee 100644
--- a/lib/System/Disassembler.cpp
+++ b/lib/System/Disassembler.cpp
@@ -44,33 +44,29 @@ std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
uint64_t pc) {
std::stringstream res;
-#if defined (__i386__) || defined (__amd64__) || defined (__x86_64__)
+#if (defined (__i386__) || defined (__amd64__) || defined (__x86_64__)) \
+ && USE_UDIS86
unsigned bits;
# if defined(__i386__)
bits = 32;
# else
bits = 64;
# endif
-
-# if USE_UDIS86
+
ud_t ud_obj;
-
+
ud_init(&ud_obj);
ud_set_input_buffer(&ud_obj, start, length);
ud_set_mode(&ud_obj, bits);
ud_set_pc(&ud_obj, pc);
ud_set_syntax(&ud_obj, UD_SYN_ATT);
-
+
res << std::setbase(16)
<< std::setw(bits/4);
-
+
while (ud_disassemble(&ud_obj)) {
res << ud_insn_off(&ud_obj) << ":\t" << ud_insn_asm(&ud_obj) << "\n";
}
-# else
- res << "No disassembler available. See configure help for options.\n";
-# endif
-
#else
res << "No disassembler available. See configure help for options.\n";
#endif