make #includes consistent
[hiphop-php.git] / hphp / runtime / base / debuggable.h
blob6d13050c5fc87a6dacc48b3e5f706173732b2778
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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"
23 namespace HPHP {
24 ///////////////////////////////////////////////////////////////////////////////
26 /**
27 * Implement this interface to report information to debugger or execute
28 * debugger commands.
30 class IDebuggable {
31 public:
32 enum Support {
33 SupportInfo = 1,
34 SupportDump = 2,
35 SupportVerb = 4,
38 typedef std::pair<const char *, std::string> InfoEntry;
39 typedef std::vector<InfoEntry> InfoVec;
41 public:
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);
50 public:
51 virtual ~IDebuggable() {}
53 /**
54 * Returns a map of those support bits. Tells caller which function can be
55 * called.
57 virtual int debuggerSupport() {
58 return 0;
61 /**
62 * Fill up vector with summary information.
64 virtual void debuggerInfo(InfoVec &info) {
67 /**
68 * Dump detailed information to return string.
70 virtual String debuggerDump() {
71 return String();
74 /**
75 * Execute a debugger action.
77 virtual String debuggerVerb(const std::string &verb, const StringVec &args) {
78 return String();
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 {
89 public:
90 #define HPHPD_SETTING(name, type, defval) type m_s##name;
91 HPHPD_SETTINGS
92 #undef HPHPD_SETTING
93 bool dummy;
95 DebuggerSettings() :
96 #define HPHPD_SETTING(name, type, defval) m_s##name(defval),
97 HPHPD_SETTINGS
98 #undef HPHPD_SETTING
99 dummy(false) {}
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 \
115 HPHPD_SETTINGS
117 // leaving HPHPD_SETTING defined so that DECLARE_DBG_SETTING_ACCESSORS is
118 // effective
120 ///////////////////////////////////////////////////////////////////////////////
123 #endif // incl_HPHP_DEBUGGABLE_H_