Example of Capstone for both libxenia and the UI. Going to shuffle around.

This commit is contained in:
Ben Vanik 2015-06-10 23:31:19 -07:00
parent 8ca2b17e51
commit 6d4d1db310
16 changed files with 751 additions and 8 deletions

3
.gitmodules vendored
View File

@ -25,3 +25,6 @@
[submodule "third_party/libav-bin"] [submodule "third_party/libav-bin"]
path = third_party/libav-bin path = third_party/libav-bin
url = https://github.com/DrChat/xenia-libav-bin.git url = https://github.com/DrChat/xenia-libav-bin.git
[submodule "third_party/capstone"]
path = third_party/capstone
url = https://github.com/xenia-project/capstone.git

View File

@ -10,7 +10,7 @@
<ClCompile> <ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>$(SolutionDir)\third_party\flatbuffers\include\;$(SolutionDir)\third_party\gflags\src\;$(SolutionDir)\src\;$(SolutionDir)\third_party;$(SolutionDir)\</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)\third_party\flatbuffers\include\;$(SolutionDir)\third_party\gflags\src\;$(SolutionDir)\src\;$(SolutionDir)\third_party;$(SolutionDir)\</AdditionalIncludeDirectories>
<PreprocessorDefinitions>GLEW_STATIC=1;GLEW_MX=1;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32;_WIN64=1;_AMD64=1;MICROPROFILE_MAX_THREADS=128;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>GLEW_STATIC=1;GLEW_MX=1;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32;_WIN64=1;_AMD64=1;MICROPROFILE_MAX_THREADS=128;CAPSTONE_X86_ATT_DISABLE;CAPSTONE_DIET_NO;CAPSTONE_X86_REDUCE_NO;CAPSTONE_HAS_X86;CAPSTONE_USE_SYS_DYN_MEM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>

View File

@ -13,7 +13,7 @@
<BufferSecurityCheck>false</BufferSecurityCheck> <BufferSecurityCheck>false</BufferSecurityCheck>
<ControlFlowGuard>false</ControlFlowGuard> <ControlFlowGuard>false</ControlFlowGuard>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<PreprocessorDefinitions>NDEBUG;_STATIC_CPPLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<StringPooling>true</StringPooling> <StringPooling>true</StringPooling>
</ClCompile> </ClCompile>

View File

