2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_DEBUGGABLE_H_
17 #define incl_HPHP_DEBUGGABLE_H_
19 #include "hphp/util/base.h"
20 #include "hphp/runtime/base/util/string_buffer.h"
21 #include "hphp/runtime/base/complex_types.h"
24 ///////////////////////////////////////////////////////////////////////////////
27 * Implement this interface to report information to debugger or execute
38 typedef std::pair
<const char *, std::string
> InfoEntry
;
39 typedef std::vector
<InfoEntry
> InfoVec
;
42 static void Add(InfoVec
&out
, const char *name
, const std::string
&value
);
43 static void AddServerStats(InfoVec
&out
, const char *name
,
44 const char *statsName
= nullptr);
46 static std::string
FormatNumber(const char *fmt
, int64_t n
);
47 static std::string
FormatSize(int64_t size
);
48 static std::string
FormatTime(int64_t milliSeconds
);
51 virtual ~IDebuggable() {}
54 * Returns a map of those support bits. Tells caller which function can be
57 virtual int debuggerSupport() {
62 * Fill up vector with summary information.
64 virtual void debuggerInfo(InfoVec
&info
) {
68 * Dump detailed information to return string.
70 virtual String
debuggerDump() {
75 * Execute a debugger action.
77 virtual String
debuggerVerb(const std::string
&verb
, const StringVec
&args
) {
82 #define HPHPD_SETTINGS \
83 HPHPD_SETTING(BypassCheck, bool, false) \
84 HPHPD_SETTING(PrintLevel, int, -1) \
85 HPHPD_SETTING(SmallStep, bool, false) \
86 HPHPD_SETTING(StackArgs, bool, true) \
88 class DebuggerSettings {
90 #define HPHPD_SETTING(name, type, defval) type m_s##name;
96 #define HPHPD_SETTING(name, type, defval) m_s##name(defval),
102 #define DECLARE_DBG_SETTING \
103 DebuggerSettings m_dbgSettings; \
105 #define HPHPD_SETTING(name, type, defval) \
106 type getDebugger##name () const { \
107 return m_dbgSettings.m_s##name; \
109 void setDebugger##name (type in##name) { \
110 m_dbgSettings.m_s##name = in##name; \
114 #define DECLARE_DBG_SETTING_ACCESSORS \
117 // leaving HPHPD_SETTING defined so that DECLARE_DBG_SETTING_ACCESSORS is
120 ///////////////////////////////////////////////////////////////////////////////
123 #endif // incl_HPHP_DEBUGGABLE_H_