From cbc899e9cc44a30c8b8b176cacaa493e626d6352 Mon Sep 17 00:00:00 2001 From: clc5q <clc5q@git.zephyr-software.com> Date: Sun, 20 Apr 2008 04:25:21 +0000 Subject: [PATCH] Reduce debug output. --- SMPStaticAnalyzer.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/SMPStaticAnalyzer.cpp b/SMPStaticAnalyzer.cpp index ac94d6fa..fc007b5c 100644 --- a/SMPStaticAnalyzer.cpp +++ b/SMPStaticAnalyzer.cpp @@ -481,11 +481,15 @@ void FindDataInCode(void) { msg("Unknown: %x len: %x\n", addr, InstrLen); if (0 < DataRunLen) { if (do_data_ex(addr, byteflag(), InstrLen, BADNODE)) { +#if SMP_DEBUG_FIXUP_IDB msg("Converted unknown to data at %x len: %x\n", addr, InstrLen); +#endif DataRunLen += InstrLen; } else { +#if SMP_DEBUG_FIXUP_IDB msg("Failed to convert unknown to data at %x len: %x\n", addr, InstrLen); +#endif DataRunLen = 0; IsolatedCodeTrigger = false; } @@ -796,7 +800,9 @@ bool MDPatchUnconvertedBytes(ea_t CurrDisasmAddr) { flags_t AddrFlags = getFlags(CurrDisasmAddr); if (isData(AddrFlags) || isTail(AddrFlags)) { // Bytes should have been converted to unknown already. +#if SMP_DEBUG_FIXUP_IDB msg("Cannot patch data bytes or tail bytes at %x\n", CurrDisasmAddr); +#endif return false; } SMPInstr PatchInstr(CurrDisasmAddr); @@ -808,29 +814,39 @@ bool MDPatchUnconvertedBytes(ea_t CurrDisasmAddr) { } else { if (PatchInstr.GetCmd().itype != NN_call) { +#if SMP_DEBUG_FIXUP_IDB msg("Cannot patch non-call instruction at %x\n", CurrDisasmAddr); +#endif return false; } PatchInstr.PrintOperands(); op_t CallDest = PatchInstr.GetFirstUse()->GetOp(); if ((o_near != CallDest.type) || (0 != CallDest.addr)) { +#if SMP_DEBUG_FIXUP_IDB msg("Cannot patch call unless it is call near ptr 0 at %x", CurrDisasmAddr); +#endif return false; } ea_t PatchAddr = CurrDisasmAddr; for (int i = 0; i < InstrLen; ++i) { bool ok = patch_byte(PatchAddr, 0x90); // x86 no-op if (!ok) { +#if SMP_DEBUG_FIXUP_IDB msg("patch_byte() failed at %x\n", PatchAddr); +#endif return false; } ++PatchAddr; } +#if SMP_DEBUG_FIXUP_IDB msg("Patched %d bytes successfully at %x\n", InstrLen, CurrDisasmAddr); +#endif InstrLen = ua_code(CurrDisasmAddr); if (0 >= InstrLen) { +#if SMP_DEBUG_FIXUP_IDB msg(" ... but ua_code() still failed!\n"); +#endif return false; } } // end if (0 >= InstrLen) ... else ... @@ -946,12 +962,17 @@ void FixCodeIdentification(void) { } else { if (MDPatchUnconvertedBytes(CurrDisasmAddr)) { + ; +#if SMP_DEBUG_FIXUP_IDB msg(" Patched bytes at %x\n", CurrDisasmAddr); +#endif } else { CurrRegion.FixupInstrs.push_back(CurrDisasmAddr); AllConverted = false; +#if SMP_DEBUG_FIXUP_IDB msg("FixCodeID failure at %x\n", CurrDisasmAddr); +#endif } } } // end if (isCode(InstrFlags) ... else ... @@ -1189,14 +1210,18 @@ void FindOrphanedCode(segment_t *CurrSeg, FILE *AnnotFile) { } } else if (isUnknown(InstrFlags)) { +#if SMP_DEBUG_FIXUP_IDB msg("Unanalyzed byte at %x\n", addr); +#endif // Can IDA analyze this to be code? int InstrLen = ua_code(addr); if (InstrLen > 0) { (void) generate_disasm_line(addr, disasm, sizeof(disasm) - 1); // Remove interactive color-coding tags. tag_remove(disasm, disasm, 0); +#if SMP_DEBUG_FIXUP_IDB msg("Successfully analyzed! %s\n", disasm); +#endif SMPInstr UnknownInstr(addr); UnknownInstr.Analyze(); // TODO: Get new code into a chunk. **!!** @@ -1245,8 +1270,11 @@ void AuditCodeTargets(void) { // Far call or Near call func_t *CallingFunc = get_func(xb.from); if (NULL == CallingFunc) { + ; +#if SMP_DEBUG_FIXUP_IDB msg("Call to %x Func %s from %x not in function.\n", addr, FuncName, xb.from); +#endif } } } // end if (xb.iscode) -- GitLab