Partial thread data plumbing.

This commit is contained in:
Ben Vanik
2015-06-16 21:53:40 -07:00
parent aae45515ae
commit b750370759
13 changed files with 288 additions and 31 deletions

View File

@@ -312,6 +312,7 @@ namespace Xenia.Debug {
private async Task CompleteRunStateTransition(RunState newRunState) {
await Task.WhenAll(new Task[] {
ModuleList.Invalidate(),
ThreadList.Invalidate(),
});
CurrentContext.SetRunState(newRunState);

View File

@@ -10,8 +10,21 @@ public sealed class ListThreadsResponse : Table {
public static ListThreadsResponse GetRootAsListThreadsResponse(ByteBuffer _bb, ListThreadsResponse obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
public ListThreadsResponse __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
public Thread GetThread(int j) { return GetThread(new Thread(), j); }
public Thread GetThread(Thread obj, int j) { int o = __offset(4); return o != 0 ? obj.__init(__indirect(__vector(o) + j * 4), bb) : null; }
public int ThreadLength { get { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } }
public static void StartListThreadsResponse(FlatBufferBuilder builder) { builder.StartObject(0); }
public static int CreateListThreadsResponse(FlatBufferBuilder builder,
int thread = 0) {
builder.StartObject(1);
ListThreadsResponse.AddThread(builder, thread);
return ListThreadsResponse.EndListThreadsResponse(builder);
}
public static void StartListThreadsResponse(FlatBufferBuilder builder) { builder.StartObject(1); }
public static void AddThread(FlatBufferBuilder builder, int threadOffset) { builder.AddOffset(0, threadOffset, 0); }
public static int CreateThreadVector(FlatBufferBuilder builder, int[] data) { builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddOffset(data[i]); return builder.EndVector(); }
public static void StartThreadVector(FlatBufferBuilder builder, int numElems) { builder.StartVector(4, numElems, 4); }
public static int EndListThreadsResponse(FlatBufferBuilder builder) {
int o = builder.EndObject();
return o;

View File

@@ -15,10 +15,11 @@ public enum RequestData : byte
GetModuleRequest = 7,
ListFunctionsRequest = 8,
GetFunctionRequest = 9,
StopRequest = 10,
BreakRequest = 11,
ContinueRequest = 12,
StepRequest = 13,
ListThreadsRequest = 10,
StopRequest = 11,
BreakRequest = 12,
ContinueRequest = 13,
StepRequest = 14,
};

View File

@@ -15,12 +15,13 @@ public enum ResponseData : byte
GetModuleResponse = 7,
ListFunctionsResponse = 8,
GetFunctionResponse = 9,
StopResponse = 10,
BreakResponse = 11,
ContinueResponse = 12,
StepResponse = 13,
BreakpointEvent = 14,
AccessViolationEvent = 15,
ListThreadsResponse = 10,
StopResponse = 11,
BreakResponse = 12,
ContinueResponse = 13,
StepResponse = 14,
BreakpointEvent = 15,
AccessViolationEvent = 16,
};

View File

@@ -13,10 +13,36 @@ public sealed class Thread : Table {
public XObject Object { get { return GetObject(new XObject()); } }
public XObject GetObject(XObject obj) { int o = __offset(4); return o != 0 ? obj.__init(o + bb_pos, bb) : null; }
public ThreadType Type { get { int o = __offset(6); return o != 0 ? (ThreadType)bb.GetSbyte(o + bb_pos) : (ThreadType)0; } }
public uint StackSize { get { int o = __offset(8); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint XapiThreadStartup { get { int o = __offset(10); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint StartAddress { get { int o = __offset(12); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint StartContext { get { int o = __offset(14); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint CreationFlags { get { int o = __offset(16); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint TlsAddress { get { int o = __offset(18); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint PcrAddress { get { int o = __offset(20); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint ThreadStateAddress { get { int o = __offset(22); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint ThreadId { get { int o = __offset(24); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public string Name { get { int o = __offset(26); return o != 0 ? __string(o + bb_pos) : null; } }
public uint Priority { get { int o = __offset(28); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint Affinity { get { int o = __offset(30); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public uint State { get { int o = __offset(32); return o != 0 ? bb.GetUint(o + bb_pos) : (uint)0; } }
public static void StartThread(FlatBufferBuilder builder) { builder.StartObject(2); }
public static void StartThread(FlatBufferBuilder builder) { builder.StartObject(15); }
public static void AddObject(FlatBufferBuilder builder, int objectOffset) { builder.AddStruct(0, objectOffset, 0); }
public static void AddType(FlatBufferBuilder builder, ThreadType type) { builder.AddSbyte(1, (sbyte)(type), 0); }
public static void AddStackSize(FlatBufferBuilder builder, uint stackSize) { builder.AddUint(2, stackSize, 0); }
public static void AddXapiThreadStartup(FlatBufferBuilder builder, uint xapiThreadStartup) { builder.AddUint(3, xapiThreadStartup, 0); }
public static void AddStartAddress(FlatBufferBuilder builder, uint startAddress) { builder.AddUint(4, startAddress, 0); }
public static void AddStartContext(FlatBufferBuilder builder, uint startContext) { builder.AddUint(5, startContext, 0); }
public static void AddCreationFlags(FlatBufferBuilder builder, uint creationFlags) { builder.AddUint(6, creationFlags, 0); }
public static void AddTlsAddress(FlatBufferBuilder builder, uint tlsAddress) { builder.AddUint(7, tlsAddress, 0); }
public static void AddPcrAddress(FlatBufferBuilder builder, uint pcrAddress) { builder.AddUint(8, pcrAddress, 0); }
public static void AddThreadStateAddress(FlatBufferBuilder builder, uint threadStateAddress) { builder.AddUint(9, threadStateAddress, 0); }
public static void AddThreadId(FlatBufferBuilder builder, uint threadId) { builder.AddUint(10, threadId, 0); }
public static void AddName(FlatBufferBuilder builder, int nameOffset) { builder.AddOffset(11, nameOffset, 0); }
public static void AddPriority(FlatBufferBuilder builder, uint priority) { builder.AddUint(12, priority, 0); }
public static void AddAffinity(FlatBufferBuilder builder, uint affinity) { builder.AddUint(13, affinity, 0); }
public static void AddState(FlatBufferBuilder builder, uint state) { builder.AddUint(14, state, 0); }
public static int EndThread(FlatBufferBuilder builder) {
int o = builder.EndObject();
return o;

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using xe.debug.proto;
using Xenia.Debug.Utilities;
namespace Xenia.Debug {
@@ -25,6 +26,23 @@ namespace Xenia.Debug {
this.debugger = debugger;
}
public async Task Invalidate() {
var fbb = debugger.BeginRequest();
ListThreadsRequest.StartListThreadsRequest(fbb);
int requestDataOffset = ListThreadsRequest.EndListThreadsRequest(fbb);
var response = await debugger.CommitRequest(
fbb, RequestData.ListThreadsRequest, requestDataOffset);
ListThreadsResponse responseData = new ListThreadsResponse();
response.GetResponseData(responseData);
for (int i = 0; i < responseData.ThreadLength; ++i) {
var threadData = responseData.GetThread(i);
// threadData.Name;
}
OnChanged();
}
public int Count {
get {
return threads.Count;