Moving PPC disasm to on-demand in debugger.

This commit is contained in:
Ben Vanik 2015-06-16 20:18:48 -07:00
parent 5f33087a12
commit 165d49ad3a
18 changed files with 389 additions and 337 deletions

View File

@ -106,7 +106,14 @@
<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" />
<ClInclude Include="..\xenia\base\assert.h" />
<ClInclude Include="..\xenia\base\byte_order.h" />
<ClInclude Include="..\xenia\base\math.h" />
<ClInclude Include="..\xenia\base\string_buffer.h" />
<ClInclude Include="..\xenia\cpu\frontend\ppc_disasm.h" />
<ClInclude Include="..\xenia\cpu\frontend\ppc_instr.h" />
<ClInclude Include="..\xenia\cpu\frontend\ppc_instr_tables.h" />
<ClInclude Include="disassembler.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\third_party\capstone\arch\X86\X86Disassembler.c" />
@ -120,8 +127,11 @@
<ClCompile Include="..\..\third_party\capstone\MCRegisterInfo.c" />
<ClCompile Include="..\..\third_party\capstone\SStream.c" />
<ClCompile Include="..\..\third_party\capstone\utils.c" />
<ClCompile Include="..\xenia\base\string_buffer.cc" />
<ClCompile Include="..\xenia\cpu\frontend\ppc_disasm.cc" />
<ClCompile Include="..\xenia\cpu\frontend\ppc_instr.cc" />
<ClCompile Include="assembly_info.cc" />
<ClCompile Include="x64_disassembler.cc" />
<ClCompile Include="disassembler.cc" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter.inc" />

View File

@ -31,6 +31,15 @@
<Filter Include="src\xenia\debug\native">
<UniqueIdentifier>{e530b0a2-9f4a-4b85-aee8-7185042251b1}</UniqueIdentifier>
</Filter>
<Filter Include="src\xenia\base">
<UniqueIdentifier>{3945623c-9ad7-4f3e-9918-b31ede4e115f}</UniqueIdentifier>
</Filter>
<Filter Include="src\xenia\cpu">
<UniqueIdentifier>{796d5778-3fc4-42b0-b59a-39340f5b7989}</UniqueIdentifier>
</Filter>
<Filter Include="src\xenia\cpu\frontend">
<UniqueIdentifier>{d4d6e5f8-e3d4-424e-b195-77fc1b3f5590}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\third_party\capstone\cs_priv.h">
@ -93,9 +102,30 @@
<ClInclude Include="..\..\third_party\capstone\arch\X86\X86Mapping.h">
<Filter>third_party\capstone\arch\X86</Filter>
</ClInclude>
<ClInclude Include="x64_disassembler.h">
<ClInclude Include="..\xenia\base\string_buffer.h">
<Filter>src\xenia\base</Filter>
</ClInclude>
<ClInclude Include="..\xenia\cpu\frontend\ppc_disasm.h">
<Filter>src\xenia\cpu\frontend</Filter>
</ClInclude>
<ClInclude Include="..\xenia\cpu\frontend\ppc_instr.h">
<Filter>src\xenia\cpu\frontend</Filter>
</ClInclude>
<ClInclude Include="..\xenia\base\assert.h">
<Filter>src\xenia\base</Filter>
</ClInclude>
<ClInclude Include="..\xenia\base\math.h">
<Filter>src\xenia\base</Filter>
</ClInclude>
<ClInclude Include="disassembler.h">
<Filter>src\Xenia.Debug.Native</Filter>
</ClInclude>
<ClInclude Include="..\xenia\cpu\frontend\ppc_instr_tables.h">
<Filter>src\xenia\cpu\frontend</Filter>
</ClInclude>
<ClInclude Include="..\xenia\base\byte_order.h">
<Filter>src\xenia\base</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\third_party\capstone\cs.c">
@ -131,12 +161,21 @@
<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>
<ClCompile Include="..\xenia\base\string_buffer.cc">
<Filter>src\xenia\base</Filter>
</ClCompile>
<ClCompile Include="..\xenia\cpu\frontend\ppc_disasm.cc">
<Filter>src\xenia\cpu\frontend</Filter>
</ClCompile>
<ClCompile Include="disassembler.cc">
<Filter>src\Xenia.Debug.Native</Filter>
</ClCompile>
<ClCompile Include="..\xenia\cpu\frontend\ppc_instr.cc">
<Filter>src\xenia\cpu\frontend</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\..\third_party\capstone\arch\X86\X86GenAsmWriter.inc">

View File