@ -204,6 +204,61 @@
<ClCompile Include="src\xenia\ui\win32\win32_menu_item.cc" /> <ClCompile Include="src\xenia\ui\win32\win32_menu_item.cc" />
<ClCompile Include="src\xenia\ui\win32\win32_window.cc" /> <ClCompile Include="src\xenia\ui\win32\win32_window.cc" />
<ClCompile Include="third_party\beaengine\beaengineSources\BeaEngine.c" /> <ClCompile Include="third_party\beaengine\beaengineSources\BeaEngine.c" />
<ClCompile Include="third_party\capstone\arch\X86\X86Disassembler.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86DisassemblerDecoder.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86IntelInstPrinter.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86Mapping.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86Module.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\cs.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\MCInst.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\MCInstrDesc.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\MCRegisterInfo.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\SStream.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\capstone\utils.c">
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">CompileAsCpp</CompileAs>
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Checked|x64'">CompileAsCpp</CompileAs>
</ClCompile>
<ClCompile Include="third_party\mspack\lzxd.c" /> <ClCompile Include="third_party\mspack\lzxd.c" />
<ClCompile Include="third_party\xxhash\xxhash.c" /> <ClCompile Include="third_party\xxhash\xxhash.c" />
</ItemGroup> </ItemGroup>
@ -412,6 +467,26 @@
<ClInclude Include="third_party\beaengine\include\beaengine\BeaEngine.h" /> <ClInclude Include="third_party\beaengine\include\beaengine\BeaEngine.h" />
<ClInclude Include="third_party\beaengine\include\beaengine\export.h" /> <ClInclude Include="third_party\beaengine\include\beaengine\export.h" />
<ClInclude Include="third_party\beaengine\include\beaengine\macros.h" /> <ClInclude Include="third_party\beaengine\include\beaengine\macros.h" />
<ClInclude Include="third_party\capstone\arch\X86\X86BaseInfo.h" />
<ClInclude Include="third_party\capstone\arch\X86\X86Disassembler.h" />
<ClInclude Include="third_party\capstone\arch\X86\X86DisassemblerDecoder.h" />
<ClInclude Include="third_party\capstone\arch\X86\X86DisassemblerDecoderCommon.h" />
<ClInclude Include="third_party\capstone\arch\X86\X86InstPrinter.h" />
<ClInclude Include="third_party\capstone\arch\X86\X86Mapping.h" />
<ClInclude Include="third_party\capstone\cs_priv.h" />
<ClInclude Include="third_party\capstone\include\capstone.h" />
<ClInclude Include="third_party\capstone\include\platform.h" />
<ClInclude Include="third_party\capstone\include\x86.h" />
<ClInclude Include="third_party\capstone\LEB128.h" />
<ClInclude Include="third_party\capstone\MathExtras.h" />
<ClInclude Include="third_party\capstone\MCDisassembler.h" />
<ClInclude Include="third_party\capstone\MCFixedLenDisassembler.h" />
<ClInclude Include="third_party\capstone\MCInst.h" />
<ClInclude Include="third_party\capstone\MCInstrDesc.h" />
<ClInclude Include="third_party\capstone\MCRegisterInfo.h" />
<ClInclude Include="third_party\capstone\myinttypes.h" />
<ClInclude Include="third_party\capstone\SStream.h" />
<ClInclude Include="third_party\capstone\utils.h" />
<ClInclude Include="third_party\flatbuffers\include\flatbuffers\flatbuffers.h" /> <ClInclude Include="third_party\flatbuffers\include\flatbuffers\flatbuffers.h" />
<ClInclude Include="third_party\llvm\include\llvm\ADT\BitVector.h" /> <ClInclude Include="third_party\llvm\include\llvm\ADT\BitVector.h" />
<ClInclude Include="third_party\llvm\include\llvm\Support\Compiler.h" /> <ClInclude Include="third_party\llvm\include\llvm\Support\Compiler.h" />
@ -444,6 +519,15 @@
<None Include="src\xenia\kernel\util\ordinal_table_pre.inc" /> <None Include="src\xenia\kernel\util\ordinal_table_pre.inc" />
<None Include="src\xenia\kernel\xam_table.inc" /> <None Include="src\xenia\kernel\xam_table.inc" />
<None Include="src\xenia\kernel\xboxkrnl_table.inc" /> <None Include="src\xenia\kernel\xboxkrnl_table.inc" />
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter.inc" />
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter1.inc" />
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter1_reduce.inc" />
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter_reduce.inc" />
<None Include="third_party\capstone\arch\X86\X86GenDisassemblerTables.inc" />
<None Include="third_party\capstone\arch\X86\X86GenDisassemblerTables_reduce.inc" />
<None Include="third_party\capstone\arch\X86\X86GenInstrInfo.inc" />
<None Include="third_party\capstone\arch\X86\X86GenInstrInfo_reduce.inc" />
<None Include="third_party\capstone\arch\X86\X86GenRegisterInfo.inc" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{0CE149F6-41C3-4224-9E57-C02E8C7CD312}</ProjectGuid> <ProjectGuid>{0CE149F6-41C3-4224-9E57-C02E8C7CD312}</ProjectGuid>
@ -502,7 +586,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BEA_ENGINE_STATIC=1;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BEA_ENGINE_STATIC=1;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\third_party\libav-bin\include\;$(SolutionDir)\third_party\beaengine\include\;$(SolutionDir)\third_party\llvm\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)\third_party\libav-bin\include\;$(SolutionDir)\third_party\beaengine\include\;$(SolutionDir)\third_party\llvm\include\;$(SolutionDir)\third_party\capstone\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -518,8 +602,8 @@
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BEA_ENGINE_STATIC=1;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BEA_ENGINE_STATIC=1;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\third_party\libav-bin\include\;$(SolutionDir)\third_party\beaengine\include\;$(SolutionDir)\third_party\llvm\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)\third_party\libav-bin\include\;$(SolutionDir)\third_party\beaengine\include\;$(SolutionDir)\third_party\llvm\include\;$(SolutionDir)\third_party\capstone\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -537,8 +621,8 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BEA_ENGINE_STATIC=1;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BEA_ENGINE_STATIC=1;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)\third_party\libav-bin\include\;$(SolutionDir)\third_party\beaengine\include\;$(SolutionDir)\third_party\llvm\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)\third_party\libav-bin\include\;$(SolutionDir)\third_party\beaengine\include\;$(SolutionDir)\third_party\llvm\include\;$(SolutionDir)\third_party\capstone\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>

