From c03d6eac9a72eca55afe861db5735b42e3fa40f3 Mon Sep 17 00:00:00 2001
From: Clark Coleman <clc@zephyr-software.com>
Date: Wed, 29 Jan 2020 23:04:24 -0500
Subject: [PATCH] Improve debugging output.

---
 src/base/SMPFunction.cpp                | 6 ++++--
 src/base/SMPProgram.cpp                 | 2 +-
 src/interfaces/idapro/STARSFunction.cpp | 6 +++++-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp
index 0bac2e41..1e7e8e96 100644
--- a/src/base/SMPFunction.cpp
+++ b/src/base/SMPFunction.cpp
@@ -2062,7 +2062,7 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) {
 #if SMP_COMPARE_IDA_STARS_STACK_POINTER_DELTAS
 	DebugFlag = (0 == strcmp("_dl_profile_fixup", this->GetFuncName()));
 	TraceFlag = (0 == strcmp("_dl_profile_fixup", this->GetFuncName()));
-	bool DebugFuncFound = (0x8089910 == this->GetFirstFuncAddr());
+	bool DebugFuncFound = (0x43ac70 == this->GetFirstFuncAddr());
 	DebugFlag = DebugFlag || DebugFuncFound;
 	TraceFlag = TraceFlag || DebugFuncFound;
 #endif
@@ -2500,6 +2500,8 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) {
 						else { // First RETURN statement seen.
 							ReturnSeen = true;
 							this->NetStackDelta = IncomingDelta;
+							SMP_msg("INFO: First stack delta seen at return instruction at %p : Current: %lld\n",
+								CurrInst->GetAddr(), (long long) IncomingDelta);
 #if SMP_AUDIT_STACK_POINTER_DELTAS
 							if (CALLING_CONVENTION_DEFAULT_FUNCTION_STACK_DELTA != IncomingDelta) {
 								SMP_msg("WARNING: Stack delta not %d after return instruction at %llx\n", 
@@ -2529,7 +2531,7 @@ bool SMPFunction::AnalyzeStackPointerDeltas(void) {
 				CurrBlock->SetOutgoingStackDelta(IncomingDelta); // record incoming delta for all successors
 				if (ReachesOutChanged || (!ReprocessingAllocaBlocks)) { // if anything changed (deltas or reaching defs ReachOut set)
 					list<SMPBasicBlock *>::iterator SuccIter;
-					if (DebugFlag && (0 == IncomingDelta)) {
+					if (DebugFlag && (0 == IncomingDelta) && (0 < this->GetLocalVarsSize())) {
 						SMP_msg("ERROR: Pushing WorkList items with IncomingDelta of zero. Dumping Block:\n");
 						CurrBlock->Dump();
 					}
diff --git a/src/base/SMPProgram.cpp b/src/base/SMPProgram.cpp
index a5d10c9c..ae3647a0 100644
--- a/src/base/SMPProgram.cpp
+++ b/src/base/SMPProgram.cpp
@@ -856,7 +856,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn
 			}
 #if 1
 			// bool FuncFound = (0 == strcmp("__mktime_internal", CurrFunc->GetFuncName()));
-			bool FuncFound = (0x8089910 == CurrFunc->GetFirstFuncAddr());
+			bool FuncFound = (0x43ac70 == CurrFunc->GetFirstFuncAddr());
 			if ((!changed || (IterationCounter > STARS_INTERPROCEDURAL_ITERATION_LIMIT)) && FuncFound) {
 				CurrFunc->Dump();
 				CurrFunc->DumpDotCFG();
diff --git a/src/interfaces/idapro/STARSFunction.cpp b/src/interfaces/idapro/STARSFunction.cpp
index 7a88f96f..bb30d2f9 100644
--- a/src/interfaces/idapro/STARSFunction.cpp
+++ b/src/interfaces/idapro/STARSFunction.cpp
@@ -500,9 +500,13 @@ void STARS_IDA_Function_t::BuildFuncIR(SMPFunction *func)
 									// Found a caller, with its call address in CurrXrefs.from
 									func->AddCallSource(FromAddr);
 								}
+								else if (DEFAULT == CallType) {
+									SMP_msg("ERROR: Fallthrough from %llx to func at %llx with xref type %d\n",
+										(uint64_t) FromAddr, (uint64_t) addr, CurrXrefs.GetType());
+								}
 								else {
 									SMP_msg("ERROR: Bad CallInst.Analyze() at %llx to %llx with xref type %d\n",
-										(unsigned long long) FromAddr, (unsigned long long) addr, CurrXrefs.GetType());
+										(uint64_t) FromAddr, (uint64_t) addr, CurrXrefs.GetType());
 								}
 							}
 							else { // Data xref
-- 
GitLab