Remove xdebug.error_report_stacks
[hiphop-php.git] / hphp / runtime / ext / xdebug / ext_xdebug.h
blobce8d602efd17346537ad0b2e71b5b749b5fd84bd
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1997-2010 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #ifndef incl_HPHP_EXT_XDEBUG_H_
19 #define incl_HPHP_EXT_XDEBUG_H_
21 #include <folly/Optional.h>
23 #include "hphp/runtime/ext/extension.h"
24 #include "hphp/util/thread-local.h"
25 #include "hphp/util/timer.h"
27 namespace HPHP {
29 struct XDebugServer;
31 ///////////////////////////////////////////////////////////////////////////////
33 #define XDEBUG_NAME "xdebug"
34 #define XDEBUG_VERSION NO_EXTENSION_VERSION_YET
35 #define XDEBUG_AUTHOR "HHVM"
36 #define XDEBUG_COPYRIGHT "Copyright (c) 2002-2013 by Derick Rethans"
37 #define XDEBUG_COPYRIGHT_SHORT "Copyright (c) 2002-2013"
38 #define XDEBUG_URL "http://hhvm.com/"
40 #define OUTPUT_NOT_CHECKED -1
41 #define OUTPUT_IS_TTY 1
42 #define OUTPUT_NOT_TTY 0
44 // TODO(#3704) Not all of these should be thread local and settable via ini_set
45 // Request Local ini config settings
46 // Different from php5 xdebug:
47 // framebuf_size:
48 // Added option specifying the initial number of frames the frame buffer will
49 // hold when xdebug needs to turn frame tracing/profiling on. By default this
50 // takes on 100,000, which is significantly smaller than the 2 million frames
51 // provided by the internal trace profiler, which is good, since it is very
52 // easy to turn on a feature requiring tracing/profiling support, and a huge
53 // memory hit is not expected.
54 // framebuf_expansion:
55 // Added option specifying the amount to increase the framebuffer by each
56 // time we have to resize. The previous size is multiplied by this number.
57 // By default this takes on the value 1.5 which is slightly higher than
58 // the internal trace profiler due to the decrease in initial buffer size.
59 // remote_timeout:
60 // Added option specifying the timeout to use for remote debugging, in
61 // seconds. By default, .2 (200ms).
63 // Unimplemented:
64 // extended_info, coverage_enable:
65 // unused because enabling/disabling these would have no effect on hhvm
66 // since we can toggle tracking the required information at runtime
67 // collect_vars:
68 // Unused because we can always get the variables at runtime
69 // collect_assignments:
70 // Currently unimplemented as hhvm does not have infrastructure for this.
71 // manual_url:
72 // This is not used in php5 xdebug, so it is not implemented
73 // force_display_errors:
74 // This is not relevant in hhvm as force_display_errors is always on, it is
75 // either stdout or stderr. In php, it could be a boolean in old versions.
76 // show_exception_trace:
77 // TODO(#3704) Will be implemented with error handling
78 // default_enable, dump_globals, file_link_format, show_local_vars:
79 // TODO(#3704) Will be implemented with stack trace printing
80 // cli_color, collect_includes, collect_params, collect_return,
81 // overload_var_dump, var_display_max_children, var_display_max_data,
82 // var_display_max_depth:
83 // TODO(#3704) Will be implemented when var_dump is implemented
84 #define XDEBUG_CFG \
85 XDEBUG_OPT(bool, "auto_trace", AutoTrace, false) \
86 XDEBUG_OPT(int, "cli_color", CliColor, 0) \
87 XDEBUG_OPT(bool, "collect_assignments", CollectAssignments, false) \
88 XDEBUG_OPT(int, "collect_params", CollectParams, 0) \
89 XDEBUG_OPT(bool, "collect_return", CollectReturn, false) \
90 XDEBUG_OPT(bool, "collect_vars", CollectVars, false) \
91 XDEBUG_OPT(bool, "dump_undefined", DumpUndefined, false) \
92 XDEBUG_OPT(std::string, "file_link_format", FileLinkFormat, "") \
93 XDEBUG_OPT(bool, "force_display_errors", ForceDisplayErrors, false) \
94 XDEBUG_OPT(uint64_t, "framebuf_size", FramebufSize, 100000) \
95 XDEBUG_OPT(double, "framebuf_expansion", FramebufExpansion, 1.5) \
96 XDEBUG_OPT(std::string, "idekey", IdeKey, "") \
97 XDEBUG_OPT(std::string, "manual_url", ManualUrl, "http://www.php.net") \
98 XDEBUG_OPT(bool, "profiler_append", ProfilerAppend, false) \
99 XDEBUG_OPT(bool, "profiler_enable", ProfilerEnable, false) \
100 XDEBUG_OPT(bool, "profiler_enable_trigger", ProfilerEnableTrigger, false) \
101 XDEBUG_OPT(std::string, "profiler_output_dir", ProfilerOutputDir, "/tmp") \
102 XDEBUG_OPT(std::string, "profiler_output_name", ProfilerOutputName, \
103 "cachegrind.out.%t") \
104 XDEBUG_OPT(bool, "remote_connect_back", RemoteConnectBack, false) \
105 XDEBUG_OPT(int, "remote_cookie_expire_time", RemoteCookieExpireTime, 3600) \
106 XDEBUG_OPT(std::string, "remote_handler", RemoteHandler, "dbgp") \
107 XDEBUG_OPT(std::string, "remote_host", RemoteHost, "localhost") \
108 XDEBUG_OPT(std::string, "remote_log", RemoteLog, "") \
109 XDEBUG_OPT(std::string, "remote_mode", RemoteMode, "req") \
110 XDEBUG_OPT(int, "remote_port", RemotePort, 9000) \
111 XDEBUG_OPT(double, "remote_timeout", RemoteTimeout, 0.2) \
112 XDEBUG_OPT(bool, "show_exception_trace", ShowExcptionTrace, false) \
113 XDEBUG_OPT(bool, "show_local_vars", ShowLocalVars, false) \
114 XDEBUG_OPT(bool, "show_mem_delta", ShowMemDelta, false) \
115 XDEBUG_OPT(bool, "trace_enable_trigger", TraceEnableTrigger, false) \
116 XDEBUG_OPT(int, "trace_format", TraceFormat, 0) \
117 XDEBUG_OPT(bool, "trace_options", TraceOptions, false) \
118 XDEBUG_OPT(std::string, "trace_output_dir", TraceOutputDir, "/tmp") \
119 XDEBUG_OPT(std::string, "trace_output_name", TraceOutputName, "trace.%c") \
120 XDEBUG_OPT(int, "var_display_max_children", VarDisplayMaxChildren, 128) \
121 XDEBUG_OPT(int, "var_display_max_data", VarDisplayMaxData, 512) \
122 XDEBUG_OPT(int, "var_display_max_depth", VarDisplayMaxDepth, 3)
124 // Config options that have corresponding hhvm runtime options
125 #define XDEBUG_MAPPED_CFG \
126 XDEBUG_OPT(bool, "scream", Scream, false) \
127 XDEBUG_OPT(int, "force_error_reporting", ForceErrorReporting, 0) \
128 XDEBUG_OPT(int, "halt_level", HaltLevel, 0) \
130 // Config options that can also be set from HDF configs.
131 #define XDEBUG_HDF_CFG \
132 XDEBUG_OPT(bool, "collect_includes", CollectIncludes, true) \
133 XDEBUG_OPT(bool, "default_enable", DefaultEnable, true) \
134 XDEBUG_OPT(bool, "dump_globals", DumpGlobals, true) \
135 XDEBUG_OPT(bool, "dump_once", DumpOnce, true) \
136 XDEBUG_OPT(int, "overload_var_dump", OverloadVarDump, 1) \
137 XDEBUG_OPT(bool, "remote_autostart", RemoteAutostart, false) \
138 XDEBUG_OPT(bool, "remote_enable", RemoteEnable, false) \
140 // xdebug.dump.* settings
141 #define XDEBUG_DUMP_CFG \
142 XDEBUG_OPT(std::string, "COOKIE", DumpCookie, "") \
143 XDEBUG_OPT(std::string, "FILES", DumpFiles, "") \
144 XDEBUG_OPT(std::string, "GET", DumpGet, "") \
145 XDEBUG_OPT(std::string, "POST", DumpPost, "") \
146 XDEBUG_OPT(std::string, "REQUEST", DumpRequest, "") \
147 XDEBUG_OPT(std::string, "SERVER", DumpServer, "") \
148 XDEBUG_OPT(std::string, "SESSION", DumpSession, "") \
150 // Options that notify the profiler on change
151 // collect_memory, collect_time:
152 // Added options specifying whether or not we should collect memory
153 // information and function start times for stack traces. These require
154 // profiling, which takes a lot of memory and slows things down, so these
155 // are disabled by default. If off, 0 will be displayed.
156 // max_nesting_level:
157 // Same as in php5 xdebug, except that the default value has been changed to
158 // 0, from 100 in order to prevent the profiler from being automatically
159 // enabled.
160 #define XDEBUG_PROF_CFG \
161 XDEBUG_OPT(bool, "collect_memory", CollectMemory, false) \
162 XDEBUG_OPT(bool, "collect_time", CollectTime, false) \
163 XDEBUG_OPT(uint64_t, "max_nesting_level", MaxNestingLevel, 0)
165 // These aren't settable via ini, but are request local globals
166 #define XDEBUG_CUSTOM_GLOBALS \
167 XDEBUG_OPT(bool, nullptr, ProfilerAttached, false) \
168 XDEBUG_OPT(int64_t, nullptr, InitTime, Timer::GetCurrentTimeMicros()) \
169 XDEBUG_OPT(XDebugServer*, nullptr, Server, nullptr) \
170 XDEBUG_OPT(folly::Optional<bool>, nullptr, OutputIsTTY, folly::none)
172 // Retrieves the value of the given xdebug global
173 #define XDEBUG_GLOBAL(name) (*XDebugExtension::name)
175 // Returns the ini name for the given hhvm configuration option.
176 #define XDEBUG_INI(name) ((XDEBUG_NAME ".") + std::string(name))
178 ///////////////////////////////////////////////////////////////////////////////
179 constexpr int64_t k_XDEBUG_CC_UNUSED = 1;
180 constexpr int64_t k_XDEBUG_CC_DEAD_CODE = 2;
181 constexpr int64_t k_XDEBUG_TRACE_APPEND = 1;
182 constexpr int64_t k_XDEBUG_TRACE_COMPUTERIZED = 2;
183 constexpr int64_t k_XDEBUG_TRACE_HTML = 4;
184 constexpr int64_t k_XDEBUG_TRACE_NAKED_FILENAME = 8;
185 constexpr int64_t k_XDEBUG_PROFILE_APPEND = 1;
186 ///////////////////////////////////////////////////////////////////////////////
187 Variant HHVM_FUNCTION(xdebug_get_profiler_filename);
188 void HHVM_FUNCTION(xdebug_var_dump, const Variant&, const Array&);
189 ///////////////////////////////////////////////////////////////////////////////
191 struct XDebugExtension final : Extension {
192 XDebugExtension() : Extension(XDEBUG_NAME, XDEBUG_VERSION) { }
194 void moduleLoad(const IniSetting::Map& ini, Hdf xdebug_hdf) override;
195 void moduleInit() override;
196 void requestInit() override;
197 void requestShutdown() override;
199 // Standard config options
200 #define XDEBUG_OPT(T, name, sym, val) static DECLARE_THREAD_LOCAL(T, sym);
201 XDEBUG_CFG
202 XDEBUG_MAPPED_CFG
203 XDEBUG_HDF_CFG
204 XDEBUG_DUMP_CFG
205 XDEBUG_PROF_CFG
206 XDEBUG_CUSTOM_GLOBALS
207 #undef XDEBUG_OPT
209 // Indicates whether the xdebug extension has been enabled via xdebug.enable
210 static bool Enable;
211 bool moduleEnabled() const override { return Enable; }
214 ///////////////////////////////////////////////////////////////////////////////
217 #endif // incl_HPHP_EXT_XDEBUG_H_