Re: gcov in cross-compile: have a patch, seek direction

2007-04-30 Thread Ben Elliston
On Mon, 2007-04-23 at 22:16 +0200, Danny Backx wrote:

> Gcov normally puts the files where it writes profiling information in
> the source directory. In a cross-development environment, that directory
> isn't always available.

So I discovered when debugging testsuite failures on a remote target :-)

> Gcc has support for overriding that directory at runtime.
> Unfortunately, on Windows CE, that is not always easy.

Why, is there no concept of environment variables for Windows CE
processes?  What is the real problem?

> I've patched my copy of gcc to be able to specify a different directory
> at compile-time (instead of at run time).
> 
> I can cleanup and submit my patch if there's interest.
> 
> Prior to that, I have a question : should this support be steered via
> parameters on the compiler command line, or from environment values ?

Don't use environment variables at compile time.  It makes reproducing
problems in the field extremely difficult.  We need useers to be able to
send source input plus a command line without having to further guess
their environment.

Cheers, Ben

-- 
Ben Elliston <[EMAIL PROTECTED]>
Australia Development Lab, IBM



Re: gcov in cross-compile: have a patch, seek direction

2007-05-03 Thread Danny Backx
On Tue, 2007-05-01 at 09:27 +1000, Ben Elliston wrote:
> On Mon, 2007-04-23 at 22:16 +0200, Danny Backx wrote:
> 
> > Gcov normally puts the files where it writes profiling information in
> > the source directory. In a cross-development environment, that directory
> > isn't always available.
> 
> So I discovered when debugging testsuite failures on a remote target :-)
> 
> > Gcc has support for overriding that directory at runtime.
> > Unfortunately, on Windows CE, that is not always easy.
> 
> Why, is there no concept of environment variables for Windows CE
> processes?  What is the real problem?

For all I know there's just the registry.

> > I've patched my copy of gcc to be able to specify a different directory
> > at compile-time (instead of at run time).
> > 
> > I can cleanup and submit my patch if there's interest.
> > 
> > Prior to that, I have a question : should this support be steered via
> > parameters on the compiler command line, or from environment values ?
> 
> Don't use environment variables at compile time.  It makes reproducing
> problems in the field extremely difficult.  We need useers to be able to
> send source input plus a command line without having to further guess
> their environment.

Ok, a command line option is what I have. I'll try to clean up my patch
shortly, and see if it still applies cleanly in a recent gcc tree. Our
current version is based on gcc-4.1.0. Or is a patch against that ok ?

Danny
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info


signature.asc
Description: This is a digitally signed message part


Re: gcov in cross-compile: have a patch, seek direction

2007-05-03 Thread Ben Elliston
On Thu, 2007-05-03 at 19:55 +0200, Danny Backx wrote:

> Ok, a command line option is what I have. I'll try to clean up my
> patch shortly, and see if it still applies cleanly in a recent gcc
> tree. Our current version is based on gcc-4.1.0. Or is a patch against
> that ok ?

This feature would not be accepted into GCC 4.1 or 4.2, so please bring
your patch up to date with mainline and then submit it.  I'd be
surprised if it's much work to do that.

Cheers, Ben




Re: gcov in cross-compile: have a patch, seek direction

2007-05-10 Thread Danny Backx
On Fri, 2007-05-04 at 09:49 +1000, Ben Elliston wrote:
> On Thu, 2007-05-03 at 19:55 +0200, Danny Backx wrote:
> 
> > Ok, a command line option is what I have. I'll try to clean up my
> > patch shortly, and see if it still applies cleanly in a recent gcc
> > tree. Our current version is based on gcc-4.1.0. Or is a patch against
> > that ok ?
> 
> This feature would not be accepted into GCC 4.1 or 4.2, so please bring
> your patch up to date with mainline and then submit it.  I'd be
> surprised if it's much work to do that.

As you said, it isn't much work.

Attached is a patch with a small amount of documentation but lacking a
ChangeLog entry. I'm sending it now already for you to comment on.

A usage example :
dannypc: {49} make
/home/danny/src/gcc/[EMAIL PROTECTED]/build/gcc/xgcc
-B/home/danny/src/gcc/[EMAIL PROTECTED]/build/gcc --coverage -c t.c
-fcoverage-base=/tmp  -o t1.o
/home/danny/src/gcc/[EMAIL PROTECTED]/build/gcc/xgcc
-B/home/danny/src/gcc/[EMAIL PROTECTED]/build/gcc --coverage -c t.c -o
t2.o
strings t1.o >t1.strings
strings t2.o >t2.strings
dannypc: {50} more *.strings
::
t1.strings
::
e304
Hello, world !
/tmp/t1.gcda
::
t2.strings
::
e304
Hello, world !
/home/danny/t/t2.gcda
dannypc: {51} 

