Skip to content

Hide stack traces behind -Ydebug #1057

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

Merged
merged 4 commits into from
Feb 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ class ScalaSettings extends Settings.SettingGroup {
val etaExpandKeepsStar = BooleanSetting("-Yeta-expand-keeps-star", "Eta-expand varargs methods to T* rather than Seq[T]. This is a temporary option to ease transition.")
val Yinvalidate = StringSetting("-Yinvalidate", "classpath-entry", "Invalidate classpath entry before run", "")
val noSelfCheck = BooleanSetting("-Yno-self-type-checks", "Suppress check for self-type conformance among inherited members.")
val YtraceContextCreation = BooleanSetting("-Ytrace-context-creation", "Store stack trace of context creations.")
val YshowSuppressedErrors = BooleanSetting("-Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally supressed.")
val Yheartbeat = BooleanSetting("-Yheartbeat", "show heartbeat stack trace of compiler operations.")
val Yprintpos = BooleanSetting("-Yprintpos", "show tree positions.")
val YnoDeepSubtypes = BooleanSetting("-Yno-deep-subtypes", "throw an exception on deep subtyping call stacks.")
val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
val YtestPickler = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler")
val YcheckReentrant = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.")
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ object Contexts {
private var creationTrace: Array[StackTraceElement] = _

private def setCreationTrace() =
if (this.settings.debug.value)
if (this.settings.YtraceContextCreation.value)
creationTrace = (new Throwable).getStackTrace().take(20)

/** Print all enclosing context's creation stacktraces */
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ object Denotations {
try info.signature
catch { // !!! DEBUG
case scala.util.control.NonFatal(ex) =>
println(s"cannot take signature of ${info.show}")
ctx.println(s"cannot take signature of ${info.show}")
throw ex
}
case _ => Signature.NotAMethod
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3386,7 +3386,7 @@ object Types {
class MissingType(pre: Type, name: Name)(implicit ctx: Context) extends TypeError(
i"""cannot resolve reference to type $pre.$name
|the classfile defining the type might be missing from the classpath${otherReason(pre)}""".stripMargin) {
printStackTrace()
if (ctx.debug) printStackTrace()
}

private def otherReason(pre: Type)(implicit ctx: Context): String = pre match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
val ex = new BadSignature(
sm"""error reading Scala signature of $classRoot from $source:
|error occurred at position $readIndex: $msg""")
/*if (debug)*/ original.getOrElse(ex).printStackTrace() // !!! DEBUG
if (ctx.debug) original.getOrElse(ex).printStackTrace()
throw ex
}

Expand Down Expand Up @@ -423,7 +423,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
owner.info.decls.checkConsistent()
if (slowSearch(name).exists)
System.err.println(i"**** slow search found: ${slowSearch(name)}")
new Exception().printStackTrace()
if (ctx.debug) Thread.dumpStack()
ctx.newStubSymbol(owner, name, source)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/printing/PlainPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PlainPrinter(_ctx: Context) extends Printer {

protected def recursionLimitExceeded() = {
ctx.warning("Exceeded recursion depth attempting to print.")
(new Throwable).printStackTrace
if (ctx.debug) Thread.dumpStack()
}

/** If true, tweak output so it is the same before and after pickling */
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/printing/Printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait Printers { this: Context =>
/** A function creating a printer */
def printer = {
val pr = printerFn(this)
if (this.debug) pr.plain else pr
if (this.settings.YplainPrinter.value) pr.plain else pr
}
}

2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/reporting/ConsoleReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ConsoleReporter(
if (reader != null) {
val response = reader.read().asInstanceOf[Char].toLower
if (response == 'a' || response == 's') {
(new Exception).printStackTrace()
Thread.dumpStack()
if (response == 'a')
sys.exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/transform/PatternMatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
private[TreeMakers] def incorporateOuterRebinding(outerSubst: Rebindings): Unit = {
if (currSub ne null) {
ctx.debuglog("BUG: incorporateOuterRebinding called more than once for " + ((this, currSub, outerSubst)))
Thread.dumpStack()
if (ctx.debug) Thread.dumpStack()
}
else currSub = outerSubst >> rebindings
}
Expand Down