Use custom AssemblyAnnotationWriter to improve vasm/llvm printing
[hiphop-php.git] / hphp / runtime / vm / php-debug.cpp
blob6415e902d5a2443b3698bb1a322902e6664334e3
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 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 +----------------------------------------------------------------------+
17 #include <stdlib.h>
19 #include <set>
20 #include <string>
21 #include <vector>
23 #include "hphp/util/debug.h"
24 #include "hphp/util/text-util.h"
25 #include "hphp/util/trace.h"
27 #ifndef DEBUG
29 * Forcefully always compile this unit with debug enabled, to permit mixing
30 * and matching of optimized and unoptimized binaries.
32 #define DEBUG
33 #endif
35 using std::string;
36 using std::vector;
38 #include "hphp/runtime/vm/php-debug.h"
40 namespace HPHP {
42 struct PhpDebugger {
43 std::set<string> enabledFunctions;
45 PhpDebugger() {
46 const char *env = getenv("PHPBREAKPOINTS");
47 if (env) {
48 vector<string> names;
49 split(',', env, names, true /*ignoreEmpty*/);
50 for (size_t i = 0; i < names.size(); ++i) {
51 enabledFunctions.insert(names[i]);
56 bool isBpFunction(const char* nm) const {
57 std::set<string>::const_iterator i = enabledFunctions.find(string(nm));
58 return i != enabledFunctions.end();
62 static PhpDebugger dbg;
63 bool phpBreakpointEnabled(const char* sourceName) {
64 return dbg.isBpFunction(sourceName);
70 * Add or remove functions from the debug-set from gdb. Not exposed in
71 * header files.
73 * Usage:
74 * (gdb) call phpbreak("idx")
75 * (gdb) continue
78 void phpbreak(const char* name) {
79 HPHP::dbg.enabledFunctions.insert(std::string(name));
82 void phpdisable(const char *name) {
83 HPHP::dbg.enabledFunctions.erase(std::string(name));