33
44using System ;
55using System . Collections . Generic ;
6+ using System . Text . RegularExpressions ;
67using CtfPlayback ;
78using CtfPlayback . FieldValues ;
89using LTTngCds . CookerData ;
@@ -45,13 +46,24 @@ public override int GetHashCode()
4546
4647 public string Domain { get ; }
4748 public uint Id { get ; }
49+ public string ProviderName { get ; }
4850 public string EventName { get ; }
4951 public readonly List < string > FieldNames ;
50- public EventKind ( string domain , uint id , string name , IReadOnlyList < CtfFieldValue > fields )
52+ public EventKind ( LTTngContext context , uint id , string name , IReadOnlyList < CtfFieldValue > fields )
5153 {
52- this . Domain = domain ;
54+ this . Domain = context . Domain ;
5355 this . Id = id ;
54- this . EventName = name ;
56+ Match traceLoggingMatch = TraceLoggingEventRegex . Match ( name ) ;
57+ if ( traceLoggingMatch . Success )
58+ {
59+ this . ProviderName = context . Intern ( traceLoggingMatch . Groups [ "ProviderName" ] . Value ) ;
60+ this . EventName = context . Intern ( traceLoggingMatch . Groups [ "EventName" ] . Value ) ;
61+ }
62+ else
63+ {
64+ this . ProviderName = "Unknown" ;
65+ this . EventName = context . Intern ( name ) ;
66+ }
5567 this . FieldNames = new List < string > ( fields . Count ) ;
5668 foreach ( var field in fields )
5769 {
@@ -60,16 +72,17 @@ public EventKind(string domain, uint id, string name, IReadOnlyList<CtfFieldValu
6072 }
6173
6274 private static readonly Dictionary < Key , EventKind > RegisteredKinds = new Dictionary < Key , EventKind > ( ) ;
75+ private static readonly Regex TraceLoggingEventRegex = new Regex ( "^(?<ProviderName>[a-zA-Z_.0-9]+):(?<EventName>[a-zA-Z_.0-9]+);(?<Unknown>.+);$" ) ;
6376
6477 public static bool TryGetRegisteredKind ( string domain , uint id , out EventKind kind )
6578 {
6679 return RegisteredKinds . TryGetValue ( new Key ( domain , id ) , out kind ) ;
6780 }
6881
69- public static EventKind RegisterKind ( string domain , uint id , string name , IReadOnlyList < CtfFieldValue > fields )
82+ public static EventKind RegisterKind ( LTTngContext context , uint id , string name , IReadOnlyList < CtfFieldValue > fields )
7083 {
71- EventKind kind = new EventKind ( domain , id , name , fields ) ;
72- RegisteredKinds . Add ( new Key ( domain , id ) , kind ) ;
84+ EventKind kind = new EventKind ( context , id , name , fields ) ;
85+ RegisteredKinds . Add ( new Key ( context . Domain , id ) , kind ) ;
7386 return kind ;
7487 }
7588 }
@@ -92,7 +105,7 @@ public LTTngGenericEvent(LTTngEvent data, LTTngContext context)
92105
93106 if ( ! EventKind . TryGetRegisteredKind ( context . Domain , data . Id , out this . kind ) )
94107 {
95- this . kind = EventKind . RegisterKind ( context . Domain , data . Id , data . Name , payload . Fields ) ;
108+ this . kind = EventKind . RegisterKind ( context , data . Id , data . Name , payload . Fields ) ;
96109 }
97110
98111 // As this is being written, all columns are of type 'T', so all rows are the same. For generic events,
@@ -129,6 +142,8 @@ public LTTngGenericEvent(LTTngEvent data, LTTngContext context)
129142 }
130143 }
131144
145+ public string ProviderName => this . kind . ProviderName ;
146+
132147 public string EventName => this . kind . EventName ;
133148
134149 public Timestamp Timestamp { get ; }
0 commit comments