Support TraceLogging formatting hints#2443
Open
chwarr wants to merge 1 commit into
Open
Conversation
Trace Data Helper lets you add display hints to fields in events. For example, there are hints to indicate that an integer value should hex formatted on display or that the value is a HRESULT. The commonly used [C++ TraceLogging library][0] supports these hints via its [TraceLogging Wrapper macros][1]. Add support for pretty printing the following _TDH_OUT_TYPE values: * TDH_OUTTYPE_HEXINT8 - hex, width of the underlying type * TDH_OUTTYPE_HEXINT16 - hex, width of the underlying type * TDH_OUTTYPE_HEXINT32 - hex, width of the underlying type * TDH_OUTTYPE_HEXINT64 - hex, width of the underlying type * TDH_OUTTYPE_PID - decimal number without digit seperators * TDH_OUTTYPE_TID - decimal number without digit seperators * TDH_OUTTYPE_PORT - decimal number without digit seperators, converted from network byte order * TDH_OUTTYPE_IPV4 - dotted quad * TDH_OUTTYPE_IPV6 - colon-seperated, elision of runs of zeros * TDH_OUTTYPE_SOCKETADDRESS - "address:port" for AF_INET and AF_INET6 * TDH_OUTTYPE_ERRORCODE - hex, no padding * TDH_OUTTYPE_WIN32ERROR - hex, no padding * TDH_OUTTYPE_NTSTATUS - hex, always 8 digits wide * TDH_OUTTYPE_HRESULT - hex, always 8 digits wide * TDH_OUTTYPE_CODE_POINTER - lowercase hex, minimum of 8 digits wide Fixes microsoft#2436. Given TraceLogging code like this: ``` TraceLoggingWrite( g_hMyProvider, "MyEvent", TraceLoggingUInt32(value1ToLog), TraceLoggingHexUInt32(value2ToLog)); ``` In PerfView today, this would be rendered as ``` value1ToLog="1" value2ToLog="32,769" ``` Now, it is rendered as ``` value1ToLog="1" value2ToLog="0x00008001" ``` For things like flags these format hints can make it easier to read values at a glance. There are also common values that are represented in hex, like PCI IDs. When PerfView already had support for formatting a value, its existing formating style was followed. Otherwise, I matched WPA's formatting. Changes made: * Changed TraceEvent's representation of the output type from a ushort to the new TdhOutputType enum. * Add TdhFormtter.cs that knows how to format a value with a given formatting hint. A formatting hint was chosen so that the PayloadFetch object didn't need to remember both its TdhInputType and its TdhOutputType. * Reved the FastSerializable format to include the new formatting hint. * Introduced a new FormatUtils helper for shared formatting code between TraceEvent.cs and DynamicTraceEventParser.cs * Unit tests for the new formatting logic added. * Updated the baseline files to capture the changes in formatting. [0]: https://learn.microsoft.com/windows/win32/tracelogging/trace-logging-portal [1]: https://learn.microsoft.com/windows/win32/tracelogging/tracelogging-wrapper-macros
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trace Data Helper lets you add display hints to fields in events. For example, there are hints to indicate that an integer value should hex formatted on display or that the value is a HRESULT. The commonly used C++ TraceLogging library supports these hints via its TraceLogging Wrapper macros.
Add support for pretty printing the following _TDH_OUT_TYPE values:
Fixes #2436.
Given TraceLogging code like this:
In PerfView today, this would be rendered as
Now, it is rendered as
Visually, before:
and after:
For things like flags these format hints can make it easier to read values at a glance. There are also common values that are represented in hex, like PCI IDs.
When PerfView already had support for formatting a value, its existing formating style was followed. Otherwise, I matched WPA's formatting.
Changes made: