public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: jkratoch@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  archer-jankratochvil-absdir: Merge branch 'locsymtab-dos-isabs-macfullname-config-all-priv' into locsymtab-dos-isabs-macfullname-config-all-priv-annotate
Date: Thu, 27 Dec 2012 15:04:00 -0000	[thread overview]
Message-ID: <20121227150406.12492.qmail@sourceware.org> (raw)

The branch, archer-jankratochvil-absdir has been updated
       via  c29e29e299f6d75278327496c2d4a743c66ab165 (commit)
       via  9a38f6d701280f5a5e909efb5d486e71c1359e5b (commit)
       via  c21acbb34102cdd1b9e7615d456bbaf32b6275d6 (commit)
       via  5619f049534ca36397aca7b7b844af75ce1f294b (commit)
       via  97dd35d568ed77c71902c65dff74973d56ec1dcb (commit)
       via  cffcbdccfcc844d696d6d2ec4868ec23ca043898 (commit)
      from  6add25a872441b58aab65c7820c2c25f213374c7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit c29e29e299f6d75278327496c2d4a743c66ab165
Merge: 5619f04 9a38f6d
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Dec 27 10:55:38 2012 +0100

    Merge branch 'locsymtab-dos-isabs-macfullname-config-all-priv' into locsymtab-dos-isabs-macfullname-config-all-priv-annotate

commit 9a38f6d701280f5a5e909efb5d486e71c1359e5b
Merge: 97dd35d c21acbb
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Dec 27 10:55:37 2012 +0100

    Merge branch 'locsymtab-dos-isabs-macfullname-config-all' into locsymtab-dos-isabs-macfullname-config-all-priv

commit c21acbb34102cdd1b9e7615d456bbaf32b6275d6
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Dec 27 10:55:31 2012 +0100

    .

commit 5619f049534ca36397aca7b7b844af75ce1f294b
Merge: 6add25a 97dd35d
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Dec 27 09:31:27 2012 +0100

    Merge branch 'locsymtab-dos-isabs-macfullname-config-all-priv' into locsymtab-dos-isabs-macfullname-config-all-priv-annotate

commit 97dd35d568ed77c71902c65dff74973d56ec1dcb
Merge: 4e9b5ea cffcbdc
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Dec 27 09:31:26 2012 +0100

    Merge branch 'locsymtab-dos-isabs-macfullname-config-all' into locsymtab-dos-isabs-macfullname-config-all-priv

commit cffcbdccfcc844d696d6d2ec4868ec23ca043898
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Dec 27 09:31:19 2012 +0100

    .

-----------------------------------------------------------------------

Summary of changes:
 gdb/macrotab.c |   18 +-----------
 gdb/psymtab.c  |   67 ++++++++++++++++++++-----------------------
 gdb/symtab.c   |    8 ++--
 gdb/utils.c    |   86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/utils.h    |    3 ++
 5 files changed, 125 insertions(+), 57 deletions(-)

