[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2017-08-27 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@bruno, what's the fate of this?


https://reviews.llvm.org/D22638



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2017-04-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

How do we proceed with this. Shall we close it?


https://reviews.llvm.org/D22638



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks a lot for the pointers!

I will definitely try them. What I proposed here is something similar to what 
llvm does that dumps logging messages, it should be complementary to your 
debugging aids.

Manman

In https://reviews.llvm.org/D22638#572753, @v.g.vassilev wrote:

> I am not sure whether that's useful for debugging out-of-date issues but this 
> is what I use and it is helpful.
>
> Some debugging aids (suggested by Richard Smith):
>
>   -fdiagnostics-show-note-include-stack will tell you which module a note 
> comes from
>   #pragma clang __debug dump X allows you to produce an AST dump from within 
> a source file, so you can see which modules declare a given name
>   #pragma clang __debug macro M allows you to dump a macro, which can be 
> useful to see which module(s) export visible include guards for a header
>   
>
> If a name is not visible in a modules build but is visible in a non-modules 
> build, i usually find that's due to one of two things
>
>   some part of the machinery that provides it depends on macro definitions 
> leaking into a modular header from outside, or
>   there is an include cycle involving a modular header and a non-modular 
> header



https://reviews.llvm.org/D22638



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

Also, creduce (I've specialized it a bit for modules) helps reducing the 
modules complexity 
(https://github.com/vgvassilev/creduce/blob/master/USAGE.md#reducing-clang-c-modules-bugs).
 After reduction, the debugger is much more useful.


https://reviews.llvm.org/D22638



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-10-18 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

I am not sure whether that's useful for debugging out-of-date issues but this 
is what I use and it is helpful.

Some debugging aids (suggested by Richard Smith):

  -fdiagnostics-show-note-include-stack will tell you which module a note comes 
from
  #pragma clang __debug dump X allows you to produce an AST dump from within a 
source file, so you can see which modules declare a given name
  #pragma clang __debug macro M allows you to dump a macro, which can be useful 
to see which module(s) export visible include guards for a header

If a name is not visible in a modules build but is visible in a non-modules 
build, i usually find that's due to one of two things

  some part of the machinery that provides it depends on macro definitions 
leaking into a modular header from outside, or
  there is an include cycle involving a modular header and a non-modular header


https://reviews.llvm.org/D22638



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D22638: Module: add debug_type to dump debugging messages related to modules being out of date

2016-07-21 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.

This is a patch I applied internally to debug out-of-date issues. In general is 
this the right way to add debugging messages in clang frontend?


https://reviews.llvm.org/D22638

Files:
  lib/Frontend/CompilerInstance.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ModuleManager.cpp

Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -16,6 +16,7 @@
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Serialization/GlobalModuleIndex.h"
 #include "clang/Serialization/ModuleManager.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
@@ -25,6 +26,8 @@
 #include "llvm/Support/GraphWriter.h"
 #endif
 
+#define DEBUG_TYPE "module-manager"
+
 using namespace clang;
 using namespace serialization;
 
@@ -76,6 +79,8 @@
   }
   if (lookupModuleFile(FileName, ExpectedSize, ExpectedModTime, Entry)) {
 ErrorStr = "module file out of date";
+DEBUG(llvm::dbgs() << "In addModule: size or modtime mismatch "
+   << FileName << '\n';);
 return OutOfDate;
   }
 
@@ -169,6 +174,8 @@
   assert(ImportedBy);
 delete ModuleEntry;
   }
+  DEBUG(llvm::dbgs() << "In addModule: signature mismatch "
+ << FileName << '\n';);
   return OutOfDate;
 }
   }
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -51,6 +51,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Bitcode/BitstreamWriter.h"
 #include "llvm/Support/Compression.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -62,6 +63,8 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "module-astwriter"
+
 using namespace clang;
 using namespace clang::serialization;
 
@@ -4113,6 +4116,7 @@
 uint64_t ASTWriter::WriteAST(Sema , const std::string ,
  Module *WritingModule, StringRef isysroot,
  bool hasErrors) {
+  DEBUG(llvm::dbgs() << "In WriteAST: " << OutputFile << '\n';);
   WritingAST = true;
 
   ASTHasCompilerErrors = hasErrors;
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -49,6 +49,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/Support/Compression.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -60,6 +61,8 @@
 #include 
 #include 
 
+#define DEBUG_TYPE "module-astreader"
+
 using namespace clang;
 using namespace clang::serialization;
 using namespace clang::serialization::reader;
@@ -364,6 +367,8 @@
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror=" +
   Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str();
+DEBUG(llvm::dbgs() << "In checkDiagnosticGroupMappings: DiagID "
+   << Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str() << '\n';);
 return true;
   }
 }
@@ -390,27 +395,39 @@
 if (StoredDiags.getSuppressSystemWarnings()) {
   if (Complain)
 Diags.Report(diag::err_pch_diagopt_mismatch) << "-Wsystem-headers";
+  DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: suppress system warnings"
+ << ": IsSystem "
+ << IsSystem << '\n';);
   return true;
 }
   }
 
   if (Diags.getWarningsAsErrors() && !StoredDiags.getWarningsAsErrors()) {
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror";
+DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: warnings as errors"
+   << ": IsSystem "
+   << IsSystem << '\n';);
 return true;
   }
 
   if (Diags.getWarningsAsErrors() && Diags.getEnableAllWarnings() &&
   !StoredDiags.getEnableAllWarnings()) {
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-Weverything -Werror";
+DEBUG(llvm::dbgs() << "In checkDiagnosticMappings: enable all warnings"
+   << ": IsSystem "
+   << IsSystem << '\n';);
 return true;
   }
 
   if (isExtHandlingFromDiagsError(Diags) &&
   !isExtHandlingFromDiagsError(StoredDiags)) {
 if (Complain)
   Diags.Report(diag::err_pch_diagopt_mismatch) << "-pedantic-errors";
+DEBUG(llvm::dbgs()