Class DbgTimer
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
ghidra.app.plugin.assembler.sleigh.util.DbgTimer
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
A debugging, timing, and diagnostic tool
TODO: I should probably remove this and rely on the Msg.trace() method, or at the very least, refactor this to use that.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A context for idiomatic use of theDbgTimer
in a try-with-resources blockstatic class
A (rather slow) output stream that indents every line of its output -
Field Summary
Modifier and TypeFieldDescriptionstatic final DbgTimer
An instance that prints to standard outstatic final DbgTimer
An instance that prints to /dev/nullFields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorDescriptionDbgTimer()
Create a new debugging timer, wrapping standard outDbgTimer
(OutputStream out) Create a new debugging timer, wrapping the given output stream -
Method Summary
Modifier and TypeMethodDescriptionPut the original tabbing stream backReplace the wrapped output stream (usually temporarily)Start a new, possibly long-running, task This is meant to be used idiomatically, as in a try-with-resources block:void
stop()
Stop the current taskMethods inherited from class java.io.PrintStream
append, append, append, charset, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, writeBytes
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
ACTIVE
An instance that prints to standard out -
INACTIVE
An instance that prints to /dev/null
-
-
Constructor Details
-
DbgTimer
Create a new debugging timer, wrapping the given output stream- Parameters:
out
- the stream
-
DbgTimer
public DbgTimer()Create a new debugging timer, wrapping standard out
-
-
Method Details
-
start
Start a new, possibly long-running, task This is meant to be used idiomatically, as in a try-with-resources block:try (DbgCtx dc = dbg.start("Twiddling the frobs:")) { // do some classy twiddling } // this will automatically print done and the time elapsed within the try block
This idiom is preferred because the task will be stopped even if an error occurs, if the method returns from within the block, etc.- Parameters:
message
- the message to print when the task begins- Returns:
- a context to close when the task ends
-
stop
public void stop()Stop the current taskThis will print done and the elapsed time since the start of the task. The "current task" is determined from the stack.
-
setOutputStream
Replace the wrapped output stream (usually temporarily)- Parameters:
s
- the replacement stream- Returns:
- the original stream, wrapped in a tabbing stream
- See Also:
-
resetOutputStream
Put the original tabbing stream back- Parameters:
s
- the original wrapped stream- Returns:
- the replacement stream, wrapped in a tabbing stream
- See Also:
-