From: <dan...@us...> - 2007-06-02 12:46:30
|
Revision: 926 http://svn.sourceforge.net/cegcc/?rev=926&view=rev Author: dannybackx Date: 2007-06-02 05:46:10 -0700 (Sat, 02 Jun 2007) Log Message: ----------- Put this code in SVN, has been on my disk for too long. This is the -fcoverage-base option that allows you to specify at compile time where the application will put the coverage files. This has been submitted to gcc-patches. Modified Paths: -------------- trunk/cegcc/src/gcc/gcc/ChangeLog.ce trunk/cegcc/src/gcc/gcc/common.opt trunk/cegcc/src/gcc/gcc/coverage.c trunk/cegcc/src/gcc/gcc/doc/gcov.texi trunk/cegcc/src/gcc/gcc/libgcov.c trunk/cegcc/src/gcc/gcc/opts.c trunk/cegcc/src/gcc/gcc/toplev.h Modified: trunk/cegcc/src/gcc/gcc/ChangeLog.ce =================================================================== --- trunk/cegcc/src/gcc/gcc/ChangeLog.ce 2007-05-31 21:58:28 UTC (rev 925) +++ trunk/cegcc/src/gcc/gcc/ChangeLog.ce 2007-06-02 12:46:10 UTC (rev 926) @@ -1,3 +1,12 @@ +2007-06-02 Danny Backx <dan...@us...> + * toplev.h opts.c coverage.c common.opt libgcov.c : Add support for + -fcoverage-base option. This supports --coverage in a + cross-development environment where it is not always easy to use run + time environment variables. This option works at compile time. This + has been submitted to gcc-patches. + * doc/gcov.texi : Add documentation for -fcoverage-base. + + 2006-12-21 Danny Backx <dan...@us...> * config/arm/t-strongarm-pe config/arm/t-strongarm-elf config/arm/t-pe Modified: trunk/cegcc/src/gcc/gcc/common.opt =================================================================== --- trunk/cegcc/src/gcc/gcc/common.opt 2007-05-31 21:58:28 UTC (rev 925) +++ trunk/cegcc/src/gcc/gcc/common.opt 2007-06-02 12:46:10 UTC (rev 926) @@ -309,6 +309,10 @@ Common Report Var(flag_no_common,0) Do not put uninitialized globals in the common section +fcoverage-base= +Common Joined Var(flag_coverage_base) +Directory in which to put coverage analysis files, for cross-compiler environments + fcprop-registers Common Report Var(flag_cprop_registers) Perform a register copy-propagation optimization pass Modified: trunk/cegcc/src/gcc/gcc/coverage.c =================================================================== --- trunk/cegcc/src/gcc/gcc/coverage.c 2007-05-31 21:58:28 UTC (rev 925) +++ trunk/cegcc/src/gcc/gcc/coverage.c 2007-06-02 12:46:10 UTC (rev 926) @@ -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; @@ -813,24 +814,22 @@ TREE_CHAIN (field) = fields; fields = field; - /* - * Additional environment variable for cross-development. - */ - if (gcov_cross_prefix = getenv ("GCOV_CROSS_PREFIX")) - { - filename = concat (gcov_cross_prefix, "/", da_file_name, NULL); - filename_len = strlen (filename); - filename_string = build_string (filename_len + 1, filename); - } + /* 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 = 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); + } if (filename != da_file_name) free (filename); Modified: trunk/cegcc/src/gcc/gcc/doc/gcov.texi =================================================================== --- trunk/cegcc/src/gcc/gcc/doc/gcov.texi 2007-05-31 21:58:28 UTC (rev 925) +++ trunk/cegcc/src/gcc/gcc/doc/gcov.texi 2007-06-02 12:46:10 UTC (rev 926) @@ -543,10 +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 on the target -platform, or one on the host platform: +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 @@ -559,11 +563,6 @@ @emph{Note:} GCOV_PREFIX_STRIP has no effect if GCOV_PREFIX is undefined, empty or non-absolute. - -@item -GCOV_CROSS_PREFIX is a host platform environment variable. Use it to specify -a target directory to prefix the compiled file name with, replacing the -compile directory. @end itemize For example, if the object file @file{/user/build/foo.o} was built with @@ -574,13 +573,19 @@ @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}. -Alternatively, you can set @samp{GCOV_CROSS_PREFIX=/target/run/build} when +Alternatively, you can use @samp{-fcoverage-base=/target/run/build} when compiling, to achieve the same effect. The object file will no longer contain the information @file{/user/build/foo.o} but @file{/target/run/build/foo.o}. The host and target mechanisms are independent of each other, so they can be used together. +The build time command line option can be used like this : + +@smallexample +gcc -fcoverage-base=/target/run -fprofile-arcs -o t.exe t.c +@end 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. Modified: trunk/cegcc/src/gcc/gcc/libgcov.c =================================================================== --- trunk/cegcc/src/gcc/gcc/libgcov.c 2007-05-31 21:58:28 UTC (rev 925) +++ trunk/cegcc/src/gcc/gcc/libgcov.c 2007-06-02 12:46:10 UTC (rev 926) @@ -328,7 +328,17 @@ #endif if (!gcov_open (gi_filename)) { +#ifndef UNDER_CE fprintf (stderr, "profiling:%s:Cannot open\n", gi_filename); +#else + { + wchar_t x[256]; + int l = strlen(gi_filename); + l = (l < 256) ? l : 255; + mbstowcs(x, gi_filename, l); + MessageBoxW(0, x, L"gcov_open couldn't open file", 0); + } +#endif continue; } } Modified: trunk/cegcc/src/gcc/gcc/opts.c =================================================================== --- trunk/cegcc/src/gcc/gcc/opts.c 2007-05-31 21:58:28 UTC (rev 925) +++ trunk/cegcc/src/gcc/gcc/opts.c 2007-06-02 12:46:10 UTC (rev 926) @@ -836,6 +836,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; Modified: trunk/cegcc/src/gcc/gcc/toplev.h =================================================================== --- trunk/cegcc/src/gcc/gcc/toplev.h 2007-05-31 21:58:28 UTC (rev 925) +++ trunk/cegcc/src/gcc/gcc/toplev.h 2007-06-02 12:46:10 UTC (rev 926) @@ -132,6 +132,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 *); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |