Skip to content

Commit

Permalink
TrashedRegisterFinder: dump block on exception
Browse files Browse the repository at this point in the history
Add some extra logging to help debug errors during analysis.
  • Loading branch information
throwaway96 committed Sep 3, 2023
1 parent 0332867 commit ea79e23
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Decompiler/Analysis/TrashedRegisterFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class TrashedRegisterFinder : InstructionVisitor<bool>
private IProcessorArchitecture arch;
private bool propagateToCallers;
private bool selfRecursiveCalls;
private readonly IReadOnlyProgram program;

public TrashedRegisterFinder(
IReadOnlyProgram program,
Expand All @@ -71,6 +72,7 @@ public TrashedRegisterFinder(
this.cmp = new ExpressionValueComparer();
this.worklist = new WorkStack<Block>();
this.ssas = sccGroup.ToDictionary(s => s.SsaState.Procedure, s => s.SsaState);
this.program = program;
}

/// <summary>
Expand Down Expand Up @@ -262,8 +264,19 @@ private void ProcessBlock(Block block)
this.ctx.IsDirty = false;
foreach (var stm in block.Statements)
{
if (!stm.Instruction.Accept(this))
return;
try
{
if (!stm.Instruction.Accept(this))
return;
} catch (Exception ex)
{
listener.Error(
listener.CreateStatementNavigator(program, stm),
ex,
"An error occurred when finding the trashed registers in {0}", stm);
block.Procedure.Write(false, Console.Out);
block.Procedure.Dump(true);
}
}
if (block == block.Procedure.ExitBlock)
{
Expand Down Expand Up @@ -332,6 +345,7 @@ public bool VisitAssignment(Assignment ass)
var (value, _) = ass.Src.Accept(eval!);
trace.Verbose("{0} = [{1}]", ass.Dst, value);
ctx!.SetValue(ass.Dst, value);

return true;
}

Expand Down

0 comments on commit ea79e23

Please sign in to comment.