Skip to content

Commit abaf6f4

Browse files
authored
backport of 75432 (#75460)
1 parent 3fbdf4c commit abaf6f4

File tree

12 files changed

+183
-36
lines changed

12 files changed

+183
-36
lines changed

src/mono/mono/component/hot_reload.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,13 @@ apply_enclog_pass2 (Pass2Context *ctx, MonoImage *image_base, BaselineInfo *base
21182118
if (func_code == ENC_FUNC_ADD_PARAM)
21192119
break;
21202120

2121+
if (!base_info->method_table_update)
2122+
base_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal);
2123+
if (!delta_info->method_table_update)
2124+
delta_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal);
2125+
if (!delta_info->method_ppdb_table_update)
2126+
delta_info->method_ppdb_table_update = g_hash_table_new (g_direct_hash, g_direct_equal);
2127+
21212128
if (is_addition) {
21222129
g_assertf (add_member_typedef, "EnC: new method added but I don't know the class, should be caught by pass1");
21232130
if (pass2_context_is_skeleton (ctx, add_member_typedef)) {
@@ -2139,14 +2146,6 @@ apply_enclog_pass2 (Pass2Context *ctx, MonoImage *image_base, BaselineInfo *base
21392146
add_member_typedef = 0;
21402147
}
21412148

2142-
if (!base_info->method_table_update)
2143-
base_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal);
2144-
if (!delta_info->method_table_update)
2145-
delta_info->method_table_update = g_hash_table_new (g_direct_hash, g_direct_equal);
2146-
if (!delta_info->method_ppdb_table_update)
2147-
2148-
delta_info->method_ppdb_table_update = g_hash_table_new (g_direct_hash, g_direct_equal);
2149-
21502149
int mapped_token = hot_reload_relative_delta_index (image_dmeta, delta_info, mono_metadata_make_token (token_table, token_index));
21512150
guint32 rva = mono_metadata_decode_row_col (&image_dmeta->tables [MONO_TABLE_METHOD], mapped_token - 1, MONO_METHOD_RVA);
21522151
if (rva < dil_length) {

src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ private void PopulateEnC(MetadataReader asmMetadataReaderParm, MetadataReader pd
996996
{
997997
var document = pdbMetadataReaderParm.GetDocument(methodDebugInformation.Document);
998998
var documentName = pdbMetadataReaderParm.GetString(document.Name);
999-
source = GetOrAddSourceFile(methodDebugInformation.Document, asmMetadataReaderParm.GetRowNumber(methodDebugInformation.Document), documentName);
999+
source = GetOrAddSourceFile(methodDebugInformation.Document, documentName);
10001000
}
10011001
var methodInfo = new MethodInfo(this, MetadataTokens.MethodDefinitionHandle(methodIdxAsm), entryRow, source, typeInfo, asmMetadataReaderParm, pdbMetadataReaderParm);
10021002
methods[entryRow] = methodInfo;
@@ -1019,13 +1019,13 @@ private void PopulateEnC(MetadataReader asmMetadataReaderParm, MetadataReader pd
10191019
}
10201020
}
10211021
}
1022-
private SourceFile GetOrAddSourceFile(DocumentHandle doc, int rowid, string documentName)
1022+
private SourceFile GetOrAddSourceFile(DocumentHandle doc, string documentName)
10231023
{
1024-
if (_documentIdToSourceFileTable.TryGetValue(rowid, out SourceFile source))
1024+
if (_documentIdToSourceFileTable.TryGetValue(documentName.GetHashCode(), out SourceFile source))
10251025
return source;
10261026

10271027
var src = new SourceFile(this, _documentIdToSourceFileTable.Count, doc, GetSourceLinkUrl(documentName), documentName);
1028-
_documentIdToSourceFileTable[rowid] = src;
1028+
_documentIdToSourceFileTable[documentName.GetHashCode()] = src;
10291029
return src;
10301030
}
10311031

@@ -1055,7 +1055,7 @@ private void Populate()
10551055
{
10561056
var document = pdbMetadataReader.GetDocument(methodDebugInformation.Document);
10571057
var documentName = pdbMetadataReader.GetString(document.Name);
1058-
source = GetOrAddSourceFile(methodDebugInformation.Document, asmMetadataReader.GetRowNumber(methodDebugInformation.Document), documentName);
1058+
source = GetOrAddSourceFile(methodDebugInformation.Document, documentName);
10591059
}
10601060
}
10611061
var methodInfo = new MethodInfo(this, method, asmMetadataReader.GetRowNumber(method), source, typeInfo, asmMetadataReader, pdbMetadataReader);

