don't let bin2hex call strlen
[deliverable/binutils-gdb.git] / gdb / skip.c
index f8db6f855489d75385b57a5887df99153ffe2e0c..64a0254ba37160fcede121bad5b165c4d639bb0b 100644 (file)
@@ -1,6 +1,6 @@
 /* Skipping uninteresting files and functions while stepping.
 
-   Copyright (C) 2011-2013 Free Software Foundation, Inc.
+   Copyright (C) 2011-2014 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
 #include "value.h"
 #include "valprint.h"
 #include "ui-out.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "symtab.h"
 #include "gdbcmd.h"
 #include "command.h"
@@ -32,6 +32,8 @@
 #include "objfiles.h"
 #include "exceptions.h"
 #include "breakpoint.h" /* for get_sal_arch () */
+#include "source.h"
+#include "filenames.h"
 
 struct skiplist_entry
 {
@@ -69,7 +71,7 @@ static void
 skip_file_command (char *arg, int from_tty)
 {
   struct skiplist_entry *e;
-  const struct symtab *symtab;
+  struct symtab *symtab;
   const char *filename = NULL;
 
   /* If no argument was given, try to default to the last
@@ -79,8 +81,10 @@ skip_file_command (char *arg, int from_tty)
       symtab = get_last_displayed_symtab ();
       if (symtab == NULL)
        error (_("No default file now."));
-      else
-       filename = symtab->filename;
+
+      /* It is not a typo, symtab_to_filename_for_display woule be needlessly
+        ambiguous.  */
+      filename = symtab_to_fullname (symtab);
     }
   else
     {
@@ -91,12 +95,13 @@ skip_file_command (char *arg, int from_tty)
          if (!nquery (_("\
 Ignore file pending future shared library load? ")))
            return;
-
        }
+      /* Do not use SYMTAB's filename, later loaded shared libraries may match
+         given ARG but not SYMTAB's filename.  */
       filename = arg;
     }
 
-  e = XZALLOC (struct skiplist_entry);
+  e = XCNEW (struct skiplist_entry);
   e->filename = xstrdup (filename);
   e->enabled = 1;
 
@@ -290,7 +295,7 @@ skip_delete_command (char *arg, int from_tty)
 static void
 skip_function (const char *name)
 {
-  struct skiplist_entry *e = XZALLOC (struct skiplist_entry);
+  struct skiplist_entry *e = XCNEW (struct skiplist_entry);
 
   e->enabled = 1;
   e->function_name = xstrdup (name);
@@ -330,6 +335,8 @@ int
 function_name_is_marked_for_skip (const char *function_name,
                                  const struct symtab_and_line *function_sal)
 {
+  int searched_for_fullname = 0;
+  const char *fullname = NULL;
   struct skiplist_entry *e;
 
   if (function_name == NULL)
@@ -345,11 +352,35 @@ function_name_is_marked_for_skip (const char *function_name,
          && strcmp_iw (function_name, e->function_name) == 0)
        return 1;
 
-      if (e->filename != NULL && function_sal->symtab != NULL
-         && function_sal->symtab->filename != NULL
-         && compare_filenames_for_search (function_sal->symtab->filename,
-                                          e->filename))
-       return 1;
+      if (e->filename != NULL)
+       {
+         /* Check first sole SYMTAB->FILENAME.  It does not need to be
+            a substring of symtab_to_fullname as it may contain "./" etc.  */
+         if (function_sal->symtab != NULL
+             && compare_filenames_for_search (function_sal->symtab->filename,
+                                              e->filename))
+           return 1;
+
+         /* Before we invoke realpath, which can get expensive when many
+            files are involved, do a quick comparison of the basenames.  */
+         if (!basenames_may_differ
+             && (function_sal->symtab == NULL
+                 || filename_cmp (lbasename (function_sal->symtab->filename),
+                                  lbasename (e->filename)) != 0))
+           continue;
+
+         /* Get the filename corresponding to this FUNCTION_SAL, if we haven't
+            yet.  */
+         if (!searched_for_fullname)
+           {
+             if (function_sal->symtab != NULL)
+               fullname = symtab_to_fullname (function_sal->symtab);
+             searched_for_fullname = 1;
+           }
+         if (fullname != NULL
+             && compare_filenames_for_search (fullname, e->filename))
+           return 1;
+       }
     }
 
   return 0;
This page took 0.02626 seconds and 4 git commands to generate.