PageRenderTime 44ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/runtime/ext/xdebug/ext_xdebug.h

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