View File

@ -149,6 +149,18 @@
<Filter Include="third_party\xbyak\xbyak"> <Filter Include="third_party\xbyak\xbyak">
<UniqueIdentifier>{d1405e1d-d9b0-4d8d-89ce-29d43698c415}</UniqueIdentifier> <UniqueIdentifier>{d1405e1d-d9b0-4d8d-89ce-29d43698c415}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="third_party\capstone">
<UniqueIdentifier>{49d9a353-9cc1-4ca3-95a1-9db2bd2d0eca}</UniqueIdentifier>
</Filter>
<Filter Include="third_party\capstone\include">
<UniqueIdentifier>{56f75ad9-d903-475a-a68c-0f7892e24808}</UniqueIdentifier>
</Filter>
<Filter Include="third_party\capstone\arch">
<UniqueIdentifier>{23674cd7-7387-4947-baa5-5216f6a08830}</UniqueIdentifier>
</Filter>
<Filter Include="third_party\capstone\arch\X86">
<UniqueIdentifier>{00596876-a323-4570-a5fb-71343024d429}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\xenia\emulator.cc"> <ClCompile Include="src\xenia\emulator.cc">
@ -724,6 +736,39 @@
<ClCompile Include="src\xenia\kernel\xam_avatar.cc"> <ClCompile Include="src\xenia\kernel\xam_avatar.cc">
<Filter>src\xenia\kernel</Filter> <Filter>src\xenia\kernel</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86Disassembler.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86DisassemblerDecoder.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86IntelInstPrinter.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86Mapping.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\arch\X86\X86Module.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\cs.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\MCInst.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\MCInstrDesc.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\MCRegisterInfo.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\SStream.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="third_party\capstone\utils.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\tracing.cc"> <ClCompile Include="src\xenia\gpu\tracing.cc">
<Filter>src\xenia\gpu</Filter> <Filter>src\xenia\gpu</Filter>
</ClCompile> </ClCompile>
@ -1386,6 +1431,66 @@
<ClInclude Include="src\xenia\base\ring_buffer.h"> <ClInclude Include="src\xenia\base\ring_buffer.h">
<Filter>src\xenia\base</Filter> <Filter>src\xenia\base</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="third_party\capstone\include\capstone.h">
<Filter>third_party\capstone\include</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\include\platform.h">
<Filter>third_party\capstone\include</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\include\x86.h">
<Filter>third_party\capstone\include</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\arch\X86\X86BaseInfo.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\arch\X86\X86Disassembler.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\arch\X86\X86DisassemblerDecoder.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\arch\X86\X86DisassemblerDecoderCommon.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\arch\X86\X86InstPrinter.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\arch\X86\X86Mapping.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\cs_priv.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\LEB128.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\MathExtras.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\MCDisassembler.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\MCFixedLenDisassembler.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\MCInst.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\MCInstrDesc.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\MCRegisterInfo.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\myinttypes.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\SStream.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="third_party\capstone\utils.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="src\xenia\cpu\backend\x64\x64_sequence.inl"> <None Include="src\xenia\cpu\backend\x64\x64_sequence.inl">
@ -1433,5 +1538,32 @@
<None Include="src\xenia\debug\proto\threads.fbs"> <None Include="src\xenia\debug\proto\threads.fbs">
<Filter>src\xenia\debug\proto</Filter> <Filter>src\xenia\debug\proto</Filter>
</None> </None>
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter1.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenAsmWriter1_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenDisassemblerTables.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenDisassemblerTables_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenInstrInfo.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenInstrInfo_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="third_party\capstone\arch\X86\X86GenRegisterInfo.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5AE85790-F2EA-4077-8953-825E9C0AADE9}</ProjectGuid>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>XeniaDebugNative</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\build\Xenia.Cpp.x64.Common.props" />
<Import Project="..\..\build\Xenia.Cpp.x64.Debug.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\build\Xenia.Cpp.x64.Common.props" />
<Import Project="..\..\build\Xenia.Cpp.x64.Release.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level2</WarningLevel>
<Optimization>Disabled</Optimization>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<CompileAs>CompileAsCpp</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)\third_party\capstone\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level2</WarningLevel>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<CompileAs>CompileAsCpp</CompileAs>
<AdditionalIncludeDirectories>$(SolutionDir)\third_party\capstone\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>
</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86BaseInfo.h" />
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86Disassembler.h" />
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86DisassemblerDecoder.h" />
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86DisassemblerDecoderCommon.h" />
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86InstPrinter.h" />
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86Mapping.h" />
<ClInclude Include="..\..\third_party\capstone\cs_priv.h" />
<ClInclude Include="..\..\third_party\capstone\include\capstone.h" />
<ClInclude Include="..\..\third_party\capstone\include\platform.h" />
<ClInclude Include="..\..\third_party\capstone\include\x86.h" />
<ClInclude Include="..\..\third_party\capstone\LEB128.h" />
<ClInclude Include="..\..\third_party\capstone\MathExtras.h" />
<ClInclude Include="..\..\third_party\capstone\MCDisassembler.h" />
<ClInclude Include="..\..\third_party\capstone\MCFixedLenDisassembler.h" />
<ClInclude Include="..\..\third_party\capstone\MCInst.h" />
<ClInclude Include="..\..\third_party\capstone\MCInstrDesc.h" />
<ClInclude Include="..\..\third_party\capstone\MCRegisterInfo.h" />
<ClInclude Include="..\..\third_party\capstone\myinttypes.h" />
<ClInclude Include="..\..\third_party\capstone\SStream.h" />
<ClInclude Include="..\..\third_party\capstone\utils.h" />
<ClInclude Include="x64_disassembler.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86Disassembler.c" />
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86DisassemblerDecoder.c" />
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86IntelInstPrinter.c" />
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86Mapping.c" />
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86Module.c" />
<ClCompile Include="..\..\third_party\capstone\cs.c" />
<ClCompile Include="..\..\third_party\capstone\MCInst.c" />
<ClCompile Include="..\..\third_party\capstone\MCInstrDesc.c" />
<ClCompile Include="..\..\third_party\capstone\MCRegisterInfo.c" />
<ClCompile Include="..\..\third_party\capstone\SStream.c" />
<ClCompile Include="..\..\third_party\capstone\utils.c" />
<ClCompile Include="assembly_info.cc" />
<ClCompile Include="x64_disassembler.cc" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter1.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter1_reduce.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter_reduce.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenDisassemblerTables.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenDisassemblerTables_reduce.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenInstrInfo.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenInstrInfo_reduce.inc" />
<None Include="..\..\third_party\capstone\arch\X86\X86GenRegisterInfo.inc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="third_party">
<UniqueIdentifier>{f0462696-4abd-4dc9-8290-aafff5ca6158}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{1a3b1c52-32cb-477e-9008-f2f9a6171c8c}</UniqueIdentifier>
</Filter>
<Filter Include="src\xenia">
<UniqueIdentifier>{5fb51b29-2462-49de-89c1-e332aafa0ca9}</UniqueIdentifier>
</Filter>
<Filter Include="src\xenia\debug">
<UniqueIdentifier>{15585f2e-55a4-4af5-bb24-6d6649d74ed0}</UniqueIdentifier>
</Filter>
<Filter Include="third_party\capstone">
<UniqueIdentifier>{920bc92f-e430-4c48-86dd-1a697c9a5fd1}</UniqueIdentifier>
</Filter>
<Filter Include="third_party\capstone\include">
<UniqueIdentifier>{d26b9a34-94fd-493b-841e-2ae2561bc584}</UniqueIdentifier>
</Filter>
<Filter Include="third_party\capstone\arch">
<UniqueIdentifier>{c9adeb1a-189d-4877-9bbd-c9948401b63e}</UniqueIdentifier>
</Filter>
<Filter Include="third_party\capstone\arch\X86">
<UniqueIdentifier>{4e8ea226-a18e-413a-95bd-6b3e5f4f8460}</UniqueIdentifier>
</Filter>
<Filter Include="src\Xenia.Debug.Native">
<UniqueIdentifier>{fc34f72d-e3c6-4fe7-9645-7b422ffaad57}</UniqueIdentifier>
</Filter>
<Filter Include="src\xenia\debug\native">
<UniqueIdentifier>{e530b0a2-9f4a-4b85-aee8-7185042251b1}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\third_party\capstone\cs_priv.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\LEB128.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\MathExtras.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\MCDisassembler.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\MCFixedLenDisassembler.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\MCInst.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\MCInstrDesc.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\MCRegisterInfo.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\myinttypes.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\SStream.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\utils.h">
<Filter>third_party\capstone</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\include\capstone.h">
<Filter>third_party\capstone\include</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\include\platform.h">
<Filter>third_party\capstone\include</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\include\x86.h">
<Filter>third_party\capstone\include</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86BaseInfo.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86Disassembler.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86DisassemblerDecoder.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86DisassemblerDecoderCommon.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86InstPrinter.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86Mapping.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="x64_disassembler.h">
<Filter>src\Xenia.Debug.Native</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\third_party\capstone\cs.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\MCInst.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\MCInstrDesc.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\MCRegisterInfo.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\SStream.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\utils.c">
<Filter>third_party\capstone</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86Disassembler.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86DisassemblerDecoder.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86IntelInstPrinter.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86Mapping.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86Module.c">
<Filter>third_party\capstone\arch\X86</Filter>
</ClCompile>
<ClCompile Include="x64_disassembler.cc">
<Filter>src\Xenia.Debug.Native</Filter>
</ClCompile>
<ClCompile Include="assembly_info.cc">
<Filter>src\Xenia.Debug.Native</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter1.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter1_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenDisassemblerTables.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenDisassemblerTables_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenInstrInfo.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenInstrInfo_reduce.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
<None Include="..\..\third_party\capstone\arch\X86\X86GenRegisterInfo.inc">
<Filter>third_party\capstone\arch\X86</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,45 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute(L"Xenia.Debug.Native")];
[assembly:AssemblyDescriptionAttribute(L"")];
[assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"")];
[assembly:AssemblyProductAttribute(L"Xenia.Debug.Native")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) Ben Vanik 2015")];
[assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];

