--- gdb-7.9.1/gdb/skip.c	2015-02-19 06:58:07.000000000 -0500
+++ gdb-7.9.1_skipdir/gdb/skip.c	2015-07-25 12:21:27.000000000 -0400
@@ -33,6 +33,11 @@
 #include "source.h"
 #include "filenames.h"
 
+#include <limits.h>     /* for realpath */
+#include <stdlib.h>     /* for realpath */
+#include <libgen.h>     /* for dirname */
+#include <string.h>     /* for strstr */
+
 struct skiplist_entry
 {
   int number;
@@ -66,6 +71,96 @@
        E = TMP)
 
 static void
+skip_dir_command (char *arg, int from_tty)
+{
+  struct skiplist_entry *e;
+  struct symtab *symtab;
+  const char *filename = NULL;
+  char * filename_realpath = NULL;
+  const char * dir_name = NULL;
+  char * dir_name_with_prefix = NULL;
+
+/*
+fprintf_filtered (gdb_stderr, _("skip_dir_command: 100:  Skipping directory...\n") );
+*/
+
+  /* If no argument was given, try to default to the last
+     displayed codepoint.  */
+  if (arg == NULL)
+    {
+/*
+fprintf_filtered (gdb_stderr, _("skip_dir_command: 200:  Skipping current directory...\n") );
+*/
+      symtab = get_last_displayed_symtab ();
+      if (symtab == NULL)
+	error (_("No default directory now."));
+
+      /* It is not a typo, symtab_to_filename_for_display woule be needlessly
+	 ambiguous.  */
+      filename = symtab_to_fullname (symtab);
+/*
+fprintf_filtered (gdb_stderr, _("skip_dir_command: 300:  symtab_to_fullname returned '%s'...\n"), filename);
+*/
+
+      /* Get realpath & dirname */
+      filename_realpath = realpath(filename, NULL);
+      if (filename_realpath)
+        {
+/*
+fprintf_filtered (gdb_stderr, _("skip_dir_command: 320:  realpath returned '%s'...\n"), filename_realpath);
+*/
+          dir_name = dirname(filename_realpath);
+/*
+fprintf_filtered (gdb_stderr, _("skip_dir_command: 340:  dirname returned '%s'...\n"), dir_name);
+*/
+        }
+      else
+	error (_("Failed to get realpath of '%s'."), filename);
+
+      /* TODO:  Consider adding just the dirname (no realpath)
+         for increased chances of matching. */
+    }
+  else
+    {
+/*
+fprintf_filtered (gdb_stderr, _("skip_dir_command: 400:  Skipping directory named '%s'...\n"), arg);
+*/
+      /* Get realpath */
+      filename_realpath = realpath(arg, NULL);
+      if(filename_realpath)
+        {
+          dir_name = filename_realpath;
+        }
+      else
+        error (_("Failed to get realpath of '%s'."), arg);
+    }
+
+  /* Allocate memory for dirname string + 'DIR:' prefix.
+     TODO:  use gdb-preferred allocator. */
+/*
+fprintf_filtered (gdb_stderr, _("skip_dir_command: 500:  Allocating %zd bytes...\n"), (strlen(dir_name) + 5) );
+*/
+  dir_name_with_prefix = malloc(strlen(dir_name) + 5);
+  if (!dir_name_with_prefix)
+    error (_("Failed to allocate tmp memory (%zd bytes)."), (strlen(dir_name) + 5) );
+
+  sprintf(dir_name_with_prefix, "DIR:%s", dir_name);
+
+  e = XCNEW (struct skiplist_entry);
+  e->filename = xstrdup (dir_name_with_prefix);
+  e->enabled = 1;
+
+  add_skiplist_entry (e);
+
+  printf_filtered (_("Directory '%s' will be skipped when stepping.\n"), dir_name);
+
+  free(dir_name_with_prefix);
+
+  if(filename_realpath)
+    free(filename_realpath);
+}
+
+static void
 skip_file_command (char *arg, int from_tty)
 {
   struct skiplist_entry *e;
@@ -335,7 +430,9 @@
 {
   int searched_for_fullname = 0;
   const char *fullname = NULL;
+  char * fullname_realpath = NULL;
   struct skiplist_entry *e;
+  const char * skiplist_entry_dirname = NULL;
 
   if (function_name == NULL)
     return 0;
@@ -352,33 +449,82 @@
 
       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,
+          /* Optimize by using memcmp */
+          if (strstr(e->filename, "DIR:") == e->filename)
+            {
+              /* Skip 'DIR:' prefix. */
+              skiplist_entry_dirname = e->filename + 4;
+
+/*
+fprintf_filtered (gdb_stderr, _("function_name_is_marked_for_skip: 100:  Checking if '%s' should be skipped based on directory '%s'...\n"), function_name, skiplist_entry_dirname );
+*/
+	      if (!searched_for_fullname)
+	        {
+                  if (function_sal->symtab != NULL)
+                    fullname = symtab_to_fullname (function_sal->symtab);
+	          searched_for_fullname = 1;
+/*
+fprintf_filtered (gdb_stderr, _("function_name_is_marked_for_skip: 200:  symtab_to_fullname returned '%s'.\n"), fullname );
+*/
+                }
+
+              /* Not sure if symtab_to_fullname does this, but need to get
+                 realpath of fullname. */
+              fullname_realpath = realpath(fullname, NULL);
+              if(fullname_realpath)
+                {
+/*
+fprintf_filtered (gdb_stderr, _("function_name_is_marked_for_skip: 300:  realpath returned '%s'...\n"), fullname_realpath );
+*/
+                  /* Just need to check if fullname_realpath begins with
+                     directory to exclude. Can optimize this w/ memcmp. */
+                  if(strstr(fullname_realpath, skiplist_entry_dirname) == fullname_realpath)
+                    {
+/*
+fprintf_filtered (gdb_stderr, _("function_name_is_marked_for_skip: 400:  File's dir '%s' is within exclude dir '%s'; skipping.\n"), fullname_realpath, skiplist_entry_dirname );
+*/
+                      return 1;
+                    }
+                }
+              else
+                error (_("Failed to get realpath of '%s'."), fullname);
+
+              if(fullname_realpath)
+                {
+                  free(fullname_realpath);
+                  fullname_realpath = NULL;
+                }
+            }
+          else
+          {
+	    /* 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;
+	      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;
-	}
+ 	    /* 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;
@@ -402,6 +548,13 @@
 If no function name is given, ignore the current function."),
                   &skiplist, "skip ", 1, &cmdlist);
 
+  c = add_cmd ("dir", class_breakpoint, skip_dir_command, _("\
+Ignore a directory (and all subdirectories) while stepping.\n\
+Usage: skip dir <DIRECTORY>\n\
+If no filename is given, ignore the current file."),
+	       &skiplist);
+  set_cmd_completer (c, filename_completer);
+
   c = add_cmd ("file", class_breakpoint, skip_file_command, _("\
 Ignore a file while stepping.\n\
 Usage: skip file [FILENAME]\n\
