Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sanitizer_common] Add facility to get the full report path
Add a new interface __sanitizer_get_report_path which will return the full path to the report file if __sanitizer_set_report_path was previously called (otherwise it returns null). This is useful in particular for memory profiling handlers to access the path which was specified at compile time (and passed down via __memprof_profile_filename), including the pid added to the path when the file is opened. There wasn't a test for __sanitizer_set_report_path, so I added one which additionally tests the new interface. Differential Revision: https://reviews.llvm.org/D91765
- Loading branch information
1 parent
8ecb015
commit 8f778b2
Showing
7 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
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 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 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 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 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 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
20 changes: 20 additions & 0 deletions
20
compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Test __sanitizer_set_report_path and __sanitizer_get_report_path: | ||
// RUN: %clangxx -O2 %s -o %t | ||
// RUN: %run %t | FileCheck %s | ||
|
||
#include <assert.h> | ||
#include <sanitizer/common_interface_defs.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
volatile int *null = 0; | ||
|
||
int main(int argc, char **argv) { | ||
char buff[1000]; | ||
sprintf(buff, "%s.report_path", argv[0]); | ||
__sanitizer_set_report_path(buff); | ||
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0); | ||
printf("Path %s\n", __sanitizer_get_report_path()); | ||
} | ||
|
||
// CHECK: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.report_path. |