diff mbox

Fix annoying gcov filename handling

Message ID 201103221155.03019.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou March 22, 2011, 10:55 a.m. UTC
Hi,

this is a repost of http://gcc.gnu.org/ml/gcc-patches/2008-08/msg01389.html to 
fix the annoying gcov filename handling whereby doing

  gcov path/to/file.gcda

doesn't work since gcov drops the path and, therefore, doesn't find the file.

Tested on i586-suse-linux, OK for the mainline?


2011-03-22  Tristan Gingold  <gingold@adacore.com>
            Eric Botcazou  <ebotcazou@adacore.com>

	* gcov.c (create_file_names): If no object directory is specified,
	keep the directory of the file.
diff mbox

Patch

Index: gcov.c
===================================================================
--- gcov.c	(revision 171210)
+++ gcov.c	(working copy)
@@ -644,13 +644,12 @@  release_structures (void)
     }
 }
 
-/* Generate the names of the graph and data files. If OBJECT_DIRECTORY
-   is not specified, these are looked for in the current directory,
-   and named from the basename of the FILE_NAME sans extension. If
-   OBJECT_DIRECTORY is specified and is a directory, the files are in
-   that directory, but named from the basename of the FILE_NAME, sans
-   extension. Otherwise OBJECT_DIRECTORY is taken to be the name of
-   the object *file*, and the data files are named from that.  */
+/* Generate the names of the graph and data files.  If OBJECT_DIRECTORY
+   is not specified, these are named from FILE_NAME sans extension.  If
+   OBJECT_DIRECTORY is specified and is a directory, the files are in that
+   directory, but named from the basename of the FILE_NAME, sans extension.
+   Otherwise OBJECT_DIRECTORY is taken to be the name of the object *file*
+   and the data files are named from that.  */
 
 static void
 create_file_names (const char *file_name)
@@ -685,8 +684,8 @@  create_file_names (const char *file_name
   else
     {
       name = XNEWVEC (char, length + 1);
-      name[0] = 0;
-      base = 1;
+      strcpy (name, file_name);
+      base = 0;
     }
 
   if (base)