Implement PR1240

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34959 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2007-03-06 05:32:48 +00:00
parent 415c1f7438
commit c6551ffdd5
3 changed files with 17 additions and 2 deletions

View File

@ -21,6 +21,10 @@
namespace llvm {
namespace sys {
/// This function returns true, if there is possible to use some external
/// disassembler library. False otherwise.
bool hasDisassembler(void);
/// This function provides some "glue" code to call external disassembler
/// libraries.
std::string disassembleBuffer(uint8_t* start, size_t length, uint64_t pc = 0);

View File

@ -876,8 +876,9 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
Relocations.clear();
#ifndef NDEBUG
DOUT << "Disassembled code:\n"
<< sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
if (sys::hasDisassembler())
DOUT << "Disassembled code:\n"
<< sys::disassembleBuffer(FnStart, FnEnd-FnStart, (uintptr_t)FnStart);
#endif
return false;

View File

@ -26,6 +26,16 @@
using namespace llvm;
bool llvm::sys::hasDisassembler(void)
{
#if defined (__i386__) || defined (__amd64__) || defined (__x86_64__)
// We have option to enable udis86 library.
return true;
#else
return false;
#endif
}
std::string llvm::sys::disassembleBuffer(uint8_t* start, size_t length,
uint64_t pc) {
std::stringstream res;