[prev in list] [next in list] [prev in thread] [next in thread] 

List:       oprofile-list
Subject:    Re: [Fwd: Re: oprofile archive patch updated for oprofile cvs]
From:       Will Cohen <wcohen () redhat ! com>
Date:       2004-06-25 16:53:39
Message-ID: 40DC5893.1050608 () redhat ! com
[Download RAW message or body]

John Levon wrote:
> On Thu, Apr 15, 2004 at 11:30:28AM -0400, Will Cohen wrote:
> 
> 
>>I was taking a closer look at op_bfd(). There are some other places that 
>>archive is needed in the function. I have taken a closer look and 
> 
> 
> OK
> 
> 
>>Okay, have the following:
>>
>>		cerr << "Unable to create directory for "
>>		     <<	options::outdirectory << "." << endl;
> 
> 
> Fine.
> 
> 
>>Nothing in the CodingStyle mentions anything about error message output 
>>and there are a variety of formats. There are a number of places with 
> 
> 
> It's a big mess isn't it?
> 
> john


I have reworked the oparchive patch to fix a couple problems I knew 
about. The changes allow "opreport -l" and archiving from an archive to 
work. Earlier versions did not have the invert_profile() looking in the 
proper place for executable and the sample files were not copied from an 
archive into the correct place in the new archive.

-Will

["archive12.patch" (text/plain)]

--- oprofile-0.8.1-0.20040621.archive4/doc/oprofile.xml.orig	2004-04-04 \
                13:30:55.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/doc/oprofile.xml	2004-06-25 12:13:58.000000000 \
-0400 @@ -1374,11 +1374,19 @@
 
 <variablelist>
 	<varlistentry>
+		<term><option>archive:</option><emphasis>archivepath</emphasis></term>
+		<listitem><para>
+		A path to an archive made with oparchive. Absence of this
+		tag, unlike others, means "the current system",
+		equivalent to specifying "archive:".
+		</para></listitem>
+	</varlistentry>
+	<varlistentry>
 		<term><option>session:</option><emphasis>sessionlist</emphasis></term>
 		<listitem><para>
-                A comma-separated list of session names to resolve in. Absence of \
                this
-                tag, unlike all others, means "the current session", equivalent to
-                specifying "session:current".
+		A comma-separated list of session names to resolve in. Absence of this
+		tag, unlike others, means "the current session", equivalent to
+		specifying "session:current".
 		</para></listitem>
 	</varlistentry>
 	<varlistentry>
@@ -1807,6 +1815,34 @@
 
 </sect1> <!-- opstack-details -->
 
+<sect1 id="oparchive-details">
+<title>Usage of <command>oparchive</command></title>
+
+<variablelist>
+<varlistentry><term><option>--help / -? / --usage</option></term><listitem><para>
+Show help message.
+</para></listitem></varlistentry>
+<varlistentry><term><option>--version / -v</option></term><listitem><para>
+Show version.
+</para></listitem></varlistentry>
+<varlistentry><term><option>--verbose / -V [options]</option></term><listitem><para>
+Give verbose debugging output.
+</para></listitem></varlistentry>
+<varlistentry><term><option>--image-path / -p \
[paths]</option></term><listitem><para> +Comma-separated list of additional paths to \
search for binaries. +This is needed to find modules in kernels 2.6 and upwards.
+</para></listitem></varlistentry>
+<varlistentry><term><option>--threshold / -t \
[percentage]</option></term><listitem><para> +Only output data for symbols that have \
more than the given percentage +of total samples.
+</para></listitem></varlistentry>
+<varlistentry><term><option>--output-directory / -o \
[directory]</option></term><listitem><para> +Output to the given directory. There is \
no default. This must be specified. +</para></listitem></varlistentry>
+</variablelist>
+
+</sect1> <!-- oparchive-details -->
+
 <sect1 id="opgprof-details">
 <title>Usage of <command>opgprof</command></title>
 
--- oprofile-0.8.1-0.20040621.archive4/doc/Makefile.am.orig	2004-01-24 \
                21:59:54.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/doc/Makefile.am	2004-06-25 12:13:58.000000000 \
-0400 @@ -15,7 +15,8 @@
 	opannotate.1 \
 	opgprof.1 \
 	op_help.1 \
-	opstack.1
+	opstack.1 \
+	oparchive.1
 
 htmldir = $(prefix)/share/doc/oprofile
 dist_html_DATA = oprofile.html internals.html
--- oprofile-0.8.1-0.20040621.archive4/doc/oparchive.1.in.orig	2004-06-25 \
                12:13:58.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/doc/oparchive.1.in	2004-06-25 \