View File

@ -0,0 +1,52 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#include "Xenia.Debug.Native/x64_disassembler.h"
#include "third_party/capstone/include/capstone.h"
#include "third_party/capstone/include/x86.h"
namespace Xenia {
namespace Debug {
namespace Native {
using namespace System;
using namespace System::Text;
X64Disassembler::X64Disassembler()
: capstone_handle_(0), string_builder_(gcnew StringBuilder(16 * 1024)) {
uintptr_t capstone_handle;
if (cs_open(CS_ARCH_X86, CS_MODE_64, &capstone_handle) != CS_ERR_OK) {
System::Diagnostics::Debug::Fail("Failed to initialize capstone");
return;
}
capstone_handle_ = capstone_handle;
cs_option(capstone_handle_, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL);
cs_option(capstone_handle_, CS_OPT_DETAIL, CS_OPT_OFF);
}
X64Disassembler::~X64Disassembler() {
if (capstone_handle_) {
pin_ptr<uintptr_t> capstone_handle = &capstone_handle_;
cs_close(capstone_handle);
}
}
String^ X64Disassembler::GenerateString(IntPtr code_address,
size_t code_size) {
string_builder_->Clear();
//
return string_builder_->ToString();
}
} // namespace Native
} // namespace Debug
} // namespace Xenia

