(module: WebAssembly.Module)
| 14 | * @param module |
| 15 | */ |
| 16 | export function getModuleInfo(module: WebAssembly.Module): ModuleInfo { |
| 17 | const buildIds = WebAssembly.Module.customSections(module, 'build_id'); |
| 18 | let buildId = null; |
| 19 | let debugFile = null; |
| 20 | |
| 21 | const buildId0 = buildIds[0]; |
| 22 | if (buildId0) { |
| 23 | const firstBuildId = new Uint8Array(buildId0); |
| 24 | buildId = Array.from(firstBuildId).reduce((acc, x) => { |
| 25 | return acc + x.toString(16).padStart(2, '0'); |
| 26 | }, ''); |
| 27 | } |
| 28 | |
| 29 | const externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info'); |
| 30 | const externalDebugInfo0 = externalDebugInfo[0]; |
| 31 | if (externalDebugInfo0) { |
| 32 | const firstExternalDebugInfo = new Uint8Array(externalDebugInfo0); |
| 33 | const decoder = new TextDecoder('utf-8'); |
| 34 | debugFile = decoder.decode(firstExternalDebugInfo); |
| 35 | } |
| 36 | |
| 37 | return { buildId, debugFile }; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Records a module and returns the created debug image. |
no test coverage detected