summaryrefslogtreecommitdiffstats
path: root/source/slang-record-replay/record/slang-global-session.cpp
blob: eff9cf0ab69a3fcb3ff204c355abf3bcae18d244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
#include "slang-global-session.h"

#include "../../slang/slang-compiler.h"
#include "../util/record-utility.h"
#include "slang-filesystem.h"
#include "slang-session.h"

namespace SlangRecord
{
// constructor is called in slang_createGlobalSession
GlobalSessionRecorder::GlobalSessionRecorder(
    const SlangGlobalSessionDesc* desc,
    slang::IGlobalSession* session)
    : m_actualGlobalSession(session)
{
    SLANG_RECORD_ASSERT(m_actualGlobalSession != nullptr);

    m_globalSessionHandle =
        reinterpret_cast<SlangRecord::AddressFormat>(m_actualGlobalSession.get());
    m_recordManager = new RecordManager(m_globalSessionHandle);

    // We will use the address of the global session as the filename for the record manager
    // to make it unique for each global session.
    // record slang::createGlobalSession

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::CreateGlobalSession,
            g_globalFunctionHandle);
        recorder->recordStruct(*desc);
        recorder = m_recordManager->endMethodRecord();
    }

    recorder->recordAddress(m_actualGlobalSession);
    m_recordManager->apendOutput();
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::queryInterface(SlangUUID const& uuid, void** outObject)
{
    if (uuid == Session::getTypeGuid())
    {
        // no add-ref here, the query will cause the inner session to handle the add-ref.
        this->m_actualGlobalSession->queryInterface(uuid, outObject);
        return SLANG_OK;
    }

    if (uuid == ISlangUnknown::getTypeGuid() && uuid == IGlobalSession::getTypeGuid())
    {
        addReference();
        *outObject = static_cast<slang::IGlobalSession*>(this);
        return SLANG_OK;
    }

    return SLANG_E_NO_INTERFACE;
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::createSession(slang::SessionDesc const& desc, slang::ISession** outSession)
{
    setLogLevel();
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    slang::ISession* actualSession = nullptr;

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_createSession,
            m_globalSessionHandle);
        recorder->recordStruct(desc);
        recorder = m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->createSession(desc, &actualSession);

    { // record output
        recorder->recordAddress(actualSession);
        m_recordManager->apendOutput();
    }

    if (actualSession != nullptr)
    {
        // reset the file system to our record file system. After createSession() call,
        // the Linkage will set to user provided file system or slang default file system.
        // We need to reset it to our record file system
        Slang::Linkage* linkage = static_cast<Linkage*>(actualSession);
        FileSystemRecorder* fileSystemRecord =
            new FileSystemRecorder(linkage->getFileSystemExt(), m_recordManager.get());

        Slang::ComPtr<FileSystemRecorder> resultFileSystemRecorder(fileSystemRecord);
        linkage->setFileSystem(resultFileSystemRecorder.detach());

        SessionRecorder* sessionRecord = new SessionRecorder(actualSession, m_recordManager.get());
        Slang::ComPtr<SessionRecorder> result(sessionRecord);
        *outSession = result.detach();
    }

    return res;
}

SLANG_NO_THROW SlangProfileID SLANG_MCALL GlobalSessionRecorder::findProfile(char const* name)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_findProfile,
            m_globalSessionHandle);
        recorder->recordString(name);
        recorder = m_recordManager->endMethodRecord();
    }

    SlangProfileID profileId = m_actualGlobalSession->findProfile(name);
    return profileId;
}

SLANG_NO_THROW void SLANG_MCALL
GlobalSessionRecorder::setDownstreamCompilerPath(SlangPassThrough passThrough, char const* path)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_setDownstreamCompilerPath,
            m_globalSessionHandle);
        recorder->recordEnumValue(passThrough);
        recorder->recordString(path);
        m_recordManager->endMethodRecord();
    }

    m_actualGlobalSession->setDownstreamCompilerPath(passThrough, path);
}

SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setDownstreamCompilerPrelude(
    SlangPassThrough inPassThrough,
    char const* prelude)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_setDownstreamCompilerPrelude,
            m_globalSessionHandle);
        recorder->recordEnumValue(inPassThrough);
        recorder->recordString(prelude);
        m_recordManager->endMethodRecord();
    }

    m_actualGlobalSession->setDownstreamCompilerPrelude(inPassThrough, prelude);
}

SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::getDownstreamCompilerPrelude(
    SlangPassThrough inPassThrough,
    ISlangBlob** outPrelude)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_getDownstreamCompilerPrelude,
            m_globalSessionHandle);
        recorder->recordEnumValue(inPassThrough);
        recorder = m_recordManager->endMethodRecord();
    }

    m_actualGlobalSession->getDownstreamCompilerPrelude(inPassThrough, outPrelude);

    {
        recorder->recordAddress(*outPrelude);
        m_recordManager->apendOutput();
    }
}

SLANG_NO_THROW const char* SLANG_MCALL GlobalSessionRecorder::getBuildTagString()
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    // No need to record this function. It's just a query function and it won't impact the internal
    // state.
    const char* resStr = m_actualGlobalSession->getBuildTagString();
    return resStr;
}

SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::setDefaultDownstreamCompiler(
    SlangSourceLanguage sourceLanguage,
    SlangPassThrough defaultCompiler)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_setDefaultDownstreamCompiler,
            m_globalSessionHandle);
        recorder->recordEnumValue(sourceLanguage);
        recorder->recordEnumValue(defaultCompiler);
        recorder = m_recordManager->endMethodRecord();
    }

    SlangResult res =
        m_actualGlobalSession->setDefaultDownstreamCompiler(sourceLanguage, defaultCompiler);
    return res;
}

SLANG_NO_THROW SlangPassThrough SLANG_MCALL
GlobalSessionRecorder::getDefaultDownstreamCompiler(SlangSourceLanguage sourceLanguage)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_getDefaultDownstreamCompiler,
            m_globalSessionHandle);
        recorder->recordEnumValue(sourceLanguage);
        recorder = m_recordManager->endMethodRecord();
    }

    SlangPassThrough passThrough =
        m_actualGlobalSession->getDefaultDownstreamCompiler(sourceLanguage);
    return passThrough;
}

SLANG_NO_THROW void SLANG_MCALL
GlobalSessionRecorder::setLanguagePrelude(SlangSourceLanguage inSourceLanguage, char const* prelude)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_setLanguagePrelude,
            m_globalSessionHandle);
        recorder->recordEnumValue(inSourceLanguage);
        recorder->recordString(prelude);
        recorder = m_recordManager->endMethodRecord();
    }

    m_actualGlobalSession->setLanguagePrelude(inSourceLanguage, prelude);
}

SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::getLanguagePrelude(
    SlangSourceLanguage inSourceLanguage,
    ISlangBlob** outPrelude)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_getLanguagePrelude,
            m_globalSessionHandle);
        recorder->recordEnumValue(inSourceLanguage);
        recorder = m_recordManager->endMethodRecord();
    }

    m_actualGlobalSession->getLanguagePrelude(inSourceLanguage, outPrelude);

    {
        recorder->recordAddress(*outPrelude);
        m_recordManager->apendOutput();
    }
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::createCompileRequest(slang::ICompileRequest** outCompileRequest)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_createCompileRequest,
            m_globalSessionHandle);
        recorder = m_recordManager->endMethodRecord();
    }

    SLANG_ALLOW_DEPRECATED_BEGIN
    SlangResult res = m_actualGlobalSession->createCompileRequest(outCompileRequest);
    SLANG_ALLOW_DEPRECATED_END

    {
        recorder->recordAddress(*outCompileRequest);
        m_recordManager->apendOutput();
    }

    return res;
}

SLANG_NO_THROW void SLANG_MCALL
GlobalSessionRecorder::addBuiltins(char const* sourcePath, char const* sourceString)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_addBuiltins,
            m_globalSessionHandle);
        recorder->recordString(sourcePath);
        recorder->recordString(sourceString);
        recorder = m_recordManager->endMethodRecord();
    }

    m_actualGlobalSession->addBuiltins(sourcePath, sourceString);
}

SLANG_NO_THROW void SLANG_MCALL
GlobalSessionRecorder::setSharedLibraryLoader(ISlangSharedLibraryLoader* loader)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
    // TODO: Not sure if we need to record this function. Because this functions is something like
    // the file system override, it's provided by user code. So capturing it makes no sense. The
    // only way is to wrapper this interface by our own implementation, and record it there.
    m_actualGlobalSession->setSharedLibraryLoader(loader);
}

SLANG_NO_THROW ISlangSharedLibraryLoader* SLANG_MCALL
GlobalSessionRecorder::getSharedLibraryLoader()
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_getSharedLibraryLoader,
            m_globalSessionHandle);
        recorder = m_recordManager->endMethodRecord();
    }

    ISlangSharedLibraryLoader* loader = m_actualGlobalSession->getSharedLibraryLoader();

    {
        recorder->recordAddress(loader);
        m_recordManager->apendOutput();
    }
    return loader;
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::checkCompileTargetSupport(SlangCompileTarget target)
{
    // No need to record this function. It's just a query function and it won't impact the internal
    // state.
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
    SlangResult res = m_actualGlobalSession->checkCompileTargetSupport(target);
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::checkPassThroughSupport(SlangPassThrough passThrough)
{
    // No need to record this function. It's just a query function and it won't impact the internal
    // state.
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
    SlangResult res = m_actualGlobalSession->checkPassThroughSupport(passThrough);
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::compileCoreModule(slang::CompileCoreModuleFlags flags)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_compileCoreModule,
            m_globalSessionHandle);
        recorder->recordEnumValue(flags);
        m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->compileCoreModule(flags);
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::loadCoreModule(const void* coreModule, size_t coreModuleSizeInBytes)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_loadCoreModule,
            m_globalSessionHandle);
        recorder->recordPointer(coreModule, false, coreModuleSizeInBytes);
        m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->loadCoreModule(coreModule, coreModuleSizeInBytes);
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::saveCoreModule(SlangArchiveType archiveType, ISlangBlob** outBlob)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_saveCoreModule,
            m_globalSessionHandle);
        recorder->recordEnumValue(archiveType);
        recorder = m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->saveCoreModule(archiveType, outBlob);

    {
        recorder->recordAddress(*outBlob);
        m_recordManager->apendOutput();
    }
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::compileBuiltinModule(
    slang::BuiltinModuleName module,
    slang::CompileCoreModuleFlags flags)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_compileBuiltinModule,
            m_globalSessionHandle);
        recorder->recordEnumValue(module);
        recorder->recordEnumValue(flags);
        m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->compileBuiltinModule(module, flags);
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::loadBuiltinModule(
    slang::BuiltinModuleName module,
    const void* moduleData,
    size_t sizeInBytes)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_loadBuiltinModule,
            m_globalSessionHandle);
        recorder->recordEnumValue(module);
        recorder->recordPointer(moduleData, false, sizeInBytes);
        m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->loadBuiltinModule(module, moduleData, sizeInBytes);
    return res;
}
SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::saveBuiltinModule(
    slang::BuiltinModuleName module,
    SlangArchiveType archiveType,
    ISlangBlob** outBlob)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_saveBuiltinModule,
            m_globalSessionHandle);
        recorder->recordEnumValue(module);
        recorder->recordEnumValue(archiveType);
        recorder = m_recordManager->endMethodRecord();
    }
    SlangResult res = m_actualGlobalSession->saveBuiltinModule(module, archiveType, outBlob);
    {
        recorder->recordAddress(*outBlob);
        m_recordManager->apendOutput();
    }
    return res;
}

