weed out non-file-backed mappings.  */
        gdb_assert (filename != nullptr);
 
+       if (unavailable_paths.find (filename) != unavailable_paths.end ())
+         {
+           /* We have already seen some mapping for FILENAME but failed to
+              find/open the file.  There is no point in trying the same
+              thing again so just record that the range [start, end) is
+              unavailable.  */
+           m_core_unavailable_mappings.emplace_back (start, end - start);
+           return;
+         }
+
        struct bfd *bfd = bfd_map[filename];
        if (bfd == nullptr)
          {
            if (expanded_fname == nullptr)
              {
                m_core_unavailable_mappings.emplace_back (start, end - start);
-               /* Print just one warning per path.  */
-               if (unavailable_paths.insert (filename).second)
-                 warning (_("Can't open file %s during file-backed mapping "
-                            "note processing"),
-                          filename);
+               unavailable_paths.insert (filename);
+               warning (_("Can't open file %s during file-backed mapping "
+                          "note processing"),
+                        filename);
                return;
              }
 
            if (bfd == nullptr || !bfd_check_format (bfd, bfd_object))
              {
                m_core_unavailable_mappings.emplace_back (start, end - start);
-               if (unavailable_paths.insert (filename).second)
-                 warning (_("Can't open file %s which was expanded to %s "
-                            "during file-backed mapping note processing"),
-                          filename, expanded_fname.get ());
+               unavailable_paths.insert (filename);
+               warning (_("Can't open file %s which was expanded to %s "
+                          "during file-backed mapping note processing"),
+                        filename, expanded_fname.get ());
 
                if (bfd != nullptr)
                  bfd_close (bfd);