Change-Id: I49d53f4bb7b65d32c9e1e22be89add6199ccad24 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10038 Reviewed-by: Adrien Destugues <[email protected]> Reviewed-by: Niels Sascha Reedijk <[email protected]> Tested-by: Commit checker robot <[email protected]>
45 lines
858 B
C++
45 lines
858 B
C++
/*
|
|
* Copyright © 2008 Stephan Aßmus <[email protected]>
|
|
* All rights reserved. Distributed under the terms of the MIT/X11 license.
|
|
*/
|
|
#ifndef FUNCTION_TRACER_H
|
|
#define FUNCTION_TRACER_H
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <String.h>
|
|
|
|
namespace BPrivate {
|
|
|
|
class FunctionTracer {
|
|
public:
|
|
FunctionTracer(const char* functionName, int32& depth)
|
|
: fFunctionName(functionName),
|
|
fPrepend(),
|
|
fFunctionDepth(depth)
|
|
{
|
|
fFunctionDepth++;
|
|
fPrepend.Append(' ', fFunctionDepth * 2);
|
|
|
|
printf("%s%s {\n", fPrepend.String(), fFunctionName.String());
|
|
}
|
|
|
|
~FunctionTracer()
|
|
{
|
|
// printf("%s - leave\n", fFunctionName.String());
|
|
printf("%s}\n", fPrepend.String());
|
|
fFunctionDepth--;
|
|
}
|
|
|
|
private:
|
|
BString fFunctionName;
|
|
BString fPrepend;
|
|
int32& fFunctionDepth;
|
|
};
|
|
|
|
} // namespace BPrivate
|
|
|
|
using BPrivate::FunctionTracer;
|
|
|
|
#endif // FUNCTION_TRACER_H
|