From 0ce571055abc30979c9997398cb70b168735b04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 14 Sep 2008 18:46:26 +0000 Subject: [PATCH] This class helps me with tracing function enter/leave output. It is passed a static integer that it uses for indentation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27506 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/shared/FunctionTracer.h | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 headers/private/shared/FunctionTracer.h diff --git a/headers/private/shared/FunctionTracer.h b/headers/private/shared/FunctionTracer.h new file mode 100644 index 0000000000..3431ad771f --- /dev/null +++ b/headers/private/shared/FunctionTracer.h @@ -0,0 +1,46 @@ +/* + * Copyright © 2008 Stephan Aßmus + * All rights reserved. Distributed under the terms of the MIT/X11 license. + */ +#ifndef FUNCTION_TRACER_H +#define FUNCTION_TRACER_H + +#include + +#include + +namespace BPrivate { + +class FunctionTracer { +public: + FunctionTracer(const char* className, const char* functionName, + int32& depth) + : fFunctionName(), + fPrepend(), + fFunctionDepth(depth) + { + fFunctionDepth++; + fPrepend.Append(' ', fFunctionDepth * 2); + fFunctionName << className << "::" << functionName << "()"; + + 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