SLANG_NO_THROW SlangCapabilityID SLANG_MCALL GlobalSessionRecorder::findCapability(char const* name)
{
    // No need to record this function. It's just a query function and it won't impact the internal
    // state.
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
    SlangCapabilityID capId = m_actualGlobalSession->findCapability(name);
    return capId;
}

SLANG_NO_THROW void SLANG_MCALL GlobalSessionRecorder::setDownstreamCompilerForTransition(
    SlangCompileTarget source,
    SlangCompileTarget target,
    SlangPassThrough compiler)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_setDownstreamCompilerForTransition,
            m_globalSessionHandle);
        recorder->recordEnumValue(source);
        recorder->recordEnumValue(target);
        recorder->recordEnumValue(compiler);
        m_recordManager->endMethodRecord();
    }

    m_actualGlobalSession->setDownstreamCompilerForTransition(source, target, compiler);
}

SLANG_NO_THROW SlangPassThrough SLANG_MCALL
GlobalSessionRecorder::getDownstreamCompilerForTransition(
    SlangCompileTarget source,
    SlangCompileTarget target)
{
    // No need to record this function. It's just a query function and it won't impact the internal
    // state.
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
    SlangPassThrough passThrough =
        m_actualGlobalSession->getDownstreamCompilerForTransition(source, target);
    return passThrough;
}

SLANG_NO_THROW void SLANG_MCALL
GlobalSessionRecorder::getCompilerElapsedTime(double* outTotalTime, double* outDownstreamTime)
{
    // No need to record this function. It's just a query function and it won't impact the internal
    // state.
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);
    m_actualGlobalSession->getCompilerElapsedTime(outTotalTime, outDownstreamTime);
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::setSPIRVCoreGrammar(char const* jsonPath)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_setSPIRVCoreGrammar,
            m_globalSessionHandle);
        recorder->recordString(jsonPath);
        m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->setSPIRVCoreGrammar(jsonPath);
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL GlobalSessionRecorder::parseCommandLineArguments(
    int argc,
    const char* const* argv,
    slang::SessionDesc* outSessionDesc,
    ISlangUnknown** outAllocation)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_parseCommandLineArguments,
            m_globalSessionHandle);
        recorder->recordInt32(argc);
        recorder->recordStringArray(argv, argc);
        recorder = m_recordManager->endMethodRecord();
    }

    SlangResult res =
        m_actualGlobalSession->parseCommandLineArguments(argc, argv, outSessionDesc, outAllocation);

    {
        recorder->recordAddress(outSessionDesc);
        recorder->recordAddress(*outAllocation);
        m_recordManager->apendOutput();
    }
    return res;
}

SLANG_NO_THROW SlangResult SLANG_MCALL
GlobalSessionRecorder::getSessionDescDigest(slang::SessionDesc* sessionDesc, ISlangBlob** outBlob)
{
    slangRecordLog(LogLevel::Verbose, "%p: %s\n", m_actualGlobalSession.get(), __PRETTY_FUNCTION__);

    ParameterRecorder* recorder{};
    {
        recorder = m_recordManager->beginMethodRecord(
            ApiCallId::IGlobalSession_getSessionDescDigest,
            m_globalSessionHandle);
        recorder->recordStruct(*sessionDesc);
        recorder = m_recordManager->endMethodRecord();
    }

    SlangResult res = m_actualGlobalSession->getSessionDescDigest(sessionDesc, outBlob);

    {
        recorder->recordAddress(*outBlob);
        m_recordManager->apendOutput();
    }
    return res;
}
} // namespace SlangRecord