12:42:01.000000000 -0400 @@ -0,0 +1,60 @@
+.TH OPARCHIVE 1 "@DATE@" "oprofile @VERSION@"
+.UC 4
+.SH NAME
+oparchive \- produce archive of oprofile data for offline analysis
+.SH SYNOPSIS
+.br
+.B oparchive
+[
+.I options
+]
+[profile specification]
+.SH DESCRIPTION
+
+.B oparchive
+generates a directory populated with executable, debug, and oprofile sample
+files. This directory can be move to another machine via tar and analyzed
+without further use of the data collection machine.
+
+.SH OPTIONS
+.TP
+.BI "--help / -? / --usage"
+Show help message.
+.br
+.TP
+.BI "--version / -v"
+Show version.
+.br
+.TP
+.BI "--verbose / -V [options]"
+Give verbose debugging output.
+.br
+.TP
+.BI "--image-path / -p [paths]"
+Comma-separated list of additional paths to search for binaries.
+This is needed to find modules in kernels 2.6 and upwards.
+.br
+.TP
+.BI "--threshold / -t [percentage]"
+Only output data for symbols that have more than the given percentage
+of total samples.
+.br
+.TP
+.BI "--output-directory / -o [directory]"
+Output to the given directory. There is no default. This must be specified.
+
+.SH ENVIRONMENT
+No special environment variables are recognised by oparchive.
+
+.SH FILES
+.TP
+.I /var/lib/oprofile/samples/
+The location of the generated sample files.
+
+.SH VERSION
+.TP
+This man page is current for @PACKAGE@-@VERSION@.
+
+.SH SEE ALSO
+.BR @OP_DOCDIR@,
+.BR oprofile(1)
--- oprofile-0.8.1-0.20040621.archive4/doc/oprofile.1.in.orig	2004-01-24 \
                12:24:41.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/doc/oprofile.1.in	2004-06-25 \
12:13:58.000000000 -0400 @@ -27,6 +27,12 @@
 ]
 [ profile specification ]
 .br