View File

@ -0,0 +1,38 @@
/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2015 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_DEBUG_NATIVE_X64_DISASSEMBLER_H_
#define XENIA_DEBUG_NATIVE_X64_DISASSEMBLER_H_
#include <cstdint>
namespace Xenia {
namespace Debug {
namespace Native {
using namespace System;
using namespace System::Text;
public ref class X64Disassembler {
public:
X64Disassembler();
~X64Disassembler();
String^ GenerateString(IntPtr code_address, size_t code_size);
private:
uintptr_t capstone_handle_;
StringBuilder^ string_builder_;
};
} // namespace Native
} // namespace Debug
} // namespace Xenia
#endif // XENIA_DEBUG_NATIVE_X64_DISASSEMBLER_H_

View File

@ -113,7 +113,17 @@ namespace Xenia.Debug {
DisasmMachineCode = DisasmMachineCode.Replace("\n", "\r\n"); DisasmMachineCode = DisasmMachineCode.Replace("\n", "\r\n");
} }
DisassembleX64();
OnChanged(); OnChanged();
} }
private static Native.X64Disassembler disassembler = new Native.X64Disassembler();
private void DisassembleX64() {
var str = disassembler.GenerateString(IntPtr.Zero, 0);
System.Diagnostics.Debug.WriteLine(str);
disassembler.Dispose();
}
} }
} }

View File

