#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Intrinsics.h"
-#include "llvm/iOther.h"
+#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/Debugger/SourceFile.h"
#include "llvm/Debugger/SourceLanguage.h"
-#include "Support/FileUtilities.h"
-#include "Support/SlowOperationInformer.h"
-#include "Support/STLExtras.h"
+#include "llvm/Support/SlowOperationInformer.h"
+#include "llvm/ADT/STLExtras.h"
+#include <iostream>
+
using namespace llvm;
/// getGlobalVariablesUsing - Return all of the global variables which have the
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
if (GV->hasInitializer() && isa<ConstantArray>(GV->getInitializer())) {
ConstantArray *Init = cast<ConstantArray>(GV->getInitializer());
- if (Init->getType()->getElementType() == Type::SByteTy ||
- Init->getType()->getElementType() == Type::UByteTy) {
+ if (Init->isString()) {
std::string Result = Init->getAsString();
if (Offset < Result.size()) {
// If we are pointing INTO The string, erase the beginning...
}
}
} else if (Constant *C = dyn_cast<Constant>(V)) {
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C))
- return getStringValue(CPR->getValue(), Offset);
+ if (GlobalValue *GV = dyn_cast<GlobalValue>(C))
+ return getStringValue(GV, Offset);
else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
if (CE->getOpcode() == Instruction::GetElementPtr) {
// Turn a gep into the specified offset.
if (const ConstantInt *C = dyn_cast<ConstantInt>(CI->getOperand(3)))
CurColNo = C->getRawValue();
const Value *Op = CI->getOperand(4);
- if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Op))
- Op = CPR->getValue();
if ((CurDesc = dyn_cast<GlobalVariable>(Op)) &&
(LineNo < LastLineNo ||
SourceFile &SourceFileInfo::getSourceText() const {
// FIXME: this should take into account the source search directories!
- if (SourceText == 0) // Read the file in if we haven't already.
- if (!Directory.empty() && FileOpenable(Directory+"/"+BaseName))
- SourceText = new SourceFile(Directory+"/"+BaseName, Descriptor);
+ if (SourceText == 0) { // Read the file in if we haven't already.
+ sys::Path tmpPath;
+ if (!Directory.empty())
+ tmpPath.setDirectory(Directory);
+ tmpPath.appendFile(BaseName);
+ if (tmpPath.readable())
+ SourceText = new SourceFile(tmpPath.toString(), Descriptor);
else
SourceText = new SourceFile(BaseName, Descriptor);
+ }
return *SourceText;
}
if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Desc->getInitializer()))
if (CS->getNumOperands() > 2) {
// Entry #1 is the file descriptor.
- if (const ConstantPointerRef *CPR =
- dyn_cast<ConstantPointerRef>(CS->getOperand(1)))
- if (const GlobalVariable *GV =
- dyn_cast<GlobalVariable>(CPR->getValue()))
- SourceFile = &PI.getSourceFile(GV);
+ if (const GlobalVariable *GV =
+ dyn_cast<GlobalVariable>(CS->getOperand(1)))
+ SourceFile = &PI.getSourceFile(GV);
// Entry #2 is the function name.
Name = getStringValue(CS->getOperand(2));
// ProgramInfo implementation
//
-ProgramInfo::ProgramInfo(Module *m) : M(m) {
+ProgramInfo::ProgramInfo(Module *m) : M(m), ProgramTimeStamp(0,0) {
assert(M && "Cannot create program information with a null module!");
- ProgramTimeStamp = getFileTimestamp(M->getModuleIdentifier());
+ sys::Path modulePath(M->getModuleIdentifier());
+ ProgramTimeStamp = modulePath.getTimestamp();
SourceFilesIsComplete = false;
SourceFunctionsIsComplete = false;
if (Desc && Desc->hasInitializer())
if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Desc->getInitializer()))
if (CS->getNumOperands() > 0)
- if (const ConstantPointerRef *CPR =
- dyn_cast<ConstantPointerRef>(CS->getOperand(1)))
- SourceFileDesc = dyn_cast<GlobalVariable>(CPR->getValue());
+ if (const GlobalVariable *GV =
+ dyn_cast<GlobalVariable>(CS->getOperand(1)))
+ SourceFileDesc = GV;
const SourceLanguage &Lang = getSourceFile(SourceFileDesc).getLanguage();
return *(Result = Lang.createSourceFunctionInfo(Desc, *this));