|
|
75c84f |
From 3a5515f85ea2e007343c225e78cba66dde133327 Mon Sep 17 00:00:00 2001
|
|
|
75c84f |
From: William Cohen <wcohen@redhat.com>
|
|
|
75c84f |
Date: Wed, 6 Jul 2016 10:53:51 -0400
|
|
|
75c84f |
Subject: [PATCH 14/18] Store samples in the archive and search the appropriate
|
|
|
75c84f |
places for samples
|
|
|
75c84f |
|
|
|
75c84f |
Newer versions of oprofile use a oprofile_data directory in the
|
|
|
75c84f |
current working directory to store the samples. This presents a
|
|
|
75c84f |
complications when data archived with oparchive. The oparchive needs
|
|
|
75c84f |
to include samples in the archive. The code also needs to make sure
|
|
|
75c84f |
that samples in the archive are used and not samples from a
|
|
|
75c84f |
oprofile_data directory in the current working directory.
|
|
|
75c84f |
|
|
|
75c84f |
Signed-off-by: William Cohen <wcohen@redhat.com>
|
|
|
75c84f |
---
|
|
|
75c84f |
libpp/profile_spec.cpp | 2 ++
|
|
|
75c84f |
pp/oparchive.cpp | 39 ++++++++++++++++++++++++++++-----------
|
|
|
75c84f |
pp/oparchive_options.cpp | 5 ++---
|
|
|
75c84f |
3 files changed, 32 insertions(+), 14 deletions(-)
|
|
|
75c84f |
|
|
|
75c84f |
diff --git a/libpp/profile_spec.cpp b/libpp/profile_spec.cpp
|
|
|
75c84f |
index cd4bd80..a10d6cc 100644
|
|
|
75c84f |
--- a/libpp/profile_spec.cpp
|
|
|
75c84f |
+++ b/libpp/profile_spec.cpp
|
|
|
75c84f |
@@ -102,6 +102,8 @@ void profile_spec::set_image_or_lib_name(string const & str)
|
|
|
75c84f |
void profile_spec::parse_archive_path(string const & str)
|
|
|
75c84f |
{
|
|
|
75c84f |
archive_path = op_realpath(str);
|
|
|
75c84f |
+ /* Need to force session directory default location in the archive */
|
|
|
75c84f |
+ init_op_config_dirs(OP_SESSION_DIR_DEFAULT);
|
|
|
75c84f |
}
|
|
|
75c84f |
|
|
|
75c84f |
|
|
|
75c84f |
diff --git a/pp/oparchive.cpp b/pp/oparchive.cpp
|
|
|
75c84f |
index 5b6906d..6221e14 100644
|
|
|
75c84f |
--- a/pp/oparchive.cpp
|
|
|
75c84f |
+++ b/pp/oparchive.cpp
|
|
|
75c84f |
@@ -232,6 +232,19 @@ int oparchive(options::spec const & spec)
|
|
|
75c84f |
}
|
|
|
75c84f |
}
|
|
|
75c84f |
|
|
|
75c84f |
+ /* place samples and other related material in easily found default directory */
|
|
|
75c84f |
+ string dest_session_dir = options::outdirectory + string(OP_SESSION_DIR_DEFAULT);
|
|
|
75c84f |
+ string dest_samples_dir = dest_session_dir + string("samples");
|
|
|
75c84f |
+
|
|
|
75c84f |
+ /* dest_session_dir is parent of dest_samples and will also created */
|
|
|
75c84f |
+
|
|
|
75c84f |
+ if (!options::list_files &&
|
|
|
75c84f |
+ create_path(dest_samples_dir.c_str())) {
|
|
|
75c84f |
+ cerr << "Unable to create directory for "
|
|
|
75c84f |
+ << dest_samples_dir << "." << endl;
|
|
|
75c84f |
+ exit (EXIT_FAILURE);
|
|
|
75c84f |
+ }
|
|
|
75c84f |
+
|
|
|
75c84f |
/* copy over each of the sample files */
|
|
|
75c84f |
list<string>::iterator sit = sample_files.begin();
|
|
|
75c84f |
list<string>::iterator const send = sample_files.end();
|
|
|
75c84f |
@@ -245,9 +258,13 @@ int oparchive(options::spec const & spec)
|
|
|
75c84f |
|
|
|
75c84f |
for (; sit != send; ++sit) {
|
|
|
75c84f |
string sample_name = *sit;
|
|
|
75c84f |
+ /* determine the session name of sample file */
|
|
|
75c84f |
+ int offset = sample_name.find('{');
|
|
|
75c84f |
+ string base_samples_dir = sample_name.substr(0, offset-1);
|
|
|
75c84f |
+ string session = basename(base_samples_dir.c_str());
|
|
|
75c84f |
/* Get rid of the the archive_path from the name */
|
|
|
75c84f |
- string sample_base = sample_name.substr(archive_path.size());
|
|
|
75c84f |
- string sample_archive_file = options::outdirectory + sample_base;
|
|
|
75c84f |
+ string sample_base = sample_name.substr(offset);
|
|
|
75c84f |
+ string sample_archive_file = dest_samples_dir + "/" + session + "/" + sample_base;
|
|
|
75c84f |
|
|
|
75c84f |
cverb << vdebug << sample_name << endl;
|
|
|
75c84f |
cverb << vdebug << " destp " << sample_archive_file << endl;
|
|
|
75c84f |
@@ -268,19 +285,19 @@ int oparchive(options::spec const & spec)
|
|
|
75c84f |
cerr << "Unable to to obtain realpath for " << op_session_dir << endl;
|
|
|
75c84f |
exit (EXIT_FAILURE);
|
|
|
75c84f |
}
|
|
|
75c84f |
- string abi_name = string(real_session_dir) + "/abi";
|
|
|
75c84f |
- copy_one_file(image_ok, archive_path + abi_name,
|
|
|
75c84f |
- options::outdirectory + abi_name);
|
|
|
75c84f |
+ string abi_name = string(real_session_dir) + string("/abi");
|
|
|
75c84f |
+ string dest_abi_name = dest_session_dir + string("/abi");
|
|
|
75c84f |
+ copy_one_file(image_ok, archive_path + abi_name, dest_abi_name);
|
|
|
75c84f |
|
|
|
75c84f |
/* copy over the <session-dir>/samples/oprofiled.log file */
|
|
|
75c84f |
- string log_name = string(real_session_dir) + string("/samples") + "/oprofiled.log";
|
|
|
75c84f |
- copy_one_file(image_ok, archive_path + log_name,
|
|
|
75c84f |
- options::outdirectory + log_name);
|
|
|
75c84f |
+ string log_name = string(real_session_dir) + string("/samples") + string("/oprofiled.log");
|
|
|
75c84f |
+ string dest_log_name = dest_samples_dir + string("/oprofiled.log");
|
|
|
75c84f |
+ copy_one_file(image_ok, archive_path + log_name, dest_log_name);
|
|
|
75c84f |
|
|
|
75c84f |
/* copy over the <session-dir>/samples/operf.log file */
|
|
|
75c84f |
- log_name = string(real_session_dir) + string("/samples") + "/operf.log";
|
|
|
75c84f |
- copy_one_file(image_ok, archive_path + log_name,
|
|
|
75c84f |
- options::outdirectory + log_name);
|
|
|
75c84f |
+ log_name = string(real_session_dir) + string("/samples") + string("/operf.log");
|
|
|
75c84f |
+ dest_log_name = dest_samples_dir + string("/operf.log");
|
|
|
75c84f |
+ copy_one_file(image_ok, archive_path + log_name, dest_log_name);
|
|
|
75c84f |
|
|
|
75c84f |
free(real_session_dir);
|
|
|
75c84f |
|
|
|
75c84f |
diff --git a/pp/oparchive_options.cpp b/pp/oparchive_options.cpp
|
|
|
75c84f |
index e6f2ddc..b79bf13 100644
|
|
|
75c84f |
--- a/pp/oparchive_options.cpp
|
|
|
75c84f |
+++ b/pp/oparchive_options.cpp
|
|
|
75c84f |
@@ -124,7 +124,6 @@ void handle_options(options::spec const & spec)
|
|
|
75c84f |
|
|
|
75c84f |
if (strncmp(op_session_dir, OP_SESSION_DIR_DEFAULT, strlen(OP_SESSION_DIR_DEFAULT)))
|
|
|
75c84f |
cerr << "NOTE: The sample data in this archive is located at " << op_session_dir << endl
|
|
|
75c84f |
- << "instead of the standard location of " << OP_SESSION_DIR_DEFAULT << ". Hence, when using opreport" << endl
|
|
|
75c84f |
- << "and other post-processing tools on this archive, you must pass the following option:" << endl
|
|
|
75c84f |
- << "\t--session-dir=" << op_session_dir << endl;
|
|
|
75c84f |
+ << "and is being moved to the standard location of " << OP_SESSION_DIR_DEFAULT << "."
|
|
|
75c84f |
+ << endl;
|
|
|
75c84f |
}
|
|
|
75c84f |
--
|
|
|
75c84f |
2.7.4
|
|
|
75c84f |
|