From 74f6fd98da68e0171f4d9c3712ff74577b288b05 Mon Sep 17 00:00:00 2001 From: Clark Coleman <clc@zephyr-software.com> Date: Sat, 21 Nov 2020 15:36:21 -0500 Subject: [PATCH] Clean up integer types and debug output. --- src/base/SMPFunction.cpp | 728 ++++++++++++++++++++++----------------- 1 file changed, 408 insertions(+), 320 deletions(-) diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index 730bd4ab..98841957 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -894,7 +894,8 @@ bool SMPFunction::InheritCalleeMemExpr(size_t MemExprWidth, STARSExpression *Cur } } else { - SMP_msg("ERROR: ExpandExpr() failure in InheritCalleeMemExpr() at CallAddr %llx\n", (uint64_t) InstAddr); + SMP_msg("ERROR: ExpandExpr() failure in InheritCalleeMemExpr() at CallAddr %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } } return changed; @@ -933,7 +934,8 @@ bool SMPFunction::InheritCalleeMemRangeExpr(STARSExpression *CalleeMemRangeExpr, } } // end for all InArgRegNums if (!ReplacedInArgSSANum) { - SMP_msg("ERROR: SPARK: Callee loop range expr did not see InArgSSANums replaced at call site %llx\n", (uint64_t) InstAddr); + SMP_msg("ERROR: SPARK: Callee loop range expr did not see InArgSSANums replaced at call site %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } if (VerboseOutput) { SMP_msg("INFO: LoopCalleeMemRangeExpr before expansion:"); @@ -979,8 +981,8 @@ bool SMPFunction::InheritCalleeMemRangeExpr(STARSExpression *CalleeMemRangeExpr, } } else { // StoppedOnIV - SMP_msg("ERROR: SPARK: Expr Expand() StoppedOnIV in InheritCalleeMemRangeExpr() at %llx\n", - (uint64_t) InstAddr); + SMP_msg("ERROR: SPARK: Expr Expand() StoppedOnIV in InheritCalleeMemRangeExpr() at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); this->CalleeMemExprProblems[LoopNumPlusOne] = true; pair<STARSExprSetIter, bool> InsertResult = this->StoppedOnIVMemRangeExprs[LoopNumPlusOne].insert(CalleeMemRangeExpr); if (InsertResult.second) { // new Expr @@ -990,7 +992,8 @@ bool SMPFunction::InheritCalleeMemRangeExpr(STARSExpression *CalleeMemRangeExpr, } } else { - SMP_msg("ERROR: SPARK: ExpandExpr() failure in InheritCalleeMemRangeExpr at CallAddr %llx\n", (uint64_t) InstAddr); + SMP_msg("ERROR: SPARK: ExpandExpr() failure in InheritCalleeMemRangeExpr at CallAddr %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); this->CalleeMemExprProblems[LoopNumPlusOne] = true; } } @@ -1085,8 +1088,8 @@ void SMPFunction::BuildLoopingStringMemExprs(SMPBasicBlock *CurrBlock, SMPInstr if (LowerBoundExpr->ExpandExpr(InstAddr, LoopNum, false, true, true, true, false, LoopRegHashes, StoppedOnIV, changed, StackPtrCopySet, DepthCounter)) { if (StoppedOnIV) { this->SymbolicAnalysisProblems[LoopIndexPlusOne] = true; - SMP_msg("ERROR: SPARK: LowerBoundExpr Expand() StoppedOnIV in BuildLoopingStringMemExprs() at %llx\n", - (uint64_t)InstAddr); + SMP_msg("ERROR: SPARK: LowerBoundExpr Expand() StoppedOnIV in BuildLoopingStringMemExprs() at %llx ", (uint64_t)InstAddr); + this->DumpFuncNameAndAddr(); pair<STARSExprSetIter, bool> InsertResult = this->StoppedOnIVMemRangeExprs[LoopIndexPlusOne].insert(LowerBoundExpr); if (InsertResult.second) { // new Expr pair<STARSExprSetIter, size_t> InsertValue(InsertResult.first, ByteWidth); @@ -1175,14 +1178,14 @@ void SMPFunction::BuildLoopingStringMemExprs(SMPBasicBlock *CurrBlock, SMPInstr } } else { - SMP_msg("ERROR: SPARK: No RightTree for BuildLoopingStringMemExprs() at %llx\n", - (uint64_t) InstAddr); + SMP_msg("ERROR: SPARK: No RightTree for BuildLoopingStringMemExprs() at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); this->SymbolicAnalysisProblems[LoopIndexPlusOne] = true; } } else { // StoppedOnIV - SMP_msg("ERROR: SPARK: UpperBoundExpr Expand() StoppedOnIV in BuildLoopingStringMemExprs() at %llx\n", - (uint64_t) InstAddr); + SMP_msg("ERROR: SPARK: UpperBoundExpr Expand() StoppedOnIV in BuildLoopingStringMemExprs() at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); this->SymbolicAnalysisProblems[LoopIndexPlusOne] = true; pair<STARSExprSetIter, bool> InsertResult = this->StoppedOnIVMemRangeExprs[LoopIndexPlusOne].insert(UpperBoundExpr); if (InsertResult.second) { // new Expr @@ -1193,15 +1196,15 @@ void SMPFunction::BuildLoopingStringMemExprs(SMPBasicBlock *CurrBlock, SMPInstr } else { // error on UpperBoundExpr->ExpandExpr() this->SymbolicAnalysisProblems[LoopIndexPlusOne] = true; - SMP_msg("ERROR: SPARK: UpperBoundExpr ExpandExpr() failed in BuildLoopingStringMemExprs() at %llx\n", - (uint64_t) InstAddr); + SMP_msg("ERROR: SPARK: UpperBoundExpr ExpandExpr() failed in BuildLoopingStringMemExprs() at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } } } else { this->SymbolicAnalysisProblems[LoopIndexPlusOne] = true; - SMP_msg("ERROR: SPARK: LowerBoundExpr ExpandExpr() failed in BuildLoopingStringMemExprs() at %llx\n", - (uint64_t) InstAddr); + SMP_msg("ERROR: SPARK: LowerBoundExpr ExpandExpr() failed in BuildLoopingStringMemExprs() at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } } return; @@ -1338,7 +1341,7 @@ void SMPFunction::AddCallSource(STARS_ea_t addr) { // Convert call instruction address to beginning address of the caller. STARS_Function_t *FuncInfo = SMP_get_func(addr); if (nullptr == FuncInfo) { - SMP_msg("SERIOUS WARNING: Call location %llx not in a function.\n", (unsigned long long) addr); + SMP_msg("SERIOUS WARNING: Call location %llx not in a function.\n", (uint64_t) addr); return; } STARS_ea_t FirstAddr = FuncInfo->get_startEA(); @@ -1530,7 +1533,7 @@ void SMPFunction::AddNormalizedStackOperand(STARSOpndTypePtr OldOp, STARS_ea_t I STARS_ea_t InstAddr = StackMapIter->first.second; SMP_msg("DEBUG: NormalizedStackOps: "); PrintOperand(OldOp); - SMP_msg(" addr: %llx\n", (unsigned long long) InstAddr); + SMP_msg(" addr: %llx\n", (uint64_t) InstAddr); } } #endif @@ -1567,7 +1570,7 @@ void SMPFunction::SetControlFlowType(STARS_ea_t InstAddr, ControlFlowType JumpTy } else if (MapIter->second != ((unsigned short) JumpTypeCode)) { SMP_msg("WARNING: SPARK Ada jump type changing from %u to %u at %llx: rejected\n", MapIter->second, - (unsigned short) JumpTypeCode, (unsigned long long) InstAddr); + (unsigned short) JumpTypeCode, (uint64_t) InstAddr); #if 0 // refuse to override past value MapIter->second = (unsigned short) JumpTypeCode; #endif @@ -1611,7 +1614,7 @@ STARSOpndTypePtr SMPFunction::GetNormalizedOperand(STARS_ea_t InstAddr, const ST STARS_ea_t InstAddr = StackMapIter->first.second; SMP_msg("DEBUG: NormalizedStackOps: "); PrintOperand(OldOp); - SMP_msg(" addr: %llx\n", (unsigned long long) InstAddr); + SMP_msg(" addr: %llx\n", (uint64_t) InstAddr); } SMP_msg(" RTLop to search for: "); PrintOperand(RTLop); @@ -1946,7 +1949,7 @@ STARS_sval_t SMPFunction::GetStackAdjustmentForCallee(STARS_ea_t CallAddr) { if (0 != BlockAnalysisDelta) { CalleeAdjustment = BlockAnalysisDelta; SMP_msg("INFO: Block analysis produced callee adjustment of %ld bytes after %llx\n", - (long) CalleeAdjustment, (unsigned long long) CallAddr); + (long) CalleeAdjustment, (uint64_t) CallAddr); } return CalleeAdjustment; @@ -1968,7 +1971,7 @@ STARS_sval_t SMPFunction::GetStackDeltaForCallee(STARS_ea_t CallTargetAddr) { if (0 != GlobalAdjustment) { CalleeDelta -= GlobalAdjustment; SMP_msg("INFO: Global stack adjustment analysis produced callee delta of %ld bytes after %llx\n", - (long) CalleeDelta, (unsigned long long) CallTargetAddr); + (long) CalleeDelta, (uint64_t) CallTargetAddr); } } @@ -2069,7 +2072,7 @@ bool SMPFunction::UseIDAStackPointerDeltas(void) { CurrInst->SetStackPtrOffset(IDAProDelta); ++InstIter; if (IDATraceFlag) { - SMP_msg("INFO: IDA Pro stack delta trace: %ld at %llx\n", (long) IDAProDelta, (unsigned long long) CurrInst->GetAddr()); + SMP_msg("INFO: IDA Pro stack delta trace: %ld at %llx\n", (long) IDAProDelta, (uint64_t) CurrInst->GetAddr()); } } return true; @@ -2235,13 +2238,15 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { if (IDAProDelta != IncomingDelta) { intmax_t IDADelta = (intmax_t) IDAProDelta, OurDelta = (intmax_t) IncomingDelta; if (sizeof(STARS_sval_t) == 8) { - SMP_msg("ERROR: At inst %p block %d entry IDA Pro has stack pointer delta of %jd and we compute %jd BlockProcessed: %d\n", + SMP_msg("ERROR: At inst %p block %d entry IDA Pro has stack pointer delta of %jd and we compute %jd BlockProcessed: %d ", InstAddr, CurrBlock->GetNumber(), IDADelta, OurDelta, CurrBlock->IsProcessed()); + this->DumpFuncNameAndAddr(); } else { assert(sizeof(STARS_sval_t) == 4); - SMP_msg("ERROR: At inst %p block %d entry IDA Pro has stack pointer delta of %d and we compute %d BlockProcessed: %d\n", + SMP_msg("ERROR: At inst %p block %d entry IDA Pro has stack pointer delta of %d and we compute %d BlockProcessed: %d ", InstAddr, CurrBlock->GetNumber(), IDAProDelta, IncomingDelta, CurrBlock->IsProcessed()); + this->DumpFuncNameAndAddr(); } } } @@ -2249,8 +2254,8 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { #endif if (0 < IncomingDelta) { - SMP_msg("ERROR: Stack delta of %ld implies stack underflow in func at %llx\n", - (long) IncomingDelta, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: Stack delta of %ld implies stack underflow ", (long) IncomingDelta); + this->DumpFuncNameAndAddr(); this->AnalyzedSP = false; WorkList.clear(); break; @@ -2326,9 +2331,9 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { #if 1 else { this->AnalyzedSP = false; - SMP_msg("ERROR: Stack delta: PrevIncoming is %ld NewIncoming is %ld at %llx block %d in func %s\n", - (long) PrevIncomingDelta, (long) IncomingDelta, (unsigned long long) (*InstIter)->GetAddr(), - CurrBlock->GetNumber(), this->GetFuncName()); + SMP_msg("ERROR: Stack delta: PrevIncoming is %ld NewIncoming is %ld at %llx block %d ", + (long) PrevIncomingDelta, (long) IncomingDelta, (uint64_t) (*InstIter)->GetAddr(), CurrBlock->GetNumber()); + this->DumpFuncNameAndAddr(); WorkList.clear(); } #endif @@ -2370,7 +2375,7 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { if (CurrInst->IsBranchToOtherFunc()) { CurrInst->SetTailCall(); #if 0 - SMP_msg("INFO: Found tail call at %llx from %s: %s\n", (unsigned long long) InstAddr, this->GetFuncName(), + SMP_msg("INFO: Found tail call at %llx from %s: %s\n", (uint64_t) InstAddr, this->GetFuncName(), CurrInst->GetDisasm()); #endif } @@ -2381,7 +2386,7 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { if (this->HasUnresolvedIndirectJumps() && (STARS_BADADDR == CurrInst->GetCallTarget())) { CurrInst->SetTailCall(); #if 0 - SMP_msg("INFO: Found indirect tail call at %llx from %s: %s\n", (unsigned long long) InstAddr, this->GetFuncName(), + SMP_msg("INFO: Found indirect tail call at %llx from %s: %s\n", (uint64_t) InstAddr, this->GetFuncName(), CurrInst->GetDisasm()); #endif } @@ -2395,13 +2400,13 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { // IDA Pro special-cases the HALT instruction to make it appear that the // incoming stack delta is zero. We do no such special case delta adjudstment, // so we suppress error messages, as our delta will be non-zero. - SMP_msg("ERROR: At %llx IDA Pro has stack pointer delta of %lld and we compute %lld\n", - (unsigned long long) InstAddr, (long long) IDAProDelta, (long long) IncomingDelta); + SMP_msg("ERROR: At %llx IDA Pro has stack pointer delta of %lld and we compute %lld ", + (uint64_t) InstAddr, (long long) IDAProDelta, (long long) IncomingDelta); + this->DumpFuncNameAndAddr(); } } if (TraceFlag) { - SMP_msg("INFO: Stack delta trace: %lld at %llx\n", - (long long) IncomingDelta, (uint64_t) InstAddr); + SMP_msg("INFO: Stack delta trace: %lld at %llx\n", (long long) IncomingDelta, (uint64_t) InstAddr); } #endif @@ -2446,7 +2451,7 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { // just a tricky update of the delta for an existing item in the set. bool DeltaInserted = this->AddToStackPtrCopySet(CopyOperand, InstAddr, SavedDelta); if (TraceFlag) { - SMP_msg("INFO: Stack delta saved: %ld at %llx\n", (long) SavedDelta, (unsigned long long) InstAddr); + SMP_msg("INFO: Stack delta saved: %ld at %llx\n", (long) SavedDelta, (uint64_t) InstAddr); PrintOperand(CopyOperand); SMP_msg("\n"); } @@ -2464,8 +2469,8 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { else if (ErrorFlag) { this->AnalyzedSP = false; WorkList.clear(); - SMP_msg("ERROR: ErrorFlag=true from MDIsStackPtrSaveOrRestore() at %llx\n", - (uint64_t) InstAddr); + SMP_msg("ERROR: ErrorFlag=true from MDIsStackPtrSaveOrRestore() at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); break; } else if (CurrInst->MDIsLeaveInstr()) { @@ -2505,7 +2510,8 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { } else if (SMP_STACK_DELTA_ERROR_CODE == ((STARS_uval_t) CurrentDelta)) { this->AnalyzedSP = false; - SMP_msg("ERROR: Stack delta unanalyzeable at %llx\n", (uint64_t) InstAddr); + SMP_msg("ERROR: Stack delta unanalyzeable at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); WorkList.clear(); break; } @@ -2523,8 +2529,9 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { // the stack delta of actual return instructions elsewhere in the function. if (ReturnSeen) { // This is not the first RETURN seen. if (IncomingDelta != this->NetStackDelta) { // Inconsistent - SMP_msg("ERROR: Inconsistent stack deltas at return instruction at %p : Previous: %lld Current: %lld\n", + SMP_msg("ERROR: Inconsistent stack deltas at return instruction at %p : Previous: %lld Current: %lld ", CurrInst->GetAddr(), (long long) this->NetStackDelta, (long long) IncomingDelta); + this->DumpFuncNameAndAddr(); ConsistentNetDelta = false; this->AnalyzedSP = false; WorkList.clear(); @@ -2548,8 +2555,8 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { // have paths that pass through an alloca() call, a push, etc., then the alloca() or // push will not be undone by add esp,32. It must be undone by something like mov esp,ebp. if (ConflictingValuesSeen && !StackPointerRestoreSeen) { - SMP_msg("ERROR: Inconsistent stack deltas seen, no stack pointer restore before return instruction at %llx\n", - (uint64_t) CurrInst->GetAddr()); + SMP_msg("ERROR: Inconsistent stack deltas seen, no stack pointer restore before return instruction at %llx ", (uint64_t) CurrInst->GetAddr()); + this->DumpFuncNameAndAddr(); this->AnalyzedSP = false; WorkList.clear(); break; @@ -2616,22 +2623,23 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) { // for this function's effect on the stack delta, we told our callers that these three values would cancel out. // They do not. Our callers have now been using a bad stack delta for their call instructions. Too late for // anything but a diagnostic message. - SMP_msg("ERROR: Earlier GlobalStackAdjustment computation %ld does not agree with current NetStackDelta result for function: %s\n", - (long) this->GlobalStackAdjustment, this->GetFuncName()); + SMP_msg("ERROR: Earlier GlobalStackAdjustment computation %ld does not agree with current NetStackDelta result ", + (long) this->GlobalStackAdjustment); + this->DumpFuncNameAndAddr(); } } if (IDAProSucceeded) { if (!this->AnalyzedSP) { - SMP_msg("ERROR: Stack Ptr Delta Analysis succeeded in IDA, failed in STARS for %llx : %s\n", - (unsigned long long) this->GetFirstFuncAddr(), this->GetFuncName()); + SMP_msg("ERROR: Stack Ptr Delta Analysis succeeded in IDA, failed in STARS "); + this->DumpFuncNameAndAddr(); } } else { if (this->AnalyzedSP) { - SMP_msg("SUCCESS: Stack Ptr Delta Analysis failed in IDA, succeeded in STARS for %llx : %s\n", - (unsigned long long) this->GetFirstFuncAddr(), this->GetFuncName()); + SMP_msg("SUCCESS: Stack Ptr Delta Analysis failed in IDA, succeeded in STARS "); + this->DumpFuncNameAndAddr(); } } if (!this->AnalyzedSP) { @@ -2785,7 +2793,7 @@ void SMPFunction::AuditCallingConvention(void) { // Killed and not saved+restored if (global_STARS_program->IsCalleeSavedReg(RegNum)) { SMP_msg("WARNING: Callee-saved reg %u killed and not preserved in func at %llx\n", - RegNum, (unsigned long long) this->GetFirstFuncAddr()); + RegNum, (uint64_t) this->GetFirstFuncAddr()); } } } @@ -3096,18 +3104,19 @@ bool SMPFunction::MDFixFrameInfo(void) { // Handle all other possible changes to stack pointer register from non-control-flow instructions. // This includes the alloca() inlined call pattern (sub esp,reg) which is assigned a default size. if (CurrInstr->MDIsLeaveInstr() && (STARS_BADADDR != this->LocalVarsAllocInstr)) { - SMP_msg("ERROR: MDFixFrameInfo() found LEAVE opcode at %llx before finding a frame allocation.\n", - (unsigned long long) InstAddr); + SMP_msg("ERROR: MDFixFrameInfo() found LEAVE opcode at %llx before finding a frame allocation. ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); break; // should not find a LEAVE opcode before the frame allocation } STARS_sval_t CurrentDelta = CurrInstr->AnalyzeStackPointerDelta(0, 0); if (SMP_STACK_POINTER_BITWISE_AND_CODE == ((STARS_uval_t) CurrentDelta)) { // For now, we ignore instructions that AND a constant into the stack pointer. - SMP_msg("WARNING: Stack pointer bitwise AND ignored at %llx in MDFixFrameInfo\n", - (unsigned long long) InstAddr); + SMP_msg("WARNING: Stack pointer bitwise AND ignored at %llx in MDFixFrameInfo ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } else if (SMP_STACK_DELTA_ERROR_CODE == ((STARS_uval_t) CurrentDelta)) { - SMP_msg("ERROR: Stack delta unanalyzeable at %llx in MDFixFrameInfo\n", (unsigned long long) InstAddr); + SMP_msg("ERROR: Stack delta unanalyzeable at %llx in MDFixFrameInfo ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } else if (0 < CurrentDelta) { // deallocating stack; might be stack adjustment after a call instruction if (CallSeen) { // match the stack adjustment to the allocations before the call and remove them @@ -3127,10 +3136,13 @@ bool SMPFunction::MDFixFrameInfo(void) { else { // reached beginning of function; no allocs, only arg pushes AllocValue = OtherAllocsSize = 0; SavedRegsSize = OtherPushesSize = 0; - SMP_msg("INFO: No stack allocs other than arg pushes in %s\n", this->GetFuncName()); + SMP_msg("INFO: No stack allocs other than arg pushes "); + this->DumpFuncNameAndAddr(); + } + if (AllocBytesFound > CurrentDelta) { + SMP_msg("ERROR: Arg pushes did not match stack adjustment "); + this->DumpFuncNameAndAddr(); } - if (AllocBytesFound > CurrentDelta) - SMP_msg("ERROR: Arg pushes did not match stack adjustment in %s\n", this->GetFuncName()); break; // exit while loop } ++ListRevIter; @@ -3138,15 +3150,17 @@ bool SMPFunction::MDFixFrameInfo(void) { if (AllocBytesFound < CurrentDelta) { AllocValue = OtherAllocsSize = 0; SavedRegsSize = OtherPushesSize = 0; - SMP_msg("ERROR: Not enough stack allocs to equal call adjustment in first block of %s\n", this->GetFuncName()); + SMP_msg("ERROR: Not enough stack allocs to equal call adjustment in first block "); + this->DumpFuncNameAndAddr(); } } else if (FoundAllocInstr) { - SMP_msg("WARNING: Stack deallocation at %llx in first block with no call inst.\n", (unsigned long long) InstAddr); + SMP_msg("WARNING: Stack deallocation at %llx in first block with no call inst. ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } else { // Bad; no allocs found, but dealloc found - SMP_msg("ERROR: Stack deallocation at %llx in first block with no alloc instr or call found.\n", - (unsigned long long) InstAddr); + SMP_msg("ERROR: Stack deallocation at %llx in first block with no alloc instr or call found. ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } break; // exit after stack deallocation of any kind } @@ -3158,7 +3172,7 @@ bool SMPFunction::MDFixFrameInfo(void) { OtherAllocsSize += AllocSize; pair<STARS_ea_t, int> AllocPair(InstAddr, AllocSize); AllocPointsList.push_back(AllocPair); - SMP_msg("INFO: Miscellaneous stack pointer delta of %d found at %llx in MDFixFrameInfo\n", CurrentDelta, (unsigned long long) InstAddr); + SMP_msg("INFO: Miscellaneous stack pointer delta of %d found at %llx in MDFixFrameInfo\n", CurrentDelta, (uint64_t) InstAddr); } } else if (EBPSaved && (!ESPintoEBP)) { // found "push ebp", looking for "mov ebp,esp" @@ -3174,13 +3188,13 @@ bool SMPFunction::MDFixFrameInfo(void) { ++PostCallNonAllocInstructions; if (STARS_POST_CALL_NONALLOC_INSTR_LIMIT <= PostCallNonAllocInstructions) { SMP_msg("INFO: Stopping search of first block for frame allocations after call at %llx\n", - (unsigned long long) InstAddr); + (uint64_t) InstAddr); break; } } if (STARS_NONALLOC_INSTR_LIMIT <= NonAllocatingInstructions) { SMP_msg("INFO: Stopping search of first block for frame allocations at %llx\n", - (unsigned long long) InstAddr); + (uint64_t) InstAddr); break; } } @@ -3389,8 +3403,8 @@ bool SMPFunction::MDFindReturnTypes(void) { bool TypeErrorFlag = false; SMPOperandType NewType = SMPTypeMeet(OldType, CurrUse->GetType(), TypeErrorFlag); if (TypeErrorFlag) { - SMP_msg("ERROR: TypeMeet error in MDFindReturnTypes() func at %llx return at %llx\n", - (uint64_t) this->GetFirstFuncAddr(), (uint64_t) CurrInst->GetAddr()); + SMP_msg("ERROR: TypeMeet error in MDFindReturnTypes() return at %llx ", (uint64_t) CurrInst->GetAddr()); + this->DumpFuncNameAndAddr(); } if (NewType != OldType) { this->ReturnRegTypes[UseOp->GetReg()] = NewType; @@ -3429,7 +3443,7 @@ void SMPFunction::MDFindIncomingTypes(void) { SMPFunction *CallerFunc = this->GetProg()->FindFunction(CallerFirstAddr); if (nullptr == CallerFunc) { SMP_msg("FATAL ERROR: Program has no function at %llx which should be a caller of %llx\n", - (unsigned long long) CallerFirstAddr, (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) CallerFirstAddr, (uint64_t) this->GetFirstFuncAddr()); } assert(nullptr != CallerFunc); SMPInstr *CallSiteInst = CallerFunc->GetInstFromAddr(CallSiteAddr); @@ -3449,8 +3463,8 @@ void SMPFunction::MDFindIncomingTypes(void) { bool TypeErrorFlag = false; this->IncomingRegTypes[RegNum] = SMPTypeMeet(CallSiteType, OldType, TypeErrorFlag); if (TypeErrorFlag) { - SMP_msg("ERROR: TypeMeet error in MDFindIncomingTypes() at %llx\n", - (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: TypeMeet error in MDFindIncomingTypes() "); + this->DumpFuncNameAndAddr(); } // Note this type meet function is used in an aggressive way here, as // a mixture of UNINIT and NUMERIC at various call sites will produce NUMERIC, for example. @@ -3560,7 +3574,7 @@ void SMPFunction::BuildStackAccessTables(void) { if (!this->AnalyzedSP || (STARS_BADADDR == this->LocalVarsAllocInstr)) { SMP_msg("FindOutgoingArgsSize not called for %s ", this->GetFuncName()); SMP_msg("AnalyzedSP: %d CallsAlloca: %d LocalVarsAllocInstr: %llx \n", - this->AnalyzedSP, this->CallsAlloca, (unsigned long long) this->LocalVarsAllocInstr); + this->AnalyzedSP, this->CallsAlloca, (uint64_t) this->LocalVarsAllocInstr); return; } @@ -3615,7 +3629,8 @@ void SMPFunction::BuildStackAccessTables(void) { } if (0 < this->AllocPointDelta) { - SMP_msg("FATAL ERROR: AllocPointDelta = %ld in %s\n", (long) this->AllocPointDelta, this->GetFuncName()); + SMP_msg("FATAL ERROR: AllocPointDelta = %ld ", (long) this->AllocPointDelta); + this->DumpFuncNameAndAddr(); } assert(0 >= this->AllocPointDelta); @@ -3631,7 +3646,7 @@ void SMPFunction::BuildStackAccessTables(void) { STARS_sval_t sp_delta = CurrInst->GetStackPtrOffset(); if (0 < sp_delta) { // Stack underflow. - SMP_msg("WARNING: Stack underflow at %llx %s sp_delta: %ld\n", (unsigned long long) InstAddr, + SMP_msg("WARNING: Stack underflow at %llx %s sp_delta: %ld\n", (uint64_t) InstAddr, CurrInst->GetDisasm(), (long)sp_delta); #if 0 this->OutgoingArgsComputed = false; @@ -3668,8 +3683,8 @@ void SMPFunction::BuildStackAccessTables(void) { if (IndexedAccess) continue; // Indexed expressions can be within frame even when offset is outside frame else if (this->CallsAlloca) { - SMP_msg("ERROR: Stack access out of range at %llx due to alloca issues.\n", - (uint64_t)InstAddr); + SMP_msg("ERROR: Stack access out of range at %llx due to alloca issues. ", (uint64_t)InstAddr); + this->DumpFuncNameAndAddr(); this->AnalyzedSP = false; this->OutgoingArgsSize = 0; this->MinStackDelta = 0; @@ -3755,9 +3770,11 @@ void SMPFunction::BuildStackAccessTables(void) { pair<STARS_ea_t, struct FineGrainedInfo> InsertValue(InstAddr, StackDefFG); InsertResult = this->StackDefFGInfo.insert(InsertValue); if (!InsertResult.second) { - SMP_msg("FATAL ERROR: Duplicate item in StackDefFGInfo at %llx\n", (unsigned long long) InstAddr); + SMP_msg("FATAL ERROR: Duplicate item in StackDefFGInfo at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); SMP_msg("Inst dump follows:\n"); CurrInst->Dump(); + this->DumpDotCFG(); } assert(InsertResult.second); } @@ -3804,8 +3821,8 @@ void SMPFunction::BuildStackAccessTables(void) { if (IndexedAccess) continue; // Indexed expressions can be within frame even when offset is outside frame else if (this->CallsAlloca) { - SMP_msg("ERROR: Stack access out of range at %llx due to alloca issues.\n", - (uint64_t)InstAddr); + SMP_msg("ERROR: Stack access out of range at %llx due to alloca issues. ", (uint64_t)InstAddr); + this->DumpFuncNameAndAddr(); this->AnalyzedSP = false; this->OutgoingArgsSize = 0; this->MinStackDelta = 0; @@ -4096,8 +4113,8 @@ bool SMPFunction::MDGetStackOffsetAndSize(SMPInstr *Instr, const STARSOpndTypePt Signed = (opcode == STARS_NN_movsx); if ((0 > SignedOffset) && (!Indexed) && (BaseValue == this->MinStackAccessOffset) && (!this->DoesStackFrameExtendPastStackTop())) { // Consider asserting here. - SMP_msg("ERROR: Negative offset in MDGetStackOffsetAndSize at %llx for inst dump: \n", - (unsigned long long) Instr->GetAddr()); + SMP_msg("ERROR: Negative offset in MDGetStackOffsetAndSize at %llx for inst dump: ", (uint64_t) Instr->GetAddr()); + this->DumpFuncNameAndAddr(); Instr->Dump(); } return true; @@ -4114,7 +4131,7 @@ bool SMPFunction::MDGetStackOffsetAndSize(SMPInstr *Instr, const STARSOpndTypePt #else if (!(Indexed || (!this->StackPtrAnalysisSucceeded()) || !this->HasSTARSStackPtrAnalysisCompleted())) { SMP_msg("WARNING: Unnormalized FP-relative stack offset at %llx after stack analysis succeeded.\n", - (unsigned long long) Instr->GetAddr()); + (uint64_t) Instr->GetAddr()); } #endif unsigned short opcode = Instr->GetIDAOpcode(); @@ -4611,7 +4628,7 @@ bool SMPFunction::WritesAboveLocalFrame(const STARSOpndTypePtr &DestOp, bool OpN if (InArgWrite && OpNormalized && (0 == SignedOffset)) { SMP_msg("DANGER: Write to saved return address detected at %llx in function that begins at %llx\n", - (unsigned long long) InstAddr, (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) InstAddr, (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, RETURN_ADDRESS_WRITE); } @@ -4652,12 +4669,12 @@ bool SMPFunction::AccessAboveLocalFrame(const STARSOpndTypePtr &StackOp, bool Op if (InArgAccess && OpNormalized && (0 == SignedOffset)) { if (WriteAccess) { SMP_msg("DANGER: Write to saved return address detected at %llx in function that begins at %llx\n", - (unsigned long long) InstAddr, (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) InstAddr, (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, RETURN_ADDRESS_WRITE); } else { SMP_msg("INFO: Read of saved return address detected at %llx in function that begins at %llx\n", - (unsigned long long) InstAddr, (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) InstAddr, (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, RETURN_ADDRESS_READ); } } @@ -4849,14 +4866,14 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { #if 0 if (0 < IncomingArgsSize) { SMP_fprintf(AnnotFile, "%18llx %6llu INARGS STACK esp + %ld %s \n", - (unsigned long long) addr, (unsigned long long) IncomingArgsSize, + (uint64_t) addr, (uint64_t) IncomingArgsSize, (long) (this->GetLocalVarsSize() + CalleeSavedRegsSize + RetAddrSize), Instr->GetDisasm()); } #endif if (0 < this->RetAddrSize) { SMP_fprintf(AnnotFile, "%18llx %6d MEMORYHOLE STACK esp + %lu ReturnAddress \n", - (unsigned long long) addr, RetAddrSize, (unsigned long)(this->GetLocalVarsSize() + this->CalleeSavedRegsSize)); + (uint64_t) addr, RetAddrSize, (unsigned long)(this->GetLocalVarsSize() + this->CalleeSavedRegsSize)); } if (this->GoodLocalVarTable && (!this->NegativeOffsetStackFrameMap.empty())) { // Walk through the NegativeOffsetStackFrameMap and emit annotations for the regions. @@ -4879,7 +4896,7 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { else { // changing regions; time for annotation for previous region if (CurrentRegionType == STARS_STACK_CALLEE_SAVED_REG) { SMP_fprintf(AnnotFile, "%18llx %6u MEMORYHOLE STACK esp + %lu CalleeSavedRegs \n", - (unsigned long long) addr, CurrentRegionBytes, (unsigned long) (index + 1 - AllocIndex)); + (uint64_t) addr, CurrentRegionBytes, (unsigned long) (index + 1 - AllocIndex)); } else if (CurrentRegionType == STARS_STACK_LOCAL_FRAME) { ParentReferentID = global_STARS_program->GetDataReferentID(); @@ -4889,8 +4906,9 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { if (this->GetLocalVarsSize() != (TempRegionBytes + TempOutArgsSize)) { if (!this->HasPushAfterFrameAlloc()) { // Suspect incorrect function boundaries in most of these cases. - SMP_msg("ERROR: LocalVarsSize: %lu not sum of CurrentRegionBytes: %lu and OutArgsSize: %lu at %llx\n", + SMP_msg("ERROR: LocalVarsSize: %lu not sum of CurrentRegionBytes: %lu and OutArgsSize: %lu at %llx ", (unsigned long) this->GetLocalVarsSize(), (unsigned long)TempRegionBytes, (unsigned long)TempOutArgsSize, (uint64_t)addr); + this->DumpFuncNameAndAddr(); #if 1 this->Dump(); this->DumpDotCFG(); @@ -4898,7 +4916,7 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { } } SMP_fprintf(AnnotFile, "%18llx %6u DATAREF STACK %lu esp + 0 PARENT LocalFrame LOCALFRAME\n", - (unsigned long long) addr, CurrentRegionBytes + this->OutgoingArgsSize, (unsigned long) ParentReferentID); + (uint64_t) addr, CurrentRegionBytes + this->OutgoingArgsSize, (unsigned long) ParentReferentID); LocalFrameEmitted = true; } else if (CurrentRegionType == STARS_STACK_OUTARG) { @@ -4906,11 +4924,11 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { ParentReferentID = global_STARS_program->GetDataReferentID(); global_STARS_program->IncrementDataReferentID(); SMP_fprintf(AnnotFile, "%18llx %6u DATAREF STACK %lu esp + 0 PARENT LocalFrame LOCALFRAME\n", - (unsigned long long) addr, CurrentRegionBytes, (unsigned long)ParentReferentID); + (uint64_t) addr, CurrentRegionBytes, (unsigned long)ParentReferentID); LocalFrameEmitted = true; } SMP_fprintf(AnnotFile, "%18llx %6zu DATAREF STACK %lu esp + %d CHILDOF %lu OFFSET %d OutArgsRegion OUTARGS\n", - (unsigned long long) addr, CurrentRegionBytes, global_STARS_program->GetDataReferentID(), + (uint64_t) addr, CurrentRegionBytes, global_STARS_program->GetDataReferentID(), (unsigned long) (index + 1 - AllocIndex), ParentReferentID, 0); global_STARS_program->IncrementDataReferentID(); } @@ -4927,13 +4945,13 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { if (CurrentRegionBytes > 0) { // Get last region as we exited the loop. if (CurrentRegionType == STARS_STACK_CALLEE_SAVED_REG) { SMP_fprintf(AnnotFile, "%18llx %6u MEMORYHOLE STACK esp + 0 CalleeSavedRegs \n", - (unsigned long long) addr, CurrentRegionBytes); + (uint64_t) addr, CurrentRegionBytes); } else if (CurrentRegionType == STARS_STACK_LOCAL_FRAME) { ParentReferentID = global_STARS_program->GetDataReferentID(); global_STARS_program->IncrementDataReferentID(); SMP_fprintf(AnnotFile, "%18llx %6u DATAREF STACK %lu esp + 0 PARENT LocalFrame LOCALFRAME\n", - (unsigned long long) addr, CurrentRegionBytes, (unsigned long) ParentReferentID); + (uint64_t) addr, CurrentRegionBytes, (unsigned long) ParentReferentID); LocalFrameEmitted = true; } else if (CurrentRegionType == STARS_STACK_OUTARG) { @@ -4941,11 +4959,11 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { ParentReferentID = global_STARS_program->GetDataReferentID(); global_STARS_program->IncrementDataReferentID(); SMP_fprintf(AnnotFile, "%18llx %6u DATAREF STACK %lu esp + 0 PARENT LocalFrame LOCALFRAME\n", - (unsigned long long) addr, CurrentRegionBytes, (unsigned long)ParentReferentID); + (uint64_t) addr, CurrentRegionBytes, (unsigned long)ParentReferentID); LocalFrameEmitted = true; } SMP_fprintf(AnnotFile, "%18llx %6zu DATAREF STACK %lu esp + 0 CHILDOF %lu OFFSET %d OutArgsRegion OUTARGS\n", - (unsigned long long) addr, CurrentRegionBytes, global_STARS_program->GetDataReferentID(), ParentReferentID, 0); + (uint64_t) addr, CurrentRegionBytes, global_STARS_program->GetDataReferentID(), ParentReferentID, 0); global_STARS_program->IncrementDataReferentID(); } } @@ -4962,29 +4980,29 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { #if 0 if (0 < IncomingArgsSize) { SMP_fprintf(AnnotFile, "%18llx %6llu INARGS STACK esp + %ld %s \n", - (unsigned long long) addr, (unsigned long long) IncomingArgsSize, + (uint64_t) addr, (uint64_t) IncomingArgsSize, (long) (this->GetLocalVarsSize() + CalleeSavedRegsSize + RetAddrSize), Instr->GetDisasm()); } #endif if (0 < this->RetAddrSize) { SMP_fprintf(AnnotFile, "%18llx %6d MEMORYHOLE STACK esp + %lu ReturnAddress \n", - (unsigned long long) addr, RetAddrSize, (unsigned long) (this->GetLocalVarsSize() + this->CalleeSavedRegsSize)); + (uint64_t) addr, RetAddrSize, (unsigned long) (this->GetLocalVarsSize() + this->CalleeSavedRegsSize)); } if (0 < this->CalleeSavedRegsSize) { SMP_fprintf(AnnotFile, "%18llx %6u MEMORYHOLE STACK esp + %lu CalleeSavedRegs \n", - (unsigned long long) addr, this->CalleeSavedRegsSize, (unsigned long) this->GetLocalVarsSize()); + (uint64_t) addr, this->CalleeSavedRegsSize, (unsigned long) this->GetLocalVarsSize()); } if ((0 < this->GetLocalVarsSize()) && this->GoodLocalVarTable) { unsigned long ParentReferentID = global_STARS_program->GetDataReferentID(); global_STARS_program->IncrementDataReferentID(); SMP_fprintf(AnnotFile, "%18llx %6lu DATAREF STACK %lu esp + %d PARENT LocalFrame LOCALFRAME\n", - (unsigned long long) addr, (unsigned long) this->GetLocalVarsSize(), ParentReferentID, 0); + (uint64_t) addr, (unsigned long) this->GetLocalVarsSize(), ParentReferentID, 0); if (this->AnalyzedSP && !this->CallsAlloca && (STARS_BADADDR != this->LocalVarsAllocInstr)) { // We can only fine-grain the stack frame if we were able to analyze the stack if (this->OutgoingArgsSize > 0) { SMP_fprintf(AnnotFile, "%18llx %6zu DATAREF STACK %lu esp + %d CHILDOF %lu OFFSET %d OutArgsRegion OUTARGS\n", - (unsigned long long) addr, this->OutgoingArgsSize, global_STARS_program->GetDataReferentID(), 0, ParentReferentID, 0); + (uint64_t) addr, this->OutgoingArgsSize, global_STARS_program->GetDataReferentID(), 0, ParentReferentID, 0); global_STARS_program->IncrementDataReferentID(); } #if SMP_DEBUG_STACK_GRANULARITY @@ -5002,7 +5020,7 @@ void SMPFunction::EmitStackFrameAnnotations(FILE *AnnotFile, SMPInstr *Instr) { || (this->LocalVarTable[i].offset < (long) this->OutgoingArgsSize)) continue; SMP_fprintf(AnnotFile, "%18llx %6zu DATAREF STACK %lu esp + %ld CHILDOF %lu OFFSET %ld LOCALVAR %s \n", - (unsigned long long) addr, this->LocalVarTable[i].size, global_STARS_program->GetDataReferentID(), + (uint64_t) addr, this->LocalVarTable[i].size, global_STARS_program->GetDataReferentID(), this->LocalVarTable[i].offset, ParentReferentID, this->LocalVarTable[i].offset, this->LocalVarTable[i].VarName); global_STARS_program->IncrementDataReferentID(); @@ -5190,7 +5208,7 @@ void SMPFunction::AnalyzeFunc(void) { // it before it clutters up SSA, and just in case it has some weird code pattern // before it that obscures the fact that it is unreachable. CurrBlock->SetUnreachableBlock(true); - SMP_msg("INFO: Marking basic block unreachable due to call 0 instruction at %llx\n", (unsigned long long) InstAddr); + SMP_msg("INFO: Marking basic block unreachable due to call 0 instruction at %llx\n", (uint64_t) InstAddr); } else { if (CALL == InstDataFlowType) { @@ -5198,7 +5216,8 @@ void SMPFunction::AnalyzeFunc(void) { bool NewDirectTarget = this->AddDirectCallTarget(CallTarget); } else { - SMP_msg("ERROR: Direct call with bad target at %llx\n", (unsigned long long) InstAddr); + SMP_msg("ERROR: Direct call with bad target at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } } else { // INDIR_CALL @@ -5816,7 +5835,7 @@ void SMPFunction::AnalyzeMetadataLiveness(void) { #endif if (DebugFlag) { - SMP_msg("Inst addr: %llx \n", (unsigned long long) CurrInst->GetAddr()); + SMP_msg("Inst addr: %llx \n", (uint64_t) CurrInst->GetAddr()); } CurrDef = CurrInst->GetFirstDef(); while (CurrDef != CurrInst->GetLastDef()) { @@ -5862,8 +5881,8 @@ void SMPFunction::AnalyzeMetadataLiveness(void) { CurrUse = CurrInst->FindUse(BaseOp); if (CurrUse == CurrInst->GetLastUse()) { SMP_msg("FATAL ERROR: BaseReg %d not in USE list at %llx for %s\n", - BaseOp->GetReg(), (unsigned long long) CurrInst->GetAddr(), - CurrInst->GetDisasm()); + BaseOp->GetReg(), (uint64_t) CurrInst->GetAddr(), CurrInst->GetDisasm()); + this->DumpDotCFG(); assert(CurrUse != CurrInst->GetLastUse()); // kablooey! } if (this->IsGlobalName(BaseOp)) { @@ -5885,8 +5904,8 @@ void SMPFunction::AnalyzeMetadataLiveness(void) { CurrUse = CurrInst->FindUse(IndexOp); if (CurrUse == CurrInst->GetLastUse()) { SMP_msg("FATAL ERROR: IndexReg %d not in USE list at %llx for %s\n", - IndexOp->GetReg(), (unsigned long long) CurrInst->GetAddr(), - CurrInst->GetDisasm()); + IndexOp->GetReg(), (uint64_t) CurrInst->GetAddr(), CurrInst->GetDisasm()); + this->DumpDotCFG(); } assert(CurrUse != CurrInst->GetLastUse()); if (0 != ScaleFactor) { @@ -6287,7 +6306,8 @@ void SMPFunction::SparseConditionalConstantPropagation(void) { // endif // endfor if (CurrBlock->IsUnreachableBlock()) { // must have a call 0 instruction - SMP_msg("ERROR: Unreachable block is being visited by SCCP at %llx\n", (unsigned long long) CurrBlock->GetFirstAddr()); + SMP_msg("ERROR: Unreachable block is being visited by SCCP at %llx ", (uint64_t) CurrBlock->GetFirstAddr()); + this->DumpFuncNameAndAddr(); } enum STARSBranchConst BranchEval = STARS_BRANCH_UNKNOWN; CurrBlock->SCCPEvaluateConstants(BranchEval, CFGWorkList, SSAWorkList); // also marks block as SCCP visited @@ -6428,7 +6448,7 @@ void SMPFunction::SparseConditionalConstantPropagation(void) { (uint64_t) FirstInst->GetAddr(), FirstInst->GetSize(), FirstInst->GetDisasm()); #if STARS_DEBUG_FUNC_SCCP STARS_ea_t BlockAddr = CurrBlock->GetFirstAddr(); - SMP_msg("INFO: SCCP found unreachable block at %llx\n", (unsigned long long) BlockAddr); + SMP_msg("INFO: SCCP found unreachable block at %llx\n", (uint64_t) BlockAddr); #endif this->GetProg()->AddBlockToRemovalList(CurrBlock); #if STARS_SCCP_CONVERT_UNREACHABLE_BLOCKS @@ -6494,7 +6514,7 @@ void SMPFunction::AuditSCCPForIndirectTargets(void) { } if (ConstStruct.ConstType == STARS_CONST_HAS_VALUE) { SMP_msg("INFO: SCCP found constant value of %llx for indirect target at %llx\n", - (unsigned long long) ConstStruct.ConstValue, (unsigned long long) CurrInst->GetAddr()); + (uint64_t) ConstStruct.ConstValue, (uint64_t) CurrInst->GetAddr()); pair<set<STARS_ea_t>::iterator, bool> InsertResult = this->ConstantIndirCalls.insert(CurrInst->GetAddr()); assert(InsertResult.second); } @@ -7662,7 +7682,8 @@ void SMPFunction::DetectLoopInvariantDEFs(void) { } } else { - SMP_msg("ERROR: Unknown operand type at %llx in DetectLoopInvariantDEFs\n", (unsigned long long) DefAddr); + SMP_msg("ERROR: Unknown operand type at %llx in DetectLoopInvariantDEFs ", (uint64_t) DefAddr); + this->DumpFuncNameAndAddr(); VariantUseFound = true; break; } @@ -7672,8 +7693,8 @@ void SMPFunction::DetectLoopInvariantDEFs(void) { pair<set<STARS_ea_t>::iterator, bool> InsertResult = this->LoopInvariantDEFs[LoopIndex].insert(DefAddr); ++LoopInvariantDEFCount; #if STARS_DEBUG_LOOP_INVARIANTS - SMP_msg("INFO: Invariant DEF at %llx LoopHeadAddr: %llx\n", (unsigned long long) DefAddr, - (unsigned long long) this->GetBlockByNum(HeadBlockNum)->GetFirstAddr()); + SMP_msg("INFO: Invariant DEF at %llx LoopHeadAddr: %llx\n", (uint64_t) DefAddr, + (uint64_t) this->GetBlockByNum(HeadBlockNum)->GetFirstAddr()); #endif } } @@ -7978,15 +7999,17 @@ void SMPFunction::DetectLoopInductionVars(void) { } else { FoundBIV = false; - SMP_msg("ERROR: Non-matching BIV candidates in loop %d in func %s\n", - LoopIndex, this->GetFuncName()); + SMP_msg("ERROR: Non-matching BIV candidates in loop %d ", LoopIndex); + this->DumpFuncNameAndAddr(); SMP_msg("Current BIV candidate: "); DumpInductionVar(BIVTriple); SMP_msg("\nExisting BIV candidate: "); DumpInductionVar(CurrentFamily.BasicInductionVar); SMP_msg("\n"); - if (VerboseOutput) + if (VerboseOutput) { this->Dump(); + this->DumpDotCFG(); + } break; } } @@ -8011,8 +8034,8 @@ void SMPFunction::DetectLoopInductionVars(void) { } } // end for all Phi functions in current loop header block if (!FoundBIV) { - SMP_msg("ERROR: LOOP: BIV not found for loop %d at %llx in func %s\n", LoopIndex, - (uint64_t) HeaderBlock->GetFirstAddr(), this->GetFuncName()); + SMP_msg("ERROR: LOOP: BIV not found for loop %d at %llx ", LoopIndex, (uint64_t) HeaderBlock->GetFirstAddr()); + this->DumpFuncNameAndAddr(); ++STARS_LoopInductionVarIDFailures; } else { @@ -8436,8 +8459,8 @@ void SMPFunction::DetectLoopInductionVars2(void) { } else { FoundBIV = false; - SMP_msg("ERROR: Non-matching BIV candidates in loop %d in func %s\n", - LoopIndex, this->GetFuncName()); + SMP_msg("ERROR: Non-matching BIV candidates in loop %d ", LoopIndex); + this->DumpFuncNameAndAddr(); SMP_msg("Current BIV candidate: "); DumpInductionVar(BIVTriple); SMP_msg("\nExisting BIV candidate: "); @@ -8474,8 +8497,8 @@ void SMPFunction::DetectLoopInductionVars2(void) { } } // end for all Phi functions in header block if (!FoundBIV) { - SMP_msg("ERROR: LOOP: BIV not found for loop %d at %llx in func %s\n", LoopIndex, - (uint64_t)HeaderBlock->GetFirstAddr(), this->GetFuncName()); + SMP_msg("ERROR: LOOP: BIV not found for loop %d at %llx ", LoopIndex, (uint64_t)HeaderBlock->GetFirstAddr()); + this->DumpFuncNameAndAddr(); ++STARS_LoopInductionVarIDFailures; } else { @@ -8989,15 +9012,16 @@ bool SMPFunction::ComputeEdgeExpressions(void) { BranchExpr.Operand2 = ZeroUse; } else { - SMP_msg("ERROR: COND_BRANCH: Decrement with BranchOperator %d in test block %d DecrementAddr %llx in func %s at %llx\n", - BranchOperator, BranchBlockNum, (uint64_t)DecrementAddr, this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: COND_BRANCH: Decrement with BranchOperator %d in test block %d DecrementAddr %llx ", + BranchOperator, BranchBlockNum, (uint64_t)DecrementAddr); + this->DumpFuncNameAndAddr(); success = false; break; } } else { - SMP_msg("ERROR: COND_BRANCH: Could not find compare or test in test block %d in func %s at %llx\n", - BranchBlockNum, this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: COND_BRANCH: Could not find compare or test in test block %d ", BranchBlockNum); + this->DumpFuncNameAndAddr(); success = false; break; } @@ -9021,8 +9045,8 @@ bool SMPFunction::ComputeEdgeExpressions(void) { } else if (CurrBlock->HasIndirectJump()) { // stub out for now - SMP_msg("ERROR: INDIR_JUMP: Not ready to analyze in func %s at %llx\n", - this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: INDIR_JUMP: Not ready to analyze "); + this->DumpFuncNameAndAddr(); success = false; break; } @@ -9106,7 +9130,8 @@ void SMPFunction::ComputeInArgConstValues(void) { } } else { - SMP_msg("ERROR: Incoming ArgIndex of %u in SMPFunction::ComputeInArgConstValues\n", ArgIndex); + SMP_msg("ERROR: Incoming ArgIndex of %u in SMPFunction::ComputeInArgConstValues ", ArgIndex); + this->DumpFuncNameAndAddr(); } } } @@ -9165,8 +9190,8 @@ STARSExpression* SMPFunction::CreateLimitExpr(const std::size_t &LoopIndex, cons } } else { - SMP_msg("ERROR: ExpandExpr() failure in CreateLimitExpr() attempt to find BIV for loop %zu in func at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: ExpandExpr() failure in CreateLimitExpr() attempt to find BIV for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); } } @@ -9208,8 +9233,8 @@ STARSExpression *SMPFunction::CreateSecondaryBIVLimitExpr(const std::size_t &Loo bool ImmedMultiplier = IVFamily.BasicInductionVar.Multiplier.GetOp()->IsImmedOp(); STARS_uval_t MultiplierValue = ImmedMultiplier ? IVFamily.BasicInductionVar.Multiplier.GetOp()->GetImmedValue() : 0; if (!ImmedMultiplier || (1 != MultiplierValue)) { - SMP_msg("ERROR: BIV has multiplier of value %llu in loop %zu for Func starting at %llx\n", - (uint64_t) MultiplierValue, LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: BIV has multiplier of value %llu in loop %zu ", (uint64_t) MultiplierValue); + this->DumpFuncNameAndAddr(); return nullptr; } STARSOpndTypePtr StrideOp = IVFamily.BasicInductionVar.Addend.GetOp()->clone(); @@ -9351,7 +9376,8 @@ STARSExpression* SMPFunction::CreateIterationsExpr(std::size_t LoopIndex, const && (IVFamily.BasicInductionVar.Multiplier.GetOp()->GetImmedValue() == 1) && IVFamily.BasicInductionVar.Addend.GetOp()->IsImmedOp()); if (!SimpleBIV) { - SMP_msg("ERROR: CreateIterationsExpr() did not find SimpleBIV for loop %u\n", LoopIndex); + SMP_msg("ERROR: CreateIterationsExpr() did not find SimpleBIV for loop %u ", LoopIndex); + this->DumpFuncNameAndAddr(); return nullptr; } @@ -9460,8 +9486,9 @@ STARSExpression* SMPFunction::CreateIterationsExpr(std::size_t LoopIndex, const } } if (Undefined) { - SMP_msg("ERROR: CreateIterationsExpr() found Undefined terminating relational operator for loop %u operator %s PosIncr: %d BottomTesting: %d\n", + SMP_msg("ERROR: CreateIterationsExpr() found Undefined terminating relational operator for loop %u operator %s PosIncr: %d BottomTesting: %d ", LoopIndex, OperatorText[BranchOperator], PositiveIncrement, BottomTestingLoop); + this->DumpFuncNameAndAddr(); return nullptr; } @@ -9681,7 +9708,8 @@ bool SMPFunction::CreateSPARKMemoryWriteRangeExpr(size_t LoopIndex, bool RecordL MemoryRangeExpr = this->CreateMemoryAddressExpr(MemDefOp, CurrInst); if (nullptr == MemoryRangeExpr) { OneFailure = true; // failure - SMP_msg("ERROR: CreateSPARKMemoryWriteRangeExpr() abandoned due to CreateMemoryAddressExpr() failure at %llx.\n", (uint64_t) InstAddr); + SMP_msg("ERROR: CreateSPARKMemoryWriteRangeExpr() abandoned due to CreateMemoryAddressExpr() failure at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); continue; } // Expand and simplify the addressing expression. @@ -9705,8 +9733,9 @@ bool SMPFunction::CreateSPARKMemoryWriteRangeExpr(size_t LoopIndex, bool RecordL if (!success) { delete MemoryRangeExpr; MemoryRangeExpr = nullptr; - SMP_msg("ERROR: CreateSPARKMemoryWriteRangeExpr() error due to ExpandExpr() failure on loop %zu InstAddr %llx in func at %llx\n", - LoopIndex, (uint64_t) InstAddr, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: CreateSPARKMemoryWriteRangeExpr() error due to ExpandExpr() failure on loop %zu InstAddr %llx ", + LoopIndex, (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); OneFailure = true; // failure continue; } @@ -9809,7 +9838,8 @@ bool SMPFunction::CreateSPARKMemoryReadRangeExprs(size_t LoopIndex, bool RecordL MemoryRangeExpr = this->CreateMemoryAddressExpr(MemUseOp, CurrInst); if (nullptr == MemoryRangeExpr) { OneFailure = true; // failure - SMP_msg("ERROR: LOOP: CreateSPARKMemoryReadRangeExprs() abandoned due to CreateMemoryAddressExpr() failure at %llx.\n", (uint64_t)InstAddr); + SMP_msg("ERROR: LOOP: CreateSPARKMemoryReadRangeExprs() abandoned due to CreateMemoryAddressExpr() failure at %llx ", (uint64_t)InstAddr); + this->DumpFuncNameAndAddr(); continue; } // Expand and simplify the addressing expression. @@ -9828,8 +9858,9 @@ bool SMPFunction::CreateSPARKMemoryReadRangeExprs(size_t LoopIndex, bool RecordL if (!success) { delete MemoryRangeExpr; MemoryRangeExpr = nullptr; - SMP_msg("ERROR: LOOP: CreateSPARKMemoryReadRangeExpr() error due to ExpandExpr() failure on loop %zu InstAddr %llx in func at %llx\n", - LoopIndex, (uint64_t)InstAddr, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: CreateSPARKMemoryReadRangeExpr() error due to ExpandExpr() failure on loop %zu InstAddr %llx ", + LoopIndex, (uint64_t)InstAddr); + this->DumpFuncNameAndAddr(); OneFailure = true; // failure continue; } @@ -9900,7 +9931,8 @@ STARSExpression* SMPFunction::CreateMemoryAddressExpr(const STARSOpndTypePtr &Me STARSExpression *MemoryAddressExpr = nullptr; STARS_ea_t WriteAddr = WriteInst->GetAddr(); if (MemDefOp->GetSegReg() == STARS_x86_R_cs && (!MemDefOp->IsStaticMemOp())) { - SMP_msg("ERROR: CreateMemoryAddressExpr() fails on CS-relative MemDefOp at %llx\n", (uint64_t) WriteAddr); + SMP_msg("ERROR: CreateMemoryAddressExpr() fails on CS-relative MemDefOp at %llx ", (uint64_t) WriteAddr); + this->DumpFuncNameAndAddr(); return MemoryAddressExpr; // cannot handle IP-relative memory writes, and should only happen for reads } @@ -10491,7 +10523,8 @@ bool SMPFunction::ReplaceAllBIVsWithExprs(std::size_t LoopIndex, STARSExpression else { // Alternative: Should we not insist on SSANum match? !!!!****!!!! success = false; - SMP_msg("ERROR: CurrSSANum = %d does not match; IVFamily dump follows.\n", CurrSSANum); + SMP_msg("ERROR: CurrSSANum = %d does not match; IVFamily dump follows. ", CurrSSANum); + this->DumpFuncNameAndAddr(); DumpInductionVarFamily(IVFamily); } } @@ -10535,7 +10568,8 @@ bool SMPFunction::ReplaceAllBIVsWithExprs(std::size_t LoopIndex, STARSExpression if (nullptr == IVFamily.BIVInitExpr) { assert(0 <= IVLoopIndex); success = false; - SMP_msg("ERROR: null IVFamily.BIVInitExpr: IVFamily Dump follows.\n"); + SMP_msg("ERROR: null IVFamily.BIVInitExpr: IVFamily Dump follows. "); + this->DumpFuncNameAndAddr(); DumpInductionVarFamily(IVFamily); } else { @@ -10571,7 +10605,8 @@ bool SMPFunction::ReplaceAllBIVsWithExprs(std::size_t LoopIndex, STARSExpression else if (nullptr == IVFamily.BIVLimitExpr) { // LimitExpr case, safeguard assert(0 <= IVLoopIndex); success = false; - SMP_msg("ERROR: null IVFamily.BIVLimitExpr: IVFamily Dump follows.\n"); + SMP_msg("ERROR: null IVFamily.BIVLimitExpr: IVFamily Dump follows. "); + this->DumpFuncNameAndAddr(); DumpInductionVarFamily(IVFamily); } else { // LimitExpr case, safe to proceed @@ -10663,7 +10698,8 @@ bool SMPFunction::ReplaceAllBIVsWithExprs(std::size_t LoopIndex, STARSExpression else { // Alternative: Should we not insist on SSANum match? !!!!****!!!! success = false; - SMP_msg("ERROR: CurrSSANum = %d does not match; IVFamily dump follows.\n"); + SMP_msg("ERROR: CurrSSANum = %d does not match; IVFamily dump follows. "); + this->DumpFuncNameAndAddr(); DumpInductionVarFamily(IVFamily); } } @@ -10864,13 +10900,15 @@ bool SMPFunction::ExpandExprToInArgs(std::size_t LoopIndex, STARSExpression *Cur if (success && StoppedOnIV) { success = this->ReplaceAllIVsWithExprs(LoopIndex, CurrExpr, InitCase, changed); if (!success) { - SMP_msg("ERROR: LOOP: ReplaceAllIVs failure in ExpandExprToInArgs, InitCase %d iteration %u for UseAddr %llx loop %zu\n", + SMP_msg("ERROR: LOOP: ReplaceAllIVs failure in ExpandExprToInArgs, InitCase %d iteration %u for UseAddr %llx loop %zu ", InitCase, IterationCount, (uint64_t)OrigUseAddr, LoopIndex); + this->DumpFuncNameAndAddr(); } } else { - SMP_msg("ERROR: LOOP: ExpandExpr failure in ExpandExprToInArgs, InitCase %d iteration %u for UseAddr %llx loop %zu\n", + SMP_msg("ERROR: LOOP: ExpandExpr failure in ExpandExprToInArgs, InitCase %d iteration %u for UseAddr %llx loop %zu ", InitCase, IterationCount, (uint64_t) OrigUseAddr, LoopIndex); + this->DumpFuncNameAndAddr(); } if (success) { CurrExpr->EvaluateConsts(); @@ -10985,8 +11023,9 @@ void SMPFunction::DetectInArgRegsNeededForMemWriteExprs(void) { } else { // StoppedOnIV this->SymbolicAnalysisProblems[InnerLoopNumPlusOne] = true; - SMP_msg("ERROR: SPARK: Expr Expand() StoppedOnIV in DetectInArgRegsNeededForMemWriteExprs() at %llx\n", + SMP_msg("ERROR: SPARK: Expr Expand() StoppedOnIV in DetectInArgRegsNeededForMemWriteExprs() at %llx ", (uint64_t) MemWriteAddr); + this->DumpFuncNameAndAddr(); pair<STARSExprSetIter, bool> InsertResult = this->StoppedOnIVNonRangeExprs[InnerLoopNumPlusOne].insert(DefExpr); if (InsertResult.second) { // new Expr pair<STARSExprSetIter, size_t> InsertValue(InsertResult.first, DefWidth); @@ -10996,14 +11035,16 @@ void SMPFunction::DetectInArgRegsNeededForMemWriteExprs(void) { } else { this->SymbolicAnalysisProblems[InnerLoopNumPlusOne] = true; - SMP_msg("ERROR: ExpandExpr() failure in DetectInArgRegsNeededForMemWriteExprs() at %llx\n", + SMP_msg("ERROR: ExpandExpr() failure in DetectInArgRegsNeededForMemWriteExprs() at %llx ", (uint64_t) MemWriteAddr); + this->DumpFuncNameAndAddr(); } } } else { - SMP_msg("ERROR: CreateMemDefAddrExpr() failure in DetectInArgRegsNeededForMemWriteExprs() at %llx\n", + SMP_msg("ERROR: CreateMemDefAddrExpr() failure in DetectInArgRegsNeededForMemWriteExprs() at %llx ", (uint64_t) MemWriteAddr); + this->DumpFuncNameAndAddr(); } } } // end if not direct stack access operand @@ -11029,7 +11070,8 @@ void SMPFunction::ExpandLoopRegHashExprs(void) { STARS_regnum_t DefRegNo = (STARS_regnum_t) ExtractRegFromHash(DefHashValue); STARS_ea_t DefAddr = this->GetGlobalDefAddrForRegHash(DefHashValue); if ((STARS_BADADDR == DefAddr) || STARS_IsBlockNumPseudoID(DefAddr) || STARS_IsLiveInPseudoID(DefAddr)) { - SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() found DefAddr %llx for DefHashValue %llx\n", (uint64_t) DefAddr, (uint64_t) DefHashValue); + SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() found DefAddr %llx for DefHashValue %llx ", (uint64_t) DefAddr, (uint64_t) DefHashValue); + this->DumpFuncNameAndAddr(); this->SymbolicAnalysisProblems[LoopNum + 1] = true; } else if (STARS_IsSSAMarkerPseudoID(DefAddr)) { @@ -11060,7 +11102,8 @@ void SMPFunction::ExpandLoopRegHashExprs(void) { STARSOpndTypePtr DefOp = DefInst->MakeRegOpnd(DefRegNo); SMPRegTransfer *DefRT = DefInst->GetDefRT(DefOp); if (nullptr == DefRT) { - SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() did not find DefRT at DefAddr %llx for DefHashValue %llx\n", (uint64_t) DefAddr, (uint64_t) DefHashValue); + SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() did not find DefRT at DefAddr %llx for DefHashValue %llx ", (uint64_t) DefAddr, (uint64_t) DefHashValue); + this->DumpFuncNameAndAddr(); this->SymbolicAnalysisProblems[LoopNum + 1] = true; } else { @@ -11079,16 +11122,19 @@ void SMPFunction::ExpandLoopRegHashExprs(void) { if (InsertResult.second) { // new expr pair<STARS_regnum_t, STARSExprSetIter> InsertValue(DefRegNo, InsertResult.first); this->LoopRegSourceExprPairs[LoopNum].push_back(InsertValue); - SMP_msg("INFO: SPARK: ExpandLoopRegHashExprs() succeeded at DefAddr %llx for DefHashValue %llx\n", (uint64_t) DefAddr, (uint64_t) DefHashValue); + SMP_msg("INFO: SPARK: ExpandLoopRegHashExprs() succeeded at DefAddr %llx for DefHashValue %llx ", (uint64_t) DefAddr, (uint64_t) DefHashValue); + this->DumpFuncNameAndAddr(); } } else { - SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() StoppedOnIV for DefAddr %llx for DefHashValue %llx\n", (uint64_t)DefAddr, (uint64_t)DefHashValue); + SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() StoppedOnIV for DefAddr %llx for DefHashValue %llx ", (uint64_t)DefAddr, (uint64_t)DefHashValue); + this->DumpFuncNameAndAddr(); this->SymbolicAnalysisProblems[LoopNum + 1] = true; } } else { - SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() failed ExpandExpr for DefAddr %llx for DefHashValue %llx\n", (uint64_t) DefAddr, (uint64_t) DefHashValue); + SMP_msg("ERROR: SPARK: ExpandLoopRegHashExprs() failed ExpandExpr for DefAddr %llx for DefHashValue %llx ", (uint64_t) DefAddr, (uint64_t) DefHashValue); + this->DumpFuncNameAndAddr(); this->SymbolicAnalysisProblems[LoopNum + 1] = true; } } @@ -11118,7 +11164,7 @@ bool SMPFunction::AnalyzeSwitchStatement(SMPBasicBlock *CurrBlock) { if (!success) { StructuredSwitch = false; SMP_msg("WARNING: Unstructured switch at %llx due to SMPInstr::AnalyzeSwitchInfo failure.\n", - (unsigned long long) LastAddr); + (uint64_t) LastAddr); } else { // Mark the jumps to the default case and find the dominator node. @@ -11154,8 +11200,8 @@ bool SMPFunction::AnalyzeSwitchStatement(SMPBasicBlock *CurrBlock) { ; } else { // something odd here - SMP_msg("ERROR: Inst at %llx should jump or fall through to switch follow node.\n", - (unsigned long long) LastAddr); + SMP_msg("ERROR: Inst at %llx should jump or fall through to switch follow node ", (uint64_t) LastAddr); + this->DumpFuncNameAndAddr(); } } // Mark jumps around the default case to the INDIR_JUMP. @@ -11187,16 +11233,16 @@ bool SMPFunction::AnalyzeSwitchStatement(SMPBasicBlock *CurrBlock) { else { StructuredSwitch = false; SMP_msg("WARNING: Unstructured switch at %llx due to SMPFunction::FindSwitchStatementFollowBLock failure.\n", - (unsigned long long) LastAddr); + (uint64_t) LastAddr); } } } if (StructuredSwitch) { - SMP_msg("INFO: Structured switch at %llx\n", (unsigned long long) LastInst->GetAddr()); + SMP_msg("INFO: Structured switch at %llx\n", (uint64_t) LastInst->GetAddr()); } else { - SMP_msg("INFO: Unstructured switch at %llx\n", (unsigned long long) LastInst->GetAddr()); + SMP_msg("INFO: Unstructured switch at %llx\n", (uint64_t) LastInst->GetAddr()); } return StructuredSwitch; @@ -11241,8 +11287,7 @@ void SMPFunction::FindSwitchIDom(struct SwitchTableInfo &TableInfo) { else { // Not sure what is going on. if (!this->PrintedSPARKUnstructuredMsg) { - SMP_msg("ERROR: SPARK: Unstructured due to switch control flow at %llx ", - (uint64_t)LastAddr); + SMP_msg("ERROR: SPARK: Unstructured due to switch control flow at %llx ", (uint64_t)LastAddr); this->DumpFuncNameAndAddr(); this->PrintedSPARKUnstructuredMsg = true; } @@ -11684,8 +11729,7 @@ bool SMPFunction::AnalyzeCompoundConditionalStatements(void) { int FollowBlockNum = this->FindConditionalFollowNode((int) BlockIndex); if (SMP_BLOCKNUM_UNINIT == FollowBlockNum) { if (!this->PrintedSPARKUnstructuredMsg) { - SMP_msg("ERROR: SPARK: Unstructured due to: Cannot find follow block for SHORT_CIRCUIT_BRANCH in block %zu ", - BlockIndex); + SMP_msg("ERROR: SPARK: Unstructured due to: Cannot find follow block for SHORT_CIRCUIT_BRANCH in block %zu ", BlockIndex); this->DumpFuncNameAndAddr(); this->PrintedSPARKUnstructuredMsg = true; } @@ -12820,24 +12864,27 @@ int SMPFunction::TrackConditionalBranchTerminus(int BranchHeadBlockNum, int Curr #endif // We are looping around the same blocks, which should // not happen for a conditional branch. Terminate. - SMP_msg("ERROR: Looping on branch terminus block numbers: %d and %d for branch head: %d current block: %d Bitset: %d InList: %d in func %s\n", - CurrBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum, BlockAlreadyProcessed, BlockAlreadyInList, this->GetFuncName()); + SMP_msg("ERROR: Looping on branch terminus block numbers: %d and %d for branch head: %d current block: %d Bitset: %d InList: %d ", + CurrBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum, BlockAlreadyProcessed, BlockAlreadyInList); + this->DumpFuncNameAndAddr(); TerminusBlockNum = SMP_BLOCKNUM_UNINIT; // error signal WorkListBlockNums.clear(); this->HasStructuredCFG = false; // recovery of blocks into if-elsif-elsif-else is not possible break; } else if (STARS_COND_BRANCH_WORKLIST_LIMIT < WorkListBlockNums.size()) { - SMP_msg("ERROR: WorkList explosion on branch terminus block numbers: %d and %d for branch head: %d current block: %d in func %s\n", - CurrBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum, this->GetFuncName()); + SMP_msg("ERROR: WorkList explosion on branch terminus block numbers: %d and %d for branch head: %d current block: %d ", + CurrBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum); + this->DumpFuncNameAndAddr(); TerminusBlockNum = SMP_BLOCKNUM_UNINIT; // error signal WorkListBlockNums.clear(); this->HasStructuredCFG = false; // recovery of blocks into if-elsif-elsif-else is not possible break; } else if (STARS_COND_BRANCH_ALREADY_SEEN_LIMIT < BlockAlreadySeenCounter) { - SMP_msg("ERROR: BlockAlreadySeen limit reached on branch terminus block numbers: %d and %d for branch head: %d current block: %d in func %s\n", - CurrBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum, this->GetFuncName()); + SMP_msg("ERROR: BlockAlreadySeen limit reached on branch terminus block numbers: %d and %d for branch head: %d current block: %d ", + CurrBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum); + this->DumpFuncNameAndAddr(); TerminusBlockNum = SMP_BLOCKNUM_UNINIT; // error signal WorkListBlockNums.clear(); this->HasStructuredCFG = false; // recovery of blocks into if-elsif-elsif-else is not possible @@ -12851,8 +12898,9 @@ int SMPFunction::TrackConditionalBranchTerminus(int BranchHeadBlockNum, int Curr // Check for consistency with previous such blocks. if (0 <= TerminusBlockNum) { // had previous terminus if (SuccBlockNum != TerminusBlockNum) { - SMP_msg("ERROR: Inconsistent branch terminus block numbers: %d and %d for branch head: %d current block: %d in func %s\n", - TerminusBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum, this->GetFuncName()); + SMP_msg("ERROR: Inconsistent branch terminus block numbers: %d and %d for branch head: %d current block: %d ", + TerminusBlockNum, SuccBlockNum, BranchHeadBlockNum, CurrBlockNum); + this->DumpFuncNameAndAddr(); TerminusBlockNum = SMP_BLOCKNUM_UNINIT; // error signal WorkListBlockNums.clear(); } @@ -12865,8 +12913,9 @@ int SMPFunction::TrackConditionalBranchTerminus(int BranchHeadBlockNum, int Curr int NewTerminusBlockNum = this->TrackConditionalBranchTerminus(BranchHeadBlockNum, SuccBlockNum, BlocksSeen, BlockAlreadySeenCounter); // Perform the meet function over the old and new terminus block numbers. if (NewTerminusBlockNum == SMP_BLOCKNUM_UNINIT) { - SMP_msg("ERROR: Bad branch terminus block number from recursion for branch head: %d current block: %d in func %s\n", - BranchHeadBlockNum, CurrBlockNum, this->GetFuncName()); + SMP_msg("ERROR: Bad branch terminus block number from recursion for branch head: %d current block: %d ", + BranchHeadBlockNum, CurrBlockNum); + this->DumpFuncNameAndAddr(); TerminusBlockNum = SMP_BLOCKNUM_UNINIT; // error signal WorkListBlockNums.clear(); } @@ -12877,8 +12926,9 @@ int SMPFunction::TrackConditionalBranchTerminus(int BranchHeadBlockNum, int Curr ; // old block num takes precedence } else if (NewTerminusBlockNum != TerminusBlockNum) { - SMP_msg("ERROR: Inconsistent branch terminus block numbers: %d and %d for branch head: %d current block: %d in func %s\n", - TerminusBlockNum, NewTerminusBlockNum, BranchHeadBlockNum, CurrBlockNum, this->GetFuncName()); + SMP_msg("ERROR: Inconsistent branch terminus block numbers: %d and %d for branch head: %d current block: %d ", + TerminusBlockNum, NewTerminusBlockNum, BranchHeadBlockNum, CurrBlockNum); + this->DumpFuncNameAndAddr(); TerminusBlockNum = SMP_BLOCKNUM_UNINIT; // error signal WorkListBlockNums.clear(); } @@ -13316,7 +13366,8 @@ void SMPFunction::ChainAliasHelper(size_t BlockNum) { bool AlreadyMarkedMaybeAliased = false; STARS_ea_t LiveInDefAddr = CurrBlock->TraceLiveInOpToDefAddr(LiveInOp, AlreadyMarkedMaybeAliased); if (STARS_BADADDR == LiveInDefAddr) { - SMP_msg("FATAL ERROR: ChainAliasHelper bad LiveInDefAddr in block %zu\n", BlockNum); + SMP_msg("FATAL ERROR: ChainAliasHelper bad LiveInDefAddr in block %zu ", BlockNum); + this->DumpFuncNameAndAddr(); SMP_msg("Operand: "); PrintOperand(LiveInOp); SMP_msg("\n"); @@ -13677,7 +13728,7 @@ void SMPFunction::RemoveBlock(SMPBasicBlock *CurrBlock, list<SMPBasicBlock *>::i SMPInstr *CurrInst = (*InstIter); STARS_ea_t InstAddr = CurrInst->GetAddr(); SMP_fprintf(AnnotFile, "%18llx %6zu INSTR BELONGTO %llx \n", - (unsigned long long) InstAddr, CurrInst->GetSize(), (unsigned long long) FuncAddr); + (uint64_t) InstAddr, CurrInst->GetSize(), (uint64_t) FuncAddr); } } @@ -13718,8 +13769,9 @@ void SMPFunction::RemoveCallingBlocks(void) const { if (this->GetProg()->IsInstAddrStillInFunction(CallInstAddr, CallingFuncAddr)) { SMPFunction *CallingFunc = this->GetProg()->FindFunction(CallingFuncAddr); if (nullptr == CallingFunc) { - SMP_msg("ERROR: Cannot find function with start addr %llx and call inst at %llx\n", - (unsigned long long) CallingFuncAddr, (unsigned long long) CallInstAddr); + SMP_msg("ERROR: Cannot find function with start addr %llx and call inst at %llx ", + (uint64_t) CallingFuncAddr, (uint64_t) CallInstAddr); + this->DumpFuncNameAndAddr(); } else { SMPBasicBlock *CallingBlock = CallingFunc->GetBlockFromInstAddr(CallInstAddr); @@ -13755,7 +13807,7 @@ void SMPFunction::SetLinks(void) { STARS_ea_t BlockAddr = CurrBlock->GetFirstAddr(); if (DebugFlag) { SMP_msg("DEBUG: SetLinks processing block from %llx to %llx\n", - (unsigned long long) BlockAddr, (unsigned long long) InstAddr); + (uint64_t) BlockAddr, (uint64_t) InstAddr); } bool CondTailCall = false; if (CurrBlock->HasReturn()) { @@ -13802,7 +13854,7 @@ void SMPFunction::SetLinks(void) { map<STARS_ea_t, SMPBasicBlock *>::iterator MapEntry = this->InstBlockMap.find(FallThroughAddr); if (MapEntry == this->InstBlockMap.end()) { SMP_msg("WARNING: FixedCallPush at %llx not linked to FallThroughAddr at %llx\n", - (unsigned long long) InstAddr, (unsigned long long) FallThroughAddr); + (uint64_t) InstAddr, (uint64_t) FallThroughAddr); } else { SMPBasicBlock *Target = MapEntry->second; @@ -13813,12 +13865,13 @@ void SMPFunction::SetLinks(void) { LinkedToTarget = true; if (DebugFlag) { SMP_msg("DEBUG: SetLinks linking to successor block at %llx\n", - (unsigned long long) FallThroughAddr); + (uint64_t) FallThroughAddr); } } if (!LinkedToTarget) { - SMP_msg("ERROR: SetLinks unable to link to successor of fixed-call block ending at %llx.\n", - (unsigned long long) InstAddr); + SMP_msg("ERROR: SetLinks unable to link to successor of fixed-call block ending at %llx ", + (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); } } else { @@ -13845,7 +13898,7 @@ void SMPFunction::SetLinks(void) { LinkedToTarget = true; if (DebugFlag) { SMP_msg("DEBUG: SetLinks linking to successor block at %llx\n", - (unsigned long long) TargetAddr); + (uint64_t) TargetAddr); } #if SMP_USE_SWITCH_TABLE_INFO if (IndirJumpFlag) { @@ -13870,12 +13923,12 @@ void SMPFunction::SetLinks(void) { ++UnresolvedIndirectJumpCount; UnresolvedBranchWorkList.push_back(CurrBlock); SMP_msg("WARNING: Unresolved indirect jump at %llx FuncAddr: %llx\n", - (unsigned long long) CurrInst->GetAddr(), (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) CurrInst->GetAddr(), (uint64_t) this->GetFirstFuncAddr()); } else if (IndirCallFlag && (!LinkedToTarget) && (!SysCallFlag)) { this->SetHasUnresolvedIndirectCalls(); SMP_msg("WARNING: Unresolved indirect call at %llx FuncAddr: %llx\n", - (unsigned long long) CurrInst->GetAddr(), (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) CurrInst->GetAddr(), (uint64_t) this->GetFirstFuncAddr()); } else if (IndirJumpFlag && LinkedToTarget) { ++ResolvedIndirectJumpCount; @@ -13971,7 +14024,7 @@ void SMPFunction::SetLinks(void) { } while (changed); if (HellNodeCase && (!AddedMissingLinks)) { SMP_msg("SERIOUS WARNING: SetLinks: Function at %llx has unresolved indirect branches but no unreachable blocks.\n", - (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) this->GetFirstFuncAddr()); } #if 0 @@ -14225,7 +14278,7 @@ void SMPFunction::RPONumberBlocks(void) { if (this->HasIndirectJumps() || this->HasIndirectCalls()) { for (SMPBasicBlock *CurrBlock : this->Blocks) { if (SMP_BLOCKNUM_UNINIT == CurrBlock->GetNumber()) { - SMP_msg("WARNING: Numbering indirectly reachable block at %llx\n", (unsigned long long) CurrBlock->GetFirstAddr()); + SMP_msg("WARNING: Numbering indirectly reachable block at %llx\n", (uint64_t) CurrBlock->GetFirstAddr()); CurrBlock->SetNumber(CurrNum); CurrBlock->SetProcessed(true); this->RPOBlocks.push_back(CurrBlock); @@ -14547,13 +14600,13 @@ void SMPFunction::ComputeIDoms(void) { // Might be reachable only through indirect jumps. NewIdom = 0; // make it dominated by entry block SMP_msg("WARNING: Assuming block %d at address %llx is reachable indirectly.\n", - CurrBlock->GetNumber(), (unsigned long long) CurrBlock->GetFirstAddr()); + CurrBlock->GetNumber(), (uint64_t) CurrBlock->GetFirstAddr()); } else { // Might be exception handling code, reachable only by call stack walking. NewIdom = 0; // make it be dominated by entry block SMP_msg("WARNING: Assuming block %d at address %llx is reachable by exception handling.\n", - CurrBlock->GetNumber(), (unsigned long long) CurrBlock->GetFirstAddr()); + CurrBlock->GetNumber(), (uint64_t) CurrBlock->GetFirstAddr()); } } assert(NewIdom != SMP_BLOCKNUM_UNINIT); @@ -14689,7 +14742,7 @@ void SMPFunction::ComputeGlobalNames(void) { } // for each basic block SMP_msg("INFO: GlobalNames size is %zu for func at %llx\n", this->GlobalNames.size(), - (unsigned long long) this->GetFirstFuncAddr()); + (uint64_t) this->GetFirstFuncAddr()); assert(16777215 >= this->GlobalNames.size()); // index fits in 24 bits return; } // end of SMPFunction::ComputeGlobalNames() @@ -14789,7 +14842,8 @@ void SMPFunction::InsertPhiFunctions(void) { if (DebugFlag) SMP_msg("WorkIter: %d\n", *WorkIter); #endif if (DebugFlag && (*WorkIter > this->BlockCount)) { - SMP_msg("ERROR: WorkList block # %d out of range.\n", *WorkIter); + SMP_msg("ERROR: WorkList block # %d out of range ", *WorkIter); + this->DumpFuncNameAndAddr(); } SMPBasicBlock *WorkBlock = this->RPOBlocks[*WorkIter]; for (DomFrontIter = WorkBlock->GetFirstDomFrontier(); @@ -14799,7 +14853,8 @@ void SMPFunction::InsertPhiFunctions(void) { if (DebugFlag) SMP_msg("DomFront: %d\n", *DomFrontIter); #endif if (DebugFlag && (*DomFrontIter > this->BlockCount)) { - SMP_msg("ERROR: DomFront block # %d out of range.\n", *DomFrontIter); + SMP_msg("ERROR: DomFront block # %d out of range ", *DomFrontIter); + this->DumpFuncNameAndAddr(); } SMPBasicBlock *PhiBlock = this->RPOBlocks[*DomFrontIter]; // Before inserting a phi function for the current name in *PhiBlock, @@ -14934,9 +14989,9 @@ bool SMPFunction::CFGReducibilityHelper(std::size_t BlockNumber) { } else { // neither block dominates the other; irreducible back edge Reducible = false; - SMP_msg("SERIOUS WARNING: Function %s at %llx is irreducible because of back edge from block at %llx to %llx\n", - this->GetFuncName(), (unsigned long long) this->GetFirstFuncAddr(), - (unsigned long long) SuccBlock->GetFirstAddr(), (unsigned long long) CurrBlock->GetFirstAddr()); + SMP_msg("SERIOUS WARNING: Function is irreducible because of back edge from block at %llx to %llx ", + (uint64_t) SuccBlock->GetFirstAddr(), (uint64_t) CurrBlock->GetFirstAddr()); + this->DumpFuncNameAndAddr(); } } else { @@ -14946,7 +15001,8 @@ bool SMPFunction::CFGReducibilityHelper(std::size_t BlockNumber) { } else { Reducible = false; - SMP_msg("ERROR: Block %d out of range in CFGReducibilityHelper for parent block %u\n", SuccBlock->GetNumber(), BlockNumber); + SMP_msg("ERROR: Block %d out of range in CFGReducibilityHelper for parent block %u ", SuccBlock->GetNumber(), BlockNumber); + this->DumpFuncNameAndAddr(); } if (!Reducible) { break; @@ -15119,8 +15175,8 @@ void SMPFunction::AnalyzeLoopIterations(void) { bool MultiExitLoop = this->GetLoopFollowBlockNum(LoopIndex, FollowBlockNum); list<SMPBasicBlock *>::const_iterator TestTargBlockIter = TestBlock->GetCondNonFallThroughSucc(); if (TestTargBlockIter == TestBlock->GetLastConstSucc()) { - SMP_msg("ERROR: LOOP: Could not find NonFallThroughSuccessor in test block %d loop %u in func at %llx\n", - TestBlockNum, LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Could not find NonFallThroughSuccessor in test block %d loop %u ", TestBlockNum, LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopComparisonExprs.push_back(CurrentLoopComparisonExpr); this->LoopAnalysisProblems[LoopIndex] = true; continue; @@ -15153,31 +15209,34 @@ void SMPFunction::AnalyzeLoopIterations(void) { this->LoopComparisonExprs.push_back(CurrentLoopComparisonExpr); } else { - SMP_msg("ERROR: LOOP: Decrement with BranchOperator %d in test block %d DecrementAddr %llx loop %u in func %s at %llx\n", - BranchOperator, TestBlockNum, (uint64_t) DecrementAddr, LoopIndex, this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Decrement with BranchOperator %d in test block %d DecrementAddr %llx loop %u ", + BranchOperator, TestBlockNum, (uint64_t) DecrementAddr, LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopComparisonExprs.push_back(CurrentLoopComparisonExpr); this->LoopAnalysisProblems[LoopIndex] = true; continue; } } else { - SMP_msg("ERROR: LOOP: Could not find compare or test in test block %d loop %zu in func %s at %llx\n", - TestBlockNum, LoopIndex, this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Could not find compare or test in test block %d loop %zu ", + TestBlockNum, LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopComparisonExprs.push_back(CurrentLoopComparisonExpr); this->LoopAnalysisProblems[LoopIndex] = true; continue; } } else { - SMP_msg("ERROR: LOOP: Could not do iteration analysis on loop of type %d loop %zu in func %s at %llx\n", - LoopType, LoopIndex, this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Could not do iteration analysis on loop of type %d loop %zu ", LoopType, LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopComparisonExprs.push_back(CurrentLoopComparisonExpr); this->LoopAnalysisProblems[LoopIndex] = true; continue; // cannot analyze loop iterations } if (LoopIndex < this->LoopInductionVars.size()) { - SMP_msg("INFO: LOOP: Analyzing loop iteration exprs for function %s loop %zu\n", this->GetFuncName(), LoopIndex); + SMP_msg("INFO: LOOP: Analyzing loop iteration exprs for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); for (STARSInductionVarFamilyIter IVarVecIter = this->LoopInductionVars[LoopIndex].begin(); IVarVecIter != this->LoopInductionVars[LoopIndex].end(); ++IVarVecIter) { @@ -15351,8 +15410,8 @@ void SMPFunction::AnalyzeLoopIterations(void) { break; // Found the primary BIV for this LoopIndex } else { - SMP_msg("ERROR: LOOP: Failure to create IterationCountExpr for loop %zu in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure to create IterationCountExpr for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopAnalysisProblems[LoopIndex] = true; if (nullptr != InitExpr) delete InitExpr; @@ -15361,8 +15420,8 @@ void SMPFunction::AnalyzeLoopIterations(void) { } } else { - SMP_msg("ERROR: LOOP: Failure on ExpandExpr() for LimitExpr in AnalyzeLoopIterations() for loop %zu in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure on ExpandExpr() for LimitExpr in AnalyzeLoopIterations() for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopAnalysisProblems[LoopIndex] = true; if (nullptr != InitExpr) delete InitExpr; @@ -15371,16 +15430,16 @@ void SMPFunction::AnalyzeLoopIterations(void) { } } else { - SMP_msg("ERROR: LOOP: Failure to create LimitExpr for loop %zu in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure to create LimitExpr for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopAnalysisProblems[LoopIndex] = true; if (nullptr != InitExpr) delete InitExpr; } } else { - SMP_msg("ERROR: LOOP: Failure on ExpandExpr() for InitExpr in AnalyzeLoopIterations() for loop %zu in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure on ExpandExpr() for InitExpr in AnalyzeLoopIterations() for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopAnalysisProblems[LoopIndex] = true; if (nullptr != InitExpr) delete InitExpr; @@ -15396,12 +15455,13 @@ void SMPFunction::AnalyzeLoopIterations(void) { if (nullptr == this->LoopIterationsCountExprs[LoopIndex]) { this->LoopAnalysisProblems[LoopIndex] = true; if (this->DoesLoopWriteMemory(LoopIndex)) { - SMP_msg("ERROR: LOOP: Failure to create iteration count expr for loop %d in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure to create iteration count expr for loop %d ", LoopIndex); + this->DumpFuncNameAndAddr(); } else { - SMP_msg("SERIOUS WARNING: LOOP: Failure to create iteration count expr for non-mem-writing loop %d starting at %llx in function at %llx\n", - LoopIndex, (uint64_t)(this->GetBlockByNum((size_t) this->LoopHeadBlockNumbers[LoopIndex])->GetFirstAddr()), (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("SERIOUS WARNING: LOOP: Failure to create iteration count expr for non-mem-writing loop %d starting at %llx ", + LoopIndex, (uint64_t)(this->GetBlockByNum((size_t) this->LoopHeadBlockNumbers[LoopIndex])->GetFirstAddr())); + this->DumpFuncNameAndAddr(); } } } @@ -15452,7 +15512,8 @@ void SMPFunction::AnalyzeLoopIterations(void) { (*IVarVecIter).BIVInitExpr = InitExpr; } else { - SMP_msg("ERROR: LOOP: Cannot analyze BIV with OutsideDefAddr of %llx\n", (uint64_t)OutsideDefAddr); + SMP_msg("ERROR: LOOP: Cannot analyze BIV with OutsideDefAddr of %llx ", (uint64_t)OutsideDefAddr); + this->DumpFuncNameAndAddr(); continue; } } // end if nullptr == InitExpr @@ -15470,7 +15531,8 @@ void SMPFunction::AnalyzeLoopIterations(void) { (*IVarVecIter).BIVLimitExpr = LimitExpr; } else { - SMP_msg("ERROR: LOOP: Failure to create secondary BIV LimitExpr\n"); + SMP_msg("ERROR: LOOP: Failure to create secondary BIV LimitExpr "); + this->DumpFuncNameAndAddr(); } } } @@ -15513,7 +15575,8 @@ void SMPFunction::AnalyzeLoopIterations(void) { DIVLimitExpr = this->CreateDIVLimitExpr(LoopIndex, IVFamily, DIVIndex); success = (nullptr != DIVLimitExpr); if (!success) { - SMP_msg("ERROR: LOOP: CreateDIVLimitExpr failed for loop %zu DIVIndex %zu\n", LoopIndex, DIVIndex); + SMP_msg("ERROR: LOOP: CreateDIVLimitExpr failed for loop %zu DIVIndex %zu ", LoopIndex, DIVIndex); + this->DumpFuncNameAndAddr(); } } #if 0 @@ -15709,8 +15772,9 @@ void SMPFunction::AnalyzeLoopIterations(void) { STARS_ea_t MemWriteAddr = MemWriteInst->GetAddr(); if (StaticMemWriteAddrsEmitted.find(MemWriteAddr) == StaticMemWriteAddrsEmitted.cend()) { if (LimitSuccess && (MemWriteAddr != MemWriteUpperBoundExpanded->GetOriginalParentInst()->GetAddr())) { - SMP_msg("ERROR: LOOP: Constant lower and upper bound exprs don't have same InstAddr for MemListIndex %zu loop %zu in func %s.\n", - MemListIndex, LoopIndex, this->GetFuncName()); + SMP_msg("ERROR: LOOP: Constant lower and upper bound exprs don't have same InstAddr for MemListIndex %zu loop %zu ", + MemListIndex, LoopIndex); + this->DumpFuncNameAndAddr(); } else { int InstSize = MemWriteInst->GetSize(); @@ -15751,16 +15815,18 @@ void SMPFunction::AnalyzeLoopIterations(void) { } } else { - SMP_msg("ERROR: LOOP: ExpandExprToInArg failure for MemListIndex %zu loop %zu in function at %llx\n", - MemListIndex, LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: ExpandExprToInArg failure for MemListIndex %zu loop %zu ", + MemListIndex, LoopIndex); + this->DumpFuncNameAndAddr(); delete MemWriteLowerBoundExpanded; delete MemWriteUpperBoundExpanded; this->LoopAnalysisProblems[LoopIndex] = true; } } else { - SMP_msg("ERROR: LOOP: Failure to ReplaceIVsWithInitExpr (writes) for MemListIndex %zu loop %d in function at %llx\n", - MemListIndex, LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure to ReplaceIVsWithInitExpr (writes) for MemListIndex %zu loop %d ", + MemListIndex, LoopIndex); + this->DumpFuncNameAndAddr(); delete MemWriteLowerBound; if (nullptr != MemWriteUpperBound) delete MemWriteUpperBound; @@ -15768,8 +15834,9 @@ void SMPFunction::AnalyzeLoopIterations(void) { } } else { - SMP_msg("ERROR: LOOP: Failure to ReplaceIVsWithInitExpr (writes) for MemListIndex %zu loop %d in function at %llx\n", - MemListIndex, LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure to ReplaceIVsWithInitExpr (writes) for MemListIndex %zu loop %d ", + MemListIndex, LoopIndex); + this->DumpFuncNameAndAddr(); if (VerboseOutput) { MemWriteLowerBound->Dump(0); } @@ -15780,13 +15847,13 @@ void SMPFunction::AnalyzeLoopIterations(void) { } else { if (this->LoopWritesMemory[LoopIndex]) { - SMP_msg("ERROR: LOOP: Failure to CreateSPARKMemRangeExpr for loop %d in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure to CreateSPARKMemRangeExpr for loop %d ", LoopIndex); + this->DumpFuncNameAndAddr(); this->LoopAnalysisProblems[LoopIndex] = true; } else { - SMP_msg("INFO: LOOP: No memory writes in loop %d in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("INFO: LOOP: No memory writes in loop %d ", LoopIndex); + this->DumpFuncNameAndAddr(); } } @@ -15911,8 +15978,8 @@ void SMPFunction::AnalyzeLoopIterations(void) { STARS_ea_t MemReadAddr = MemReadInst->GetAddr(); if (StaticMemReadAddrsEmitted.find(MemReadAddr) == StaticMemReadAddrsEmitted.cend()) { if (LimitSuccess && (MemReadAddr != MemReadUpperBoundExpanded->GetOriginalParentInst()->GetAddr())) { - SMP_msg("ERROR: LOOP: (reads) Constant lower and upper bound exprs don't have same InstAddr for loop %zu in func %s.\n", - LoopIndex, this->GetFuncName()); + SMP_msg("ERROR: LOOP: (reads) Constant lower and upper bound exprs don't have same InstAddr for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); } else { int InstSize = MemReadInst->GetSize(); @@ -15954,16 +16021,16 @@ void SMPFunction::AnalyzeLoopIterations(void) { } } else { - SMP_msg("ERROR: LOOP: (reads) ExpandExprToInArg failure for loop %zu in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: (reads) ExpandExprToInArg failure for loop %zu ", LoopIndex); + this->DumpFuncNameAndAddr(); delete MemReadLowerBoundExpanded; delete MemReadUpperBoundExpanded; // this->LoopAnalysisProblems[LoopIndex] = true; } } else { - SMP_msg("ERROR: LOOP: Failure to ReplaceIVsWithInitExpr (reads) for loop %d in function at %llx\n", - LoopIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: LOOP: Failure to ReplaceIVsWithInitExpr (reads) for loop %d ", LoopIndex); + this->DumpFuncNameAndAddr(); delete MemReadLowerBound; // this->LoopAnalysisProblems[LoopIndex] = true; // this->LoopWritesGlobalStaticMemory[LoopIndex] = false; // reset @@ -16180,7 +16247,8 @@ void SMPFunction::SSARename(int BlockNumber) { unsigned int GlobIndex = ExtractGlobalIndex(*GlobIter); if (GlobIndex > this->SSAStack.size()) { // Get some debug info out to the log file before we crash. - SMP_msg("FATAL ERROR: Bad GlobIndex: %u at %llx in %s\n", GlobIndex, (unsigned long long) InstAddr, this->GetFuncName()); + SMP_msg("FATAL ERROR: Bad GlobIndex: %u at %llx ", GlobIndex, (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); exit(EXIT_FAILURE); } // Set the SSA number for this use to the top of stack SSA # (back()) @@ -16196,7 +16264,7 @@ void SMPFunction::SSARename(int BlockNumber) { SMP_msg(" Variable: "); PrintListOperand(*GlobIter); SMP_msg(" Block number: %d Address: %llx Instruction: %s\n", BlockNumber, - (unsigned long long) CurrInst->GetAddr(), CurrInst->GetDisasm()); + (uint64_t) CurrInst->GetAddr(), CurrInst->GetDisasm()); } #endif NewSSANum = SMP_SSA_UNINIT; @@ -16206,7 +16274,7 @@ void SMPFunction::SSARename(int BlockNumber) { } CurrUse = CurrInst->SetUseSSA(UseOp, NewSSANum); if (DumpFlag && (UseOp->IsRegOp()) && UseOp->MatchesReg(STARS_x86_R_ax)) { - SMP_msg("New EAX Use SSANum: %d at %llx\n", NewSSANum, (unsigned long long) CurrInst->GetAddr()); + SMP_msg("New EAX Use SSANum: %d at %llx\n", NewSSANum, (uint64_t) CurrInst->GetAddr()); } } ++CurrUse; @@ -16225,7 +16293,7 @@ void SMPFunction::SSARename(int BlockNumber) { if (RegOpFlag || MDIsDirectStackAccessOpnd(DefOp, this->UsesFramePointer())) { STARS_ea_t DefAddr = InstAddr; if (DumpFlag && RegOpFlag && DefOp->MatchesReg(STARS_x86_R_ax)) { - SMP_msg("New EAX Def SSANum: %d at %llx\n", NewSSANum, (unsigned long long) DefAddr); + SMP_msg("New EAX Def SSANum: %d at %llx\n", NewSSANum, (uint64_t) DefAddr); } // Map the final SSA number to the DEF address. @@ -16424,7 +16492,7 @@ void SMPFunction::AnalyzeSystemCalls(void) { } bool UnresolvedCallee = ((STARS_BADADDR == EAXDefAddr) || (STARS_IsBlockNumPseudoID(EAXDefAddr)) || (STARS_IsSSAMarkerPseudoID(EAXDefAddr))); - SMP_msg("INFO: System call number def addr at %llx\n", (unsigned long long) EAXDefAddr); + SMP_msg("INFO: System call number def addr at %llx\n", (uint64_t) EAXDefAddr); STARS_uval_t SysCallNumber = 0; if (!UnresolvedCallee) { // We have an instruction addr in EAXDefAddr. @@ -16439,7 +16507,7 @@ void SMPFunction::AnalyzeSystemCalls(void) { UnresolvedCallee = (UseIter == EAXDefInst->GetLastUse()); } if (!UnresolvedCallee) { - SMP_msg("INFO: System call set of EAX. Use found. at: %llx\n", (unsigned long long) EAXDefAddr); + SMP_msg("INFO: System call set of EAX. Use found. at: %llx\n", (uint64_t) EAXDefAddr); STARSOpndTypePtr UseOp = UseIter->GetOp(); // if UseOp is nullptr or not an immediate, callee cannot be resolved. @@ -16451,7 +16519,7 @@ void SMPFunction::AnalyzeSystemCalls(void) { // Resolve if UseOp is an immediate. if (!UnresolvedCallee) { SysCallNumber = UseOp->GetImmedValue(); - SMP_msg("INFO: System call set of EAX. Use was immed. %d at: %llx\n", SysCallNumber, (unsigned long long) EAXDefAddr); + SMP_msg("INFO: System call set of EAX. Use was immed. %d at: %llx\n", SysCallNumber, (uint64_t) EAXDefAddr); ++UseIter; // check there is not a second use. @@ -16460,7 +16528,7 @@ void SMPFunction::AnalyzeSystemCalls(void) { } if (!UnresolvedCallee) { SMP_msg("INFO: System call set of EAX determined solid. number: %u at: %llx\n", - (unsigned int) SysCallNumber, (unsigned long long) EAXDefAddr); + (unsigned int) SysCallNumber, (uint64_t) EAXDefAddr); } } if (!UnresolvedCallee) { // we have a good SysCallNumber @@ -16902,10 +16970,10 @@ void SMPFunction::ApplyProfilerInformation(ProfilerInformation* pi) // lookup whether a load at this instruction was profiled as always numeric InstructionInformation* ii = pi->GetInfo(CurrInst->GetAddr()); if (ii && DebugFlag) - SMP_msg("Found instruction information for %llx\n", (unsigned long long) CurrInst->GetAddr()); + SMP_msg("Found instruction information for %llx\n", (uint64_t) CurrInst->GetAddr()); if (ii && ii->isNumeric()) { #if SMP_DEBUG_PROFILED_TYPE_INFERENCE - SMP_msg("Found instruction information for %llx and it's numeric!\n", (unsigned long long) CurrInst->GetAddr()); + SMP_msg("Found instruction information for %llx and it's numeric!\n", (uint64_t) CurrInst->GetAddr()); #endif CurrInst->UpdateMemLoadTypes((SMPOperandType)(NUMERIC|PROF_BASE)); } @@ -17460,14 +17528,16 @@ void SMPFunction::UpdateLoopFollowBlockNum(int LoopHeadBlockNum, int FollowBlock // dominates our LoopHeadBlockNum, SPARK translation will loop infinitely. bool FollowDominatesHead = this->DoesBlockDominateBlock(FollowBlockNum, LoopHeadBlockNum); if (FollowDominatesHead) { - SMP_msg("ERROR: SPARK: UpdateLoopFollowBlockNum() ignoring follow block %d which dominates loop head block %d in func %s at %llx loop %zu\n", - FollowBlockNum, LoopHeadBlockNum, this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr(), LoopNum); + SMP_msg("ERROR: SPARK: UpdateLoopFollowBlockNum() ignoring follow block %d which dominates loop head block %d in loop %zu ", + FollowBlockNum, LoopHeadBlockNum, LoopNum); + this->DumpFuncNameAndAddr(); return; } bool FollowInsideLoop = this->IsBlockInLoop(FollowBlockNum, LoopNum); if (FollowInsideLoop) { - SMP_msg("ERROR: SPARK: UpdateLoopFollowBlockNum() ignoring follow block %d inside loop with head block %d in func %s at %llx loop %zu\n", - FollowBlockNum, LoopHeadBlockNum, this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr(), LoopNum); + SMP_msg("ERROR: SPARK: UpdateLoopFollowBlockNum() ignoring follow block %d inside loop with head block %d in loop %zu", + FollowBlockNum, LoopHeadBlockNum, LoopNum); + this->DumpFuncNameAndAddr(); this->DumpDotCFG(); return; } @@ -17977,7 +18047,6 @@ void SMPFunction::MarkSpecialNumericErrorCases(void) { this->HasStructuredCFG = false; // Unstructured conditionals if (!this->PrintedSPARKUnstructuredMsg) { SMP_msg("ERROR: SPARK: Unstructured due to miscellaneous CondFollowNode error "); - this->DumpFuncNameAndAddr(); this->PrintedSPARKUnstructuredMsg = true; } else { @@ -18199,13 +18268,14 @@ void SMPFunction::GatherIncomingArgTypes(void) { bool TypeErrorFlag = false; this->InArgTypes[ArgIndex] = (unsigned short) SMPTypeMeet((SMPOperandType) this->InArgTypes[ArgIndex], ArgType, TypeErrorFlag); if (TypeErrorFlag) { - SMP_msg("ERROR: TypeMeet error in GatherIncomingArgType() for func at %llx\n", - (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: TypeMeet error in GatherIncomingArgType() "); + this->DumpFuncNameAndAddr(); } } } else { - SMP_msg("ERROR: Incoming ArgIndex of %u in SMPFunction::GatherIncomingArgTypes\n", ArgIndex); + SMP_msg("ERROR: Incoming ArgIndex of %u in SMPFunction::GatherIncomingArgTypes ", ArgIndex); + this->DumpFuncNameAndAddr(); } } } @@ -18466,7 +18536,8 @@ void SMPFunction::AnalyzeBufferUses(void) { } } else { - SMP_msg("ERROR: Argument position not found in AnalyzeBufferUses, ArgRegNum: %d\n", (int) ArgRegNum); + SMP_msg("ERROR: Argument position not found in AnalyzeBufferUses, ArgRegNum: %d ", (int) ArgRegNum); + this->DumpFuncNameAndAddr(); } } ++LinkIter; @@ -18582,8 +18653,8 @@ bool SMPFunction::FindShadowingPoint2(const ShadowPoint CriticalOp, const bool T for (size_t PhiIndex = 0; PhiIndex < PhiIter->GetPhiListSize(); ++PhiIndex) { int PhiUseSSANum = PhiIter->GetUseSSANum(PhiIndex); if (0 > PhiUseSSANum) { - SMP_msg("ERROR: FindShadowingPoint2() cannot trace uninitialized Phi USE at CurrShadowAddr %p in func at %p\n", - CurrShadowAddr, this->GetFirstFuncAddr()); + SMP_msg("ERROR: FindShadowingPoint2() cannot trace uninitialized Phi USE at CurrShadowAddr %p ", CurrShadowAddr); + this->DumpFuncNameAndAddr(); ValidShadowing = false; break; } @@ -18676,8 +18747,8 @@ bool SMPFunction::FindShadowingPoint2(const ShadowPoint CriticalOp, const bool T for (STARSDefUseIter UseIter = CurrInst->GetFirstUse(); UseIter != CurrInst->GetLastUse(); ++UseIter) { int UseSSANum = UseIter->GetSSANum(); if (0 > UseSSANum) { - SMP_msg("ERROR: FindShadowingPoint2() cannot trace uninitialized CondMove USE at CurrShadowAddr %p in func at %p\n", - CurrShadowAddr, this->GetFirstFuncAddr()); + SMP_msg("ERROR: FindShadowingPoint2() cannot trace uninitialized CondMove USE at CurrShadowAddr %p ", CurrShadowAddr); + this->DumpFuncNameAndAddr(); ValidShadowing = false; break; } @@ -18996,7 +19067,7 @@ bool SMPFunction::ComputeReturnTargets(bool FirstIteration) { STARS_Function_t *FuncInfo = SMP_get_func(CallAddr); if (nullptr == FuncInfo) { SMP_msg("SERIOUS WARNING: ComputeReturnTargets: Call location %llx not in a function.\n", - (unsigned long long) CallAddr); + (uint64_t) CallAddr); this->SetIsCalledFromOrphanedCode(); // IncompleteCaller = true; continue; @@ -19095,11 +19166,11 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { || (this->HasUnresolvedIndirectJumps()) || (this->HasSharedChunks())); if (this->StaticFunc) { - SMP_fprintf(AnnotFile, "%18llx %6zu FUNC LOCAL %s ", (unsigned long long) this->GetStartAddr(), + SMP_fprintf(AnnotFile, "%18llx %6zu FUNC LOCAL %s ", (uint64_t) this->GetStartAddr(), this->Size, this->GetFuncName()); } else { - SMP_fprintf(AnnotFile, "%18llx %6zu FUNC GLOBAL %s ", (unsigned long long) this->GetStartAddr(), + SMP_fprintf(AnnotFile, "%18llx %6zu FUNC GLOBAL %s ", (uint64_t) this->GetStartAddr(), this->Size, this->GetFuncName()); } switch (this->GetReturnAddressStatus()) @@ -19165,7 +19236,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { if (ArgLimit >= STARS_MAX_ARGS_PER_FUNC) { ArgLimit = STARS_MAX_ARGS_PER_FUNC - 1; } - SMP_fprintf(InfoAnnotFile, "%18llx %6u FUNC INARGS %4u ", (unsigned long long) this->GetStartAddr(), this->Size, + SMP_fprintf(InfoAnnotFile, "%18llx %6u FUNC INARGS %4u ", (uint64_t) this->GetStartAddr(), this->Size, ArgLimit + 1); for (ArgIndex = 0; ArgIndex <= ArgLimit; ++ArgIndex) { SMP_fprintf(InfoAnnotFile, "ARG%u %u ", ArgIndex, this->InArgTypes[ArgIndex]); @@ -19173,7 +19244,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { SMP_fprintf(InfoAnnotFile, "\n"); } - SMP_fprintf(AnnotFile, "%18llx %6d FUNC MMSAFENESS ", (unsigned long long) this->GetStartAddr(), 0); + SMP_fprintf(AnnotFile, "%18llx %6d FUNC MMSAFENESS ", (uint64_t) this->GetStartAddr(), 0); if (!IsSpecSafe()) SMP_fprintf(AnnotFile, "UNSAFE\n"); else if (!IsSafe()) @@ -19186,7 +19257,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { // If function has problems that limited our analyses, emit an information annotation so that // other tools can be aware of which analyses will be sound. if (FuncHasProblems) { - SMP_fprintf(InfoAnnotFile, "%18llx %6zu FUNC PROBLEM %s ", (unsigned long long) this->GetStartAddr(), + SMP_fprintf(InfoAnnotFile, "%18llx %6zu FUNC PROBLEM %s ", (uint64_t) this->GetStartAddr(), this->Size, this->GetFuncName()); if (!this->AnalyzedSP) { SMP_fprintf(InfoAnnotFile, "STACKANALYSIS "); @@ -19243,7 +19314,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { SMP_msg("WARNING: FloatNop not used as marker instruction at %llx\n", (uint64_t) addr); } SMP_fprintf(AnnotFile, "%18llx %6zu INSTR BELONGTO %llx \n", - (unsigned long long) addr, CurrInst->GetSize(), (unsigned long long) GetStartAddr()); + (uint64_t) addr, CurrInst->GetSize(), (uint64_t) GetStartAddr()); if (this->LocalVarsAllocInstr == addr) { AllocSeen = true; if (this->NeedsStackReferent) @@ -19254,11 +19325,11 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { // Prevent mmStrata from extending the caller's stack frame // to include the new allocation. SMP_fprintf(AnnotFile, "%18llx %6d INSTR LOCAL SafeFrameAlloc %s \n", - (unsigned long long) addr, -1, CurrInst->GetDisasm()); + (uint64_t) addr, -1, CurrInst->GetDisasm()); } else if (CurrInst->MDIsPushInstr()) { SMP_fprintf(AnnotFile, "%18llx %6d INSTR LOCAL NoWarn %s \n", - (unsigned long long) addr, -3, CurrInst->GetDisasm()); + (uint64_t) addr, -3, CurrInst->GetDisasm()); } // mmStrata ignores the DATAREF annotations anyway, so even though // they are not needed, emit them for use by Strata and other tools @@ -19280,7 +19351,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { DeallocTrigger = true; } else if (DeallocTrigger) { // Time for annotation - SMP_fprintf(AnnotFile, "%18llx %6lu DEALLOC STACK esp - %lu %s\n", (unsigned long long) addr, + SMP_fprintf(AnnotFile, "%18llx %6lu DEALLOC STACK esp - %lu %s\n", (uint64_t) addr, (unsigned long) this->GetLocalVarsSize(), (unsigned long) this->GetLocalVarsSize(), CurrInst->GetDisasm()); DeallocTrigger = false; } @@ -19324,9 +19395,9 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { } else { if (!this->AreReturnTargetsComputed()) - SMP_msg("INFO: Return targets were not computed for func at %llx\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Return targets were not computed for func at %llx\n", (uint64_t) this->GetFirstFuncAddr()); else if (!this->FuncReturnsToCaller()) - SMP_msg("INFO: Return targets not computed for non-returning func at %llx\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Return targets not computed for non-returning func at %llx\n", (uint64_t) this->GetFirstFuncAddr()); } // Loop through all instructions in the function. @@ -19360,7 +19431,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { } SMP_fprintf(AnnotFile, "%18llx %6zu INSTR BELONGTO %llx \n", - (unsigned long long) addr, CurrInst->GetSize(), (unsigned long long) GetStartAddr()); + (uint64_t) addr, CurrInst->GetSize(), (uint64_t) GetStartAddr()); SMPitype CurrDataFlow = CurrInst->GetDataFlowType(); bool IndirCallFlag = (CurrDataFlow == INDIR_CALL); if ((CurrDataFlow == INDIR_JUMP) || IndirCallFlag) { @@ -19383,11 +19454,11 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { // Prevent mmStrata from extending the caller's stack frame // to include the new allocation. SMP_fprintf(AnnotFile, "%18llx %6d INSTR LOCAL SafeFrameAlloc %s \n", - (unsigned long long) addr, -1, CurrInst->GetDisasm()); + (uint64_t) addr, -1, CurrInst->GetDisasm()); } else if (CurrInst->MDIsPushInstr()) { SMP_fprintf(AnnotFile, "%18llx %6d INSTR LOCAL NoWarn %s \n", - (unsigned long long) addr, -3, CurrInst->GetDisasm()); + (uint64_t) addr, -3, CurrInst->GetDisasm()); } // mmStrata ignores the DATAREF annotations anyway, so even though // they are not needed, emit them for use by Strata and other tools @@ -19409,7 +19480,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { DeallocTrigger = true; } else if (DeallocTrigger) { // Time for annotation - SMP_fprintf(AnnotFile, "%18llx %6lu DEALLOC STACK esp - %lu %s\n", (unsigned long long) addr, + SMP_fprintf(AnnotFile, "%18llx %6lu DEALLOC STACK esp - %lu %s\n", (uint64_t) addr, (unsigned long) this->GetLocalVarsSize(), (unsigned long) this->GetLocalVarsSize(), CurrInst->GetDisasm()); DeallocTrigger = false; } @@ -19466,7 +19537,7 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { if ((*CurrInst)->IsMarkerInst()) ++CurrInst; STARS_ea_t addr = (*CurrInst)->GetAddr(); - SMP_fprintf(AnnotFile, "%18llx %6d BLOCK PROFILECOUNT %s\n", (unsigned long long)addr, + SMP_fprintf(AnnotFile, "%18llx %6d BLOCK PROFILECOUNT %s\n", (uint64_t)addr, (*CurrInst)->GetSize(), (*CurrInst)->GetDisasm()); #endif } @@ -19526,7 +19597,8 @@ void SMPFunction::EmitReturnTargetAnnotations(void) { STARS_Function_t *FuncInfo = SMP_get_func(RetTargetAddr); if (nullptr == FuncInfo) { RetDeadRegsProblem = true; - SMP_msg("ERROR: Return target ID %llx not in any function.\n", (uint64_t) RetTargetAddr); + SMP_msg("ERROR: Return target ID %llx not in any function ", (uint64_t) RetTargetAddr); + this->DumpFuncNameAndAddr(); break; // cannot produce valid set } // Get first addr in func and map to SMPFunction *. @@ -19819,7 +19891,7 @@ bool SMPFunction::IsDefUsedInUnsafeMemWrite(STARSOpndTypePtr DefOp, int DefSSANu } #if STARS_DEBUG_DUPLICATE_SEARCHES else { - SMP_msg("INFO: Duplicate search avoided at %llx for DefHashIndex %x\n", (unsigned long long) DefAddr, DefHashIndex); + SMP_msg("INFO: Duplicate search avoided at %llx for DefHashIndex %x\n", (uint64_t) DefAddr, DefHashIndex); } #endif } @@ -19844,7 +19916,7 @@ bool SMPFunction::IsCallerReturnAddressReadOrWritten(void) { // the saved regs above the caller stack frame, but maybe to the caller's // return address. SMP_msg("INFO: Func at %llx accesses above the local vars of caller func at %llx\n", - (unsigned long long) this->GetFirstFuncAddr(), (unsigned long long) CallerFunc->GetFirstFuncAddr()); + (uint64_t) this->GetFirstFuncAddr(), (uint64_t) CallerFunc->GetFirstFuncAddr()); CallerVulnerable = true; } } @@ -19989,13 +20061,13 @@ void SMPFunction::MarkFunctionSafe() { this->MultipleEntryPoints = true; SearchForCodeAddressesTaken = false; // don't need to look for more SMP_msg("INFO: Func at %llx becoming multi-entry because code addr %llx found in data.\n", - (unsigned long long) FirstAddr, (unsigned long long) address); + (uint64_t) FirstAddr, (uint64_t) address); } else if (this->GetProg()->IsCodeXrefFromData(address)) { this->MultipleEntryPoints = true; SearchForCodeAddressesTaken = false; // don't need to look for more SMP_msg("INFO: Func at %llx becoming multi-entry because code addr %llx found in CodeXrefsFromData.\n", - (unsigned long long) FirstAddr, (unsigned long long) address); + (uint64_t) FirstAddr, (uint64_t) address); } } @@ -20048,7 +20120,7 @@ void SMPFunction::MarkFunctionSafe() { STARSOpndTypePtr CopyOp = DefIter->GetOp(); int DefSSANum = DefIter->GetSSANum(); if ((CopyOp->IsRegOp()) && this->HasGoodSSAForm() && (!HasStackPointerCopy) && (!(this->IsDefUsedInUnsafeMemWrite(CopyOp, DefSSANum, address)))) { - SMP_msg("INFO: Safe stack pointer copy at %llx\n", (unsigned long long) address); + SMP_msg("INFO: Safe stack pointer copy at %llx\n", (uint64_t) address); } else { HasStackPointerCopy = true; @@ -20062,7 +20134,7 @@ void SMPFunction::MarkFunctionSafe() { } #if 1 SMP_msg(" Function %s marked as unsafe due to stack pointer copy ", this->GetFuncName()); - SMP_msg("%s %llx \n", CurrInst->GetDisasm(), (unsigned long long) CurrInst->GetAddr()); + SMP_msg("%s %llx \n", CurrInst->GetDisasm(), (uint64_t) CurrInst->GetAddr()); #endif } } @@ -20194,7 +20266,10 @@ void SMPFunction::MarkFunctionSafe() { } } else { - SMP_msg("FATAL ERROR: Unknown memory operand type in MarkFunctionSafe at %llx\n", (unsigned long long) address); + SMP_msg("FATAL ERROR: Unknown memory operand type in MarkFunctionSafe at %llx ", (uint64_t) address); + this->DumpFuncNameAndAddr(); + this->Dump(); + this->DumpDotCFG(); assert(false); } } // end if HasMemDestOperand() in current instruction @@ -20239,7 +20314,7 @@ void SMPFunction::MarkFunctionSafe() { // write to it, which is detected in the AccessesReturnAddress boolean flag below. if (NonLoopingLeafFunc && this->HasUnsafeIndirectWrites) { this->HasUnsafeIndirectWrites = false; - SMP_msg("INFO: Resetting HasUnsafeIndirectWrites for non-looping leaf func at %llx\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Resetting HasUnsafeIndirectWrites for non-looping leaf func at %llx\n", (uint64_t) this->GetFirstFuncAddr()); } // For mmStrata bounds checking of the stack frame, we don't care @@ -20282,33 +20357,33 @@ void SMPFunction::MarkFunctionSafe() { #endif // We have conditions that cause fast returns to be unsafe even though the return address is safe. if (this->PossibleIndirectCallTarget) { - SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it is indirect call target.\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it is indirect call target.\n", (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, INDIRECTLY_CALLED); } if (this->PossibleTailCallTarget) { - SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it is tail call target.\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it is tail call target.\n", (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, TAIL_CALL_TARGET); } if (HasNoCallers) { - SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it has no callers.\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it has no callers.\n", (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, NO_CALLERS); } if (MakesTailCall) { - SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it makes a tail call.\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it makes a tail call.\n", (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, MAKES_TAIL_CALL); } if (this->MultipleEntryPoints) { - SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it has multiple entry points.\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it has multiple entry points.\n", (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, MULTIPLE_ENTRY_POINTS); } if (this->HasUnresolvedIndirectJumps()) { - SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it has unresolved indirect jumps.\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because it has unresolved indirect jumps.\n", (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, UNRESOLVED_INDIR_JUMP); } if (UnsafeReturnAddr) { #if STARS_CONSERVATIVE_FAST_RETURNS - SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because its return addr is UNSAFE.\n", (unsigned long long) this->GetFirstFuncAddr()); + SMP_msg("INFO: Function at %llx becoming unsafe for fast returns because its return addr is UNSAFE.\n", (uint64_t) this->GetFirstFuncAddr()); this->SetUnsafeForFastReturns(true, UNSAFE_RETURN_ADDRESS); #endif @@ -20403,11 +20478,13 @@ void SMPFunction::PreProcessForSPARKAdaTranslation(void) { if (OutOfRange) { if (IndexedAccess) { // Index can bring offset back into range. Ignore. - SMP_msg("WARNING: SPARK: Imprecise range on indexed access at %llx\n", (uint64_t) InstAddr); + SMP_msg("WARNING: SPARK: Imprecise range on indexed access at %llx ", (uint64_t) InstAddr); + this->DumpFuncNameAndAddr(); continue; } else { - SMP_msg("ERROR: SPARK: Imprecise range on non-indexed access at %llx\n", (uint64_t)InstAddr); + SMP_msg("ERROR: SPARK: Imprecise range on non-indexed access at %llx ", (uint64_t)InstAddr); + this->DumpFuncNameAndAddr(); continue; } } @@ -21863,7 +21940,8 @@ void SMPFunction::EmitFuncSPARKAda(void) { } } if (!TranslationComplete) { - SMP_msg("ERROR: Incomplete SPARK Ada translation for %s\n", this->GetFuncName()); + SMP_msg("ERROR: Incomplete SPARK Ada translation "); + this->DumpFuncNameAndAddr(); this->DumpDotCFG(); this->Dump(); } @@ -22371,7 +22449,8 @@ void SMPFunction::EmitSPARKProcPrePostMemConditions(FILE *BodyFile, FILE *Header void SMPFunction::EmitSPARKMemRange(FILE *HeaderFile, bool PreconditionSection, bool ProcessingLoop, bool HasArgs, STARSExpression *LowerExpr, STARSExpression *UpperExpr, size_t &OutputCount, size_t MemWidth) { if (nullptr == LowerExpr) { - SMP_msg("ERROR: SPARK: EmitSPARKMemRange() called with LowerExpr == nullptr in func at %llx\n", (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: SPARK: EmitSPARKMemRange() called with LowerExpr == nullptr "); + this->DumpFuncNameAndAddr(); return; } @@ -22859,8 +22938,9 @@ string SMPFunction::EmitSPARKProcForLoopHeaderBlock(int LoopIndex, int HeaderBlo // Print lower bound mem expr. STARSExpression *MemExpr = (*(this->TempRangeExprWidthIters[VecIndex].first)); if (nullptr == MemExpr) { - SMP_msg("ERROR: SPARK: nullptr for lower bound mem expr in EmitSPARKProcForLoopHeaderBlock() in func %s at %llx loop %d VecIndex %zu\n", - this->GetFuncName(), (uint64_t) this->GetFirstFuncAddr(), LoopIndex, VecIndex); + SMP_msg("ERROR: SPARK: nullptr for lower bound mem expr in EmitSPARKProcForLoopHeaderBlock() in loop %d VecIndex %zu ", + LoopIndex, VecIndex); + this->DumpFuncNameAndAddr(); continue; } MemExpr->PrintSPARKArgLocationStrings(HeaderFile, false, LoopNum, OutputCount, RegsPrinted); @@ -22899,7 +22979,8 @@ string SMPFunction::EmitSPARKProcForLoopHeaderBlock(int LoopIndex, int HeaderBlo STARSExpression *LowerExpr = (*this->TempRangeExprWidthIters[VecIndex].first); STARSExpression *UpperExpr = (*this->TempRangeExprWidthIters[VecIndex].second); if (nullptr == LowerExpr) { - SMP_msg("ERROR: SPARK: LowerExpr nullptr, VecIndex %zu in func at %llx\n", VecIndex, (uint64_t) this->GetFirstFuncAddr()); + SMP_msg("ERROR: SPARK: LowerExpr nullptr, VecIndex %zu ", VecIndex); + this->DumpFuncNameAndAddr(); } else { this->EmitSPARKMemRange(HeaderFile, true, true, HasArgs, LowerExpr, UpperExpr, OutputCount, 0); @@ -23571,7 +23652,8 @@ void SMPFunction::EmitSPARKAdaForBlock(int CurrBlockNum, int FollowBlockNum, FIL bool GoodCode = (((FlowType == CALL) || (FlowType == HALT) || CurrBlock->IsUnreachableBlock() || LastInst->IsNop()) && (0 == NumSuccessors)); if (!GoodCode) { - SMP_msg("ERROR: SPARK: Bad control flow at end of block, inst at %llx\n", (uint64_t)LastInst->GetAddr()); + SMP_msg("ERROR: SPARK: Bad control flow at end of block, inst at %llx ", (uint64_t)LastInst->GetAddr()); + this->DumpFuncNameAndAddr(); SMP_fprintf(SPARKBodyFile, "\nERROR\n"); } } @@ -23686,9 +23768,11 @@ void SMPFunction::EmitSPARKAdaForLoop(int HeaderBlockNum, int FollowBlockNum, FI else if (FlowType == COND_BRANCH) { if (LastCFType == JUMP_TO_SWITCH_INDIR_JUMP) { // conditional branch to INDIR_JUMP is not well-structured; should not occur - SMP_msg("FATAL ERROR: COND_BRANCH of type JUMP_TO_SWITCH_INDIR_JUMP at %llx\n", - (unsigned long long) LastAddr); - assert(LastCFType != JUMP_TO_SWITCH_INDIR_JUMP); + SMP_msg("FATAL ERROR: COND_BRANCH of type JUMP_TO_SWITCH_INDIR_JUMP at %llx ", (uint64_t) LastAddr); + this->DumpFuncNameAndAddr(); + this->DumpDotCFG(); + this->Dump(); + assert(LastCFType != JUMP_TO_SWITCH_INDIR_JUMP); // kablooey! } else if (IsLoopExitFlow(LastCFType)) { // Middle exit, else it would be loop header or tail handled above. @@ -23959,8 +24043,9 @@ void SMPFunction::EmitSPARKAdaForSwitch(int HeaderBlockNum, int FollowBlockNum, SwitchIndex = MapIter->second; } else { - SMP_msg("FATAL ERROR: Failed to find INDIR_JUMP addr %llx in SwitchJumpMap.\n", (unsigned long long) LastAddr); - SMP_fprintf(SPARKBodyFile, "ERROR in switch statement translation at %llx.\n", (unsigned long long) LastAddr); + SMP_msg("FATAL ERROR: Failed to find INDIR_JUMP addr %llx in SwitchJumpMap ", (uint64_t) LastAddr); + this->DumpFuncNameAndAddr(); + SMP_fprintf(SPARKBodyFile, "ERROR in switch statement translation at %llx.\n", (uint64_t) LastAddr); assert(false); } } @@ -24365,7 +24450,8 @@ int SMPFunction::FindFollowBlockNum(SMPBasicBlock *CurrBlock, bool StartAtLastIn FollowBlockNum = this->SwitchInfoArray.at(SwitchIndex).FollowNodeNum; } else { // leave error code of SMP_BLOCKNUM_UNINIT in FollowBlockNum - SMP_msg("ERROR: Failed to find INDIR_JUMP addr %llx in SwitchJumpMap.\n", (unsigned long long) LastAddr); + SMP_msg("ERROR: Failed to find INDIR_JUMP addr %llx in SwitchJumpMap ", (uint64_t) LastAddr); + this->DumpFuncNameAndAddr(); } } else if (FlowType == COND_BRANCH) { @@ -24392,8 +24478,9 @@ int SMPFunction::FindFollowBlockNum(SMPBasicBlock *CurrBlock, bool StartAtLastIn FollowBlockNum = MapIter->second; } else { - SMP_msg("ERROR: Failed to find COND_BRANCH entry for addr %llx in JumpFollowNodesMap.\n", - (unsigned long long) LastAddr); + SMP_msg("ERROR: Failed to find COND_BRANCH entry for addr %llx in JumpFollowNodesMap ", + (uint64_t) LastAddr); + this->DumpFuncNameAndAddr(); } } } @@ -24500,12 +24587,12 @@ void SMPFunction::EmitShadowingHelper(FILE *InfoAnnotFile, SMPInstr *CurrInst, b if (ShadowFuncPtrs) { // Emit the annotation to shadow the InArg value at the top of the function. SMP_fprintf(InfoAnnotFile, "%18llx %6zu INSTR FPTRSHADOW ", - (unsigned long long) ShadowAddr, ShadowInst->GetSize()); + (uint64_t) ShadowAddr, ShadowInst->GetSize()); } else if (ShadowArgs) { // Emit the annotation to shadow the InArg value at the top of the function. SMP_fprintf(InfoAnnotFile, "%18llx %6zu INSTR ARGSHADOW ", - (unsigned long long) ShadowAddr, ShadowInst->GetSize()); + (uint64_t) ShadowAddr, ShadowInst->GetSize()); } AnnotPrintOperand(UnnormalizedUseOp, InfoAnnotFile, UseFP, ShadowInst->MDIsAddressing64bit()); SMP_fprintf(InfoAnnotFile, " SHADOWID %u\n", CurrentShadowID); @@ -24518,11 +24605,11 @@ void SMPFunction::EmitShadowingHelper(FILE *InfoAnnotFile, SMPInstr *CurrInst, b SMPInstr *ShadowCheckInst = this->GetInstFromAddr(ShadowCheckAddr); if (FuncPtr) { SMP_fprintf(InfoAnnotFile, "%18llx %6zu INSTR FPTRCHECK ", - (unsigned long long) ShadowCheckAddr, ShadowCheckInst->GetSize()); + (uint64_t) ShadowCheckAddr, ShadowCheckInst->GetSize()); } else { SMP_fprintf(InfoAnnotFile, "%18llx %6zu INSTR ARGCHECK ", - (unsigned long long) ShadowCheckAddr, ShadowCheckInst->GetSize()); + (uint64_t) ShadowCheckAddr, ShadowCheckInst->GetSize()); } STARSOpndTypePtr UseOp = ShadowCheckInst->GetFirstRightOperandNoNorm(); // for annotation printing AnnotPrintOperand(UseOp, InfoAnnotFile, UseFP, ShadowCheckInst->MDIsAddressing64bit()); @@ -24762,7 +24849,8 @@ void SMPFunction::EmitStackMemRangeAnnotations(STARSExpression *MemLowerBound, S SMP_fprintf(InfoAnnotFile, "%s%s\n", OutputString3.c_str(), OutputString2.c_str()); } else { - SMP_msg("ERROR: Inst at %llx should be lea of either stack or static mem address.\n", (uint64_t) StackPtrCopyInstAddr); + SMP_msg("ERROR: Inst at %llx should be lea of either stack or static mem address ", (uint64_t) StackPtrCopyInstAddr); + this->DumpFuncNameAndAddr(); } } // end for all addrs in StackPtrCopiesVector[index] } -- GitLab