+.B oparchive
+[
+.I options
+]
+[ profile specification ]
+.br
 .B opgprof
 [
 .I options
@@ -59,6 +65,9 @@
 .SH OPANNOTATE
 .B opannotate
 can produce annotated source or mixed source and assembly output.
+.SH OPARCHIVE
+.B oparchive
+produces oprofile archive for offline analysis
 .SH OPGPROF
 .B opgprof
 can produce a gprof-format profile for a single binary.
--- oprofile-0.8.1-0.20040621.archive4/libpp/profile_spec.cpp.orig	2004-05-07 \
                11:27:51.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/libpp/profile_spec.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -30,9 +30,10 @@
 // we should maintain the original to maintain the wordexp etc.
 string const fixup_image_spec(string const & str, extra_images const & extra)
 {
+	std::string dummy_archive_path;
 	// FIXME: what todo if an error in find_image_path() ?
 	image_error error;
-	return find_image_path(str, extra, error);
+	return find_image_path(dummy_archive_path, str, extra, error);
 }
 
 
@@ -55,6 +56,7 @@
 	sample_file_set(false),
 	extra(extra)
 {
+	parse_table["archive"] = &profile_spec::parse_archive_path;
 	parse_table["sample-file"] = &profile_spec::parse_sample_file;
 	parse_table["binary"] = &profile_spec::parse_binary;
 	parse_table["session"] = &profile_spec::parse_session;
@@ -121,6 +123,18 @@
 }
 
 
+void profile_spec::parse_archive_path(string const & str)
+{
+	archive_path = op_realpath(str);
+}
+
+
+string profile_spec::get_archive_path() const
+{
+	return archive_path;
+}
+
+
 void profile_spec::parse_sample_file(string const & str)
 {
 	sample_file_set = true;
@@ -440,7 +454,7 @@
 
 		string base_dir;
 		if ((*cit)[0] != '.' && (*cit)[0] != '/')
-			base_dir = OP_SAMPLES_DIR;
+			base_dir = archive_path + OP_SAMPLES_DIR;
 		base_dir += *cit;
 
 		base_dir = op_realpath(base_dir);
--- oprofile-0.8.1-0.20040621.archive4/libpp/profile_spec.h.orig	2004-02-20 \
                17:40:43.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libpp/profile_spec.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -58,6 +58,12 @@
 	 */
 	bool match(filename_spec const & file_spec) const;
 
+	/**
+	 * return archive name
+	 * returns an empty string if not using an archive.
+	 */
+	std::string get_archive_path() const;
+
 private:
 	profile_spec(extra_images const & extra);
 
@@ -91,6 +97,7 @@
 	/**
 	 * implement tag parsing: PP:3.3 to 3.16
 	 */
+	void parse_archive_path(std::string const &);
 	void parse_sample_file(std::string const &);
 	void parse_binary(std::string const &);
 	void parse_session(std::string const &);
@@ -121,6 +128,7 @@
 			     std::string & value);
 
 	filename_spec file_spec;
+	std::string archive_path;
 	std::string binary;
 	std::vector<std::string> session;
 	std::vector<std::string> session_exclude;
--- oprofile-0.8.1-0.20040621.archive4/libpp/populate.h.orig	2004-01-17 \
                21:21:15.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libpp/populate.h	2004-06-25 12:13:58.000000000 \
-0400 @@ -20,7 +20,8 @@
 /// Load all sample file information for exactly one binary image.
 /// return false if none of the image contains debug information
 bool
-populate_for_image(profile_container & samples, inverted_profile const & ip,
-   string_filter const & symbol_filter);
+populate_for_image(std::string const & archive_path,
+   profile_container & samples,
+   inverted_profile const & ip, string_filter const & symbol_filter);
 
 #endif /* POPULATE_H */
--- oprofile-0.8.1-0.20040621.archive4/libpp/populate.cpp.orig	2004-01-17 \
                21:21:15.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libpp/populate.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -49,11 +49,12 @@
 
 
 bool
-populate_for_image(profile_container & samples, inverted_profile const & ip,
-   string_filter const & symbol_filter)
+populate_for_image(string const & archive_path, profile_container & samples,
+   inverted_profile const & ip, string_filter const & symbol_filter)
 {
 	bool ok = ip.error == image_ok;
-	op_bfd abfd(ip.image, symbol_filter, ok);
+
+	op_bfd abfd(archive_path, ip.image, symbol_filter, ok);
 	if (!ok && ip.error == image_ok)
 		ip.error = image_format_failure;
 
--- oprofile-0.8.1-0.20040621.archive4/libpp/callgraph_container.cpp.orig	2004-05-28 \
                14:29:37.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/libpp/callgraph_container.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -269,7 +269,8 @@
 }
 
 
-void callgraph_container::populate(list<inverted_profile> const & iprofiles,
+void callgraph_container::populate(string const & archive_path, 
+   list<inverted_profile> const & iprofiles,
    extra_images const & extra, bool debug_info, double threshold,
    bool merge_lib)
 {
@@ -281,12 +282,13 @@
 	list<inverted_profile>::const_iterator const end = iprofiles.end();
 	for (it = iprofiles.begin(); it != end; ++it) {
 		// populate_caller_image take care about empty sample filename
-		populate_for_image(symbols, *it, string_filter());
+		populate_for_image(archive_path, symbols, *it,
+			string_filter());
 	}
 
 	for (it = iprofiles.begin(); it != end; ++it) {
 		for (size_t i = 0; i < it->groups.size(); ++i) {
-			populate(it->groups[i], it->image, extra,
+			populate(archive_path, it->groups[i], it->image, extra,
 				i, symbols, debug_info, merge_lib);
 		}
 	}
@@ -297,7 +299,8 @@
 }
 
 
-void callgraph_container::populate(list<image_set> const & lset,
+void callgraph_container::populate(string const & archive_path,
+	list<image_set> const & lset,
 	string const & app_image, extra_images const & extra, size_t pclass,
 	profile_container const & symbols, bool debug_info, bool merge_lib)
 {
@@ -308,14 +311,16 @@
 		list<profile_sample_files>::const_iterator pend
 			= lit->files.end();
 		for (pit = lit->files.begin(); pit != pend; ++pit) {
-			populate(pit->cg_files, app_image, extra, pclass,
+			populate(archive_path, pit->cg_files, app_image,
+				 extra, pclass,
 				 symbols, debug_info, merge_lib);
 		}
 	}
 }
 
 
-void callgraph_container::populate(list<string> const & cg_files,
+void callgraph_container::populate(string const & archive_path,
+	list<string> const & cg_files,
 	string const & app_image, extra_images const & extra, size_t pclass,
 	profile_container const & symbols, bool debug_info, bool merge_lib)
 {
@@ -327,17 +332,19 @@
 
 		image_error error;
 		string caller_binary =
-			find_image_path(caller_file.lib_image, extra, error);
+			find_image_path(archive_path, caller_file.lib_image,
+					extra, error);
 
 		if (error != image_ok)
-			report_image_error(caller_file.lib_image, error, false);
+			report_image_error(archive_path + caller_file.lib_image,
+					   error, false);
 
 		cverb << vdebug << "caller binary name: "
 		      << caller_binary  << "\n";
 
 		bool bfd_caller_ok = true;
-		op_bfd caller_bfd(caller_binary, string_filter(),
-		                  bfd_caller_ok);
+		op_bfd caller_bfd(archive_path, caller_binary,
+				  string_filter(), bfd_caller_ok);
 		if (!bfd_caller_ok)
 			report_image_error(caller_binary,
 			                   image_format_failure, false);
@@ -345,7 +352,7 @@
 		parsed_filename callee_file = parse_filename(*it);
 
 		string callee_binary =
-			find_image_path(callee_file.cg_image,
+			find_image_path(archive_path, callee_file.cg_image,
 			                extra, error);
 		if (error != image_ok)
 			report_image_error(callee_file.cg_image, error, false);
@@ -354,8 +361,8 @@
 		      << callee_binary << endl;
 
 		bool bfd_callee_ok = true;
-		op_bfd callee_bfd(callee_binary, string_filter(),
-		                  bfd_callee_ok);
+		op_bfd callee_bfd(archive_path, callee_binary,
+				  string_filter(), bfd_callee_ok);
 		if (!bfd_callee_ok)
 			report_image_error(callee_binary,
 		                           image_format_failure, false);
--- oprofile-0.8.1-0.20040621.archive4/libpp/callgraph_container.h.orig	2004-02-17 \
                17:43:56.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libpp/callgraph_container.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -116,7 +116,8 @@
 	 * Currently all errors core dump.
 	 * FIXME: consider if this should be a ctor
 	 */
-	void populate(std::list<inverted_profile> const & iprofiles,
+	void populate(std::string const & archive_path,
+		      std::list<inverted_profile> const & iprofiles,
 		      extra_images const & extra, bool debug_info,
 		      double threshold, bool merge_lib);
 
@@ -150,12 +151,14 @@
 		 profile_container const & symbols, bool debug_info,
 		 size_t pclass);
 
-	void populate(std::list<image_set> const & lset,
+	void populate(std::string const & archive_path,
+		      std::list<image_set> const & lset,
 		      std::string const & app_image,
 		      extra_images const & extra, size_t pclass,
 		      profile_container const & symbols, bool debug_info,
 		      bool merge_lib);
-	void populate(std::list<std::string> const & cg_files,
+	void populate(std::string const & archive_path,
+		      std::list<std::string> const & cg_files,
 		      std::string const & app_image,
 		      extra_images const & extra, size_t pclass,
 		      profile_container const & symbols, bool debug_info,
--- oprofile-0.8.1-0.20040621.archive4/libpp/arrange_profiles.cpp.orig	2004-05-28 \
                14:29:37.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/libpp/arrange_profiles.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -674,8 +674,8 @@
 
 /// Pull out all the images, removing any we can't access.
 void
-verify_and_fill(app_map_t & app_map, list<inverted_profile> & plist,
-                extra_images const & extra)
+verify_and_fill(std::string archive_path, app_map_t & app_map,
+		list<inverted_profile> & plist, extra_images const & extra)
 {
 	app_map_t::iterator it = app_map.begin();
 	app_map_t::iterator const end = app_map.end();
@@ -683,7 +683,8 @@
 	for (; it != end; ++it) {
 		plist.push_back(it->second);
 		inverted_profile & ip = plist.back();
-		ip.image = find_image_path(ip.image, extra, ip.error);
+		ip.image = find_image_path(archive_path, ip.image, extra,
+					   ip.error);
 	}
 }
 
@@ -691,7 +692,8 @@
 
 
 list<inverted_profile> const
-invert_profiles(profile_classes const & classes, extra_images const & extra)
+invert_profiles(std::string archive_path, profile_classes const & classes,
+		extra_images const & extra)
 {
 	app_map_t app_map;
 
@@ -729,7 +731,7 @@
 
 	list<inverted_profile> inverted_list;
 
-	verify_and_fill(app_map, inverted_list, extra);
+	verify_and_fill(archive_path, app_map, inverted_list, extra);
 
 	return inverted_list;
 }
--- oprofile-0.8.1-0.20040621.archive4/libpp/arrange_profiles.h.orig	2004-01-17 \
                21:21:14.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libpp/arrange_profiles.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -220,6 +220,7 @@
  * applicable (hence image_set).
  */
 std::list<inverted_profile> const
-invert_profiles(profile_classes const & classes, extra_images const & extra);
+invert_profiles(std::string archive_path, profile_classes const & classes,
+		extra_images const & extra);
 
 #endif /* !ARRANGE_PROFILES_H */
--- oprofile-0.8.1-0.20040621.archive4/libpp/locate_images.cpp.orig	2004-01-19 \
                15:00:25.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libpp/locate_images.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -93,11 +93,12 @@
 } // anon namespace
 
 
-string const find_image_path(string const & image_name,
+string const find_image_path(string const & archive_path,
+			     string const & image_name,
                              extra_images const & extra_images,
                              image_error & error)
 {
-	string const image = op_realpath(image_name);
+	string const image = op_realpath(archive_path + image_name);
 
 	// simplest case
 	if (op_file_readable(image)) {
--- oprofile-0.8.1-0.20040621.archive4/libpp/locate_images.h.orig	2004-01-17 \
                21:21:14.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libpp/locate_images.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -68,7 +68,8 @@
  * If we fail to find the file we fill in error and return the original string.
  */
 std::string const
-find_image_path(std::string const & image_name,
+find_image_path(std::string const & archive_path,
+		std::string const & image_name,
                 extra_images const & extra_images,
                 image_error & error);
 
--- oprofile-0.8.1-0.20040621.archive4/libutil++/op_bfd.h.orig	2004-05-13 \
                16:24:18.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/libutil++/op_bfd.h	2004-06-25 \
12:31:42.000000000 -0400 @@ -86,7 +86,8 @@
 	 * open the bfd (because it's not there or whatever). On out,
 	 * it's set to false if the bfd couldn't be loaded.
 	 */
-	op_bfd(std::string const & filename,
+	op_bfd(std::string const & archive_path,
+	       std::string const & filename,
 	       string_filter const & symbol_filter,
 	       bool & ok);
 
@@ -145,7 +146,7 @@
 
 	/** return the text section filepos. */
 	unsigned long const get_start_offset() const { return text_offset; }
-
+ 
 	/// return the image name of the underlying binary image
 	std::string get_filename() const;
 
@@ -256,4 +257,6 @@
                          std::string const & dir_in,
                          std::string const & global_in,
                          std::string & filename);
+
+extern bfd * open_bfd(std::string const & file);
 #endif /* !OP_BFD_H */
--- oprofile-0.8.1-0.20040621.archive4/libutil++/op_bfd.cpp.orig	2004-05-13 \
                16:24:18.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/libutil++/op_bfd.cpp	2004-06-25 \
12:31:22.000000000 -0400 @@ -48,6 +48,8 @@
 	}
 }
 
+}
+
 
 bfd * open_bfd(string const & file)
 {
@@ -65,6 +67,8 @@
 }
 
 
+namespace {
+
 bfd * fdopen_bfd(string const & file, int fd)
 {
 	/* bfd keeps its own reference to the filename char *,
@@ -212,8 +216,8 @@
 }
 
 
-op_bfd::op_bfd(string const & fname, string_filter const & symbol_filter,
-               bool & ok)
+op_bfd::op_bfd(string const & archive_path, string const & fname,
+	       string_filter const & symbol_filter, bool & ok)
 	:
 	filename(fname),
 	file_size(-1),
@@ -222,6 +226,7 @@
 	text_offset(0),
 	debug_info(false)
 {
+	string image_path = archive_path + filename;
 	int fd;
 	struct stat st;
 	// after creating all symbol it's convenient for user code to access
@@ -234,9 +239,9 @@
 	if (!ok)
 		goto out_fail;
 
-	fd = open(filename.c_str(), O_RDONLY);
+	fd = open(image_path.c_str(), O_RDONLY);
 	if (fd == -1) {
-		cverb << vbfd << "open failed for " << filename << endl;
+		cverb << vbfd << "open failed for " << image_path << endl;
 		ok = false;
 		goto out_fail;
 	}
@@ -249,10 +254,10 @@
 
 	file_size = st.st_size;
 
-	ibfd = fdopen_bfd(filename, fd);
+	ibfd = fdopen_bfd(image_path, fd);
 
 	if (!ibfd) {
-		cverb << vbfd << "fdopen_bfd failed for " << filename << endl;
+		cverb << vbfd << "fdopen_bfd failed for " << image_path << endl;
 		ok = false;
 		goto out_fail;
 	}
@@ -277,8 +282,8 @@
 
 	// if no debugging section check to see if there is an .debug file
 	if (!debug_info) {
-		string global(DEBUGDIR);
-		string dirname(filename.substr(0, filename.rfind('/')));
+		string global(archive_path + DEBUGDIR);
+		string dirname(image_path.substr(0, image_path.rfind('/')));
 		if (find_separate_debug_file (ibfd, dirname, global,
 					      debug_filename)) {
 			cverb << vbfd
--- oprofile-0.8.1-0.20040621.archive4/libutil++/file_manip.cpp.orig	2004-01-24 \
                15:05:15.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/libutil++/file_manip.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -27,6 +27,19 @@
 using namespace std;
 
 
+bool copy_file(string const & source, string const & destination)
+{
+	struct stat buf;
+	int status = stat(source.c_str(), &buf);
+
+	if (status == 0) {
+		string copy_command("cp -a -f " + source + " " + destination);
+		status = system(copy_command.c_str());
+	}
+	return !status;
+}
+
+
 bool is_directory(string const & dirname)
 {
 	struct stat st;
--- oprofile-0.8.1-0.20040621.archive4/libutil++/file_manip.h.orig	2004-05-13 \
                16:24:18.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/libutil++/file_manip.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -16,6 +16,15 @@
 #include <list>
 
 
+/**
+ * copy_file - copy a file or subtree
+ * @param source        filename to copy from
+ * @param destination   filename to copy into
+ *
+ * return true if copying successful
+ */
+bool copy_file(std::string const & source, std::string const & destination);
+
 /// return true if dir is an existing directory
 bool is_directory(std::string const & dirname);
 
--- oprofile-0.8.1-0.20040621.archive4/pp/Makefile.am.orig	2004-01-17 \
                21:21:15.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/Makefile.am	2004-06-25 12:13:58.000000000 \
-0400 @@ -9,7 +9,7 @@
 
 AM_CXXFLAGS = @OP_CXXFLAGS@
 
-bin_PROGRAMS = opreport opannotate opgprof opstack
+bin_PROGRAMS = opreport opannotate opgprof opstack oparchive
 
 LIBS=@POPT_LIBS@ @BFD_LIBS@
 
@@ -43,3 +43,8 @@
 	opstack_options.h opstack_options.cpp \
 	$(pp_common)
 opstack_LDADD = $(common_libs)
+
+oparchive_SOURCES = oparchive.cpp \
+	oparchive_options.h oparchive_options.cpp \
+	$(pp_common)
+oparchive_LDADD = $(common_libs)
--- oprofile-0.8.1-0.20040621.archive4/pp/oparchive.cpp.orig	2004-06-25 \
                12:13:58.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/pp/oparchive.cpp	2004-06-25 12:13:58.000000000 \
-0400 @@ -0,0 +1,140 @@
+/**
+ * @file oparchive.cpp
+ * Implement oparchive utility
+ *
+ * @remark Copyright 2003, 2004 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author Will Cohen
+ * @author John Levon
+ * @author Philippe Elie
+ */
+
+#include <iostream>
+#include <fstream>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include "op_file.h"
+#include "op_bfd.h"
+#include "op_config.h"
+#include "oparchive_options.h"
+#include "file_manip.h"
+#include "cverb.h"
+#include "image_errors.h"
+
+using namespace std;
+
+namespace {
+
+int oparchive(vector<string> const & non_options)
+{
+	handle_options(non_options);
+
+	/* Check to see if directory can be created */
+	if (create_path(options::outdirectory.c_str())) {
+		cerr << "Unable to create directory for " 
+		     <<	options::outdirectory << "." << endl;
+		exit (EXIT_FAILURE);
+	}
+
+	/* copy over each of the executables and the debuginfo files */
+	list<inverted_profile> iprofiles
+		= invert_profiles(options::archive_path, classes,
+				  options::extra_found_images);
+
+	report_image_errors(iprofiles);
+
+	list<inverted_profile>::iterator it = iprofiles.begin();
+	list<inverted_profile>::iterator const end = iprofiles.end();
+
+	cverb << vdebug << "(exe_names)" << endl << endl;
+	for (; it != end; ++it) {
+		string exe_name = it->image;
+		string exe_archive_file = options::outdirectory + exe_name;
+
+		cverb << vdebug << exe_name << endl;
+		/* Create directory for executable file. */
+		if (create_path(exe_archive_file.c_str())) {
+			cerr << "Unable to create directory for "
+			     << exe_archive_file << "." << endl;
+			exit (EXIT_FAILURE);
+		}
+
+		/* Copy actual executable files */
+		copy_file(options::archive_path + exe_name, exe_archive_file);
+
+		/* If there are any debuginfo files, copy them over.
+		 * Need to copy the debug info file in the same
+		 * directory as the executable. The /usr/lib/debug
+		 *  search path is not going to work.
+		 */
+		bfd * ibfd = open_bfd(exe_name);
+		if (ibfd) {
+			string global(options::archive_path + DEBUGDIR);
+			string dirname = op_dirname(options::archive_path + 
+						    exe_name);
+			string debug_filename;
+			if (find_separate_debug_file(ibfd, dirname, global,
+				debug_filename)) {
+				/* found something copy it over */
+				string dest_debug = options::outdirectory +
+					dirname + "/" +
+					op_basename(debug_filename);
+				copy_file(debug_filename, dest_debug);
+			}
+			bfd_close(ibfd);
+		}
+	}
+
+	/* copy over each of the sample files */
+	list<string>::iterator sit = sample_files.begin();
+	list<string>::iterator const send = sample_files.end();
+
+	cverb << vdebug << "(sample_names)" << endl << endl;
+
+	/* Copy over each of the sample files.  The sample files are
+	 * copied after the executables to avoid the situation where
+	 * executable is newer than the sample file.
+	 */
+	for (; sit != send; ++sit) {
+		string sample_name = *sit;
+		string sample_base = sample_name;
+		/* Get rid of the the archive_path from the name */
+		sample_base.replace(sample_base.find(options::archive_path),
+				    options::archive_path.size(), "");
+		string sample_archive_file = options::outdirectory + sample_base;
+		
+		cverb << vdebug << (sample_name) << endl;
+		cverb << vdebug << " destp " << sample_archive_file << endl;
+		if (create_path(sample_archive_file.c_str())) {
+			cerr << "Unable to create directory for "
+			     <<	sample_archive_file << "." << endl;
+			exit (EXIT_FAILURE);
+		}
+
+		/* Copy over actual sample file. */
+		copy_file(sample_name, sample_archive_file);
+	}
+
+	/* copy over the /var/lib/oprofile/abi file if it exists */
+	string abi_name = "/var/lib/oprofile/abi";
+	copy_file(options::archive_path + abi_name,
+		  options::outdirectory + abi_name);
+
+	/* copy over the /var/lib/oprofile/oprofiled.log file */
+	string log_name = "/var/lib/oprofile/oprofiled.log";
+	copy_file(options::archive_path + log_name,
+		  options::outdirectory + log_name);
+
+	return 0;
+}
+
+}  // anonymous namespace
+
+
+int main(int argc, char const * argv[])
+{
+	run_pp_tool(argc, argv, oparchive);
+}
--- oprofile-0.8.1-0.20040621.archive4/pp/oparchive_options.cpp.orig	2004-06-25 \
                12:13:58.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/pp/oparchive_options.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -0,0 +1,100 @@
+/**
+ * @file oparchive_options.cpp
+ * Options for oparchive tool
+ *
+ * @remark Copyright 2002, 2003, 2004 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author William Cohen
+ * @author Philippe Elie
+ */
+
+#include <vector>
+#include <list>
+#include <iostream>
+#include <algorithm>
+#include <iterator>
+#include <fstream>
+
+#include "profile_spec.h"
+#include "arrange_profiles.h"
+#include "oparchive_options.h"
+#include "popt_options.h"
+#include "string_filter.h"
+#include "file_manip.h"
+#include "cverb.h"
+
+
+using namespace std;
+
+profile_classes classes;
+std::list<std::string> sample_files;
+
+namespace options {
+	std::string archive_path;
+	bool exclude_dependent;
+	merge_option merge_by;
+	std::string outdirectory;
+}
+
+
+namespace {
+
+vector<string> mergespec;
+
+popt::option options_array[] = {
+	popt::option(options::outdirectory, "output-directory", 'o',
+	             "output to the given directory", "directory"),
+	popt::option(options::exclude_dependent, "exclude-dependent", 'x',
+		     "exclude libs, kernel, and module samples for applications")
+};
+
+
+/**
+ * check incompatible or meaningless options
+ *
+ */
+void check_options()
+{
+	using namespace options;
+
+	/* output directory is required */
+	if (outdirectory.size() == 0) {
+		cerr << "Requires --output-directory option." << endl;
+		exit(EXIT_FAILURE);
+	}
+}
+
+}  // anonymous namespace
+
+
+void handle_options(vector<string> const & non_options)
+{
+	using namespace options;
+
+	merge_by = handle_merge_option(mergespec, true, exclude_dependent);
+	check_options();
+
+	profile_spec const spec =
+		profile_spec::create(non_options, extra_found_images);
+
+	sample_files = spec.generate_file_list(exclude_dependent, true);
+
+	archive_path = spec.get_archive_path();
+	cverb << vsfile << "Archive: " << archive_path << endl;
+
+	cverb << vsfile << "Matched sample files: " << sample_files.size()
+	      << endl;
+	copy(sample_files.begin(), sample_files.end(),
+	     ostream_iterator<string>(cverb << vsfile, "\n"));
+
+	classes = arrange_profiles(sample_files, merge_by);
+
+	cverb << vsfile << "profile_classes:\n" << classes << endl;
+
+	if (classes.v.empty()) {
+		cerr << "error: no sample files found: profile specification "
+		     "too strict ?" << endl;
+		exit(EXIT_FAILURE);
+	}
+}
--- oprofile-0.8.1-0.20040621.archive4/pp/oparchive_options.h.orig	2004-06-25 \
                12:13:58.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/pp/oparchive_options.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -0,0 +1,39 @@
+/**
+ * @file oparchive_options.h
+ * Options for oparchive tool
+ *
+ * @remark Copyright 2003 OProfile authors
+ * @remark Read the file COPYING
+ *
+ * @author Will Cohen
+ * @author Philippe Elie
+ */
+
+#ifndef OPARCHIVE_OPTIONS_H
+#define OPARCHIVE_OPTIONS_H
+
+#include "common_option.h"
+
+class profile_classes;
+class merge_option;
+
+namespace options {
+	extern std::string archive_path;
+	extern bool exclude_dependent;
+	extern merge_option merge_by;
+	extern std::string outdirectory;
+}
+
+/// All the chosen sample files.
+extern profile_classes classes;
+extern std::list<std::string> sample_files;
+
+/**
+ * handle_options - process command line
+ * @param non_options vector of non options string
+ *
+ * Process the arguments, fatally complaining on error.
+ */
+void handle_options(std::vector<std::string> const & non_options);
+
+#endif // OPARCHIVE_OPTIONS_H
--- oprofile-0.8.1-0.20040621.archive4/pp/opreport.cpp.orig	2004-01-31 \
                18:42:54.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opreport.cpp	2004-06-25 12:13:58.000000000 \
-0400 @@ -415,7 +415,8 @@
 	}
 
 	list<inverted_profile> iprofiles
-		= invert_profiles(classes, options::extra_found_images);
+		= invert_profiles(options::archive_path, classes,
+				  options::extra_found_images);
 
 	report_image_errors(iprofiles);
 
@@ -423,7 +424,8 @@
 	list<inverted_profile>::iterator const end = iprofiles.end();
 
 	for (; it != end; ++it)
-		populate_for_image(samples, *it, options::symbol_filter);
+		populate_for_image(options::archive_path, samples,
+			*it, options::symbol_filter);
 
 	output_header();
 
--- oprofile-0.8.1-0.20040621.archive4/pp/opreport_options.h.orig	2004-02-02 \
                16:51:30.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opreport_options.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -23,6 +23,7 @@
 class merge_option;
 
 namespace options {
+	extern std::string archive_path;
 	extern demangle_type demangle;
 	extern bool symbols;
 	extern bool debug_info;
--- oprofile-0.8.1-0.20040621.archive4/pp/opreport_options.cpp.orig	2004-01-20 \
                08:49:32.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opreport_options.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -29,6 +29,7 @@
 profile_classes classes;
 
 namespace options {
+	std::string archive_path;
 	demangle_type demangle = dmt_normal;
 	bool symbols;
 	bool debug_info;
@@ -199,6 +200,9 @@
 
 	list<string> sample_files = spec.generate_file_list(exclude_dependent, true);
 
+	archive_path = spec.get_archive_path();
+	cverb << vsfile << "Archive: " << archive_path << endl;
+
 	cverb << vsfile << "Matched sample files: " << sample_files.size()
 	      << endl;
 	copy(sample_files.begin(), sample_files.end(),
--- oprofile-0.8.1-0.20040621.archive4/pp/opstack.cpp.orig	2004-02-20 \
                22:53:47.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opstack.cpp	2004-06-25 12:13:58.000000000 \
-0400 @@ -62,12 +62,14 @@
 	}
 
 	list<inverted_profile> iprofiles
-		= invert_profiles(classes, options::extra_found_images);
+		= invert_profiles(options::archive_path, classes,
+				  options::extra_found_images);
 
 	report_image_errors(iprofiles);
 
 	callgraph_container cg_container;
-	cg_container.populate(iprofiles, options::extra_found_images,
+	cg_container.populate(options::archive_path, iprofiles,
+		options::extra_found_images,
 		options::debug_info, options::threshold,
 			      options::merge_by.lib);
 
--- oprofile-0.8.1-0.20040621.archive4/pp/opstack_options.h.orig	2004-02-17 \
                17:43:56.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opstack_options.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -20,6 +20,7 @@
 extern profile_classes classes;
 
 namespace options {
+	extern std::string archive_path;
 	extern demangle_type demangle;
 	extern merge_option merge_by;
 	extern bool long_filenames;
--- oprofile-0.8.1-0.20040621.archive4/pp/opstack_options.cpp.orig	2004-02-01 \
                17:34:05.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opstack_options.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -23,6 +23,7 @@
 profile_classes classes;
 
 namespace options {
+	std::string archive_path;
 	demangle_type demangle = dmt_normal;
 	bool exclude_dependent;
 	merge_option merge_by;
@@ -75,6 +76,9 @@
 	list<string> sample_files =
 		spec.generate_file_list(exclude_dependent, false);
 
+	archive_path = spec.get_archive_path();
+	cverb << vsfile << "Archive: " << archive_path << endl;
+
 	cverb << vsfile << "Matched sample files: " << sample_files.size()
 	      << endl;
 	copy(sample_files.begin(), sample_files.end(),
--- oprofile-0.8.1-0.20040621.archive4/pp/opannotate_options.cpp.orig	2004-01-20 \
                08:49:32.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opannotate_options.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -26,6 +26,7 @@
 profile_classes classes;
 
 namespace options {
+	std::string archive_path;
 	demangle_type demangle = dmt_normal;
 	string output_dir;
 	vector<string> search_dirs;
@@ -110,6 +111,9 @@
 
 	list<string> sample_files = spec.generate_file_list(exclude_dependent, true);
 
+	archive_path = spec.get_archive_path();
+	cverb << vsfile << "Archive: " << archive_path << endl;
+
 	cverb << vsfile << "Matched sample files: " << sample_files.size()
 	      << endl;
 	copy(sample_files.begin(), sample_files.end(),
--- oprofile-0.8.1-0.20040621.archive4/pp/opannotate_options.h.orig	2003-11-03 \
                18:48:50.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opannotate_options.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -21,6 +21,7 @@
 class profile_classes;
 
 namespace options {
+	extern std::string archive_path;
 	extern demangle_type demangle;
 	extern bool source;
 	extern bool assembly;
--- oprofile-0.8.1-0.20040621.archive4/pp/opgprof.cpp.orig	2004-01-24 \
                20:53:56.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opgprof.cpp	2004-06-25 12:13:58.000000000 \
-0400 @@ -270,7 +270,8 @@
 
 	bool ok = image_profile.error == image_ok;
 	// FIXME: symbol_filter would be allowed through option
-	op_bfd abfd(image_profile.image, string_filter(), ok);
+	op_bfd abfd(options::archive_path, image_profile.image,
+		    string_filter(), ok);
 	if (!ok && image_profile.error == image_ok)
 		image_profile.error = image_format_failure;
 
--- oprofile-0.8.1-0.20040621.archive4/pp/opgprof_options.cpp.orig	2004-01-20 \
                08:49:32.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opgprof_options.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -25,6 +25,7 @@
 inverted_profile image_profile;
 
 namespace options {
+	std::string archive_path;
 	string gmon_filename = "gmon.out";
 
 	// Ugly, for build only
@@ -66,7 +67,8 @@
 	size_t nr_classes = classes.v.size();
 
 	list<inverted_profile> iprofiles
-		= invert_profiles(classes, options::extra_found_images);
+		= invert_profiles(options::archive_path, classes,
+				  options::extra_found_images);
 
 	if (nr_classes == 1 && iprofiles.size() == 1) {
 		image_profile = *(iprofiles.begin());
@@ -98,12 +100,15 @@
 
 void handle_options(vector<string> const & non_options)
 {
-	cverb << vsfile << "output filename: " << options::gmon_filename
-	      << endl;
-
 	profile_spec const spec =
 		profile_spec::create(non_options, options::extra_found_images);
 
+	options::archive_path = spec.get_archive_path();
+	cverb << vsfile << "Archive: " << options::archive_path << endl;
+
+	cverb << vsfile << "output filename: " << options::gmon_filename
+	      << endl;
+
 	// we do a first try with exclude-dependent if it fails we include
 	// dependent. First try should catch "opgrof /usr/bin/make" whilst
 	// the second catch "opgprof /lib/libc-2.2.5.so"
--- oprofile-0.8.1-0.20040621.archive4/pp/opgprof_options.h.orig	2003-11-03 \
                18:48:50.000000000 -0500
+++ oprofile-0.8.1-0.20040621.archive4/pp/opgprof_options.h	2004-06-25 \
12:13:58.000000000 -0400 @@ -17,6 +17,7 @@
 #include "common_option.h"
 
 namespace options {
+	extern std::string archive_path;
 	extern std::string gmon_filename;
 }
 
--- oprofile-0.8.1-0.20040621.archive4/pp/opannotate.cpp.orig	2004-05-13 \
                16:24:21.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/pp/opannotate.cpp	2004-06-25 \
12:13:58.000000000 -0400 @@ -677,7 +677,8 @@
 	list<string> images;
 
 	list<inverted_profile> iprofiles
-		= invert_profiles(classes, options::extra_found_images);
+		= invert_profiles(options::archive_path, classes,
+				  options::extra_found_images);
 
 	report_image_errors(iprofiles);
 
@@ -686,8 +687,8 @@
 
 	bool debug_info = false;
 	for (; it != end; ++it) {
-		debug_info |= populate_for_image(*samples, *it,
-		   options::symbol_filter);
+		debug_info |= populate_for_image(options::archive_path,
+			*samples, *it, options::symbol_filter);
 		images.push_back(it->image);
 	}
 
--- oprofile-0.8.1-0.20040621.archive4/configure.in.orig	2004-05-11 \
                09:37:11.000000000 -0400
+++ oprofile-0.8.1-0.20040621.archive4/configure.in	2004-06-25 12:13:58.000000000 \
-0400 @@ -215,6 +215,7 @@
 	doc/opannotate.1 \
 	doc/opgprof.1 \
 	doc/opstack.1 \
+	doc/oparchive.1 \
 	doc/srcdoc/Doxyfile \
 	libpp/Makefile \
 	pp/Makefile \


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
oprofile-list mailing list
oprofile-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oprofile-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic