-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue#1395 : Dump on error fix #3406
Changes from 22 commits
97ff12d
629a1a9
deab153
c0e6deb
d1ffe78
11e70d3
25b602a
4719fac
1e1ce11
eb424fd
c324094
941cab0
d71f608
2237a00
53a6c12
4bfe445
46aef3a
e5efd64
7b431cb
8f4123a
c16f886
987c560
f7cb763
8de96f8
80ac56b
d11fcf7
c0d2ff5
340c22d
c82f4b5
42aeb4f
e1c8ac2
f712249
b615462
7d44943
3f99303
062a284
4ccbadb
4460e8c
7f7ce23
b434c02
8fafccd
004d5e8
ae972ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1783,6 +1783,10 @@ | |
already reported the bug, and you want to continue using the checker on a | ||
large codebase without being inundated in stack traces. | ||
|
||
\item \code{-AdumpOnErrors}: Outputs the stack trace of the program when the | ||
Checker Framework encounters an error or warning. The option also requires a | ||
boolean parameter to enables its functionality (e.g. \code{-AdumpOnErrors=true}). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The boolean shouldn't be required, see the other boolean flags above. Just passing |
||
|
||
\end{itemize} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -565,10 +565,12 @@ protected void warnUnneededSuppressions() { | |
protected void printOrStoreMessage( | ||
Diagnostic.Kind kind, String message, Tree source, CompilationUnitTree root) { | ||
assert this.currentRoot == root; | ||
StackTraceElement[] trace = Thread.currentThread().getStackTrace(); | ||
if (messageStore == null) { | ||
super.printOrStoreMessage(kind, message, source, root); | ||
printStackTrace(trace); | ||
} else { | ||
CheckerMessage checkerMessage = new CheckerMessage(kind, message, source, this); | ||
CheckerMessage checkerMessage = new CheckerMessage(kind, message, source, this, trace); | ||
messageStore.add(checkerMessage); | ||
} | ||
} | ||
|
@@ -584,6 +586,22 @@ private void printStoredMessages(CompilationUnitTree unit) { | |
if (messageStore != null) { | ||
for (CheckerMessage msg : messageStore) { | ||
super.printOrStoreMessage(msg.kind, msg.message, msg.source, unit); | ||
printStackTrace(msg.trace); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Output the given stack trace if the "dumpOnErrors" option is enabled. | ||
* | ||
* @param trace stack trace when the checker encountered a warning/error | ||
*/ | ||
private void printStackTrace(StackTraceElement[] trace) { | ||
boolean dumpOnErrors = getBooleanOption("dumpOnErrors", false); | ||
if (dumpOnErrors) { | ||
for (StackTraceElement elem : trace) { | ||
String msg = "\tat " + elem; | ||
message(Diagnostic.Kind.NOTE, msg); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want individual messages for each element. Build up one string, including line breaks, and issue one NOTE. |
||
} | ||
} | ||
} | ||
|
@@ -600,12 +618,42 @@ private static class CheckerMessage { | |
*/ | ||
final BaseTypeChecker checker; | ||
|
||
/** Stores the stack trace till the point the checker encounters an error. */ | ||
final StackTraceElement @Nullable [] trace; | ||
|
||
/** | ||
* Constructor method for checker message without stack trace storage. | ||
* | ||
* @param kind kind of diagnostic | ||
* @param message error message that needs to be printed | ||
* @param source tree element causing the error | ||
* @param checker the type-checker in use | ||
*/ | ||
private CheckerMessage( | ||
Diagnostic.Kind kind, String message, Tree source, BaseTypeChecker checker) { | ||
this(kind, message, source, checker, null); | ||
} | ||
|
||
/** | ||
* Constructor method for checker message if stack trace needs to be stored. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, there are no calls of the constructor without a trace, so why have two constructors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated the summary and removed the first redundant constructor from BaseTypeChecker. |
||
* | ||
* @param kind kind of diagnostic, for example, error or warning | ||
* @param message error message that needs to be printed | ||
* @param source tree element causing the error | ||
* @param checker the type-checker in use | ||
* @param trace the stack trace when the checker encounters an error | ||
*/ | ||
private CheckerMessage( | ||
Diagnostic.Kind kind, | ||
String message, | ||
Tree source, | ||
BaseTypeChecker checker, | ||
StackTraceElement @Nullable [] trace) { | ||
this.kind = kind; | ||
this.message = message; | ||
this.source = source; | ||
this.checker = checker; | ||
this.trace = trace; | ||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,6 +313,10 @@ | |
// org.checkerframework.framework.util.typeinference.DefaultTypeArgumentInference | ||
"showInferenceSteps", | ||
|
||
// Output stack trace when checker encounters errors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the short message I proposed for the manual. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have used the short message in my latest commit. |
||
// org.checkerframework.common.basetype.BaseTypeChecker.printStackTrace() | ||
"dumpOnErrors", | ||
wmdietl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Visualizing the CFG | ||
|
||
// Implemented in the wrapper rather than this file, but worth noting here. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the
of the program
and shorten tooutput a stack trace when reporting errors or warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the documentation in my latest commit.