* [wasm-ep] Trim trailing nul when parsing IPC command strings
The protocol spec says there's a length and a nul terminator, but sending that literal UTF-16 nul to ep_enable_2 means we use an incorrect name when looking for the provider.
* [wasm-ep] Fix formating of event pipe provider strings
convert the 64-bit "keywords" mask into a hex string properly by padding both halves with zeroes after calling the JS Number.toString() method
* use Array splice instead of String substring
* Address review feedback
</PropertyGroup>
<PropertyGroup>
- <MonoDiagnosticsMock Condition="'$(MonoDiagnosticsMock)' == ''">false</MonoDiagnosticsMock>
+ <MonoDiagnosticsMock Condition="('$(MonoDiagnosticsMock)' == '') and ('$(Configuration)' == 'Debug')">true</MonoDiagnosticsMock>
</PropertyGroup>
<ItemGroup>
result[i] = (buf[j + 2 * i + 1] << 8) | buf[j + 2 * i];
}
advancePos(pos, length * 2);
+
+ /* Trim trailing nul character(s) that are added by the protocol */
+ let trailingNulStart = -1;
+ for (let i = result.length - 1; i >= 0; i--) {
+ if (result[i] === 0) {
+ trailingNulStart = i;
+ } else {
+ break;
+ }
+ }
+ if (trailingNulStart >= 0)
+ result.splice(trailingNulStart);
+
return String.fromCharCode.apply(null, result);
}
};
function keywordsToHexString(k: [number, number]): string {
const lo = k[0];
const hi = k[1];
- const lo_hex = lo.toString(16);
- const hi_hex = hi.toString(16);
+ const lo_hex = leftPad(lo.toString(16), "0", 8);
+ const hi_hex = leftPad(hi.toString(16), "0", 8);
return hi_hex + lo_hex;
}
+
+ function leftPad(s: string, fill: string, width: number): string {
+ if (s.length >= width)
+ return s;
+ const prefix = fill.repeat(width - s.length);
+ return prefix + s;
+ }
}