-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Merge pull request #1449 from RelationalAI/nhd-Salsa-downstream Downstream from https://github.com/RelationalAI-oss/Salsa.jl - Merge pull request #1485 from RelationalAI/compathelper/new_version/2… …020-03-28-00-14-03-879-1646924221 CompatHelper: bump compat for "PProf" to "1.0" - Merge pull request #1523 from RelationalAI/nhd-Salsa-display-dependen… …cy-graph Add Salsa inspect.jl to dump a dot graph / SVG from deps Add "SALSA_TRACE" logging for `get!()`; use `check_ENV` in Salsa. - Merge pull request #1590 from RelationalAI/nhd-Salsa-downstream Downstream #10 - Merge pull request #1628 from RelationalAI/nhd-salsa-tracing-fix Fix up Salsa trace to not dump the whole Input map in log.
- Loading branch information
Showing
4 changed files
with
107 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,78 @@ | ||
module DebugMode | ||
module Debug | ||
|
||
export @debug_mode, DBG | ||
export @debug_mode, enable_debug, disable_debug, enable_trace_logging, disable_trace_logging | ||
|
||
# This file was modeled on the debug mode found in src/QueryEvaluator/trie_interface.jl | ||
|
||
DBG = true | ||
# `static_debug_mode` is a flag that enables/disables all debug mode checks | ||
const static_debug_mode = true | ||
|
||
|
||
""" | ||
`debug_mode` is a flag that enables/disables the debug mode for the query evaluator | ||
@debug_mode expr... | ||
Execute `expr` only when static and runtime debug modes are enabled. | ||
""" | ||
const debug_mode = true | ||
|
||
if debug_mode | ||
""" | ||
Execute only in debug mode | ||
""" | ||
macro debug_mode(instr) | ||
esc(:( | ||
if DBG != Nothing | ||
$instr | ||
macro debug_mode(instr) | ||
if static_debug_mode | ||
quote | ||
if debug_enabled() | ||
$(esc(instr)) | ||
end | ||
)) | ||
end | ||
else | ||
:() | ||
end | ||
end | ||
|
||
if static_debug_mode | ||
# Runtime debug mode controls | ||
function enable_debug() | ||
global _DBG = true | ||
end | ||
function disable_debug() | ||
global _DBG = false | ||
end | ||
debug_enabled() = _DBG | ||
_DBG = true | ||
|
||
|
||
# Runtime trace logging controls | ||
function enable_trace_logging() | ||
global _tracing = true | ||
end | ||
function disable_trace_logging() | ||
global _tracing = false | ||
end | ||
trace_logging_enabled() = _tracing | ||
_tracing = false | ||
else | ||
macro debug_mode(instr) | ||
# Runtime Debugging is disabled. | ||
_emit_debug_warning() = | ||
@warn """ | ||
Cannot enable runtime debug statements because debug is disabled statically. | ||
To enable, reload Salsa after setting `static_debug_mode = true` in: | ||
$(@__FILE__) | ||
""" | ||
|
||
enable_debug() = _emit_debug_warning() | ||
disable_debug() = _emit_debug_warning() | ||
debug_enabled() = false | ||
|
||
enable_trace_logging() = _emit_debug_warning() | ||
disable_trace_logging() = _emit_debug_warning() | ||
trace_logging_enabled() = false | ||
end | ||
|
||
macro dbg_log_trace(expr) | ||
if static_debug_mode | ||
quote | ||
if trace_logging_enabled() | ||
$(esc(expr)) | ||
end | ||
end | ||
else | ||
:() | ||
end | ||
end | ||
|
||
end # module DebugMode | ||
end # module Debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters