Skip to content

Commit 54f941e

Browse files
authored
Merge pull request #482 from mstange/push-knuzkyssulpx
Copy etw-reader into the samply package
2 parents a1b1eec + d0197dd commit 54f941e

22 files changed

+3563
-270
lines changed

Cargo.lock

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

etw-reader/src/etw_types.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Deref for EventRecord {
2222

2323
impl EventRecord {
2424
pub(crate) fn user_buffer(&self) -> &[u8] {
25-
if self.UserData == std::ptr::null_mut() {
25+
if self.UserData.is_null() {
2626
return &[];
2727
}
2828
unsafe { std::slice::from_raw_parts(self.UserData as *mut _, self.UserDataLength.into()) }
@@ -71,21 +71,21 @@ pub const EVENT_HEADER_FLAG_32_BIT_HEADER: u16 = Etw::EVENT_HEADER_FLAG_32_BIT_H
7171
/// [DECODING_SOURCE]: https://microsoft.github.io/windows-docs-rs/doc/bindings/Windows/Win32/Etw/struct.DECODING_SOURCE.html
7272
#[derive(Debug)]
7373
pub enum DecodingSource {
74-
DecodingSourceXMLFile,
75-
DecodingSourceWbem,
76-
DecodingSourceWPP,
77-
DecodingSourceTlg,
78-
DecodingSourceMax,
74+
XMLFile,
75+
Wbem,
76+
Wpp,
77+
Tlg,
78+
Max,
7979
}
8080

8181
impl From<Etw::DECODING_SOURCE> for DecodingSource {
8282
fn from(val: Etw::DECODING_SOURCE) -> Self {
8383
match val {
84-
Etw::DecodingSourceXMLFile => DecodingSource::DecodingSourceXMLFile,
85-
Etw::DecodingSourceWbem => DecodingSource::DecodingSourceWbem,
86-
Etw::DecodingSourceWPP => DecodingSource::DecodingSourceWPP,
87-
Etw::DecodingSourceTlg => DecodingSource::DecodingSourceTlg,
88-
_ => DecodingSource::DecodingSourceMax,
84+
Etw::DecodingSourceXMLFile => DecodingSource::XMLFile,
85+
Etw::DecodingSourceWbem => DecodingSource::Wbem,
86+
Etw::DecodingSourceWPP => DecodingSource::Wpp,
87+
Etw::DecodingSourceTlg => DecodingSource::Tlg,
88+
_ => DecodingSource::Max,
8989
}
9090
}
9191
}

etw-reader/src/lib.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,23 @@
1+
use fxhash::FxHasher;
2+
use memoffset::offset_of;
3+
pub use windows::core::GUID;
14
use windows::core::{h, HSTRING, PWSTR};
25
use windows::Win32::Foundation::{
36
GetLastError, ERROR_INSUFFICIENT_BUFFER, ERROR_MORE_DATA, MAX_PATH,
47
};
8+
use windows::Win32::System::Diagnostics::Etw;
59
use windows::Win32::System::Diagnostics::Etw::{
610
EnumerateTraceGuids, EnumerateTraceGuidsEx, TraceGuidQueryInfo, TraceGuidQueryList,
711
CONTROLTRACE_HANDLE, EVENT_TRACE_FLAG, TRACE_GUID_INFO, TRACE_GUID_PROPERTIES,
812
TRACE_PROVIDER_INSTANCE_INFO,
913
};
1014

11-
use crate::parser::{Parser, ParserError, TryParse};
12-
use crate::schema::SchemaLocator;
13-
use crate::tdh_types::{PrimitiveDesc, PropertyDesc, TdhInType};
14-
use crate::traits::EncodeUtf16;
15-
16-
#[macro_use]
17-
extern crate memoffset;
18-
1915
use std::borrow::Cow;
2016
use std::collections::HashMap;
2117
use std::hash::BuildHasherDefault;
2218
use std::mem;
2319
use std::path::Path;
2420

25-
use etw_types::EventRecord;
26-
use fxhash::FxHasher;
27-
use tdh_types::{Property, TdhOutType};
28-
use windows::Win32::System::Diagnostics::Etw;
29-
3021
// typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE;
3122
pub(crate) type TraceHandle = u64;
3223
pub const INVALID_TRACE_HANDLE: TraceHandle = u64::MAX;
@@ -46,7 +37,12 @@ pub mod utils;
4637
//pub mod trace;
4738
//pub mod provider;
4839

49-
pub use windows::core::GUID;
40+
use etw_types::EventRecord;
41+
use parser::{Parser, ParserError, TryParse};
42+
use schema::SchemaLocator;
43+
use tdh_types::{PrimitiveDesc, PropertyDesc, TdhInType};
44+
use tdh_types::{Property, TdhOutType};
45+
use traits::EncodeUtf16;
5046

5147
pub type FastHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
5248
#[repr(C)]

etw-reader/src/parser.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ impl<'a> Parser<'a> {
179179
// as the size of AppName
180180

181181
// Fallback to Tdh
182-
return Ok(
183-
tdh::property_size(self.event.record(), &property.name).unwrap() as usize,
184-
);
182+
Ok(tdh::property_size(self.event.record(), &property.name).unwrap() as usize)
185183
}
186184
PropertyLength::Length(length) => {
187185
// TODO: Study heuristic method used in krabsetw :)
@@ -222,9 +220,7 @@ impl<'a> Parser<'a> {
222220
}
223221
}
224222
}
225-
return Ok(
226-
tdh::property_size(self.event.record(), &property.name).unwrap() as usize,
227-
);
223+
Ok(tdh::property_size(self.event.record(), &property.name).unwrap() as usize)
228224
}
229225
}
230226
}