@ -0,0 +1,82 @@
/**
******************************************************************************
* 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/disassembler.h"
#include "xenia/base/byte_order.h"
#include "xenia/base/string_buffer.h"
#include "xenia/cpu/frontend/ppc_disasm.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;
Disassembler::Disassembler()
: capstone_handle_(0), string_buffer_(new xe::StringBuffer()) {
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);
}
Disassembler::~Disassembler() {
if (capstone_handle_) {
pin_ptr<uintptr_t> capstone_handle = &capstone_handle_;
cs_close(capstone_handle);
}
delete string_buffer_;
}
String^ Disassembler::DisassemblePPC(IntPtr code_address, size_t code_size) {
string_buffer_->Reset();
auto code_base = reinterpret_cast<const uint32_t*>(code_address.ToPointer());
for (int i = 0; i < code_size / 4; ++i) {
xe::cpu::frontend::InstrData instr;
instr.address = uint32_t(code_address.ToInt64()) + i * 4;
instr.code = xe::byte_swap(code_base[i]);
instr.type = xe::cpu::frontend::GetInstrType(instr.code);
string_buffer_->AppendFormat("%.8X %.8X ", instr.address, instr.code);
xe::cpu::frontend::DisasmPPC(instr, string_buffer_);
string_buffer_->Append("\r\n");
}
return gcnew String(string_buffer_->ToString());
}
String^ Disassembler::DisassembleX64(IntPtr code_address, size_t code_size) {
string_buffer_->Reset();
auto code_base = reinterpret_cast<const uint8_t*>(code_address.ToPointer());
auto code_ptr = code_base;
size_t remaining_code_size = code_size;
uint64_t address = uint64_t(code_address.ToInt64());
cs_insn insn = {0};
while (remaining_code_size &&
cs_disasm_iter(capstone_handle_, &code_ptr, &remaining_code_size,
&address, &insn)) {
string_buffer_->AppendFormat("%.8X %-6s %s\n", uint32_t(insn.address),
insn.mnemonic, insn.op_str);
}
return gcnew String(string_buffer_->ToString());
}
} // namespace Native
} // namespace Debug
} // namespace Xenia

View File

@ -7,11 +7,13 @@
******************************************************************************
*/
#ifndef XENIA_DEBUG_NATIVE_X64_DISASSEMBLER_H_
#define XENIA_DEBUG_NATIVE_X64_DISASSEMBLER_H_
#ifndef XENIA_DEBUG_NATIVE_DISASSEMBLER_H_
#define XENIA_DEBUG_NATIVE_DISASSEMBLER_H_
#include <cstdint>
#include "xenia/base/string_buffer.h"
namespace Xenia {
namespace Debug {
namespace Native {
@ -19,20 +21,21 @@ namespace Native {
using namespace System;
using namespace System::Text;
public ref class X64Disassembler {
public ref class Disassembler {
public:
X64Disassembler();
~X64Disassembler();
Disassembler();
~Disassembler();
String^ GenerateString(IntPtr code_address, size_t code_size);
String^ DisassemblePPC(IntPtr code_address, size_t code_size);
String^ DisassembleX64(IntPtr code_address, size_t code_size);
private:
uintptr_t capstone_handle_;
StringBuilder^ string_builder_;
xe::StringBuffer* string_buffer_;
};
} // namespace Native
} // namespace Debug
} // namespace Xenia
#endif // XENIA_DEBUG_NATIVE_X64_DISASSEMBLER_H_
#endif // XENIA_DEBUG_NATIVE_DISASSEMBLER_H_

View File

@ -1,52 +0,0 @@
/**
******************************************************************************
* 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

@ -44,6 +44,8 @@ namespace Xenia.Debug {
private uint nextRequestId = 1;
private FileMappingHandle memoryHandle;
private FileMappingHandle codeCacheHandle;
private IntPtr codeCachePtr;
public unsafe byte* TranslateVirtual(uint address) {
return (byte*)Memory.VirtualMembase.ToPointer() + address;
@ -140,7 +142,7 @@ namespace Xenia.Debug {
var attachResponse = new AttachResponse();
response.GetResponseData(attachResponse);
// Open mmap to share memroy.
// Open mmap to share memory.
memoryHandle = FileMapping.OpenFileMapping(
FileMapAccess.FILE_MAP_ALL_ACCESS, false, attachResponse.MemoryFile);
if (memoryHandle.IsInvalid) {
@ -149,6 +151,19 @@ namespace Xenia.Debug {
return;
}
// Open mmap to code cache.
codeCacheHandle =
FileMapping.OpenFileMapping(FileMapAccess.FILE_MAP_ALL_ACCESS, false,
attachResponse.CodeCacheFile);
if (codeCacheHandle.IsInvalid) {
System.Diagnostics.Debug.Fail("Unable to open target code cache");
Detach();
return;
}
codeCachePtr = FileMapping.MapViewOfFileEx(
codeCacheHandle, FileMapAccess.FILE_MAP_ALL_ACCESS, 0, 0,
attachResponse.CodeCacheSize, attachResponse.CodeCacheBase);
// Setup the memory system. This maps the emulator memory into our address
// space.
if (!Memory.InitializeMapping(memoryHandle)) {
@ -166,6 +181,11 @@ namespace Xenia.Debug {
Memory.UninitializeMapping();
if (codeCacheHandle != null) {
FileMapping.UnmapViewOfFile(codeCachePtr);
codeCacheHandle.Close();
codeCacheHandle = null;
}
if (memoryHandle != null) {
memoryHandle.Close();
memoryHandle = null;

View File

@ -17,6 +17,8 @@ using Xenia.Debug.Utilities;
namespace Xenia.Debug {
public class Function : Changeable<Function> {
private static Native.Disassembler disassembler = new Native.Disassembler();
// status: declared, defined, failed
// behavior: default, prolog, epilog, epilog_return, extern
// extern info?
@ -25,7 +27,16 @@ namespace Xenia.Debug {
public readonly Module Module;
public readonly ulong Identifier;
public readonly uint AddressStart;
public readonly uint AddressEnd;
public uint AddressEnd {
get; private set;
}
public uint MachineCodeStart {
get; private set;
}
public uint MachineCodeEnd {
get; private set;
}
// source map
@ -42,17 +53,43 @@ namespace Xenia.Debug {
// caller history
// instruction execution counts
public string DisasmPpc {
get; private set;
private string disasmPpc;
public unsafe string DisasmPpc {
get {
if (disasmPpc != null) {
return disasmPpc;
}
if (AddressEnd == 0) {
return "(unavailable)";
}
disasmPpc = disassembler.DisassemblePPC(
new IntPtr(Debugger.TranslateVirtual(AddressStart)),
AddressEnd - AddressStart + 4);
return disasmPpc;
}
}
public string DisasmHirUnoptimized {
get; private set;
}
public string DisasmHirOptimized {
get; private set;
}
private string disasmMachineCode;
public string DisasmMachineCode {
get; private set;
get {
if (disasmMachineCode != null) {
return disasmMachineCode;
}
if (MachineCodeStart == 0) {
return null;
}
disasmMachineCode = disassembler.DisassembleX64(
new IntPtr(MachineCodeStart), MachineCodeEnd - MachineCodeStart + 1);
disasmMachineCode = disasmMachineCode.Replace("\n", "\r\n");
return disasmMachineCode;
}
}
public Function(Debugger debugger, Module module, xe.debug.proto.FunctionEntry functionEntry) {
@ -96,33 +133,21 @@ namespace Xenia.Debug {
response.GetResponseData(responseData);
var functionData = responseData.Function;
this.DisasmPpc = functionData.DisasmPpc;
this.AddressEnd = functionData.AddressEnd;
this.MachineCodeStart = functionData.MachineCodeStart;
this.MachineCodeEnd = functionData.MachineCodeEnd;
this.DisasmHirUnoptimized = functionData.DisasmHirRaw;
this.DisasmHirOptimized = functionData.DisasmHirOpt;
this.DisasmMachineCode = functionData.DisasmMachineCode;
if (DisasmPpc != null) {
DisasmPpc = DisasmPpc.Replace("\n", "\r\n");
}
if (DisasmHirUnoptimized != null) {
DisasmHirUnoptimized = DisasmHirUnoptimized.Replace("\n", "\r\n");
}
if (DisasmHirOptimized != null) {
DisasmHirOptimized = DisasmHirOptimized.Replace("\n", "\r\n");
}
if (DisasmMachineCode != null) {
DisasmMachineCode = DisasmMachineCode.Replace("\n", "\r\n");
}
DisassembleX64();
OnChanged();
}
private static Native.X64Disassembler disassembler = new Native.X64Disassembler();
private void DisassembleX64() {
var str = disassembler.GenerateString(IntPtr.Zero, 0);
System.Diagnostics.Debug.WriteLine(str);
}
}
}

View File

@ -11,24 +11,36 @@ public sealed class AttachResponse : Table {
public AttachResponse __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
public string MemoryFile { get { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } }
public string FunctionsFile { get { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } }
public string FunctionsTraceFile { get { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; } }
public string CodeCacheFile { get { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } }
public uint CodeCacheBase { get { int o = __offset(8); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint CodeCacheSize { get { int o = __offset(10); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public string FunctionsFile { get { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; } }
public string FunctionsTraceFile { get { int o = __offset(14); return o != 0 ? __string(o + bb_pos) : null; } }
public static int CreateAttachResponse(FlatBufferBuilder builder,
int memory_file = 0,
int code_cache_file = 0,
uint code_cache_base = 0,
uint code_cache_size = 0,
int functions_file = 0,
int functions_trace_file = 0) {
builder.StartObject(3);
builder.StartObject(6);
AttachResponse.AddFunctionsTraceFile(builder, functions_trace_file);
AttachResponse.AddFunctionsFile(builder, functions_file);
AttachResponse.AddCodeCacheSize(builder, code_cache_size);
AttachResponse.AddCodeCacheBase(builder, code_cache_base);
AttachResponse.AddCodeCacheFile(builder, code_cache_file);
AttachResponse.AddMemoryFile(builder, memory_file);
return AttachResponse.EndAttachResponse(builder);
}
public static void StartAttachResponse(FlatBufferBuilder builder) { builder.StartObject(3); }
public static void StartAttachResponse(FlatBufferBuilder builder) { builder.StartObject(6); }
public static void AddMemoryFile(FlatBufferBuilder builder, int memoryFileOffset) { builder.AddOffset(0, memoryFileOffset, 0); }
public static void AddFunctionsFile(FlatBufferBuilder builder, int functionsFileOffset) { builder.AddOffset(1, functionsFileOffset, 0); }
public static void AddFunctionsTraceFile(FlatBufferBuilder builder, int functionsTraceFileOffset) { builder.AddOffset(2, functionsTraceFileOffset, 0); }
public static void AddCodeCacheFile(FlatBufferBuilder builder, int codeCacheFileOffset) { builder.AddOffset(1, codeCacheFileOffset, 0); }
public static void AddCodeCacheBase(FlatBufferBuilder builder, uint codeCacheBase) { builder.AddUint(2, codeCacheBase, 0); }
public static void AddCodeCacheSize(FlatBufferBuilder builder, uint codeCacheSize) { builder.AddUint(3, codeCacheSize, 0); }
public static void AddFunctionsFile(FlatBufferBuilder builder, int functionsFileOffset) { builder.AddOffset(4, functionsFileOffset, 0); }
public static void AddFunctionsTraceFile(FlatBufferBuilder builder, int functionsTraceFileOffset) { builder.AddOffset(5, functionsTraceFileOffset, 0); }
public static int EndAttachResponse(FlatBufferBuilder builder) {
int o = builder.EndObject();
return o;

View File

@ -14,26 +14,26 @@ public sealed class Function : Table {
public uint AddressStart { get { int o = __offset(6); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint AddressEnd { get { int o = __offset(8); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public string Name { get { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; } }
public string DisasmPpc { get { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; } }
public string DisasmHirRaw { get { int o = __offset(14); return o != 0 ? __string(o + bb_pos) : null; } }
public string DisasmHirOpt { get { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; } }
public string DisasmMachineCode { get { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; } }
public uint MachineCodeStart { get { int o = __offset(12); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint MachineCodeEnd { get { int o = __offset(14); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public string DisasmHirRaw { get { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; } }
public string DisasmHirOpt { get { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; } }
public static int CreateFunction(FlatBufferBuilder builder,
ulong identifier = 0,
uint address_start = 0,
uint address_end = 0,
int name = 0,
int disasm_ppc = 0,
uint machine_code_start = 0,
uint machine_code_end = 0,
int disasm_hir_raw = 0,
int disasm_hir_opt = 0,
int disasm_machine_code = 0) {
int disasm_hir_opt = 0) {
builder.StartObject(8);
Function.AddIdentifier(builder, identifier);
Function.AddDisasmMachineCode(builder, disasm_machine_code);
Function.AddDisasmHirOpt(builder, disasm_hir_opt);
Function.AddDisasmHirRaw(builder, disasm_hir_raw);
Function.AddDisasmPpc(builder, disasm_ppc);
Function.AddMachineCodeEnd(builder, machine_code_end);
Function.AddMachineCodeStart(builder, machine_code_start);
Function.AddName(builder, name);
Function.AddAddressEnd(builder, address_end);
Function.AddAddressStart(builder, address_start);
@ -45,10 +45,10 @@ public sealed class Function : Table {
public static void AddAddressStart(FlatBufferBuilder builder, uint addressStart) { builder.AddUint(1, addressStart, 0); }
public static void AddAddressEnd(FlatBufferBuilder builder, uint addressEnd) { builder.AddUint(2, addressEnd, 0); }
public static void AddName(FlatBufferBuilder builder, int nameOffset) { builder.AddOffset(3, nameOffset, 0); }
public static void AddDisasmPpc(FlatBufferBuilder builder, int disasmPpcOffset) { builder.AddOffset(4, disasmPpcOffset, 0); }
public static void AddDisasmHirRaw(FlatBufferBuilder builder, int disasmHirRawOffset) { builder.AddOffset(5, disasmHirRawOffset, 0); }
public static void AddDisasmHirOpt(FlatBufferBuilder builder, int disasmHirOptOffset) { builder.AddOffset(6, disasmHirOptOffset, 0); }
public static void AddDisasmMachineCode(FlatBufferBuilder builder, int disasmMachineCodeOffset) { builder.AddOffset(7, disasmMachineCodeOffset, 0); }
public static void AddMachineCodeStart(FlatBufferBuilder builder, uint machineCodeStart) { builder.AddUint(4, machineCodeStart, 0); }
public static void AddMachineCodeEnd(FlatBufferBuilder builder, uint machineCodeEnd) { builder.AddUint(5, machineCodeEnd, 0); }
public static void AddDisasmHirRaw(FlatBufferBuilder builder, int disasmHirRawOffset) { builder.AddOffset(6, disasmHirRawOffset, 0); }
public static void AddDisasmHirOpt(FlatBufferBuilder builder, int disasmHirOptOffset) { builder.AddOffset(7, disasmHirOptOffset, 0); }
public static int EndFunction(FlatBufferBuilder builder) {
int o = builder.EndObject();
return o;

View File

@ -115,7 +115,7 @@ bool X64Assembler::Assemble(FunctionInfo* symbol_info, HIRBuilder* builder,
X64Function* fn = new X64Function(symbol_info);
fn->set_debug_info(std::move(debug_info));
fn->Setup(machine_code, code_size);
fn->Setup(reinterpret_cast<uint8_t*>(machine_code), code_size);
*out_function = fn;

View File

@ -19,15 +19,15 @@ namespace backend {
namespace x64 {
X64Function::X64Function(FunctionInfo* symbol_info)
: Function(symbol_info), machine_code_(nullptr), code_size_(0) {}
: Function(symbol_info), machine_code_(nullptr), machine_code_length_(0) {}
X64Function::~X64Function() {
// machine_code_ is freed by code cache.
}
void X64Function::Setup(void* machine_code, size_t code_size) {
void X64Function::Setup(uint8_t* machine_code, size_t machine_code_length) {
machine_code_ = machine_code;
code_size_ = code_size;
machine_code_length_ = machine_code_length;
}
bool X64Function::AddBreakpointImpl(debug::Breakpoint* breakpoint) {

View File

@ -24,10 +24,10 @@ class X64Function : public Function {
X64Function(FunctionInfo* symbol_info);
virtual ~X64Function();
void* machine_code() const { return machine_code_; }
size_t code_size() const { return code_size_; }
uint8_t* machine_code() const override { return machine_code_; }
size_t machine_code_length() const override { return machine_code_length_; }
void Setup(void* machine_code, size_t code_size);
void Setup(uint8_t* machine_code, size_t machine_code_length);
protected:
virtual bool AddBreakpointImpl(debug::Breakpoint* breakpoint);
@ -35,8 +35,8 @@ class X64Function : public Function {
virtual bool CallImpl(ThreadState* thread_state, uint32_t return_address);
private:
void* machine_code_;
size_t code_size_;
uint8_t* machine_code_;
size_t machine_code_length_;
};
} // namespace x64

View File

@ -37,6 +37,9 @@ class Function {
debug_info_ = std::move(debug_info);
}
virtual uint8_t* machine_code() const = 0;
virtual size_t machine_code_length() const = 0;
bool AddBreakpoint(debug::Breakpoint* breakpoint);
bool RemoveBreakpoint(debug::Breakpoint* breakpoint);

View File

@ -20,6 +20,7 @@
#include "xenia/base/logging.h"
#include "xenia/base/string.h"
#include "xenia/base/threading.h"
#include "xenia/cpu/backend/code_cache.h"
#include "xenia/cpu/function.h"
#include "xenia/cpu/processor.h"
#include "xenia/emulator.h"
@ -211,11 +212,14 @@ void Debugger::OnMessage(std::vector<uint8_t> buffer) {
switch (request->request_data_type()) {
case proto::RequestData_AttachRequest: {
// Send debug info.
auto code_cache = emulator()->processor()->backend()->code_cache();
response_data_type = proto::ResponseData_AttachResponse;
response_data_offset =
proto::CreateAttachResponse(
fbb, fbb.CreateString(
xe::to_string(emulator()->memory()->file_name())),
fbb.CreateString(xe::to_string(code_cache->file_name())),
code_cache->base_address(), code_cache->total_size(),
fbb.CreateString(xe::to_string(functions_path_)),
fbb.CreateString(xe::to_string(functions_trace_path_))).Union();
@ -355,19 +359,19 @@ void Debugger::OnMessage(std::vector<uint8_t> buffer) {
auto function_info =
reinterpret_cast<xe::cpu::FunctionInfo*>(request_data->identifier());
auto function = function_info->function();
if (!function) {
// Attempt to resolve.
emulator_->processor()->ResolveFunction(function_info->address(),
&function);
}
flatbuffers::Offset<flatbuffers::String> name_offset;
if (!function_info->name().empty()) {
name_offset = fbb.CreateString(function_info->name());
}
flatbuffers::Offset<flatbuffers::String> disasm_ppc_offset;
flatbuffers::Offset<flatbuffers::String> disasm_hir_raw_offset;
flatbuffers::Offset<flatbuffers::String> disasm_hir_opt_offset;
flatbuffers::Offset<flatbuffers::String> disasm_machine_code_offset;
if (function && function->debug_info()) {
auto debug_info = function->debug_info();
if (debug_info->source_disasm()) {
disasm_ppc_offset = fbb.CreateString(debug_info->source_disasm());
}
if (debug_info->raw_hir_disasm()) {
disasm_hir_raw_offset =
fbb.CreateString(debug_info->raw_hir_disasm());
@ -375,20 +379,20 @@ void Debugger::OnMessage(std::vector<uint8_t> buffer) {
if (debug_info->hir_disasm()) {
disasm_hir_opt_offset = fbb.CreateString(debug_info->hir_disasm());
}
if (debug_info->machine_code_disasm()) {
disasm_machine_code_offset =
fbb.CreateString(debug_info->machine_code_disasm());
}
}
auto function_data = proto::FunctionBuilder(fbb);
function_data.add_identifier(request_data->identifier());
function_data.add_address_start(function_info->address());
function_data.add_address_end(function_info->end_address());
function_data.add_name(name_offset);
function_data.add_disasm_ppc(disasm_ppc_offset);
if (function) {
function_data.add_machine_code_start(
uint32_t(uintptr_t(function->machine_code())));
function_data.add_machine_code_end(uint32_t(uintptr_t(
function->machine_code() + function->machine_code_length())));
}
function_data.add_disasm_hir_raw(disasm_hir_raw_offset);
function_data.add_disasm_hir_opt(disasm_hir_opt_offset);
function_data.add_disasm_machine_code(disasm_machine_code_offset);
auto function_offset = function_data.Finish();
response_data_type = proto::ResponseData_GetFunctionResponse;
auto response_data = proto::GetFunctionResponseBuilder(fbb);

View File

@ -11,6 +11,9 @@ table AttachRequest {
}
table AttachResponse {
memory_file:string;
code_cache_file:string;
code_cache_base:uint;
code_cache_size:uint;
functions_file:string;
functions_trace_file:string;
}

View File

@ -98,15 +98,7 @@ enum RequestData {
};
inline const char **EnumNamesRequestData() {
static const char *names[] = {
"NONE", "AttachRequest",
"ListBreakpointsRequest", "AddBreakpointsRequest",
"UpdateBreakpointsRequest", "RemoveBreakpointsRequest",
"ListModulesRequest", "GetModuleRequest",
"ListFunctionsRequest", "GetFunctionRequest",
"StopRequest", "BreakRequest",
"ContinueRequest", "StepRequest",
nullptr};
static const char *names[] = { "NONE", "AttachRequest", "ListBreakpointsRequest", "AddBreakpointsRequest", "UpdateBreakpointsRequest", "RemoveBreakpointsRequest", "ListModulesRequest", "GetModuleRequest", "ListFunctionsRequest", "GetFunctionRequest", "StopRequest", "BreakRequest", "ContinueRequest", "StepRequest", nullptr };
return names;
}
@ -134,16 +126,7 @@ enum ResponseData {
};
inline const char **EnumNamesResponseData() {
static const char *names[] = {
"NONE", "AttachResponse",
"ListBreakpointsResponse", "AddBreakpointsResponse",
"UpdateBreakpointsResponse", "RemoveBreakpointsResponse",
"ListModulesResponse", "GetModuleResponse",
"ListFunctionsResponse", "GetFunctionResponse",
"StopResponse", "BreakResponse",
"ContinueResponse", "StepResponse",
"BreakpointEvent", "AccessViolationEvent",
nullptr};
static const char *names[] = { "NONE", "AttachResponse", "ListBreakpointsResponse", "AddBreakpointsResponse", "UpdateBreakpointsResponse", "RemoveBreakpointsResponse", "ListModulesResponse", "GetModuleResponse", "ListFunctionsResponse", "GetFunctionResponse", "StopResponse", "BreakResponse", "ContinueResponse", "StepResponse", "BreakpointEvent", "AccessViolationEvent", nullptr };
return names;
}
@ -176,15 +159,22 @@ inline flatbuffers::Offset<AttachRequest> CreateAttachRequest(flatbuffers::FlatB
struct AttachResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const flatbuffers::String *memory_file() const { return GetPointer<const flatbuffers::String *>(4); }
const flatbuffers::String *functions_file() const { return GetPointer<const flatbuffers::String *>(6); }
const flatbuffers::String *functions_trace_file() const { return GetPointer<const flatbuffers::String *>(8); }
const flatbuffers::String *code_cache_file() const { return GetPointer<const flatbuffers::String *>(6); }
uint32_t code_cache_base() const { return GetField<uint32_t>(8, 0); }
uint32_t code_cache_size() const { return GetField<uint32_t>(10, 0); }
const flatbuffers::String *functions_file() const { return GetPointer<const flatbuffers::String *>(12); }
const flatbuffers::String *functions_trace_file() const { return GetPointer<const flatbuffers::String *>(14); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* memory_file */) &&
verifier.Verify(memory_file()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* functions_file */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* code_cache_file */) &&
verifier.Verify(code_cache_file()) &&
VerifyField<uint32_t>(verifier, 8 /* code_cache_base */) &&
VerifyField<uint32_t>(verifier, 10 /* code_cache_size */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* functions_file */) &&
verifier.Verify(functions_file()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* functions_trace_file */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* functions_trace_file */) &&
verifier.Verify(functions_trace_file()) &&
verifier.EndTable();
}
@ -194,23 +184,32 @@ struct AttachResponseBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_memory_file(flatbuffers::Offset<flatbuffers::String> memory_file) { fbb_.AddOffset(4, memory_file); }
void add_functions_file(flatbuffers::Offset<flatbuffers::String> functions_file) { fbb_.AddOffset(6, functions_file); }
void add_functions_trace_file(flatbuffers::Offset<flatbuffers::String> functions_trace_file) { fbb_.AddOffset(8, functions_trace_file); }
void add_code_cache_file(flatbuffers::Offset<flatbuffers::String> code_cache_file) { fbb_.AddOffset(6, code_cache_file); }
void add_code_cache_base(uint32_t code_cache_base) { fbb_.AddElement<uint32_t>(8, code_cache_base, 0); }
void add_code_cache_size(uint32_t code_cache_size) { fbb_.AddElement<uint32_t>(10, code_cache_size, 0); }
void add_functions_file(flatbuffers::Offset<flatbuffers::String> functions_file) { fbb_.AddOffset(12, functions_file); }
void add_functions_trace_file(flatbuffers::Offset<flatbuffers::String> functions_trace_file) { fbb_.AddOffset(14, functions_trace_file); }
AttachResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
AttachResponseBuilder &operator=(const AttachResponseBuilder &);
flatbuffers::Offset<AttachResponse> Finish() {
auto o = flatbuffers::Offset<AttachResponse>(fbb_.EndTable(start_, 3));
auto o = flatbuffers::Offset<AttachResponse>(fbb_.EndTable(start_, 6));
return o;
}
};
inline flatbuffers::Offset<AttachResponse> CreateAttachResponse(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::String> memory_file = 0,
flatbuffers::Offset<flatbuffers::String> code_cache_file = 0,
uint32_t code_cache_base = 0,
uint32_t code_cache_size = 0,
flatbuffers::Offset<flatbuffers::String> functions_file = 0,
flatbuffers::Offset<flatbuffers::String> functions_trace_file = 0) {
AttachResponseBuilder builder_(_fbb);
builder_.add_functions_trace_file(functions_trace_file);
builder_.add_functions_file(functions_file);
builder_.add_code_cache_size(code_cache_size);
builder_.add_code_cache_base(code_cache_base);
builder_.add_code_cache_file(code_cache_file);
builder_.add_memory_file(memory_file);
return builder_.Finish();
}
@ -303,14 +302,8 @@ inline bool VerifyRequestData(flatbuffers::Verifier &verifier, const void *union
case RequestData_RemoveBreakpointsRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::RemoveBreakpointsRequest *>(union_obj));
case RequestData_ListModulesRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::ListModulesRequest *>(union_obj));
case RequestData_GetModuleRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::GetModuleRequest *>(union_obj));
case RequestData_ListFunctionsRequest:
return verifier.VerifyTable(
reinterpret_cast<const xe::debug::proto::ListFunctionsRequest *>(
union_obj));
case RequestData_GetFunctionRequest:
return verifier.VerifyTable(
reinterpret_cast<const xe::debug::proto::GetFunctionRequest *>(
union_obj));
case RequestData_ListFunctionsRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::ListFunctionsRequest *>(union_obj));
case RequestData_GetFunctionRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::GetFunctionRequest *>(union_obj));
case RequestData_StopRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::StopRequest *>(union_obj));
case RequestData_BreakRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::BreakRequest *>(union_obj));
case RequestData_ContinueRequest: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::ContinueRequest *>(union_obj));
@ -329,14 +322,8 @@ inline bool VerifyResponseData(flatbuffers::Verifier &verifier, const void *unio
case ResponseData_RemoveBreakpointsResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::RemoveBreakpointsResponse *>(union_obj));
case ResponseData_ListModulesResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::ListModulesResponse *>(union_obj));
case ResponseData_GetModuleResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::GetModuleResponse *>(union_obj));
case ResponseData_ListFunctionsResponse:
return verifier.VerifyTable(
reinterpret_cast<const xe::debug::proto::ListFunctionsResponse *>(
union_obj));
case ResponseData_GetFunctionResponse:
return verifier.VerifyTable(
reinterpret_cast<const xe::debug::proto::GetFunctionResponse *>(
union_obj));
case ResponseData_ListFunctionsResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::ListFunctionsResponse *>(union_obj));
case ResponseData_GetFunctionResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::GetFunctionResponse *>(union_obj));
case ResponseData_StopResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::StopResponse *>(union_obj));
case ResponseData_BreakResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::BreakResponse *>(union_obj));
case ResponseData_ContinueResponse: return verifier.VerifyTable(reinterpret_cast<const xe::debug::proto::ContinueResponse *>(union_obj));

