Skip to content

Add constructor for schema from EVENT_RECORD and PTRACE_EVENT_INFO - #265

Merged
Matt Swann (swannman) merged 4 commits into
microsoft:masterfrom
wwh1004:scheme-ctor
Dec 2, 2025
Merged

Add constructor for schema from EVENT_RECORD and PTRACE_EVENT_INFO#265
Matt Swann (swannman) merged 4 commits into
microsoft:masterfrom
wwh1004:scheme-ctor

Conversation

@wwh1004

Copy link
Copy Markdown
Contributor

A custom TRACE_EVENT_INFO can be provided as fallback. See #249

// Hardcoded profile schema used as fallback
static uint8_t kHardcodedSampledProfileSchema[] = {
    0xad, 0x4a, 0x81, 0x9e, 0x04, 0x32, 0xd2, 0x11, 0x9a, 0x82, 0x00, 0x60,
    0x08, 0xa8, 0x69, 0x39, 0xb4, 0xbf, 0x1d, 0xce, 0x7e, 0x13, 0xa6, 0x4d,
    0x87, 0xb0, 0x3f, 0x59, 0xaa, 0x10, 0x2c, 0xbc, 0x00, 0x00, 0x02, 0x00,
    0x00, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x01, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x04,
    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x01, 0x00, 0x00,
    0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00,
    0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x52, 0x01, 0x00, 0x00,
    0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5e, 0x01, 0x00, 0x00,
    0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x53, 0x00, 0x4e, 0x00, 0x54, 0x00,
    0x5f, 0x00, 0x53, 0x00, 0x79, 0x00, 0x73, 0x00, 0x74, 0x00, 0x65, 0x00,
    0x6d, 0x00, 0x54, 0x00, 0x72, 0x00, 0x61, 0x00, 0x63, 0x00, 0x65, 0x00,
    0x00, 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x66, 0x00, 0x49, 0x00,
    0x6e, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x53, 0x00, 0x61, 0x00,
    0x6d, 0x00, 0x70, 0x00, 0x6c, 0x00, 0x65, 0x00, 0x50, 0x00, 0x72, 0x00,
    0x6f, 0x00, 0x66, 0x00, 0x00, 0x00, 0x49, 0x00, 0x6e, 0x00, 0x73, 0x00,
    0x74, 0x00, 0x72, 0x00, 0x75, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00,
    0x6f, 0x00, 0x6e, 0x00, 0x50, 0x00, 0x6f, 0x00, 0x69, 0x00, 0x6e, 0x00,
    0x74, 0x00, 0x65, 0x00, 0x72, 0x00, 0x00, 0x00, 0x54, 0x00, 0x68, 0x00,
    0x72, 0x00, 0x65, 0x00, 0x61, 0x00, 0x64, 0x00, 0x49, 0x00, 0x64, 0x00,
    0x00, 0x00, 0x43, 0x00, 0x6f, 0x00, 0x75, 0x00, 0x6e, 0x00, 0x74, 0x00,
    0x00, 0x00, 0x52, 0x00, 0x65, 0x00, 0x73, 0x00, 0x65, 0x00, 0x72, 0x00,
    0x76, 0x00, 0x65, 0x00, 0x64, 0x00, 0x00, 0x00,
};

{
    TDHSTATUS status = ERROR_SUCCESS;
    auto buffer =
        trace_context.schema_locator.get_event_schema_no_throw(record, status);
    if (buffer == nullptr) {
      buffer = (PTRACE_EVENT_INFO)kHardcodedSampledProfileSchema;
    }
    krabs::schema schema(record, buffer);
    krabs::parser parser(schema);
}

@swannman Matt Swann (swannman) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Would you mind bumping the version numbers in the three .nuspec files so we can publish updates after merging your PR?

@wwh1004

Copy link
Copy Markdown
Contributor Author

No problem.

@swannman

Copy link
Copy Markdown
Member

wwh1004 (@wwh1004) quick reminder to bump the nuspec versions so we can merge your PR. Thanks!

@swannman Matt Swann (swannman) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, thank you!

@swannman
Matt Swann (swannman) merged commit 1b26db4 into microsoft:master Dec 2, 2025
2 checks passed
@wwh1004
wwh1004 (wwh1004) deleted the scheme-ctor branch December 2, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants