-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safer traces, part 2: Trace builder #63
Merged
Merged
Conversation
This file contains 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
This commit does not compile, but will make it possible for a following commit to remove the not-so-idiomatic fill_info()
Also, this commit: * fixes a possible panic when trying to write an arbitrary-length String to a u8 array * better checks the error conditions for StartTraceW (a null handle should be considered invalid)
This largely refactors trace.rs and evntrace.rs * evntrace now solely contains safe wrappers over Windows API functions, without any internal state (struct NativeEtw has been removed) that's the duty of trace.rs to handle these API correctly and in the right order. * Traces instances are now created with a Builder pattern, to clearly mark which fields may be mutable and which will stay constant. This will make it very easy to fix races in issue n4r1b#45 Also, as minor improvements: * the builder now enforces the trace name is truncated to TRACE_NAME_MAX_CHARS, so that both EVENT_TRACE_LOGFILEW and EVENT_TRACE_PROPERTIES have consistently truncated logger names * TraceData is renamed CallbackData. That's mainly a matter of taste, even though it makes its intent clearer, and thus makes it easier to review the `unsafe` blocks * errors from evntrace are now better forwarded to callers * checks for invalid handles from the Windows API has been made more explicit * the public API for traces (and trace builder) is now simplified, and hides some of the "really weird" (to say the least) design choices of ETW. Distinction between open/start/process is now clearer to the user Also, the `process` now exists in different flavours, that do not all hide the thread spawning. This offers more control to the end user. * Traces can explictly be closed, and are closed if still open on Drop (maybe that was the case in ferrisetw 0.1, I'm not sure) * This removes the distinction between TraceTrait and TraceBaseTrait Sorry, I did not manage to split this large commit into smaller chunks. It's probably easier to read only the result of it rather than the diffs, which do not make much sense since most of evntrace.rs and trace.rs are now diffs.
This was referenced Nov 7, 2022
Merged
Merged
Merged
Merged
n4r1b
approved these changes
Nov 11, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! lgtm
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.
Fixes #17
Fixes #45
Fixes #26
Sorry, that's a rather large diff, but I did not manage to split it in smaller commits or PR :-/
As stated on the commit message for
Trace now has a Builder
, it's probably easier to read the result of this very commit rather than its changes.