Fix Decode exception condition (#1377)
This commit is contained in:
parent
788ca6a411
commit
863b0c8dcb
1 changed files with 10 additions and 4 deletions
|
@ -4,6 +4,7 @@ using ARMeilleure.Memory;
|
||||||
using ARMeilleure.State;
|
using ARMeilleure.State;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace ARMeilleure.Decoders
|
namespace ARMeilleure.Decoders
|
||||||
{
|
{
|
||||||
|
@ -132,18 +133,23 @@ namespace ARMeilleure.Decoders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blocks.Count == 0)
|
if (blocks.Count == 1 && blocks[0].OpCodes.Count == 0)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException($"Decoded 0 blocks. Entry point = 0x{address:X}.");
|
Debug.Assert(blocks[0].Exit);
|
||||||
|
Debug.Assert(blocks[0].Address == blocks[0].EndAddress);
|
||||||
|
|
||||||
|
throw new InvalidOperationException($"Decoded a single empty exit block. Entry point = 0x{address:X}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!singleBlock)
|
if (!singleBlock)
|
||||||
{
|
{
|
||||||
return TailCallRemover.RunPass(address, blocks);
|
return TailCallRemover.RunPass(address, blocks);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return blocks.ToArray();
|
return blocks.ToArray();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool BinarySearch(List<Block> blocks, ulong address, out int index)
|
public static bool BinarySearch(List<Block> blocks, ulong address, out int index)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue