Class DbgTimer
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.PrintStream
-
- ghidra.app.plugin.assembler.sleigh.util.DbgTimer
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
public class DbgTimer extends java.io.PrintStream
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
Nested Classes Modifier and Type Class Description static class
DbgTimer.DbgCtx
A context for idiomatic use of theDbgTimer
in a try-with-resources blockstatic class
DbgTimer.TabbingOutputStream
A (rather slow) output stream that indents every line of its output
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DbgTimer.TabbingOutputStream
resetOutputStream(DbgTimer.TabbingOutputStream s)
Put the original tabbing stream backDbgTimer.TabbingOutputStream
setOutputStream(java.io.OutputStream s)
Replace the wrapped output stream (usually temporarily)DbgTimer.DbgCtx
start(java.lang.Object message)
Start a new, possibly long-running, taskvoid
stop()
Stop the current task This will print done and the elapsed time since the start of the task.-
Methods inherited from class java.io.PrintStream
append, append, append, 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
-
-
-
-
Method Detail
-
start
public DbgTimer.DbgCtx start(java.lang.Object message)
Start a new, possibly long-running, task- Parameters:
message
- the message to print when the task begins- Returns:
- a context to close when the task ends
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
-
stop
public void stop()
Stop the current task This will print done and the elapsed time since the start of the task. The "current task" is determined from the stack.
-
setOutputStream
public DbgTimer.TabbingOutputStream setOutputStream(java.io.OutputStream s)
Replace the wrapped output stream (usually temporarily)- Parameters:
s
- the replacement stream- Returns:
- the original stream, wrapped in a tabbing stream
- See Also:
resetOutputStream(TabbingOutputStream)
-
resetOutputStream
public DbgTimer.TabbingOutputStream resetOutputStream(DbgTimer.TabbingOutputStream s)
Put the original tabbing stream back- Parameters:
s
- the original wrapped stream- Returns:
- the replacement stream, wrapped in a tabbing stream
- See Also:
setOutputStream(OutputStream)
-
-