-
Notifications
You must be signed in to change notification settings - Fork 14
Add extra checks to select the right mapping and filter samples within it. #266
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
Add extra checks to select the right mapping and filter samples within it. #266
Conversation
* Pass pointers to the perf profile proto and the main memory mapping instead of storing them as class members. * The `PerfParser` also does not need to be held on to - it is used only once. * The `PerfReader` must be held on to since it owns all of the perf related data.
// Memory mapping protection flag bits on Linux, from `sys/mman.h`. | ||
constexpr int kProtRead = 0b001; /* PROT_READ */ | ||
constexpr int kProtWrite = 0b010; /* PROT_WRITE */ | ||
constexpr int kProtExec = 0b100; /* PROT_EXEC */ |
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.
Can we use PROT_READ
, PROT_WRITE
, and PROT_EXEC
directly in our code?
Normally, they should be provided by sys/mman.h
- and if they are, I'd go for the system definitions rather than define our own.
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.
They are indeed provided by sys/mman.h
, but I opted to define them here with the comment pointing to sys/mman.h
so that it doesn't stop this from being built on Windows. I could use a __has_include(<sys/mman.h>)
with a preprocessor macro at the top to use sys/mman.h
whenever possible and just define PROT_{READ,WRITE,EXEC}
otherwise. Or would simply dropping Windows compatibility make more sense?
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.
We already have a Linux-only (POSIX maybe) dependency with finding accessed addresses, so I'm not too worried about that.
But we could do the __has_include
check and include it if defined, otherwise take our own definitions.
…bject. * A new check of the sample PID against the main mapping PID. * Remove the check for whether the block's code was within the bounds of the executable segment in terms of file addresses, this is redundant as long as the mapping is valid.
be2c757
to
93b3cdf
Compare
of the executable segment in terms of file addresses, this is
redundant as long as the mapping is valid.