diff options
author | Dean Michael Berris <dberris@google.com> | 2017-01-03 04:35:24 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2017-01-03 04:35:24 +0000 |
commit | 55278303a867879391300d56e1a390b7db57e689 (patch) | |
tree | 1bdf91d720f19e5ac4c43ab42708b4930de50e61 /test | |
parent | b92697bddf3ec2631db9e850b6a885636748c08f (diff) |
[XRay] [compiler-rt] Include argv[0] in the log file name.
Summary:
If you decide to recompile parts of your Linux distro with XRay, it may
be useful to know which trace belongs to which binary. While there, get
rid of the incorrect strncat() usage; it always returns a pointer to the
start which makes that if() always true. Replace with snprintf which is
bounded so that enough from both strings fits nicely.
Reviewers: dberris
Subscribers: danalbert, srhines, kubabrecka, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D27912
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290861 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/xray/TestCases/Linux/argv0-log-file-name.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/xray/TestCases/Linux/argv0-log-file-name.cc b/test/xray/TestCases/Linux/argv0-log-file-name.cc new file mode 100644 index 000000000..1765ce9b5 --- /dev/null +++ b/test/xray/TestCases/Linux/argv0-log-file-name.cc @@ -0,0 +1,14 @@ +// Check to make sure argv[0] is contained within the (randomised) XRay log file +// name. + +// RUN: %clangxx_xray -std=c++11 %s -o %t +// RUN: %run %t > xray.log.file.name 2>&1 +// RUN: ls | FileCheck xray.log.file.name +// RUN: rm xray-log.* xray.log.file.name + +#include <cstdio> +#include <libgen.h> + +[[clang::xray_always_instrument]] int main(int argc, char *argv[]) { + printf("// CHECK: xray-log.%s.{{.*}}\n", basename(argv[0])); +} |