First 500 lines of diff:
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 1eabded..55053f5 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -501,25 +501,9 @@ struct macro_source_file *
 macro_lookup_inclusion (struct macro_source_file *source, const char *name)
 {
   /* Is SOURCE itself named NAME?  */
-  if (filename_cmp (name, source->fullname) == 0)
+  if (filenames_are_same_file (name, source->fullname))
     return source;
 
-  /* The filename in the source structure is probably a full path, but
-     NAME could be just the final component of the name.  */
-  {
-    int name_len = strlen (name);
-    int src_name_len = strlen (source->fullname);
-
-    /* We do mean < here, and not <=; if the lengths are the same,
-       then the filename_cmp above should have triggered, and we need to
-       check for a slash here.  */
-    if (name_len < src_name_len
-        && IS_DIR_SEPARATOR (source->fullname[src_name_len - name_len - 1])
-        && filename_cmp (name,
-			 source->fullname + src_name_len - name_len) == 0)
-      return source;
-  }
-
   /* It's not us.  Try all our children, and return the lowest.  */
   {
     struct macro_source_file *child;
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 3c0b79c..1dd9861 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -174,6 +174,8 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
 
   ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
   {
+    const char *fullname;
+
     /* We can skip shared psymtabs here, because any file name will be
        attached to the unshared psymtab.  */
     if (pst->user != NULL)
@@ -183,7 +185,9 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
     if (pst->anonymous)
       continue;
 
-    if (compare_filenames_for_search (pst->filename, name))
+    fullname = psymtab_to_fullname (pst);
+
+    if (compare_filenames_for_search (fullname, name))
       {
 	if (partial_map_expand_apply (objfile, name, full_path, real_path,
 				      pst, callback, data))
@@ -200,29 +204,30 @@ partial_map_symtabs_matching_filename (struct objfile *objfile,
        this symtab and use its absolute path.  */
     if (full_path != NULL)
       {
+        char *fp = xfullpath (fullname);
+	struct cleanup *cleanups = make_cleanup (xfree, fp);
+
 	gdb_assert (IS_ABSOLUTE_PATH (full_path));
-	psymtab_to_fullname (pst);
-	if (pst->fullname != NULL
-	    && FILENAME_CMP (full_path, pst->fullname) == 0)
+	if (FILENAME_CMP (fp, full_path) == 0
+	    || compare_filenames_for_search (fp, name))
 	  {
 	    if (partial_map_expand_apply (objfile, name, full_path, real_path,
 					  pst, callback, data))
-	      return 1;
+	      {
+		do_cleanups (cleanups);
+		return 1;
+	      }
 	  }
+	do_cleanups (cleanups);
       }
 
     if (real_path != NULL)
       {
-        char *rp = NULL;
+	const char *rp = psymtab_to_realname (pst);
 
 	gdb_assert (IS_ABSOLUTE_PATH (real_path));
-	psymtab_to_fullname (pst);
-        if (pst->fullname != NULL)
-          {
-            rp = gdb_realpath (pst->fullname);
-            make_cleanup (xfree, rp);
-          }
-	if (rp != NULL && FILENAME_CMP (real_path, rp) == 0)
+	if (FILENAME_CMP (rp, real_path) == 0
+	    || compare_filenames_for_search (rp, name))
 	  {
 	    if (partial_map_expand_apply (objfile, name, full_path, real_path,
 					  pst, callback, data))
@@ -1196,28 +1201,24 @@ map_symbol_filenames_psymtab (struct objfile *objfile,
 static const char *
 psymtab_to_fullname (struct partial_symtab *ps)
 {
-  int r;
-
-  if (!ps)
-    return NULL;
-  if (ps->anonymous)
-    return NULL;
+  gdb_assert (!ps->anonymous);
 
   /* Use cached copy if we have it.
      We rely on forget_cached_source_info being called appropriately
      to handle cases like the file being moved.  */
-  if (ps->fullname)
-    return ps->fullname;
-
-  r = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
-
-  if (r >= 0)
+  if (ps->fullname == NULL)
     {
-      close (r);
-      return ps->fullname;
-    }
+      int fd = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
 
-  return NULL;
+      if (fd >= 0)
+	close (fd);
+      else if (ps->dirname == NULL)
+	ps->fullname = xstrdup (ps->filename);
+      else
+	ps->fullname = concat (ps->dirname, SLASH_STRING, ps->filename, NULL);
+    } 
+
+  return ps->fullname;
 }
 
 static const char *
@@ -1227,13 +1228,7 @@ psymtab_to_realname (struct partial_symtab *ps)
     return NULL;
 
   if (ps->realname == NULL)
-    {
-      const char *fullname = psymtab_to_fullname (ps);
-
-      if (fullname == NULL)
-	return NULL;
-      ps->realname = gdb_realpath (fullname); 
-    }
+    ps->realname = gdb_realpath (psymtab_to_fullname (ps)); 
 
   return ps->realname;
 }
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 87e71ab..3beeec5 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3916,9 +3916,9 @@ rbreak_command (char *regexp, int from_tty)
     {
       if (p->msymbol == NULL)
 	{
-	  const char *filename = symtab_to_filename (p->symtab);
+	  const char *fullname = symtab_to_fullname (p->symtab);
 
-	  int newlen = (strlen (filename)
+	  int newlen = (strlen (fullname)
 			+ strlen (SYMBOL_LINKAGE_NAME (p->symbol))
 			+ 4);
 
@@ -3927,7 +3927,7 @@ rbreak_command (char *regexp, int from_tty)
 	      string = xrealloc (string, newlen);
 	      len = newlen;
 	    }
-	  strcpy (string, filename);
+	  strcpy (string, fullname);
 	  strcat (string, ":'");
 	  strcat (string, SYMBOL_LINKAGE_NAME (p->symbol));
 	  strcat (string, "'");
@@ -3936,7 +3936,7 @@ rbreak_command (char *regexp, int from_tty)
 			     p->symtab,
 			     p->symbol,
 			     p->block,
-			     filename);
+			     symtab_to_filename (p->symtab));
 	}
       else
 	{
diff --git a/gdb/utils.c b/gdb/utils.c
index 6026450..bc93b53 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3310,6 +3310,92 @@ xfullpath (const char *filename)
   return result;
 }
 
+/* Fallback for filenames_are_same_file - if the filename strings do not match
+   make the expensive query of system whether the file inodes are the same.  */
+
+static int
+filenames_are_same_file_stat (const char *filename1, const char *filename2)
+{
+  struct stat stat1, stat2;
+
+  if (stat (filename1, &stat1) != 0 || stat (filename2, &stat2) != 0)
+    return 0;
+
+  /* MS-Windows may provide just zero instead.  We have to rely on filename_cmp
+     there.  */
+  if (stat1.st_ino == 0)
+    return 0;
+
+  return stat1.st_dev == stat2.st_dev && stat1.st_ino == stat2.st_ino;
+}
+
+/* Remove "./" substrings and reduce "//" to "/" in the path *VECP parsed by
+   dirnames_to_char_ptr_vec.  */
+
+static void
+filenames_are_same_file_simplify (VEC (char_ptr) **vecp)
+{
+  int ix = 0;
+
+  while (ix < VEC_length (char_ptr, *vecp))
+    {
+      char *s = VEC_index (char_ptr, *vecp, ix);
+
+      if (*s == '\0' || strcmp (s, ".") == 0)
+	{
+	  xfree (s);
+	  VEC_ordered_remove (char_ptr, *vecp, ix);
+	}
+      else
+	ix++;
+    }
+}
+
+/* Check if FILENAME1 and FILENAME2 point to the same file inode.  Try to
+   reduce the number of stat system calls.  */
+
+int
+filenames_are_same_file (const char *filename1, const char *filename2)
+{
+  VEC (char_ptr) *vec1, *vec2;
+  struct cleanup *back_to;
+  int ix;
+
+  /* Acceleration only.  */
+  if (filename_cmp (filename1, filename2) == 0)
+    return 1;
+
+  if ((IS_ABSOLUTE_PATH (filename1) && !IS_ABSOLUTE_PATH (filename2))
+      || (!IS_ABSOLUTE_PATH (filename1) && IS_ABSOLUTE_PATH (filename2)))
+    return filenames_are_same_file_stat (filename1, filename2);
+
+  vec1 = dirnames_to_char_ptr_vec (filename1);
+  filenames_are_same_file_simplify (&vec1);
+  back_to = make_cleanup_free_char_ptr_vec (vec1);
+  vec2 = dirnames_to_char_ptr_vec (filename2);
+  filenames_are_same_file_simplify (&vec2);
+  make_cleanup_free_char_ptr_vec (vec2);
+
+  if (VEC_length (char_ptr, vec1) != VEC_length (char_ptr, vec2))
+    {
+      do_cleanups (back_to);
+      return filenames_are_same_file_stat (filename1, filename2);
+    }
+
+  for (ix = 0; ix < VEC_length (char_ptr, vec1); ix++)
+    {
+      const char *s1 = VEC_index (char_ptr, vec1, ix);
+      const char *s2 = VEC_index (char_ptr, vec2, ix);
+
+      if (filename_cmp (s1, s2) != 0)
+	{
+	  do_cleanups (back_to);
+	  return filenames_are_same_file_stat (filename1, filename2);
+	}
+    }
+
+  return 1;
+}
 
 /* This is the 32-bit CRC function used by the GNU separate debug
    facility.  An executable may contain a section named
diff --git a/gdb/utils.h b/gdb/utils.h
index 4bb6ac8..1ffabf6 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -124,6 +124,9 @@ extern char *gdb_realpath (const char *);
 
 extern char *xfullpath (const char *);
 
+extern int filenames_are_same_file (const char *filename1,
+				    const char *filename2);
+
 extern int gdb_filename_fnmatch (const char *pattern, const char *string,
 				 int flags);
 


hooks/post-receive
--
Repository for Project Archer.


             reply	other threads:[~2012-12-27 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-27 15:04 jkratoch [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-01-01 16:47 jkratoch
2012-12-25 17:00 jkratoch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121227150406.12492.qmail@sourceware.org \
    --to=jkratoch@sourceware.org \
    --cc=archer-commits@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).