Cleanup of the comments
This commit is contained in:
parent
3672fd455b
commit
de5bcf9913
@ -44,14 +44,14 @@ type Scanner struct {
|
|||||||
// Scanner without exporting it.
|
// Scanner without exporting it.
|
||||||
type logger = *log.Logger
|
type logger = *log.Logger
|
||||||
|
|
||||||
// An Observer is a callback that can be registerd with Scanner.OnFound. It
|
// An Observer is a callback that can be registered with Scanner.OnFound. It
|
||||||
// will be called with a pid and an offset. Observers are called concurrently.
|
// will be called with a pid and an offset. Observers are called concurrently.
|
||||||
// They have to be thread-safe.
|
// They have to be thread-safe.
|
||||||
type Observer func(pid int, offset uint64) error
|
type Observer func(pid int, offset uint64) error
|
||||||
|
|
||||||
// NewScanner returns a new Scanner that scans all running processes for the
|
// NewScanner returns a new Scanner that scans all running processes for the
|
||||||
// given symbol name in all memory-mapped files matching the given pathglob.
|
// given symbol name in all memory-mapped files matching the given pathglob.
|
||||||
// To be useful, one or more Observer functions should be registerd with
|
// To be useful, one or more Observer functions should be registered with
|
||||||
// Scanner.OnFound(). The scanning starts with a call of Scanner.Run().
|
// Scanner.OnFound(). The scanning starts with a call of Scanner.Run().
|
||||||
func NewScanner(symbol, pathglob string) *Scanner {
|
func NewScanner(symbol, pathglob string) *Scanner {
|
||||||
return &Scanner{
|
return &Scanner{
|
||||||
@ -67,8 +67,8 @@ func NewScanner(symbol, pathglob string) *Scanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug sets the scanner into debugging mode. It must called only once before
|
// Debug sets the scanner into debugging mode. It must be called only once
|
||||||
// a call to Scanner.Run().
|
// before a call to Scanner.Run().
|
||||||
func (S *Scanner) DebugOn() {
|
func (S *Scanner) DebugOn() {
|
||||||
// Use the embedded *log.Logger for debugging.
|
// Use the embedded *log.Logger for debugging.
|
||||||
S.debugf = S.Printf
|
S.debugf = S.Printf
|
||||||
@ -77,15 +77,15 @@ func (S *Scanner) DebugOn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setErrorf puts the Scanner into an error state with the given error
|
// setErrorf puts the Scanner into an error state with the given error
|
||||||
// statement. It also logs the error.
|
// statement. It also logs the error. setErrorf is not thread-safe.
|
||||||
func (S *Scanner) setErrorf(format string, a ...interface{}) {
|
func (S *Scanner) setErrorf(format string, a ...interface{}) {
|
||||||
S.err = fmt.Errorf(format, a...)
|
S.err = fmt.Errorf(format, a...)
|
||||||
S.Printf(format, a...)
|
S.Printf(format, a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnFound puts an Observer function into the interal queue. The functions are
|
// OnFound puts an Observer function into the internal queue. The functions
|
||||||
// called in sequence in their own goroutine whenever the scanner finds the
|
// are called in sequence in their own goroutine whenever the scanner finds the
|
||||||
// symbol in the a running program. That implies that an Observer has to be
|
// symbol in a running program. That implies that an Observer has to be
|
||||||
// thread-safe. Errors from the observers will be logged.
|
// thread-safe. Errors from the observers will be logged.
|
||||||
//
|
//
|
||||||
// Calling OnFound is not thread-safe.
|
// Calling OnFound is not thread-safe.
|
||||||
@ -94,10 +94,10 @@ func (S *Scanner) OnFound(fun Observer) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run starts the scanning process. It scans the maps file all processes in
|
// Run starts the scanning process. It scans the entries of all /proc/NNN/maps
|
||||||
// /proc for pathnames that match the provided pathglob and that are ELF
|
// files for pathnames that match the provided path-glob and are executables or
|
||||||
// executables or shared libraries. It searches for the provided symbol in
|
// shared libraries in ELF formmat. It searches for the provided symbol in
|
||||||
// those files and calls the registered Observer functions concurrently with
|
// those files and calls the registered Observer functions, concurrently, with
|
||||||
// the pid and offset of the symbol.
|
// the pid and offset of the symbol.
|
||||||
//
|
//
|
||||||
// Run will return an error if it couldn't read the proc filesystem. Otherwise
|
// Run will return an error if it couldn't read the proc filesystem. Otherwise
|
||||||
|
Loading…
Reference in New Issue
Block a user