2003-09-22 23:44:46 +00:00
|
|
|
//===- ReaderWrappers.cpp - Parse bytecode from file or buffer -----------===//
|
2003-10-20 19:43:21 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-09-22 23:44:46 +00:00
|
|
|
//
|
|
|
|
// This file implements loading and parsing a bytecode file and parsing a
|
|
|
|
// bytecode module from a given buffer.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-06-29 23:24:14 +00:00
|
|
|
#include "llvm/Bytecode/Analyzer.h"
|
2003-11-19 16:06:55 +00:00
|
|
|
#include "llvm/Bytecode/Reader.h"
|
2004-06-29 23:24:14 +00:00
|
|
|
#include "Reader.h"
|
2003-10-18 05:54:18 +00:00
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/Instructions.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/FileUtilities.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
#include "llvm/Config/unistd.h"
|
2003-12-29 21:35:05 +00:00
|
|
|
#include <cerrno>
|
2003-11-19 16:06:55 +00:00
|
|
|
using namespace llvm;
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2003-10-18 05:54:18 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// BytecodeFileReader - Read from an mmap'able file descriptor.
|
|
|
|
//
|
|
|
|
|
2003-09-22 23:38:23 +00:00
|
|
|
namespace {
|
|
|
|
/// BytecodeFileReader - parses a bytecode file from a file
|
|
|
|
///
|
2004-06-29 23:24:14 +00:00
|
|
|
class BytecodeFileReader : public BytecodeReader {
|
2003-09-22 23:38:23 +00:00
|
|
|
private:
|
|
|
|
unsigned char *Buffer;
|
2004-05-28 00:24:41 +00:00
|
|
|
unsigned Length;
|
2003-09-22 23:38:23 +00:00
|
|
|
|
|
|
|
BytecodeFileReader(const BytecodeFileReader&); // Do not implement
|
2003-09-23 15:09:26 +00:00
|
|
|
void operator=(const BytecodeFileReader &BFR); // Do not implement
|
2003-09-22 23:38:23 +00:00
|
|
|
|
|
|
|
public:
|
2004-06-29 23:24:14 +00:00
|
|
|
BytecodeFileReader(const std::string &Filename, llvm::BytecodeHandler* H=0);
|
2003-09-22 23:38:23 +00:00
|
|
|
~BytecodeFileReader();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2003-12-12 00:47:44 +00:00
|
|
|
static std::string ErrnoMessage (int savedErrNum, std::string descr) {
|
|
|
|
return ::strerror(savedErrNum) + std::string(", while trying to ") + descr;
|
|
|
|
}
|
|
|
|
|
2004-06-29 23:24:14 +00:00
|
|
|
BytecodeFileReader::BytecodeFileReader(const std::string &Filename,
|
|
|
|
llvm::BytecodeHandler* H )
|
|
|
|
: BytecodeReader(H)
|
|
|
|
{
|
2004-05-28 00:24:41 +00:00
|
|
|
Buffer = (unsigned char*)ReadFileIntoAddressSpace(Filename, Length);
|
|
|
|
if (Buffer == 0)
|
|
|
|
throw "Error reading file '" + Filename + "'.";
|
2003-09-22 23:38:23 +00:00
|
|
|
|
2003-10-08 19:55:47 +00:00
|
|
|
try {
|
|
|
|
// Parse the bytecode we mmapped in
|
2004-08-21 20:52:03 +00:00
|
|
|
ParseBytecode(Buffer, Length, Filename);
|
2003-10-08 19:55:47 +00:00
|
|
|
} catch (...) {
|
2004-05-28 00:24:41 +00:00
|
|
|
UnmapFileFromAddressSpace(Buffer, Length);
|
2003-10-08 19:55:47 +00:00
|
|
|
throw;
|
|
|
|
}
|
2003-09-22 23:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BytecodeFileReader::~BytecodeFileReader() {
|
|
|
|
// Unmmap the bytecode...
|
2004-05-28 00:24:41 +00:00
|
|
|
UnmapFileFromAddressSpace(Buffer, Length);
|
2003-09-22 23:38:23 +00:00
|
|
|
}
|
|
|
|
|
2003-10-18 05:54:18 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// BytecodeBufferReader - Read from a memory buffer
|
|
|
|
//
|
2003-09-23 16:13:28 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
/// BytecodeBufferReader - parses a bytecode file from a buffer
|
|
|
|
///
|
2004-06-29 23:24:14 +00:00
|
|
|
class BytecodeBufferReader : public BytecodeReader {
|
2003-09-23 16:13:28 +00:00
|
|
|
private:
|
|
|
|
const unsigned char *Buffer;
|
|
|
|
bool MustDelete;
|
|
|
|
|
|
|
|
BytecodeBufferReader(const BytecodeBufferReader&); // Do not implement
|
|
|
|
void operator=(const BytecodeBufferReader &BFR); // Do not implement
|
|
|
|
|
|
|
|
public:
|
|
|
|
BytecodeBufferReader(const unsigned char *Buf, unsigned Length,
|
2004-06-29 23:24:14 +00:00
|
|
|
const std::string &ModuleID,
|
2004-07-04 11:03:03 +00:00
|
|
|
llvm::BytecodeHandler* Handler = 0);
|
2003-09-23 16:13:28 +00:00
|
|
|
~BytecodeBufferReader();
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf,
|
2003-09-24 22:04:02 +00:00
|
|
|
unsigned Length,
|
2004-06-29 23:24:14 +00:00
|
|
|
const std::string &ModuleID,
|
2004-07-04 11:03:03 +00:00
|
|
|
llvm::BytecodeHandler* H )
|
2004-06-29 23:24:14 +00:00
|
|
|
: BytecodeReader(H)
|
2003-09-23 16:13:28 +00:00
|
|
|
{
|
|
|
|
// If not aligned, allocate a new buffer to hold the bytecode...
|
|
|
|
const unsigned char *ParseBegin = 0;
|
2004-08-04 22:56:46 +00:00
|
|
|
if (reinterpret_cast<uint64_t>(Buf) & 3) {
|
2003-09-24 22:04:02 +00:00
|
|
|
Buffer = new unsigned char[Length+4];
|
2003-09-24 22:34:17 +00:00
|
|
|
unsigned Offset = 4 - ((intptr_t)Buffer & 3); // Make sure it's aligned
|
2003-09-23 16:13:28 +00:00
|
|
|
ParseBegin = Buffer + Offset;
|
2003-09-24 22:04:02 +00:00
|
|
|
memcpy((unsigned char*)ParseBegin, Buf, Length); // Copy it over
|
2003-09-23 16:13:28 +00:00
|
|
|
MustDelete = true;
|
|
|
|
} else {
|
|
|
|
// If we don't need to copy it over, just use the caller's copy
|
2003-09-23 21:19:11 +00:00
|
|
|
ParseBegin = Buffer = Buf;
|
2003-09-23 16:13:28 +00:00
|
|
|
MustDelete = false;
|
|
|
|
}
|
2003-10-08 19:55:47 +00:00
|
|
|
try {
|
2004-08-21 20:52:03 +00:00
|
|
|
ParseBytecode(ParseBegin, Length, ModuleID);
|
2003-10-08 19:55:47 +00:00
|
|
|
} catch (...) {
|
|
|
|
if (MustDelete) delete [] Buffer;
|
|
|
|
throw;
|
|
|
|
}
|
2003-09-23 16:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BytecodeBufferReader::~BytecodeBufferReader() {
|
|
|
|
if (MustDelete) delete [] Buffer;
|
|
|
|
}
|
|
|
|
|
2003-10-18 05:54:18 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// BytecodeStdinReader - Read bytecode from Standard Input
|
|
|
|
//
|
2003-09-23 16:13:28 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
/// BytecodeStdinReader - parses a bytecode file from stdin
|
|
|
|
///
|
2004-06-29 23:24:14 +00:00
|
|
|
class BytecodeStdinReader : public BytecodeReader {
|
2003-09-23 16:13:28 +00:00
|
|
|
private:
|
|
|
|
std::vector<unsigned char> FileData;
|
|
|
|
unsigned char *FileBuf;
|
|
|
|
|
|
|
|
BytecodeStdinReader(const BytecodeStdinReader&); // Do not implement
|
|
|
|
void operator=(const BytecodeStdinReader &BFR); // Do not implement
|
|
|
|
|
|
|
|
public:
|
2004-06-29 23:24:14 +00:00
|
|
|
BytecodeStdinReader( llvm::BytecodeHandler* H = 0 );
|
2003-09-23 16:13:28 +00:00
|
|
|
};
|
|
|
|
}
|
2003-09-22 23:38:23 +00:00
|
|
|
|
2004-06-29 23:24:14 +00:00
|
|
|
BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H )
|
|
|
|
: BytecodeReader(H)
|
|
|
|
{
|
2003-09-22 23:38:23 +00:00
|
|
|
int BlockSize;
|
|
|
|
unsigned char Buffer[4096*4];
|
|
|
|
|
|
|
|
// Read in all of the data from stdin, we cannot mmap stdin...
|
2003-11-11 22:41:34 +00:00
|
|
|
while ((BlockSize = ::read(0 /*stdin*/, Buffer, 4096*4))) {
|
2003-09-22 23:38:23 +00:00
|
|
|
if (BlockSize == -1)
|
2003-12-12 00:47:44 +00:00
|
|
|
throw ErrnoMessage(errno, "read from standard input");
|
2003-09-23 16:13:28 +00:00
|
|
|
|
2003-09-22 23:38:23 +00:00
|
|
|
FileData.insert(FileData.end(), Buffer, Buffer+BlockSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FileData.empty())
|
|
|
|
throw std::string("Standard Input empty!");
|
|
|
|
|
|
|
|
FileBuf = &FileData[0];
|
2004-08-21 20:52:03 +00:00
|
|
|
ParseBytecode(FileBuf, FileData.size(), "<stdin>");
|
2003-09-22 23:38:23 +00:00
|
|
|
}
|
|
|
|
|
2003-10-18 05:54:18 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Varargs transmogrification code...
|
2003-09-23 16:13:28 +00:00
|
|
|
//
|
2003-10-18 05:54:18 +00:00
|
|
|
|
|
|
|
// CheckVarargs - This is used to automatically translate old-style varargs to
|
|
|
|
// new style varargs for backwards compatibility.
|
|
|
|
static ModuleProvider *CheckVarargs(ModuleProvider *MP) {
|
|
|
|
Module *M = MP->getModule();
|
|
|
|
|
|
|
|
// Check to see if va_start takes arguments...
|
|
|
|
Function *F = M->getNamedFunction("llvm.va_start");
|
|
|
|
if (F == 0) return MP; // No varargs use, just return.
|
|
|
|
|
|
|
|
if (F->getFunctionType()->getNumParams() == 0)
|
|
|
|
return MP; // Modern varargs processing, just return.
|
|
|
|
|
|
|
|
// If we get to this point, we know that we have an old-style module.
|
|
|
|
// Materialize the whole thing to perform the rewriting.
|
|
|
|
MP->materializeModule();
|
|
|
|
|
|
|
|
// If the user is making use of obsolete varargs intrinsics, adjust them for
|
|
|
|
// the user.
|
|
|
|
if (Function *F = M->getNamedFunction("llvm.va_start")) {
|
|
|
|
assert(F->asize() == 1 && "Obsolete va_start takes 1 argument!");
|
|
|
|
|
|
|
|
const Type *RetTy = F->getFunctionType()->getParamType(0);
|
|
|
|
RetTy = cast<PointerType>(RetTy)->getElementType();
|
|
|
|
Function *NF = M->getOrInsertFunction("llvm.va_start", RetTy, 0);
|
|
|
|
|
|
|
|
for (Value::use_iterator I = F->use_begin(), E = F->use_end(); I != E; )
|
|
|
|
if (CallInst *CI = dyn_cast<CallInst>(*I++)) {
|
|
|
|
Value *V = new CallInst(NF, "", CI);
|
|
|
|
new StoreInst(V, CI->getOperand(1), CI);
|
|
|
|
CI->getParent()->getInstList().erase(CI);
|
|
|
|
}
|
|
|
|
F->setName("");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Function *F = M->getNamedFunction("llvm.va_end")) {
|
|
|
|
assert(F->asize() == 1 && "Obsolete va_end takes 1 argument!");
|
|
|
|
const Type *ArgTy = F->getFunctionType()->getParamType(0);
|
|
|
|
ArgTy = cast<PointerType>(ArgTy)->getElementType();
|
|
|
|
Function *NF = M->getOrInsertFunction("llvm.va_end", Type::VoidTy,
|
|
|
|
ArgTy, 0);
|
|
|
|
|
|
|
|
for (Value::use_iterator I = F->use_begin(), E = F->use_end(); I != E; )
|
|
|
|
if (CallInst *CI = dyn_cast<CallInst>(*I++)) {
|
|
|
|
Value *V = new LoadInst(CI->getOperand(1), "", CI);
|
|
|
|
new CallInst(NF, V, "", CI);
|
|
|
|
CI->getParent()->getInstList().erase(CI);
|
|
|
|
}
|
|
|
|
F->setName("");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Function *F = M->getNamedFunction("llvm.va_copy")) {
|
|
|
|
assert(F->asize() == 2 && "Obsolete va_copy takes 2 argument!");
|
|
|
|
const Type *ArgTy = F->getFunctionType()->getParamType(0);
|
|
|
|
ArgTy = cast<PointerType>(ArgTy)->getElementType();
|
|
|
|
Function *NF = M->getOrInsertFunction("llvm.va_copy", ArgTy,
|
|
|
|
ArgTy, 0);
|
|
|
|
|
|
|
|
for (Value::use_iterator I = F->use_begin(), E = F->use_end(); I != E; )
|
|
|
|
if (CallInst *CI = dyn_cast<CallInst>(*I++)) {
|
|
|
|
Value *V = new CallInst(NF, CI->getOperand(2), "", CI);
|
|
|
|
new StoreInst(V, CI->getOperand(1), CI);
|
|
|
|
CI->getParent()->getInstList().erase(CI);
|
|
|
|
}
|
|
|
|
F->setName("");
|
|
|
|
}
|
|
|
|
return MP;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-09-23 16:13:28 +00:00
|
|
|
// Wrapper functions
|
2003-10-18 05:54:18 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-09-23 16:13:28 +00:00
|
|
|
|
|
|
|
/// getBytecodeBufferModuleProvider - lazy function-at-a-time loading from a
|
|
|
|
/// buffer
|
2003-10-04 20:14:59 +00:00
|
|
|
ModuleProvider*
|
2003-11-19 16:06:55 +00:00
|
|
|
llvm::getBytecodeBufferModuleProvider(const unsigned char *Buffer,
|
|
|
|
unsigned Length,
|
2004-06-29 23:24:14 +00:00
|
|
|
const std::string &ModuleID,
|
2004-07-04 11:03:03 +00:00
|
|
|
BytecodeHandler* H ) {
|
2004-06-29 23:24:14 +00:00
|
|
|
return CheckVarargs(
|
|
|
|
new BytecodeBufferReader(Buffer, Length, ModuleID, H));
|
2003-09-22 23:38:23 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 16:13:28 +00:00
|
|
|
/// ParseBytecodeBuffer - Parse a given bytecode buffer
|
|
|
|
///
|
2003-11-19 16:06:55 +00:00
|
|
|
Module *llvm::ParseBytecodeBuffer(const unsigned char *Buffer, unsigned Length,
|
|
|
|
const std::string &ModuleID,
|
|
|
|
std::string *ErrorStr){
|
2003-09-23 16:13:28 +00:00
|
|
|
try {
|
2003-10-04 20:14:59 +00:00
|
|
|
std::auto_ptr<ModuleProvider>
|
2003-10-04 19:19:37 +00:00
|
|
|
AMP(getBytecodeBufferModuleProvider(Buffer, Length, ModuleID));
|
|
|
|
return AMP->releaseModule();
|
2003-09-23 16:13:28 +00:00
|
|
|
} catch (std::string &err) {
|
2003-09-24 22:10:47 +00:00
|
|
|
if (ErrorStr) *ErrorStr = err;
|
2003-09-23 16:13:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-09-22 23:38:23 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 16:13:28 +00:00
|
|
|
/// getBytecodeModuleProvider - lazy function-at-a-time loading from a file
|
2003-09-22 23:38:23 +00:00
|
|
|
///
|
2004-06-29 23:24:14 +00:00
|
|
|
ModuleProvider *llvm::getBytecodeModuleProvider(const std::string &Filename,
|
2004-07-04 11:03:03 +00:00
|
|
|
BytecodeHandler* H) {
|
2003-09-22 23:38:23 +00:00
|
|
|
if (Filename != std::string("-")) // Read from a file...
|
2004-06-29 23:24:14 +00:00
|
|
|
return CheckVarargs(new BytecodeFileReader(Filename,H));
|
2003-09-22 23:38:23 +00:00
|
|
|
else // Read from stdin
|
2004-06-29 23:24:14 +00:00
|
|
|
return CheckVarargs(new BytecodeStdinReader(H));
|
2003-09-22 23:38:23 +00:00
|
|
|
}
|
|
|
|
|
2003-09-23 16:13:28 +00:00
|
|
|
/// ParseBytecodeFile - Parse the given bytecode file
|
|
|
|
///
|
2003-11-19 16:06:55 +00:00
|
|
|
Module *llvm::ParseBytecodeFile(const std::string &Filename,
|
|
|
|
std::string *ErrorStr) {
|
2003-09-23 16:13:28 +00:00
|
|
|
try {
|
2003-10-04 20:14:59 +00:00
|
|
|
std::auto_ptr<ModuleProvider> AMP(getBytecodeModuleProvider(Filename));
|
2003-10-04 19:19:37 +00:00
|
|
|
return AMP->releaseModule();
|
2003-09-23 16:13:28 +00:00
|
|
|
} catch (std::string &err) {
|
2003-09-24 22:10:47 +00:00
|
|
|
if (ErrorStr) *ErrorStr = err;
|
2003-09-23 16:13:28 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-09-22 23:38:23 +00:00
|
|
|
}
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2004-06-29 23:24:14 +00:00
|
|
|
// AnalyzeBytecodeFile - analyze one file
|
2004-08-21 20:52:03 +00:00
|
|
|
Module* llvm::AnalyzeBytecodeFile(
|
|
|
|
const std::string &Filename, ///< File to analyze
|
|
|
|
BytecodeAnalysis& bca, ///< Statistical output
|
|
|
|
std::string *ErrorStr, ///< Error output
|
2004-09-12 20:56:38 +00:00
|
|
|
std::ostream* output ///< Dump output
|
|
|
|
)
|
2004-06-29 23:24:14 +00:00
|
|
|
{
|
|
|
|
try {
|
2004-09-12 20:47:33 +00:00
|
|
|
BytecodeHandler* analyzerHandler =createBytecodeAnalyzerHandler(bca,output);
|
2004-06-29 23:24:14 +00:00
|
|
|
std::auto_ptr<ModuleProvider> AMP(
|
|
|
|
getBytecodeModuleProvider(Filename,analyzerHandler));
|
|
|
|
return AMP->releaseModule();
|
|
|
|
} catch (std::string &err) {
|
|
|
|
if (ErrorStr) *ErrorStr = err;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// AnalyzeBytecodeBuffer - analyze a buffer
|
|
|
|
Module* llvm::AnalyzeBytecodeBuffer(
|
2004-08-21 20:52:03 +00:00
|
|
|
const unsigned char* Buffer, ///< Pointer to start of bytecode buffer
|
|
|
|
unsigned Length, ///< Size of the bytecode buffer
|
|
|
|
const std::string& ModuleID, ///< Identifier for the module
|
|
|
|
BytecodeAnalysis& bca, ///< The results of the analysis
|
|
|
|
std::string* ErrorStr, ///< Errors, if any.
|
2004-09-12 20:56:38 +00:00
|
|
|
std::ostream* output ///< Dump output, if any
|
|
|
|
)
|
2004-06-29 23:24:14 +00:00
|
|
|
{
|
|
|
|
try {
|
2004-08-21 20:52:03 +00:00
|
|
|
BytecodeHandler* hdlr = createBytecodeAnalyzerHandler(bca, output);
|
2004-06-29 23:24:14 +00:00
|
|
|
std::auto_ptr<ModuleProvider>
|
|
|
|
AMP(getBytecodeBufferModuleProvider(Buffer, Length, ModuleID, hdlr));
|
|
|
|
return AMP->releaseModule();
|
|
|
|
} catch (std::string &err) {
|
|
|
|
if (ErrorStr) *ErrorStr = err;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-24 22:46:20 +00:00
|
|
|
bool llvm::GetBytecodeDependentLibraries(const std::string &fname,
|
2004-09-12 20:47:33 +00:00
|
|
|
Module::LibraryListType& deplibs) {
|
2004-08-24 22:46:20 +00:00
|
|
|
try {
|
|
|
|
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fname));
|
|
|
|
Module* M = AMP->releaseModule();
|
2004-11-06 08:56:40 +00:00
|
|
|
|
2004-08-24 22:46:20 +00:00
|
|
|
deplibs = M->getLibraries();
|
|
|
|
delete M;
|
|
|
|
return true;
|
|
|
|
} catch (...) {
|
|
|
|
deplibs.clear();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-06 08:56:40 +00:00
|
|
|
// Get just the externally visible defined symbols from the bytecode
|
|
|
|
bool llvm::GetBytecodeSymbols(const sys::Path& fName,
|
|
|
|
std::vector<std::string>& symbols) {
|
|
|
|
try {
|
|
|
|
std::auto_ptr<ModuleProvider> AMP( getBytecodeModuleProvider(fName.get()));
|
|
|
|
|
|
|
|
// Get the module from the provider
|
|
|
|
Module* M = AMP->releaseModule();
|
|
|
|
|
|
|
|
// Loop over global variables
|
|
|
|
for (Module::giterator GI = M->gbegin(), GE=M->gend(); GI != GE; ++GI) {
|
|
|
|
if (GI->hasInitializer()) {
|
|
|
|
std::string name ( GI->getName() );
|
|
|
|
if (!name.empty()) {
|
|
|
|
symbols.push_back(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Loop over functions
|
|
|
|
for (Module::iterator FI = M->begin(), FE=M->end(); FI != FE; ++FI) {
|
|
|
|
if (!FI->isExternal()) {
|
|
|
|
std::string name ( FI->getName() );
|
|
|
|
if (!name.empty()) {
|
|
|
|
symbols.push_back(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done with the module
|
|
|
|
delete M;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} catch (...) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-29 23:24:14 +00:00
|
|
|
// vim: sw=2 ai
|