-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MemProf] Add interface for reseting the profile file descriptor #73714
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Test to ensure that multiple rounds of dumping, using the | ||
// __memprof_profile_reset interface to close the initial file | ||
// and cause the profile to be reopened, works as expected. | ||
|
||
// RUN: %clangxx_memprof %s -o %t | ||
|
||
// RUN: rm -f %t.log.* | ||
// RUN: %env_memprof_opts=print_text=true:log_path=%t.log %run %t | ||
|
||
// Check both outputs, starting with the renamed initial dump, then remove it so | ||
// that the second glob matches a single file. | ||
// RUN: FileCheck %s --dump-input=always < %t.log.*.sv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the dump-input left over from debugging? The default is on fail which seems fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this came in when I copied from another test, where it is presumably leftover debugging. I removed from here. |
||
// RUN: rm -f %t.log.*.sv | ||
// RUN: FileCheck %s --dump-input=always < %t.log.* | ||
// CHECK: Memory allocation stack id | ||
|
||
#include <sanitizer/memprof_interface.h> | ||
#include <stdio.h> | ||
|
||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <string> | ||
int main(int argc, char **argv) { | ||
char *x = (char *)malloc(10); | ||
memset(x, 0, 10); | ||
free(x); | ||
__memprof_profile_dump(); | ||
// Save the initial dump in a different file. | ||
std::string origname = __sanitizer_get_report_path(); | ||
std::string svname = origname + ".sv"; | ||
rename(origname.c_str(), svname.c_str()); | ||
// This should cause the current file descriptor to be closed and the | ||
// the internal state reset so that the profile filename is reopened | ||
// on the next write. | ||
__memprof_profile_reset(); | ||
// This will dump to origname again. | ||
__memprof_profile_dump(); | ||
return 0; | ||
} |
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 you add a comment why we need to set this to kInvalidFd?
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.
Done