Пример #1
0
 private static void clearLTTngTraceHandle(ref LTTngTraceHandle handle)
 {
     handle.id            = -1;
     handle.ctx           = IntPtr.Zero;
     handle.ctf_iter      = IntPtr.Zero;
     handle.last_iter_pos = IntPtr.Zero;
 }
Пример #2
0
 public static extern LttngReaderStatusCode set_start_end_time(ref LTTngTraceHandle handle, ulong start_time_epoch, ulong end_time_epoch);
Пример #3
0
 public static extern LttngReaderStatusCode read_next_event(ref LTTngTraceHandle trace_handle, ref EventRecord evDesc, StringBuilder unstructured_event_text, [MarshalAs(UnmanagedType.LPStr)] StringBuilder taskname_eventname, ref ulong timestamp_unix_epoch_nano_s, ref bool is_unstructured);
Пример #4
0
 public static extern LttngReaderStatusCode finalize_trace_processing(ref LTTngTraceHandle trace_handle);
Пример #5
0
 public static extern LttngReaderStatusCode initialize_trace_processing(StringBuilder trace_file_folder_path, ulong start_time_epoch_ns, ulong end_time_epoch_ns, out LTTngTraceHandle trace_handle);
Пример #6
0
        private LttngReaderStatusCode ProcessTrace(DateTime startTime, DateTime endTime, ref LTTngTraceHandle traceHandle, out ulong eventReadFailureCount)
        {
            EventRecord eventRecord       = new EventRecord();
            ulong       lastReadTimestamp = 0;

            // needed for processing unstructured events in Linux
            bool          isUnstructured     = false;
            StringBuilder unstructuredRecord = new StringBuilder(LttngReaderBindings.MAX_LTTNG_UNSTRUCTURED_EVENT_LEN + 1);
            StringBuilder taskNameEventName  = new StringBuilder(LttngReaderBindings.MAX_LTTNG_TASK_EVENT_NAME_LEN + 1);

            ulong startTimeEpochNanoS = LttngTraceFolderEventReader.ConvertToUnixEpoch(startTime);
            ulong endTimeEpochNanoS   = LttngTraceFolderEventReader.ConvertToUnixEpoch(endTime);

            // set start and end time for reading traces
            LttngReaderStatusCode res = LttngReaderBindings.set_start_end_time(ref traceHandle, startTimeEpochNanoS, endTimeEpochNanoS);

            eventReadFailureCount = 0;

            if (res != LttngReaderStatusCode.SUCCESS)
            {
                return(res);
            }

            res = LttngReaderBindings.read_next_event(ref traceHandle, ref eventRecord, unstructuredRecord, taskNameEventName, ref lastReadTimestamp, ref isUnstructured);

            while (res == LttngReaderStatusCode.SUCCESS || res == LttngReaderStatusCode.FAILED_TO_READ_EVENT)
            {
                if (res == LttngReaderStatusCode.FAILED_TO_READ_EVENT)
                {
                    eventReadFailureCount++;
                    continue;
                }

                EventRecordEventArgs eventRecordEventArgs;
                this.lastEventReadTimestamp = lastReadTimestamp;

                if (isUnstructured)
                {
                    try
                    {
                        eventRecord.EventHeader.TimeStamp = LttngTraceFolderEventReader.ConvertFromUnixEpoch(lastReadTimestamp).ToFileTimeUtc();
                    }
                    catch (Exception)
                    {
                        // Flagging error with minimum timestamp so we can continue processing other events.
                        eventRecord.EventHeader.TimeStamp = 0;
                    }

                    eventRecordEventArgs = new EventRecordEventArgs(eventRecord);

                    eventRecordEventArgs.IsUnstructured     = isUnstructured;
                    eventRecordEventArgs.TaskNameEventName  = taskNameEventName.ToString();
                    eventRecordEventArgs.UnstructuredRecord = unstructuredRecord.ToString();
                }
                else
                {
                    eventRecordEventArgs = new EventRecordEventArgs(eventRecord);
                }

                this.EventRead(this, eventRecordEventArgs);

                if (eventRecordEventArgs.Cancel)
                {
                    return(LttngReaderStatusCode.SUCCESS);
                }

                res = LttngReaderBindings.read_next_event(ref traceHandle, ref eventRecord, unstructuredRecord, taskNameEventName, ref lastReadTimestamp, ref isUnstructured);
            }

            return(res);
        }