View File

@ -45,10 +45,11 @@ table Function {
address_end:uint;
name:string;
disasm_ppc:string;
machine_code_start:uint;
machine_code_end:uint;
disasm_hir_raw:string;
disasm_hir_opt:string;
disasm_machine_code:string;
}
table ListFunctionsRequest {

View File

@ -49,13 +49,10 @@ MANUALLY_ALIGNED_STRUCT(4) ListModuleEntry FLATBUFFERS_FINAL_CLASS {
public:
ListModuleEntry(uint32_t handle, uint32_t function_count)
: handle_(flatbuffers::EndianScalar(handle)),
function_count_(flatbuffers::EndianScalar(function_count)) {}
: handle_(flatbuffers::EndianScalar(handle)), function_count_(flatbuffers::EndianScalar(function_count)) { }
uint32_t handle() const { return flatbuffers::EndianScalar(handle_); }
uint32_t function_count() const {
return flatbuffers::EndianScalar(function_count_);
}
uint32_t function_count() const { return flatbuffers::EndianScalar(function_count_); }
};
STRUCT_END(ListModuleEntry, 8);
@ -128,23 +125,19 @@ inline flatbuffers::Offset<ListModulesRequest> CreateListModulesRequest(flatbuff
}
struct ListModulesResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const flatbuffers::Vector<const ListModuleEntry *> *entry() const {
return GetPointer<const flatbuffers::Vector<const ListModuleEntry *> *>(4);
}
const flatbuffers::Vector<const ListModuleEntry *> *entry() const { return GetPointer<const flatbuffers::Vector<const ListModuleEntry *> *>(4); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* entry */) &&
verifier.Verify(entry()) && verifier.EndTable();
verifier.Verify(entry()) &&
verifier.EndTable();
}
};
struct ListModulesResponseBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_entry(
flatbuffers::Offset<flatbuffers::Vector<const ListModuleEntry *>> entry) {
fbb_.AddOffset(4, entry);
}
void add_entry(flatbuffers::Offset<flatbuffers::Vector<const ListModuleEntry *>> entry) { fbb_.AddOffset(4, entry); }
ListModulesResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ListModulesResponseBuilder &operator=(const ListModulesResponseBuilder &);
flatbuffers::Offset<ListModulesResponse> Finish() {
@ -153,10 +146,8 @@ struct ListModulesResponseBuilder {
}
};
inline flatbuffers::Offset<ListModulesResponse> CreateListModulesResponse(
flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::Vector<const ListModuleEntry *>> entry =
0) {
inline flatbuffers::Offset<ListModulesResponse> CreateListModulesResponse(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::Vector<const ListModuleEntry *>> entry = 0) {
ListModulesResponseBuilder builder_(_fbb);
builder_.add_entry(entry);
return builder_.Finish();
@ -223,37 +214,26 @@ struct FunctionEntry FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
uint64_t identifier() const { return GetField<uint64_t>(4, 0); }
uint32_t address_start() const { return GetField<uint32_t>(6, 0); }
uint32_t address_end() const { return GetField<uint32_t>(8, 0); }
const flatbuffers::String *name() const {
return GetPointer<const flatbuffers::String *>(10);
}
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(10); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<uint64_t>(verifier, 4 /* identifier */) &&
VerifyField<uint32_t>(verifier, 6 /* address_start */) &&
VerifyField<uint32_t>(verifier, 8 /* address_end */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* name */) &&
verifier.Verify(name()) && verifier.EndTable();
verifier.Verify(name()) &&
verifier.EndTable();
}
};
struct FunctionEntryBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_identifier(uint64_t identifier) {
fbb_.AddElement<uint64_t>(4, identifier, 0);
}
void add_address_start(uint32_t address_start) {
fbb_.AddElement<uint32_t>(6, address_start, 0);
}
void add_address_end(uint32_t address_end) {
fbb_.AddElement<uint32_t>(8, address_end, 0);
}
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
fbb_.AddOffset(10, name);
}
FunctionEntryBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
start_ = fbb_.StartTable();
}
void add_identifier(uint64_t identifier) { fbb_.AddElement<uint64_t>(4, identifier, 0); }
void add_address_start(uint32_t address_start) { fbb_.AddElement<uint32_t>(6, address_start, 0); }
void add_address_end(uint32_t address_end) { fbb_.AddElement<uint32_t>(8, address_end, 0); }
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(10, name); }
FunctionEntryBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
FunctionEntryBuilder &operator=(const FunctionEntryBuilder &);
flatbuffers::Offset<FunctionEntry> Finish() {
auto o = flatbuffers::Offset<FunctionEntry>(fbb_.EndTable(start_, 4));
@ -261,9 +241,10 @@ struct FunctionEntryBuilder {
}
};
inline flatbuffers::Offset<FunctionEntry> CreateFunctionEntry(
flatbuffers::FlatBufferBuilder &_fbb, uint64_t identifier = 0,
uint32_t address_start = 0, uint32_t address_end = 0,
inline flatbuffers::Offset<FunctionEntry> CreateFunctionEntry(flatbuffers::FlatBufferBuilder &_fbb,
uint64_t identifier = 0,
uint32_t address_start = 0,
uint32_t address_end = 0,
flatbuffers::Offset<flatbuffers::String> name = 0) {
FunctionEntryBuilder builder_(_fbb);
builder_.add_identifier(identifier);
@ -277,21 +258,11 @@ struct Function FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
uint64_t identifier() const { return GetField<uint64_t>(4, 0); }
uint32_t address_start() const { return GetField<uint32_t>(6, 0); }
uint32_t address_end() const { return GetField<uint32_t>(8, 0); }
const flatbuffers::String *name() const {
return GetPointer<const flatbuffers::String *>(10);
}
const flatbuffers::String *disasm_ppc() const {
return GetPointer<const flatbuffers::String *>(12);
}
const flatbuffers::String *disasm_hir_raw() const {
return GetPointer<const flatbuffers::String *>(14);
}
const flatbuffers::String *disasm_hir_opt() const {
return GetPointer<const flatbuffers::String *>(16);
}
const flatbuffers::String *disasm_machine_code() const {
return GetPointer<const flatbuffers::String *>(18);
}
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(10); }
uint32_t machine_code_start() const { return GetField<uint32_t>(12, 0); }
uint32_t machine_code_end() const { return GetField<uint32_t>(14, 0); }
const flatbuffers::String *disasm_hir_raw() const { return GetPointer<const flatbuffers::String *>(16); }
const flatbuffers::String *disasm_hir_opt() const { return GetPointer<const flatbuffers::String *>(18); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<uint64_t>(verifier, 4 /* identifier */) &&
@ -299,53 +270,28 @@ struct Function FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VerifyField<uint32_t>(verifier, 8 /* address_end */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* name */) &&
verifier.Verify(name()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* disasm_ppc */) &&
verifier.Verify(disasm_ppc()) &&
VerifyField<flatbuffers::uoffset_t>(verifier,
14 /* disasm_hir_raw */) &&
VerifyField<uint32_t>(verifier, 12 /* machine_code_start */) &&
VerifyField<uint32_t>(verifier, 14 /* machine_code_end */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 16 /* disasm_hir_raw */) &&
verifier.Verify(disasm_hir_raw()) &&
VerifyField<flatbuffers::uoffset_t>(verifier,
16 /* disasm_hir_opt */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 18 /* disasm_hir_opt */) &&
verifier.Verify(disasm_hir_opt()) &&
VerifyField<flatbuffers::uoffset_t>(verifier,
18 /* disasm_machine_code */) &&
verifier.Verify(disasm_machine_code()) && verifier.EndTable();
verifier.EndTable();
}
};
struct FunctionBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_identifier(uint64_t identifier) {
fbb_.AddElement<uint64_t>(4, identifier, 0);
}
void add_address_start(uint32_t address_start) {
fbb_.AddElement<uint32_t>(6, address_start, 0);
}
void add_address_end(uint32_t address_end) {
fbb_.AddElement<uint32_t>(8, address_end, 0);
}
void add_name(flatbuffers::Offset<flatbuffers::String> name) {
fbb_.AddOffset(10, name);
}
void add_disasm_ppc(flatbuffers::Offset<flatbuffers::String> disasm_ppc) {
fbb_.AddOffset(12, disasm_ppc);
}
void add_disasm_hir_raw(
flatbuffers::Offset<flatbuffers::String> disasm_hir_raw) {
fbb_.AddOffset(14, disasm_hir_raw);
}
void add_disasm_hir_opt(
flatbuffers::Offset<flatbuffers::String> disasm_hir_opt) {
fbb_.AddOffset(16, disasm_hir_opt);
}
void add_disasm_machine_code(
flatbuffers::Offset<flatbuffers::String> disasm_machine_code) {
fbb_.AddOffset(18, disasm_machine_code);
}
FunctionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
start_ = fbb_.StartTable();
}
void add_identifier(uint64_t identifier) { fbb_.AddElement<uint64_t>(4, identifier, 0); }
void add_address_start(uint32_t address_start) { fbb_.AddElement<uint32_t>(6, address_start, 0); }
void add_address_end(uint32_t address_end) { fbb_.AddElement<uint32_t>(8, address_end, 0); }
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(10, name); }
void add_machine_code_start(uint32_t machine_code_start) { fbb_.AddElement<uint32_t>(12, machine_code_start, 0); }
void add_machine_code_end(uint32_t machine_code_end) { fbb_.AddElement<uint32_t>(14, machine_code_end, 0); }
void add_disasm_hir_raw(flatbuffers::Offset<flatbuffers::String> disasm_hir_raw) { fbb_.AddOffset(16, disasm_hir_raw); }
void add_disasm_hir_opt(flatbuffers::Offset<flatbuffers::String> disasm_hir_opt) { fbb_.AddOffset(18, disasm_hir_opt); }
FunctionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
FunctionBuilder &operator=(const FunctionBuilder &);
flatbuffers::Offset<Function> Finish() {
auto o = flatbuffers::Offset<Function>(fbb_.EndTable(start_, 8));
@ -353,28 +299,28 @@ struct FunctionBuilder {
}
};
inline flatbuffers::Offset<Function> CreateFunction(
flatbuffers::FlatBufferBuilder &_fbb, uint64_t identifier = 0,
uint32_t address_start = 0, uint32_t address_end = 0,
inline flatbuffers::Offset<Function> CreateFunction(flatbuffers::FlatBufferBuilder &_fbb,
uint64_t identifier = 0,
uint32_t address_start = 0,
uint32_t address_end = 0,
flatbuffers::Offset<flatbuffers::String> name = 0,
flatbuffers::Offset<flatbuffers::String> disasm_ppc = 0,
uint32_t machine_code_start = 0,
uint32_t machine_code_end = 0,
flatbuffers::Offset<flatbuffers::String> disasm_hir_raw = 0,
flatbuffers::Offset<flatbuffers::String> disasm_hir_opt = 0,
flatbuffers::Offset<flatbuffers::String> disasm_machine_code = 0) {
flatbuffers::Offset<flatbuffers::String> disasm_hir_opt = 0) {
FunctionBuilder builder_(_fbb);
builder_.add_identifier(identifier);
builder_.add_disasm_machine_code(disasm_machine_code);
builder_.add_disasm_hir_opt(disasm_hir_opt);
builder_.add_disasm_hir_raw(disasm_hir_raw);
builder_.add_disasm_ppc(disasm_ppc);
builder_.add_machine_code_end(machine_code_end);
builder_.add_machine_code_start(machine_code_start);
builder_.add_name(name);
builder_.add_address_end(address_end);
builder_.add_address_start(address_start);
return builder_.Finish();
}
struct ListFunctionsRequest FLATBUFFERS_FINAL_CLASS
: private flatbuffers::Table {
struct ListFunctionsRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
uint32_t module_id() const { return GetField<uint32_t>(4, 0); }
uint32_t function_index_start() const { return GetField<uint32_t>(6, 0); }
uint32_t function_index_end() const { return GetField<uint32_t>(8, 0); }
@ -390,30 +336,21 @@ struct ListFunctionsRequest FLATBUFFERS_FINAL_CLASS
struct ListFunctionsRequestBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_module_id(uint32_t module_id) {
fbb_.AddElement<uint32_t>(4, module_id, 0);
}
void add_function_index_start(uint32_t function_index_start) {
fbb_.AddElement<uint32_t>(6, function_index_start, 0);
}
void add_function_index_end(uint32_t function_index_end) {
fbb_.AddElement<uint32_t>(8, function_index_end, 0);
}
ListFunctionsRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
void add_module_id(uint32_t module_id) { fbb_.AddElement<uint32_t>(4, module_id, 0); }
void add_function_index_start(uint32_t function_index_start) { fbb_.AddElement<uint32_t>(6, function_index_start, 0); }
void add_function_index_end(uint32_t function_index_end) { fbb_.AddElement<uint32_t>(8, function_index_end, 0); }
ListFunctionsRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ListFunctionsRequestBuilder &operator=(const ListFunctionsRequestBuilder &);
flatbuffers::Offset<ListFunctionsRequest> Finish() {
auto o =
flatbuffers::Offset<ListFunctionsRequest>(fbb_.EndTable(start_, 3));
auto o = flatbuffers::Offset<ListFunctionsRequest>(fbb_.EndTable(start_, 3));
return o;
}
};
inline flatbuffers::Offset<ListFunctionsRequest> CreateListFunctionsRequest(
flatbuffers::FlatBufferBuilder &_fbb, uint32_t module_id = 0,
uint32_t function_index_start = 0, uint32_t function_index_end = 0) {
inline flatbuffers::Offset<ListFunctionsRequest> CreateListFunctionsRequest(flatbuffers::FlatBufferBuilder &_fbb,
uint32_t module_id = 0,
uint32_t function_index_start = 0,
uint32_t function_index_end = 0) {
ListFunctionsRequestBuilder builder_(_fbb);
builder_.add_function_index_end(function_index_end);
builder_.add_function_index_start(function_index_start);
@ -421,16 +358,13 @@ inline flatbuffers::Offset<ListFunctionsRequest> CreateListFunctionsRequest(
return builder_.Finish();
}
struct ListFunctionsResponse FLATBUFFERS_FINAL_CLASS
: private flatbuffers::Table {
const flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>> *entry() const {
return GetPointer<
const flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>> *>(4);
}
struct ListFunctionsResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>> *entry() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>> *>(4); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* entry */) &&
verifier.Verify(entry()) && verifier.VerifyVectorOfTables(entry()) &&
verifier.Verify(entry()) &&
verifier.VerifyVectorOfTables(entry()) &&
verifier.EndTable();
}
};
@ -438,26 +372,17 @@ struct ListFunctionsResponse FLATBUFFERS_FINAL_CLASS
struct ListFunctionsResponseBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_entry(flatbuffers::Offset<
flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>>> entry) {
fbb_.AddOffset(4, entry);
}
ListFunctionsResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
void add_entry(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>>> entry) { fbb_.AddOffset(4, entry); }
ListFunctionsResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ListFunctionsResponseBuilder &operator=(const ListFunctionsResponseBuilder &);
flatbuffers::Offset<ListFunctionsResponse> Finish() {
auto o =
flatbuffers::Offset<ListFunctionsResponse>(fbb_.EndTable(start_, 1));
auto o = flatbuffers::Offset<ListFunctionsResponse>(fbb_.EndTable(start_, 1));
return o;
}
};
inline flatbuffers::Offset<ListFunctionsResponse> CreateListFunctionsResponse(
flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>>>
entry = 0) {
inline flatbuffers::Offset<ListFunctionsResponse> CreateListFunctionsResponse(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<FunctionEntry>>> entry = 0) {
ListFunctionsResponseBuilder builder_(_fbb);
builder_.add_entry(entry);
return builder_.Finish();
@ -475,12 +400,8 @@ struct GetFunctionRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
struct GetFunctionRequestBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_identifier(uint64_t identifier) {
fbb_.AddElement<uint64_t>(4, identifier, 0);
}
GetFunctionRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) {
start_ = fbb_.StartTable();
}
void add_identifier(uint64_t identifier) { fbb_.AddElement<uint64_t>(4, identifier, 0); }
GetFunctionRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
GetFunctionRequestBuilder &operator=(const GetFunctionRequestBuilder &);
flatbuffers::Offset<GetFunctionRequest> Finish() {
auto o = flatbuffers::Offset<GetFunctionRequest>(fbb_.EndTable(start_, 1));
@ -488,33 +409,28 @@ struct GetFunctionRequestBuilder {
}
};
inline flatbuffers::Offset<GetFunctionRequest> CreateGetFunctionRequest(
flatbuffers::FlatBufferBuilder &_fbb, uint64_t identifier = 0) {
inline flatbuffers::Offset<GetFunctionRequest> CreateGetFunctionRequest(flatbuffers::FlatBufferBuilder &_fbb,
uint64_t identifier = 0) {
GetFunctionRequestBuilder builder_(_fbb);
builder_.add_identifier(identifier);
return builder_.Finish();
}
struct GetFunctionResponse FLATBUFFERS_FINAL_CLASS
: private flatbuffers::Table {
struct GetFunctionResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
const Function *function() const { return GetPointer<const Function *>(4); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* function */) &&
verifier.VerifyTable(function()) && verifier.EndTable();
verifier.VerifyTable(function()) &&
verifier.EndTable();
}
};
struct GetFunctionResponseBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_function(flatbuffers::Offset<Function> function) {
fbb_.AddOffset(4, function);
}
GetFunctionResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
void add_function(flatbuffers::Offset<Function> function) { fbb_.AddOffset(4, function); }
GetFunctionResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
GetFunctionResponseBuilder &operator=(const GetFunctionResponseBuilder &);
flatbuffers::Offset<GetFunctionResponse> Finish() {
auto o = flatbuffers::Offset<GetFunctionResponse>(fbb_.EndTable(start_, 1));
@ -522,8 +438,7 @@ struct GetFunctionResponseBuilder {
}
};
inline flatbuffers::Offset<GetFunctionResponse> CreateGetFunctionResponse(
flatbuffers::FlatBufferBuilder &_fbb,
inline flatbuffers::Offset<GetFunctionResponse> CreateGetFunctionResponse(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<Function> function = 0) {
GetFunctionResponseBuilder builder_(_fbb);
builder_.add_function(function);