-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[eventpipe] Use MonoImage:module_name when filename is NULL #73018
[eventpipe] Use MonoImage:module_name when filename is NULL #73018
Conversation
…is null When assemblies are bundled (for example in WASM), the filename field is set to NULL and the name field is set to the basename of the assembly.
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsWhen assemblies are bundled (for example in WASM), the filename field is set to NULL and the name field is set to the basename of the assembly. Contributes to #72481 With this PR and with #72859 I can generate a trace and run
and generate a .mibc file.
|
Sample PerfTrace line for a ModuleLoad event:
without this PR, the ModuleILPath was And here's a
|
src/mono/mono/eventpipe/ep-rt-mono.c
Outdated
@@ -3784,7 +3784,7 @@ get_module_event_data ( | |||
if (image && image->aot_module) | |||
module_data->module_flags |= MODULE_FLAGS_NATIVE_MODULE; | |||
|
|||
module_data->module_il_path = image && image->filename ? image->filename : ""; | |||
module_data->module_il_path = image && image->filename ? image->filename : (image && image->name ? image->name : ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, in what case would we get module_il_path = ""
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. good point. image->name
is always non-null. If it's not set explicitly (for example when doing Aseembly.Load(byte[])
it's set to "data-%p"
. @lateralusX is it better to have ""
or some arbitrary made-up name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, this value can be used by tooling to locate and potentially load the module. if we have "" I guess there is bigger chance that the tool will understand that its missing, compared to having some made up value that it probably will try to use and fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what CoreCLR does:
// if we do not have a module path yet, we put the module name
if(bIsDynamicAssembly || ModuleILPath==NULL || wcslen(ModuleILPath) <= 2)
{
moduleName.SetUTF8(pModule->GetSimpleName());
ModuleILPath = (PWCHAR)moduleName.GetUnicode();
ModuleNativePath = (PWCHAR)pEmptyString;
}
So they assume they always have a valid module name or it will end up with an empty string (SString moduleName = SString::Empty();
).
So if we should have same behavior in case we have missing module name it should revert to "".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, changed it to use the module name if available and fall back to ""
4fcc7f5
to
6e145cc
Compare
module name comes from the metadata Module table and is something like "Foo.dll" even if the assembly is loaded from a bundle or from Assembly.Load(byte[]), whereas image->name might be "data-0x00abcdef" for byte loads
6e145cc
to
2009c30
Compare
I guess the title should be Use MonoImage:filename ? |
8c6d99c
to
2009c30
Compare
(accidentally pushed unrelated work to this PR; reverted back to reviewed version) |
No pipelines are associated with this pull request. |
When assemblies are bundled (for example in WASM), the filename field is set to NULL; use the module name (from the metadata Module table).
Contributes to #72481
With this PR and with #72859 I can generate a trace and run
and generate a .mibc file.