etw-reader/src/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,12 @@ impl<'a> TypedEvent<'a> {
466466
}
467467
}
468468

469-
impl<'a> PartialEq for TypedEvent<'a> {
469+
impl PartialEq for TypedEvent<'_> {
470470
fn eq(&self, other: &Self) -> bool {
471471
self.schema.event_schema.event_id() == other.schema.event_schema.event_id()
472472
&& self.schema.event_schema.provider_guid() == other.schema.event_schema.provider_guid()
473473
&& self.schema.event_schema.event_version() == other.schema.event_schema.event_version()
474474
}
475475
}
476476

477-
impl<'a> Eq for TypedEvent<'a> {}
477+
impl Eq for TypedEvent<'_> {}

samply/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ num-derive = "0.4"
8484
runas = "1.2.0"
8585
which = "7.0.0"
8686
winver = "1"
87-
etw-reader = { path = "../etw-reader" }
87+
88+
# etw-reader = { path = "../etw-reader" }
8889
# linux-perf-data = "0.10.1"
8990

9091
[target.'cfg(windows)'.dependencies.windows]

samply/src/windows/coreclr.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ use std::convert::TryInto;
33
use std::fmt::Display;
44

55
use bitflags::bitflags;
6-
use etw_reader::parser::{Parser, TryParse};
7-
use etw_reader::schema::TypedEvent;
8-
use etw_reader::{self, event_properties_to_string};
96
use fxprof_processed_profile::*;
107
use num_derive::FromPrimitive;
118
use num_traits::FromPrimitive;
@@ -14,6 +11,10 @@ use super::elevated_helper::ElevatedRecordingProps;
1411
use crate::shared::recording_props::{CoreClrProfileProps, ProfileCreationProps};
1512
use crate::windows::profile_context::{KnownCategory, ProfileContext};
1613

14+
use super::etw_reader::event_properties_to_string;
15+
use super::etw_reader::parser::{Parser, TryParse};
16+
use super::etw_reader::schema::TypedEvent;
17+
1718
struct SavedMarkerInfo {
1819
start_timestamp_raw: u64,
1920
name: String,

0 commit comments

Comments
 (0)