src/mono/wasm/debugger/BrowserDebugProxy/MonoProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ private async Task<bool> SendBreakpointsOfMethodUpdated(SessionId sessionId, Exe
871871
{
872872
var methodId = retDebuggerCmdReader.ReadInt32();
873873
var method = await context.SdbAgent.GetMethodInfo(methodId, token);
874-
if (method == null)
874+
if (method == null || method.Info.Source is null)
875875
{
876876
return true;
877877
}

src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestBase.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ internal async Task<JObject> LoadAssemblyDynamicallyALCAndRunMethod(string asm_f
13221322
return await WaitFor(Inspector.PAUSE);
13231323
}
13241324

1325-
internal async Task<JObject> LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges(string asm_file, string pdb_file, string class_name, string method_name, bool expectBpResolvedEvent)
1325+
internal async Task<JObject> LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges(string asm_file, string pdb_file, string class_name, string method_name, bool expectBpResolvedEvent, params string[] sourcesToWait)
13261326
{
13271327
byte[] bytes = File.ReadAllBytes(asm_file);
13281328
string asm_base64 = Convert.ToBase64String(bytes);
@@ -1338,7 +1338,7 @@ internal async Task<JObject> LoadAssemblyAndTestHotReloadUsingSDBWithoutChanges(
13381338

13391339
Task eventTask = expectBpResolvedEvent
13401340
? WaitForBreakpointResolvedEvent()
1341-
: WaitForScriptParsedEventsAsync("MethodBody0.cs", "MethodBody1.cs");
1341+
: WaitForScriptParsedEventsAsync(sourcesToWait);
13421342
(await cli.SendCommand("Runtime.evaluate", load_assemblies, token)).AssertOk();
13431343
await eventTask;
13441344

@@ -1397,7 +1397,7 @@ internal async Task<JObject> LoadAssemblyAndTestHotReloadUsingSDB(string asm_fil
13971397
return await WaitFor(Inspector.PAUSE);
13981398
}
13991399

1400-
internal async Task<JObject> LoadAssemblyAndTestHotReload(string asm_file, string pdb_file, string asm_file_hot_reload, string class_name, string method_name, bool expectBpResolvedEvent)
1400+
internal async Task<JObject> LoadAssemblyAndTestHotReload(string asm_file, string pdb_file, string asm_file_hot_reload, string class_name, string method_name, bool expectBpResolvedEvent, string[] sourcesToWait, string methodName2 = "", string methodName3 = "")
14011401
{
14021402
byte[] bytes = File.ReadAllBytes(asm_file);
14031403
string asm_base64 = Convert.ToBase64String(bytes);
@@ -1434,13 +1434,18 @@ internal async Task<JObject> LoadAssemblyAndTestHotReload(string asm_file, strin
14341434

14351435
Task eventTask = expectBpResolvedEvent
14361436
? WaitForBreakpointResolvedEvent()
1437-
: WaitForScriptParsedEventsAsync("MethodBody0.cs", "MethodBody1.cs");
1437+
: WaitForScriptParsedEventsAsync(sourcesToWait);
14381438
(await cli.SendCommand("Runtime.evaluate", load_assemblies, token)).AssertOk();
14391439
await eventTask;
14401440

1441+
if (methodName2 == "")
1442+
methodName2 = method_name;
1443+
if (methodName3 == "")
1444+
methodName3 = method_name;
1445+
14411446
var run_method = JObject.FromObject(new
14421447
{
1443-
expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] TestHotReload:RunMethod', '" + class_name + "', '" + method_name + "'); }, 1);"
1448+
expression = "window.setTimeout(function() { invoke_static_method('[debugger-test] TestHotReload:RunMethod', '" + class_name + "', '" + method_name + "', '" + methodName2 + "', '" + methodName3 + "'); }, 1);"
14441449
});
14451450

14461451
await cli.SendCommand("Runtime.evaluate", run_method, token);

0 commit comments

Comments
 (0)