llvm.org GIT mirror llvm / 3cf9f37
Drop the udis86 wrapper from llvm::sys This optional dependency on the udis86 library was added some time back to aid JIT development, but doesn't make much sense to link into LLVM binaries these days. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213300 91177308-0d34-0410-b5e6-96231b3b80d8 Alp Toker 5 years ago
8 changed file(s) with 0 addition(s) and 155 deletion(s). Raw diff Collapse all Expand all
14961496 AC_CHECK_LIB(z, compress2)
14971497 fi
14981498
1499 dnl Allow extra x86-disassembler library
1500 AC_ARG_WITH(udis86,
1501 AS_HELP_STRING([--with-udis86=],
1502 [Use udis86 external x86 disassembler library]),
1503 [
1504 AC_SUBST(USE_UDIS86, [1])
1505 case "$withval" in
1506 /usr/lib|yes) ;;
1507 *) LDFLAGS="$LDFLAGS -L${withval}" ;;
1508 esac
1509 AC_CHECK_LIB(udis86, ud_init, [], [
1510 echo "Error! You need to have libudis86 around."
1511 exit -1
1512 ])
1513 ],
1514 AC_SUBST(USE_UDIS86, [0]))
1515 AC_DEFINE_UNQUOTED([USE_UDIS86],$USE_UDIS86,
1516 [Define if use udis86 library])
1517
15181499 dnl Allow OProfile support for JIT output.
15191500 AC_ARG_WITH(oprofile,
15201501 AS_HELP_STRING([--with-oprofile=],
712712 generating the documentation can take a long time and producess 100s of
713713 megabytes of output.
714714
715 ``--with-udis86``
716
717 LLVM can use external disassembler library for various purposes (now it's used
718 only for examining code produced by JIT). This option will enable usage of
719 `udis86 `_ x86 (both 32 and 64 bits)
720 disassembler library.
721
722715 To configure LLVM, follow these steps:
723716
724717 #. Change directory into the object root directory:
178178 /* Define to 1 if you have the `shell32' library (-lshell32). */
179179 #cmakedefine HAVE_LIBSHELL32 ${HAVE_LIBSHELL32}
180180
181 /* Define to 1 if you have the `udis86' library (-ludis86). */
182 #undef HAVE_LIBUDIS86
183
184181 /* Define to 1 if you have the 'z' library (-lz). */
185182 #cmakedefine HAVE_LIBZ ${HAVE_LIBZ}
186183
517514 /* Define to 1 if your declares `struct tm'. */
518515 #undef TM_IN_SYS_TIME
519516
520 /* Define if use udis86 library */
521 #undef USE_UDIS86
522
523517 /* Type of 1st arg on ELM Callback */
524518 #cmakedefine WIN32_ELMCB_PCSTR ${WIN32_ELMCB_PCSTR}
525519
160160 /* Define to 1 if you have the `shell32' library (-lshell32). */
161161 #undef HAVE_LIBSHELL32
162162
163 /* Define to 1 if you have the `udis86' library (-ludis86). */
164 #undef HAVE_LIBUDIS86
165
166163 /* Define to 1 if you have the `z' library (-lz). */
167164 #undef HAVE_LIBZ
168165
486483 /* Define to 1 if your declares `struct tm'. */
487484 #undef TM_IN_SYS_TIME
488485
489 /* Define if use udis86 library */
490 #undef USE_UDIS86
491
492486 /* Type of 1st arg on ELM Callback */
493487 #undef WIN32_ELMCB_PCSTR
494488
+0
-35
include/llvm/Support/Disassembler.h less more
None //===- llvm/Support/Disassembler.h ------------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the necessary glue to call external disassembler
10 // libraries.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SYSTEM_DISASSEMBLER_H
15 #define LLVM_SYSTEM_DISASSEMBLER_H
16
17 #include "llvm/Support/DataTypes.h"
18 #include
19
20 namespace llvm {
21 namespace sys {
22
23 /// This function returns true, if there is possible to use some external
24 /// disassembler library. False otherwise.
25 bool hasDisassembler();
26
27 /// This function provides some "glue" code to call external disassembler
28 /// libraries.
29 std::string disassembleBuffer(uint8_t* start, size_t length, uint64_t pc = 0);
30
31 }
32 }
33
34 #endif // LLVM_SYSTEM_DISASSEMBLER_H
3535 #include "llvm/IR/ValueHandle.h"
3636 #include "llvm/IR/ValueMap.h"
3737 #include "llvm/Support/Debug.h"
38 #include "llvm/Support/Disassembler.h"
3938 #include "llvm/Support/ErrorHandling.h"
4039 #include "llvm/Support/ManagedStatic.h"
4140 #include "llvm/Support/Memory.h"
928927 MemMgr->setMemoryExecutable();
929928
930929 DEBUG({
931 if (sys::hasDisassembler()) {
932 dbgs() << "JIT: Disassembled code:\n";
933 dbgs() << sys::disassembleBuffer(FnStart, FnEnd-FnStart,
934 (uintptr_t)FnStart);
935 } else {
936930 dbgs() << "JIT: Binary code:\n";
937931 uint8_t* q = FnStart;
938932 for (int i = 0; q < FnEnd; q += 4, ++i) {
954948 dbgs() << '\n';
955949 }
956950 dbgs()<< '\n';
957 }
958951 });
959952
960953 if (MMI)
7272
7373 # System
7474 Atomic.cpp
75 Disassembler.cpp
7675 DynamicLibrary.cpp
7776 Errno.cpp
7877 Host.cpp
+0
-74
lib/Support/Disassembler.cpp less more
None //===- lib/Support/Disassembler.cpp -----------------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the necessary glue to call external disassembler
10 // libraries.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Support/Disassembler.h"
15 #include "llvm/Config/config.h"
16 #include
17 #include
18 #include
19 #include
20
21 #if USE_UDIS86
22 #include
23 #endif
24
25 using namespace llvm;
26
27 bool llvm::sys::hasDisassembler()
28 {
29 #if defined (__i386__) || defined (__amd64__) || defined (__x86_64__)
30 // We have option to enable udis86 library.
31 # if USE_UDIS86
32 return true;
33 #else
34 return false;
35 #endif
36 #else
37 return false;
38 #endif
39 }
40
41 std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
42 uint64_t pc) {
43 #if (defined (__i386__) || defined (__amd64__) || defined (__x86_64__)) \
44 && USE_UDIS86
45 std::stringstream res;
46
47 unsigned bits;
48 # if defined(__i386__)
49 bits = 32;
50 # else
51 bits = 64;
52 # endif
53
54 ud_t ud_obj;
55
56 ud_init(&ud_obj);
57 ud_set_input_buffer(&ud_obj, start, length);
58 ud_set_mode(&ud_obj, bits);
59 ud_set_pc(&ud_obj, pc);
60 ud_set_syntax(&ud_obj, UD_SYN_ATT);
61
62 res << std::setbase(16)
63 << std::setw(bits/4);
64
65 while (ud_disassemble(&ud_obj)) {
66 res << ud_insn_off(&ud_obj) << ":\t" << ud_insn_asm(&ud_obj) << "\n";
67 }
68
69 return res.str();
70 #else
71 return "No disassembler available. See configure help for options.\n";
72 #endif
73 }