Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling support for scopes in methods in the debugger #732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions mono/mini/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -10026,21 +10026,24 @@ static void GetSequencePointsAndSourceFilesUniqueSequencePoints(MonoMethod* meth
}
}

static const Il2CppMethodExecutionContextInfoC* GetExecutionContextInfo(MonoMethod* method, uint32_t* count)
static void GetExecutionContextAndHeaderInfo(MonoMethod* method, uint32_t* executionContextInfoCount, const Il2CppMethodExecutionContextInfoC **executionContextInfo, const Il2CppMethodHeaderInfoC **headerInfo)
{
void *seqPointIter = NULL;
Il2CppSequencePointC *seqPoint;
while (seqPoint = il2cpp_get_method_sequence_points(method, &seqPointIter))
{
if (il2cpp_mono_methods_match(seqPoint->method, method))
{
*count = seqPoint->executionContextInfoCount;
return seqPoint->executionContextInfos;
*executionContextInfoCount = seqPoint->executionContextInfoCount;
*executionContextInfo = seqPoint->executionContextInfos;
*headerInfo = seqPoint->header;
return;
}
}

g_assert(FALSE); // shouldn't be ever reached
}

#endif // IL2CPP_MONO_DEBUGGER

static ErrorCode
Expand Down Expand Up @@ -10281,10 +10284,25 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
g_free (locals_map);
#else
uint32_t executionInfoCount, localVariableCount = 0, i;
const Il2CppMethodExecutionContextInfoC* executionContextInfo = GetExecutionContextInfo(method, &executionInfoCount);
const Il2CppMethodExecutionContextInfoC* executionContextInfo;
const Il2CppMethodHeaderInfoC* headerInfo;

GetExecutionContextAndHeaderInfo(method, &executionInfoCount, &executionContextInfo, &headerInfo);

if (CHECK_PROTOCOL_VERSION(2, 43)) {
buffer_add_int(buf, 0);
if (headerInfo)
{
buffer_add_int(buf, headerInfo->numScopes);
for (i = 0; i < headerInfo->numScopes; ++i)
{
buffer_add_int(buf, headerInfo->scopes[i].startOffset);
buffer_add_int(buf, headerInfo->scopes[i].endOffset);
}
}
else
{
buffer_add_int(buf, 0);
}
}

for (i = 0; i < executionInfoCount; i++)
Expand All @@ -10307,10 +10325,12 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g
buffer_add_string(buf, executionContextInfo[i].name);
}

for (i = 0; i < localVariableCount; i++)
for (i = 0; i < executionInfoCount; i++)
{
buffer_add_int(buf, 0);
buffer_add_int(buf, 0);
if (executionContextInfo[i].variableKind == kMethodVariableKindC_LocalVariable) {
buffer_add_int(buf, executionContextInfo[i].start);
buffer_add_int(buf, executionContextInfo[i].end);
}
}
#endif // !IL2CPP_MONO_DEBUGGER
break;
Expand Down
16 changes: 16 additions & 0 deletions mono/mini/il2cpp-c-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,28 @@ typedef struct
const Il2CppMonoType* const* const type;
const char* const name;
const MethodVariableKindC variableKind;
const int start;
const int end;
} Il2CppMethodExecutionContextInfoC;

typedef struct
{
int startOffset;
int endOffset;
} Il2CppMethodScopeC;

typedef struct
{
int codeSize;
int numScopes;
Il2CppMethodScopeC *scopes;
} Il2CppMethodHeaderInfoC;

typedef struct
{
const Il2CppMethodExecutionContextInfoC* const executionContextInfos;
const uint32_t executionContextInfoCount;
const Il2CppMethodHeaderInfoC *header;
const Il2CppMonoMethod* method;
const char* const sourceFile;
const uint8_t sourceFileHash[16];
Expand Down