If I need to change the implementation in some way, please advise.

Danny

-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
Index: doc/gcov.texi
===
--- doc/gcov.texi	(revision 124505)
+++ doc/gcov.texi	(working copy)
@@ -543,9 +543,14 @@
 absolute directory structure on the target system. The program will try
 to create the needed directory structure, if it is not already present.
 
-To support cross-profiling, a program compiled with @option{-fprofile-arcs}
-can relocate the data files based on two environment variables: 
+There are two options to support cross-profiling. A command line argument
+to the compiler (-fcoverage-base) allows you to override the directory
+stored in the object file; this happens at compile time. Alternatively,
+two runtime environment variables allow you to relocate the data files.
+Both options have effect only on programs compiled with @option{-fprofile-arcs}.
 
+The two environment variables: 
+
 @itemize @bullet
 @item
 GCOV_PREFIX contains the prefix to add to the absolute paths 
@@ -568,6 +573,12 @@
 @samp{GCOV_PREFIX=/target/run} and @samp{GCOV_PREFIX_STRIP=1}.  Such a
 setting will name the data file @file{/target/run/build/foo.gcda}.
 
+The build time command line option can be used like this :
+
[EMAIL PROTECTED]
+gcc -fcoverage-base=/target/run -fprofile-arcs -o t.exe t.c
[EMAIL PROTECTED] smallexample
+
 You must move the data files to the expected directory tree in order to
 use them for profile directed optimizations (@option{--use-profile}), or to
 use the @command{gcov} tool.
Index: toplev.h
===
--- toplev.h	(revision 124505)
+++ toplev.h	(working copy)
@@ -133,6 +133,7 @@
 extern int flag_unswitch_loops;
 extern int flag_cprop_registers;
 extern int time_report;
+extern char *coverage_base;
 
 /* Things to do with target switches.  */
 extern void print_version (FILE *, const char *);
Index: opts.c
===
--- opts.c	(revision 124505)
+++ opts.c	(working copy)
@@ -1425,6 +1425,10 @@
   fix_register (arg, 0, 0);
   break;
 
+case OPT_fcoverage_base_:
+  coverage_base = xstrdup(arg);
+  break;
+
 case OPT_fdiagnostics_show_location_:
   if (!strcmp (arg, "once"))
 	diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
Index: coverage.c
===
--- coverage.c	(revision 124505)
+++ coverage.c	(working copy)
@@ -89,6 +89,7 @@
 static char *bbg_file_name;
 static unsigned bbg_file_opened;
 static int bbg_function_announced;
+char *coverage_base = NULL;
 
 /* Name of the count data file.  */
 static char *da_file_name;
@@ -826,12 +827,24 @@
   field = build_decl (FIELD_DECL, NULL_TREE, string_type);
   TREE_CHAIN (field) = fields;
   fields = field;
-  filename = getpwd ();
-  filename = (filename && da_file_name[0] != '/'
+
+  /* Additional command line argument for cross-development */
+  if (coverage_base)
+{
+  filename = concat (coverage_base, "/", da_file_name, NULL);
+  filename_len = strlen (filename);
+  filename_string = build_string (filename_len + 1, filename);
+}
+  else
+{
+  filename = getpwd ();
+  filename = (filename && da_file_name[0] != '/'
 	  ? concat (filename, "/", da_file_name, NULL)
 	  : da_file_name);
-  filename_len = strlen (filename);
-  filename_string = build_string (filename_len + 1, filename);
+  filename_len = strlen (filename);
+  filename_string = build_string (filename_len + 1, filename);
+}
+
   if (filename !=

Re: gcov in cross-compile: have a patch, seek direction

2007-05-10 Thread Ben Elliston
On Thu, 2007-05-10 at 21:36 +0200, Danny Backx wrote:

> Attached is a patch with a small amount of documentation but lacking a
> ChangeLog entry. I'm sending it now already for you to comment on.

Please submit patches to the gcc-patches mailing list, not the main gcc
list.  Oh, and please include a ChangeLog entry: it is customary to
always include one, even for preliminary attempts.

Cheers, Ben

-- 
Ben Elliston <[EMAIL PROTECTED]>
Australia Development Lab, IBM