@ -125,6 +125,12 @@
<Compile Include="Utilities\FileMapping.cs" /> <Compile Include="Utilities\FileMapping.cs" />
<Compile Include="Utilities\TaskExtensions.cs" /> <Compile Include="Utilities\TaskExtensions.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xenia.Debug.Native\Xenia.Debug.Native.vcxproj">
<Project>{5ae85790-f2ea-4077-8953-825e9c0aade9}</Project>
<Name>Xenia.Debug.Native</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -19,9 +19,18 @@
#include "xenia/cpu/processor.h" #include "xenia/cpu/processor.h"
#include "xenia/profiling.h" #include "xenia/profiling.h"
//#define DISASM_BEAENGINE
#define DISASM_CAPSTONE
#ifdef DISASM_BEAENGINE
namespace BE { namespace BE {
#include <beaengine/BeaEngine.h> #include <beaengine/BeaEngine.h>
} // namespace BE } // namespace BE
#endif // DISASM_BEAENGINE
#ifdef DISASM_CAPSTONE
#include "third_party/capstone/include/capstone.h"
#include "third_party/capstone/include/x86.h"
#endif // DISASM_CAPSTONE
namespace xe { namespace xe {
namespace cpu { namespace cpu {
@ -34,12 +43,26 @@ using namespace xe::cpu;
using xe::cpu::hir::HIRBuilder; using xe::cpu::hir::HIRBuilder;
X64Assembler::X64Assembler(X64Backend* backend) X64Assembler::X64Assembler(X64Backend* backend)
: Assembler(backend), x64_backend_(backend) {} : Assembler(backend), x64_backend_(backend), capstone_handle_(0) {
#ifdef DISASM_CAPSTONE
if (cs_open(CS_ARCH_X86, CS_MODE_64, &capstone_handle_) != CS_ERR_OK) {
assert_always("Failed to initialize capstone");
}
cs_option(capstone_handle_, CS_OPT_SYNTAX, CS_OPT_SYNTAX_INTEL);
cs_option(capstone_handle_, CS_OPT_DETAIL, CS_OPT_OFF);
#endif // DISASM_CAPSTONE
}
X64Assembler::~X64Assembler() { X64Assembler::~X64Assembler() {
// Emitter must be freed before the allocator. // Emitter must be freed before the allocator.
emitter_.reset(); emitter_.reset();
allocator_.reset(); allocator_.reset();
#ifdef DISASM_CAPSTONE
if (capstone_handle_) {
cs_close(&capstone_handle_);
}
#endif // DISASM_CAPSTONE
} }
bool X64Assembler::Initialize() { bool X64Assembler::Initialize() {
@ -106,6 +129,7 @@ void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code,
auto source_map_index = 0; auto source_map_index = 0;
uint32_t next_code_offset = source_map_entries[0].code_offset; uint32_t next_code_offset = source_map_entries[0].code_offset;
#if defined(DISASM_BEAENGINE)
BE::DISASM disasm = {0}; BE::DISASM disasm = {0};
disasm.Archi = 64; disasm.Archi = 64;
disasm.Options = BE::Tabulation + BE::MasmSyntax + BE::PrefixedNumeral; disasm.Options = BE::Tabulation + BE::MasmSyntax + BE::PrefixedNumeral;
@ -133,6 +157,31 @@ void X64Assembler::DumpMachineCode(DebugInfo* debug_info, void* machine_code,
str->AppendFormat("%.8X %s\n", uint32_t(disasm.EIP), disasm.CompleteInstr); str->AppendFormat("%.8X %s\n", uint32_t(disasm.EIP), disasm.CompleteInstr);
disasm.EIP += len; disasm.EIP += len;
} }
#elif defined(DISASM_CAPSTONE)
const uint8_t* code_ptr = reinterpret_cast<uint8_t*>(machine_code);
size_t remaining_code_size = code_size;
uint64_t address = uint64_t(machine_code);
cs_insn insn = {0};
while (remaining_code_size &&
cs_disasm_iter(capstone_handle_, &code_ptr, &remaining_code_size,
&address, &insn)) {
// Look up source offset.
auto code_offset =
uint32_t(code_ptr - reinterpret_cast<uint8_t*>(machine_code));
if (code_offset >= next_code_offset &&
source_map_index < source_map_count) {
auto& source_map_entry = source_map_entries[source_map_index];
str->AppendFormat("%.8X ", source_map_entry.source_offset);
++source_map_index;
next_code_offset = source_map_entries[source_map_index].code_offset;
} else {
str->Append(" ");
}
str->AppendFormat("%.8X %-6s %s\n", uint32_t(insn.address),
insn.mnemonic, insn.op_str);
}
#endif // DISASM_BEAENGINE / DISASM_CAPSTONE
} }
} // namespace x64 } // namespace x64

View File

@ -46,6 +46,7 @@ class X64Assembler : public Assembler {
X64Backend* x64_backend_; X64Backend* x64_backend_;
std::unique_ptr<X64Emitter> emitter_; std::unique_ptr<X64Emitter> emitter_;
std::unique_ptr<XbyakAllocator> allocator_; std::unique_ptr<XbyakAllocator> allocator_;
uintptr_t capstone_handle_;
StringBuffer string_buffer_; StringBuffer string_buffer_;
}; };

1
third_party/capstone vendored Submodule

@ -0,0 +1 @@
Subproject commit f9f948aaaa6d6e6da094127b202e08167994c521

View File

@ -44,6 +44,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xe-cpu-ppc-test", "src\xeni
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xenia.Debug", "src\Xenia.Debug\Xenia.Debug.csproj", "{58348C66-1B0D-497C-B51A-28E99DF1EF74}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xenia.Debug", "src\Xenia.Debug\Xenia.Debug.csproj", "{58348C66-1B0D-497C-B51A-28E99DF1EF74}"
ProjectSection(ProjectDependencies) = postProject
{5AE85790-F2EA-4077-8953-825E9C0AADE9} = {5AE85790-F2EA-4077-8953-825E9C0AADE9}
EndProjectSection
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "debugging", "debugging", "{345BD157-B21D-4989-9CE4-FA3C90FFC095}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "debugging", "debugging", "{345BD157-B21D-4989-9CE4-FA3C90FFC095}"
EndProject EndProject
@ -59,6 +62,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xe-gpu-trace-viewer", "src\
{838020F9-94AA-4314-996D-69B923C45D39} = {838020F9-94AA-4314-996D-69B923C45D39} {838020F9-94AA-4314-996D-69B923C45D39} = {838020F9-94AA-4314-996D-69B923C45D39}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Xenia.Debug.Native", "src\Xenia.Debug.Native\Xenia.Debug.Native.vcxproj", "{5AE85790-F2EA-4077-8953-825E9C0AADE9}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Checked|x64 = Checked|x64 Checked|x64 = Checked|x64
@ -138,6 +143,12 @@ Global
{21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Debug|x64.Build.0 = Debug|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Debug|x64.Build.0 = Debug|x64
{21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Release|x64.ActiveCfg = Release|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Release|x64.ActiveCfg = Release|x64
{21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Release|x64.Build.0 = Release|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Release|x64.Build.0 = Release|x64
{5AE85790-F2EA-4077-8953-825E9C0AADE9}.Checked|x64.ActiveCfg = Debug|x64
{5AE85790-F2EA-4077-8953-825E9C0AADE9}.Checked|x64.Build.0 = Debug|x64
{5AE85790-F2EA-4077-8953-825E9C0AADE9}.Debug|x64.ActiveCfg = Debug|x64
{5AE85790-F2EA-4077-8953-825E9C0AADE9}.Debug|x64.Build.0 = Debug|x64
{5AE85790-F2EA-4077-8953-825E9C0AADE9}.Release|x64.ActiveCfg = Release|x64
{5AE85790-F2EA-4077-8953-825E9C0AADE9}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -153,5 +164,6 @@ Global
{75A94CEB-442C-45B6-AEEC-A5F16D4543F3} = {345BD157-B21D-4989-9CE4-FA3C90FFC095} {75A94CEB-442C-45B6-AEEC-A5F16D4543F3} = {345BD157-B21D-4989-9CE4-FA3C90FFC095}
{C75532C4-765B-418E-B09B-46D36B2ABDB1} = {FCCBE57F-ECAE-420A-8A82-4B85F722C272} {C75532C4-765B-418E-B09B-46D36B2ABDB1} = {FCCBE57F-ECAE-420A-8A82-4B85F722C272}
{21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC} = {FD0BCA5D-908D-4091-AC05-47C2A640BA72} {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC} = {FD0BCA5D-908D-4091-AC05-47C2A640BA72}
{5AE85790-F2EA-4077-8953-825E9C0AADE9} = {345BD157-B21D-4989-9CE4-FA3C90FFC095}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal