Bug 1686229 - Part2. Add the loadStatus field to the third-party-modules ping. r=chutten
authorToshihito Kikuchi <tkikuchi@mozilla.com>
Sat, 23 Jan 2021 00:14:13 +0000
changeset 564376 2635f936fdeb0cc866a4f5fc1c83d23e83dc169b
parent 564375 7709195b22a91a068b41b8ae8bd6dff2db56453c
child 564377 172ac9e345fb37d3c7211f02c77e3ecdaf62e560
push id134820
push userabutkovits@mozilla.com
push dateSat, 23 Jan 2021 00:29:32 +0000
treeherderautoland@172ac9e345fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1686229
milestone86.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1686229 - Part2. Add the loadStatus field to the third-party-modules ping. r=chutten This patch adds a new field "loadStatus" to the third-party-modules ping, which derives from `ProcessedModuleLoadEvent::mLoadStatus` introduced by the earlier patch. Differential Revision: https://phabricator.services.mozilla.com/D102408
toolkit/components/telemetry/docs/data/third-party-modules-ping.rst
toolkit/components/telemetry/other/UntrustedModulesDataSerializer.cpp
toolkit/components/telemetry/tests/unit/test_ThirdPartyModulesPing.js
toolkit/xre/test/gtest/TestUntrustedModules.cpp
--- a/toolkit/components/telemetry/docs/data/third-party-modules-ping.rst
+++ b/toolkit/components/telemetry/docs/data/third-party-modules-ping.rst
@@ -54,17 +54,19 @@ were loaded into Firefox processes.
                 "threadName": <string>,
                 // The sanitized name of the module that was requested by the invoking code. Only exists when it is different from resolvedDllName.
                 "requestedDllName": <string>,
                 // The base address to which the loader mapped the module.
                 "baseAddress": <string formatted as "0x%x">,
                 // Index of the element in the modules array that contains details about the module that was loaded during this event.
                 "moduleIndex": <int>,
                 // True if the module is included in the executable's Import Directory Table.
-                "isDependent": <bool>
+                "isDependent": <bool>,
+                // The status of DLL load. This corresponds to enum ModuleLoadInfo::Status.
+                "loadStatus": <int>
               },
               ... Additional events (maximum 50)
             ],
             "combinedStacks": [
               "memoryMap": [
                 [
                   // Name of the module symbol file, e.g. ``xul.pdb``
                   <string>,
--- a/toolkit/components/telemetry/other/UntrustedModulesDataSerializer.cpp
+++ b/toolkit/components/telemetry/other/UntrustedModulesDataSerializer.cpp
@@ -292,16 +292,23 @@ bool UntrustedModulesDataSerializer::Ser
 
   JS::RootedValue jsIsDependent(aCx);
   jsIsDependent.setBoolean(aEvent.mIsDependent);
   if (!JS_DefineProperty(aCx, obj, "isDependent", jsIsDependent,
                          JSPROP_ENUMERATE)) {
     return false;
   }
 
+  JS::RootedValue jsLoadStatus(aCx);
+  jsLoadStatus.setNumber(aEvent.mLoadStatus);
+  if (!JS_DefineProperty(aCx, obj, "loadStatus", jsLoadStatus,
+                         JSPROP_ENUMERATE)) {
+    return false;
+  }
+
   aElement.setObject(*obj);
 
   return true;
 }
 
 static nsDependentCString GetProcessTypeString(GeckoProcessType aType) {
   nsDependentCString strProcType;
   if (aType == GeckoProcessType_Default) {
--- a/toolkit/components/telemetry/tests/unit/test_ThirdPartyModulesPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_ThirdPartyModulesPing.js
@@ -127,16 +127,19 @@ add_task(async function test_send_ping()
     Assert.ok(typeof event.baseAddress == "string", "'baseAddress' exists");
 
     Assert.ok(typeof event.moduleIndex == "number", "'moduleIndex' exists");
     Assert.ok(event.moduleIndex >= 0, "'moduleIndex' is non-negative");
 
     Assert.ok(typeof event.isDependent == "boolean", "'isDependent' exists");
     Assert.ok(!event.isDependent, "'isDependent' is false");
 
+    Assert.ok(typeof event.loadStatus == "number", "'loadStatus' exists");
+    Assert.ok(event.loadStatus == 0, "'loadStatus' is 0 (Loaded)");
+
     let modRecord = found.payload.modules[event.moduleIndex];
     Assert.ok(modRecord, "module record for this event exists");
     Assert.ok(
       typeof modRecord.resolvedDllName == "string",
       "'resolvedDllName' exists"
     );
     Assert.ok(typeof modRecord.trustFlags == "number", "'trustFlags' exists");
 
--- a/toolkit/xre/test/gtest/TestUntrustedModules.cpp
+++ b/toolkit/xre/test/gtest/TestUntrustedModules.cpp
@@ -144,16 +144,17 @@ static void ValidateUntrustedModules(con
     moduleSet.PutEntry(module);
   }
 
   for (const auto& evt : aData.mEvents) {
     EXPECT_EQ(evt.mThreadId, ::GetCurrentThreadId());
     // Make sure mModule is pointing to an entry of mModules.
     EXPECT_TRUE(moduleSet.Contains(evt.mModule));
     EXPECT_FALSE(evt.mIsDependent);
+    EXPECT_EQ(evt.mLoadStatus, 0);
   }
 
   // No check for the mXULLoadDurationMS field because the field has a value
   // in CCov build GTest, but it is empty in non-CCov build (bug 1681936).
   EXPECT_GT(aData.mEvents.length(), 0);
   EXPECT_GT(aData.mStacks.GetModuleCount(), 0);
   EXPECT_EQ(aData.mSanitizationFailures, 0);
   EXPECT_EQ(aData.mTrustTestFailures, 0);
@@ -308,17 +309,17 @@ BOOL CALLBACK UntrustedModulesFixture::I
 #define PROCESS_OBJ(TYPE, PID) \
   u"\"" TYPE u"\\." PID u"\":{" \
     u"\"processType\":\"" TYPE u"\",\"elapsed\":\\d+\\.\\d+," \
     u"\"sanitizationFailures\":0,\"trustTestFailures\":0," \
     u"\"events\":\\[{" \
       u"\"processUptimeMS\":\\d+,\"loadDurationMS\":\\d+\\.\\d+," \
       u"\"threadID\":\\d+,\"threadName\":\"Main Thread\"," \
       u"\"baseAddress\":\"0x[0-9a-f]+\",\"moduleIndex\":0," \
-      u"\"isDependent\":false}\\]," \
+      u"\"isDependent\":false,\"loadStatus\":0}\\]," \
     u"\"combinedStacks\":{" \
       u"\"memoryMap\":\\[\\[\"\\w+\\.\\w+\",\"[0-9A-Z]+\"\\]" \
         u"(,\\[\"\\w+\\.\\w+\",\"[0-9A-Z]+\\\"\\])*\\]," \
       u"\"stacks\":\\[\\[\\[\\d+,\\d+\\]" \
         u"(,\\[\\d+,\\d+\\])*\\]\\]}}"
 
 TEST_F(UntrustedModulesFixture, Serialize) {
   // clang-format off