Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging in TrashedRegisterFinder.ProcessBlock #1284

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading