forked from OSchip/llvm-project
Make sure to handle %'s in strings correctly so that the names of BB's and functions are actually printed!
llvm-svn: 5234
This commit is contained in:
parent
962d5befb3
commit
b9636a70e5
|
@ -26,8 +26,8 @@ DisablePtrHashing("tracedisablehashdisable", cl::Hidden,
|
||||||
cl::desc("Disable pointer hashing"));
|
cl::desc("Disable pointer hashing"));
|
||||||
|
|
||||||
static cl::list<string>
|
static cl::list<string>
|
||||||
TraceFuncName("tracefunc", cl::desc("trace only specific functions"),
|
TraceFuncNames("tracefunc", cl::desc("trace only specific functions"),
|
||||||
cl::value_desc("function"), cl::Hidden);
|
cl::value_desc("function"), cl::Hidden);
|
||||||
|
|
||||||
static void TraceValuesAtBBExit(BasicBlock *BB,
|
static void TraceValuesAtBBExit(BasicBlock *BB,
|
||||||
Function *Printf, Function* HashPtrToSeqNum,
|
Function *Printf, Function* HashPtrToSeqNum,
|
||||||
|
@ -37,13 +37,12 @@ static void TraceValuesAtBBExit(BasicBlock *BB,
|
||||||
// or if the function is in the specified list.
|
// or if the function is in the specified list.
|
||||||
//
|
//
|
||||||
inline static bool
|
inline static bool
|
||||||
TraceThisFunction(Function &func)
|
TraceThisFunction(Function &F)
|
||||||
{
|
{
|
||||||
if (TraceFuncName.size() == 0)
|
if (TraceFuncNames.empty()) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
return std::find(TraceFuncName.begin(), TraceFuncName.end(), func.getName())
|
return std::find(TraceFuncNames.begin(), TraceFuncNames.end(), F.getName())
|
||||||
!= TraceFuncName.end();
|
!= TraceFuncNames.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,7 +221,7 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
|
||||||
Tmp.erase(Tmp.begin(), I);
|
Tmp.erase(Tmp.begin(), I);
|
||||||
I = std::find(Tmp.begin(), Tmp.end(), '%');
|
I = std::find(Tmp.begin(), Tmp.end(), '%');
|
||||||
}
|
}
|
||||||
|
Message += Tmp;
|
||||||
Module *Mod = BB->getParent()->getParent();
|
Module *Mod = BB->getParent()->getParent();
|
||||||
|
|
||||||
// Turn the marker string into a global variable...
|
// Turn the marker string into a global variable...
|
||||||
|
@ -232,7 +231,7 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, Instruction *InsertBefore,
|
||||||
Instruction *GEP =
|
Instruction *GEP =
|
||||||
new GetElementPtrInst(fmtVal,
|
new GetElementPtrInst(fmtVal,
|
||||||
vector<Value*>(2,ConstantSInt::get(Type::LongTy, 0)),
|
vector<Value*>(2,ConstantSInt::get(Type::LongTy, 0)),
|
||||||
"trstr", InsertBefore);
|
"trstrp", InsertBefore);
|
||||||
|
|
||||||
// Insert a call to the hash function if this is a pointer value
|
// Insert a call to the hash function if this is a pointer value
|
||||||
if (V && isa<PointerType>(V->getType()) && !DisablePtrHashing) {
|
if (V && isa<PointerType>(V->getType()) && !DisablePtrHashing) {
|
||||||
|
@ -350,7 +349,7 @@ static inline void InsertCodeToShowFunctionEntry(Function &F, Function *Printf,
|
||||||
Instruction *InsertPos = BB.begin();
|
Instruction *InsertPos = BB.begin();
|
||||||
|
|
||||||
std::ostringstream OutStr;
|
std::ostringstream OutStr;
|
||||||
WriteAsOperand(OutStr, &F, true);
|
WriteAsOperand(OutStr, &F);
|
||||||
InsertPrintInst(0, &BB, InsertPos, "ENTERING FUNCTION: " + OutStr.str(),
|
InsertPrintInst(0, &BB, InsertPos, "ENTERING FUNCTION: " + OutStr.str(),
|
||||||
Printf, HashPtrToSeqNum);
|
Printf, HashPtrToSeqNum);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue