cl::Flag QuietMode ("quiet" , "Do not emit any non-program output");
cl::Alias QuietModeA("q" , "Alias for -quiet", cl::NoFlags, QuietMode);
cl::Flag ArrayChecksEnabled("array-checks", "Enable array bound checks");
+cl::Flag AbortOnExceptions("abort-on-exception", "Halt execution on a machine exception");
// Create a TargetData structure to handle memory addressing and size/alignment
// computations
}
// Allocate enough memory to hold the type...
- GenericValue Result;
// FIXME: Don't use CALLOC, use a tainted malloc.
- Result.PointerVal = (PointerTy)calloc(NumElements, TD.getTypeSize(Ty));
+ void *Memory = calloc(NumElements, TD.getTypeSize(Ty));
+
+ GenericValue Result;
+ Result.PointerVal = (PointerTy)Memory;
assert(Result.PointerVal != 0 && "Null pointer returned by malloc!");
SetValue(I, Result, SF);
- if (I->getOpcode() == Instruction::Alloca) {
- // TODO: FIXME: alloca should keep track of memory to free it later...
- }
+ if (I->getOpcode() == Instruction::Alloca)
+ ECStack.back().Allocas.add(Memory);
}
static void executeFreeInst(FreeInst *I, ExecutionContext &SF) {
<< " Subscript #" << (ArgOff-I->getFirstIndexOperandNumber())
<< "\n";
// Get outta here!!!
- siglongjmp(SignalRecoverBuffer, -1);
+ siglongjmp(SignalRecoverBuffer, SIGTRAP);
}
Ty = ST->getElementType();
// Assign slot numbers to the method arguments...
const Method::ArgumentListType &ArgList = M->getArgumentList();
for (Method::ArgumentListType::const_iterator AI = ArgList.begin(),
- AE = ArgList.end(); AI != AE; ++AI) {
- MethodArgument *MA = *AI;
- MA->addAnnotation(new SlotNumber(getValueSlot(MA)));
- }
+ AE = ArgList.end(); AI != AE; ++AI)
+ (*AI)->addAnnotation(new SlotNumber(getValueSlot(*AI)));
// Iterate over all of the instructions...
unsigned InstNum = 0;
- for (Method::inst_iterator MI = M->inst_begin(), ME = M->inst_end();
- MI != ME; ++MI) {
- Instruction *I = *MI; // For each instruction...
- I->addAnnotation(new InstNumber(++InstNum, getValueSlot(I))); // Add Annote
+ for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ BasicBlock *BB = *MI;
+ for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; ++II){
+ Instruction *I = *II; // For each instruction... Add Annote
+ I->addAnnotation(new InstNumber(++InstNum, getValueSlot(I)));
+ }
}
}
//
if (int SigNo = sigsetjmp(SignalRecoverBuffer, 1)) {
--SF.CurInst; // Back up to erroring instruction
- if (SigNo != SIGINT && SigNo != -1) {
+ if (SigNo != SIGINT) {
cout << "EXCEPTION OCCURRED [" << _sys_siglistp[SigNo] << "]:\n";
printStackTrace();
+ // If -abort-on-exception was specified, terminate LLI instead of trying
+ // to debug it.
+ //
+ if (AbortOnExceptions) exit(1);
} else if (SigNo == SIGINT) {
cout << "CTRL-C Detected, execution halted.\n";
}