Skip to content

Commit

Permalink
Fix #488
Browse files Browse the repository at this point in the history
Added a few MacOS traps.

Ran regression tests.
  • Loading branch information
uxmal committed Oct 24, 2017
1 parent 567761f commit 6c7c09c
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 39 deletions.
6 changes: 2 additions & 4 deletions src/Arch/M68k/M68kDisassembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public override M68kInstruction DisassembleInstruction()
if (!rdr.IsValid)
return null;
var addr = rdr.Address;
if (addr.ToLinear() == 0x0010010A) //$DEBUG
addr.ToString();
var offset = rdr.Offset;
try
{
Expand Down Expand Up @@ -3148,8 +3146,8 @@ private static void GenTable()
new OpRec("sl:E0,e6", 0xf000, 0x2000, 0xfff, Opcode.move), // d68000_move_32
new OpRec("sw:E0,A9", 0xf1c0, 0x3040, 0xfff, Opcode.movea), // d68000_movea_16
new OpRec("sl:E0,A9", 0xf1c0, 0x2040, 0xfff, Opcode.movea), // d68000_movea_32
new OpRec("E0,c", 0xffc0, 0x44c0, 0xbff, Opcode.move), // d68000_move_to_ccr
new OpRec("c,E0", 0xffc0, 0x42c0, 0xbf8, Opcode.move), // d68010_move_fr_ccr
new OpRec("sw:E0,c", 0xffc0, 0x44c0, 0xbff, Opcode.move), // d68000_move_to_ccr
new OpRec("sw:c,E0", 0xffc0, 0x42c0, 0xbf8, Opcode.move), // d68010_move_fr_ccr
new OpRec(d68000_move_to_sr , 0xffc0, 0x46c0, 0xbff),
new OpRec(d68000_move_fr_sr , 0xffc0, 0x40c0, 0xbf8),
new OpRec(d68000_move_to_usp , 0xfff8, 0x4e60, 0x000),
Expand Down
1 change: 1 addition & 0 deletions src/Arch/M68k/M68kInstruction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private string DataSizeSuffix(PrimitiveType dataWidth)
case 8: return ".b";
case 16: return ".w";
case 32: return ".l";
case 64: return ".q";
}
}
throw new InvalidOperationException(string.Format("Unsupported data width {0}.", dataWidth.BitSize));
Expand Down
46 changes: 41 additions & 5 deletions src/Environments/MacOS/macos_classic.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<library xmlns="http://schemata.jklnet.org/Decompiler">
<Types>
<typedef name="ParamBlk">
<struct size="50">
</struct>
</typedef>
<typedef name="OSErr">
<prim domain="SignedInt" size="2" />
</typedef>
</Types>
<service name="_Open"><syscallinfo><vector>A000</vector></syscallinfo></service>
<service name="_Close"><syscallinfo><vector>A001</vector></syscallinfo></service>
<service name="_Read"><syscallinfo><vector>A002</vector></syscallinfo></service>
Expand All @@ -12,7 +21,12 @@
<service name="_Delete"><syscallinfo><vector>A009</vector></syscallinfo></service>
<service name="_OpenRF"><syscallinfo><vector>A00A</vector></syscallinfo></service>
<service name="_Rename"><syscallinfo><vector>A00B</vector></syscallinfo></service>
<service name="_GetFileInfo"><syscallinfo><vector>A00C</vector></syscallinfo></service>
<service name="_GetFileInfo"><syscallinfo><vector>A00C</vector></syscallinfo>
<signature>
<return><type>OSErr</type><reg>d0</reg></return>
<arg><ptr><type>ParamBlk</type></ptr><reg>a1</reg></arg>
</signature>
</service>
<service name="_SetFileInfo"><syscallinfo><vector>A00D</vector></syscallinfo></service>
<service name="_UnmountVol"><syscallinfo><vector>A00E</vector></syscallinfo></service>
<service name="_MountVol"><syscallinfo><vector>A00F</vector></syscallinfo></service>
Expand All @@ -28,7 +42,11 @@
<service name="_InitZone"><syscallinfo><vector>A019</vector></syscallinfo></service>
<service name="_SetZone"><syscallinfo><vector>A01B</vector></syscallinfo></service>
<service name="_FreeMem"><syscallinfo><vector>A01C</vector></syscallinfo></service>
<service name="_DisposePtr"><syscallinfo><vector>A01F</vector></syscallinfo></service>
<service name="_DisposePtr"><syscallinfo><vector>A01F</vector></syscallinfo>
<signature>
<arg name="ptr"><reg>a0</reg></arg>
</signature>
</service>
<service name="_SetPtrSize"><syscallinfo><vector>A020</vector></syscallinfo></service>
<service name="_GetPtrSize"><syscallinfo><vector>A021</vector></syscallinfo></service>
<service name="_DisposeHandle"><syscallinfo><vector>A023</vector></syscallinfo></service>
Expand All @@ -50,7 +68,13 @@
<arg name="zoneLimit"><ptr><void/></ptr><stack/></arg>
</signature>
</service>
<service name="_BlockMove"><syscallinfo><vector>A02E</vector></syscallinfo></service>
<service name="_BlockMove"><syscallinfo><vector>A02E</vector></syscallinfo>
<signature>
<arg name="src"><ptr><void/></ptr><reg>a0</reg></arg>
<arg name="dst"><ptr><void/></ptr><reg>a1</reg></arg>
<arg name="count"><prim domain="SignedInt" size="4" /><reg>d0</reg></arg>
</signature>
</service>
<service name="_PostEvent"><syscallinfo><vector>A02F</vector></syscallinfo></service>
<service name="_OSEventAvail"><syscallinfo><vector>A030</vector></syscallinfo></service>
<service name="_GetOSEvent"><syscallinfo><vector>A031</vector></syscallinfo></service>
Expand All @@ -66,7 +90,14 @@
<service name="_ReadDateTime"><syscallinfo><vector>A039</vector></syscallinfo></service>
<service name="_SetDateTime"><syscallinfo><vector>A03A</vector></syscallinfo></service>
<service name="_Delay"><syscallinfo><vector>A03B</vector></syscallinfo></service>
<service name="_CmpString"><syscallinfo><vector>A03C</vector></syscallinfo></service>
<service name="_CmpString"><syscallinfo><vector>A03C</vector></syscallinfo>
<signature>
<return><prim domain="SignedInt" size="4"/></return>
<arg><ptr><prim domain="Character" size="1"/></ptr><reg>a0</reg></arg>
<arg><ptr><prim domain="Character" size="1"/></ptr><reg>a1</reg></arg>
<arg><prim domain="UnsignedInt" size="4"/><reg>d0</reg></arg> <!-- packed words hi.lo -->
</signature>
</service>
<service name="_DrvrInstall"><syscallinfo><vector>A03D</vector></syscallinfo></service>
<service name="_DrvrRemove"><syscallinfo><vector>A03E</vector></syscallinfo></service>
<service name="_InitUtil"><syscallinfo><vector>A03F</vector></syscallinfo></service>
Expand Down Expand Up @@ -708,7 +739,12 @@
<service name="_SecondsToDate"><syscallinfo><vector>A9C6</vector></syscallinfo></service>
<service name="_DateToSeconds"><syscallinfo><vector>A9C7</vector></syscallinfo></service>
<service name="_SysBeep"><syscallinfo><vector>A9C8</vector></syscallinfo></service>
<service name="_SysError"><syscallinfo><vector>A9C9</vector></syscallinfo></service>
<service name="_SysError"><syscallinfo><vector>A9C9</vector></syscallinfo>
<signature>
<arg name="d0"><prim domain="UnsignedInt" size="2"/><reg>d0</reg></arg>
<arg name="msg"><ptr><void /></ptr><stack /></arg>
</signature>
</service>
<service name="_PutIcon"><syscallinfo><vector>A9CA</vector></syscallinfo></service>
<service name="_TEGetText"><syscallinfo><vector>A9CB</vector></syscallinfo></service>
<service name="_TEInit">
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/Windows/Controls/MixedCodeDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private static Address Align(Address addr, uint alignment)
private void CollectInstructions()
{
this.instructions = new Dictionary<ImageMapBlock, MachineInstruction[]>();
foreach (var bi in program.ImageMap.Items.Values.OfType<ImageMapBlock>())
foreach (var bi in program.ImageMap.Items.Values.OfType<ImageMapBlock>().ToList())
{
var instrs = new List<MachineInstruction>();
var addrStart = bi.Address;
Expand Down
4 changes: 2 additions & 2 deletions src/UnitTests/Arch/M68k/M68kDisassemblerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,13 @@ public void M68kdis_oril()
[Test]
public void M68kdis_move_to_ccr()
{
RunTest("move\td3,ccr", 0x44c3);
RunTest("move.w\td3,ccr", 0x44c3);
}

[Test]
public void M68kdis_move_fr_ccr()
{
RunTest("move\tccr,(a3)", 0x42d3, 0x0000);
RunTest("move.w\tccr,(a3)", 0x42d3, 0x0000);
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/UnitTests/Arch/M68k/RewriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ public void M68krw_move_to_ccr()
Rewrite(0x44c3);
AssertCode( // move\td3,ccr
"0|L--|00010000(2): 1 instructions",
"1|L--|ccr = d3");
"1|L--|ccr = (word16) d3");
}

[Test]
Expand Down
47 changes: 21 additions & 26 deletions subjects/regression.log
Original file line number Diff line number Diff line change
Expand Up @@ -2046,8 +2046,6 @@ Parameter name: Linear address 00000000 is not in known segment.
at Reko.Typing.TypeAnalyzer.RewriteProgram(Program program) in C:\dev\uxmal\reko\master\src\Decompiler\Typing\TypeAnalyzer.cs:line 90
at Reko.DecompilerDriver.ReconstructTypes() in C:\dev\uxmal\reko\master\src\Decompiler\Decompiler.cs:line 312
fn00000000004028C0: warning: Structure analysis stopped making progress, quitting. Please report this issue at https://github.com/uxmal/reko
fn0000000000410E90: warning: Structure analysis stopped making progress, quitting. Please report this issue at https://github.com/uxmal/reko
fn0000000000411360: warning: Structure analysis stopped making progress, quitting. Please report this issue at https://github.com/uxmal/reko

=== Elf-x86-64\ais3_crackme\ais3_crackme
*** Elf-x86-64\ais3_crackme\ais3_crackme
Expand Down Expand Up @@ -2370,20 +2368,23 @@ fn0000000000411360: warning: Structure analysis stopped making progress, quittin
at Reko.Core.Code.Declaration.Accept(InstructionVisitor v) in C:\dev\uxmal\reko\master\src\Core\Code\Declaration.cs:line 49
at Reko.Typing.TypeCollector.CollectTypes() in C:\dev\uxmal\reko\master\src\Decompiler\Typing\TypeCollector.cs:line 77
fn0800_1073: error: An error occurred while rewriting procedure to high-level language.
Unable to cast object of type 'Reko.Core.Types.MemberPointer' to type 'Reko.Core.Types.PrimitiveType'.
at Reko.Core.Expressions.Constant.Create(DataType dt, Int64 value) in C:\dev\uxmal\reko\master\src\Core\Expressions\Constant.cs:line 46
at Reko.Structure.StructureAnalysis.ReduceIncSwitch(Region n, Region follow) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 590
at Reko.Structure.StructureAnalysis.ReduceSwitchRegion(Region n) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 397
at Reko.Structure.StructureAnalysis.ReduceAcyclic(Region n) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 257
at Reko.Structure.StructureAnalysis.Execute() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 140
Can't collapse l0800_113C (IncSwitch) => l0800_1560
at Reko.Structure.StructureAnalysis.CollapseToTailRegion(Region from, Region to, AbsynStatement stm) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 867
at Reko.Structure.StructureAnalysis.VirtualizeEdge(VirtualEdge vEdge) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 817
at Reko.Structure.StructureAnalysis.VirtualizeIrregularExits(Region header, Region latch, Region follow, ISet`1 lexicalNodes) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 1322
at Reko.Structure.StructureAnalysis.RefineLoop(Region head, ISet`1 loopNodes) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 1078
at Reko.Structure.StructureAnalysis.ProcessUnresolvedRegions() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 277
at Reko.Structure.StructureAnalysis.Execute() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 152
at Reko.Structure.StructureAnalysis.Structure() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 69
at Reko.DecompilerDriver.StructureProgram() in C:\dev\uxmal\reko\master\src\Decompiler\Decompiler.cs:line 484
fn0800_16F3: error: An error occurred while rewriting procedure to high-level language.
The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Reko.Core.Lib.DominatorGraph`1.BuildDominanceFrontiers(DirectedGraph`1 graph, Dictionary`2 idoms) in C:\dev\uxmal\reko\master\src\Core\Lib\DominatorGraph.cs:line 195
at Reko.Core.Lib.DominatorGraph`1..ctor(DirectedGraph`1 graph, T entryNode) in C:\dev\uxmal\reko\master\src\Core\Lib\DominatorGraph.cs:line 46
at Reko.Structure.StructureAnalysis.Execute() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 126
Can't collapse l0800_17AE (IncSwitch) => l0800_17E6
at Reko.Structure.StructureAnalysis.CollapseToTailRegion(Region from, Region to, AbsynStatement stm) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 867
at Reko.Structure.StructureAnalysis.VirtualizeEdge(VirtualEdge vEdge) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 817
at Reko.Structure.StructureAnalysis.VirtualizeIrregularExits(Region header, Region latch, Region follow, ISet`1 lexicalNodes) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 1322
at Reko.Structure.StructureAnalysis.RefineLoop(Region head, ISet`1 loopNodes) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 1078
at Reko.Structure.StructureAnalysis.ProcessUnresolvedRegions() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 277
at Reko.Structure.StructureAnalysis.Execute() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 152
at Reko.Structure.StructureAnalysis.Structure() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 69
at Reko.DecompilerDriver.StructureProgram() in C:\dev\uxmal\reko\master\src\Decompiler\Decompiler.cs:line 484

Expand Down Expand Up @@ -3784,20 +3785,14 @@ Parameter name: Linear address 00000000 is not in known segment.
at Reko.Typing.TypeCollector.CollectTypes() in C:\dev\uxmal\reko\master\src\Decompiler\Typing\TypeCollector.cs:line 81
at Reko.Typing.TypeAnalyzer.RewriteProgram(Program program) in C:\dev\uxmal\reko\master\src\Decompiler\Typing\TypeAnalyzer.cs:line 90
at Reko.DecompilerDriver.ReconstructTypes() in C:\dev\uxmal\reko\master\src\Decompiler\Decompiler.cs:line 312
fn0800_9107: error: An error occurred while rewriting procedure to high-level language.
The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Reko.Core.Lib.DominatorGraph`1.BuildDominanceFrontiers(DirectedGraph`1 graph, Dictionary`2 idoms) in C:\dev\uxmal\reko\master\src\Core\Lib\DominatorGraph.cs:line 195
at Reko.Core.Lib.DominatorGraph`1..ctor(DirectedGraph`1 graph, T entryNode) in C:\dev\uxmal\reko\master\src\Core\Lib\DominatorGraph.cs:line 46
at Reko.Structure.StructureAnalysis.Execute() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 126
at Reko.Structure.StructureAnalysis.Structure() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 69
at Reko.DecompilerDriver.StructureProgram() in C:\dev\uxmal\reko\master\src\Decompiler\Decompiler.cs:line 484
fn0800_9828: error: An error occurred while rewriting procedure to high-level language.
The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Reko.Core.Lib.DominatorGraph`1.BuildDominanceFrontiers(DirectedGraph`1 graph, Dictionary`2 idoms) in C:\dev\uxmal\reko\master\src\Core\Lib\DominatorGraph.cs:line 195
at Reko.Core.Lib.DominatorGraph`1..ctor(DirectedGraph`1 graph, T entryNode) in C:\dev\uxmal\reko\master\src\Core\Lib\DominatorGraph.cs:line 46
at Reko.Structure.StructureAnalysis.Execute() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 126
Can't collapse l0800_98F7 (IncSwitch) => l0800_9C82
at Reko.Structure.StructureAnalysis.CollapseToTailRegion(Region from, Region to, AbsynStatement stm) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 867
at Reko.Structure.StructureAnalysis.VirtualizeEdge(VirtualEdge vEdge) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 817
at Reko.Structure.StructureAnalysis.VirtualizeIrregularExits(Region header, Region latch, Region follow, ISet`1 lexicalNodes) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 1322
at Reko.Structure.StructureAnalysis.RefineLoop(Region head, ISet`1 loopNodes) in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 1078
at Reko.Structure.StructureAnalysis.ProcessUnresolvedRegions() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 277
at Reko.Structure.StructureAnalysis.Execute() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 152
at Reko.Structure.StructureAnalysis.Structure() in C:\dev\uxmal\reko\master\src\Decompiler\Structure\StructureAnalysis.cs:line 69
at Reko.DecompilerDriver.StructureProgram() in C:\dev\uxmal\reko\master\src\Decompiler\Decompiler.cs:line 484
fn1483_1BB9: error: An error occurred while rewriting procedure to high-level language.
Expand Down

0 comments on commit 6c7c09c

Please sign in to comment.