kill unsafe
[hiphop-php.git] / hphp / hhbbc / debug.h
blobac6459568437c8a1ff1105e44ef2a7c62d61242f
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present 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_HHBBC_DEBUG_H_
17 #define incl_HHBBC_DEBUG_H_
19 #include "hphp/util/trace.h"
21 #include "hphp/hhbbc/misc.h"
22 #include "hphp/hhbbc/representation.h"
23 #include "hphp/hhbbc/unit-util.h"
25 namespace HPHP { namespace HHBBC {
27 //////////////////////////////////////////////////////////////////////
30 * If the hhbbc_dump trace module is on, dump the entire program to a
31 * temporary directory as readable text.
33 void debug_dump_program(const Index&, const php::Program&);
34 std::string debug_dump_to();
35 void dump_representation(const std::string& dir, const php::Unit*);
36 void dump_index(const std::string&, const Index&, const php::Unit*);
39 * Utilities for printing the state of the program after various
40 * transformations.
43 inline void banner(const char* what) {
44 TRACE_SET_MOD(hhbbc);
45 FTRACE(2, "{:-^70}\n", what);
48 inline void state_after(const char* when, const php::Unit& u) {
49 TRACE_SET_MOD(hhbbc);
50 Trace::Bump bumper{Trace::hhbbc, kSystemLibBump, is_systemlib_part(u)};
51 FTRACE(4, "{:-^70}\n{}{:-^70}\n", when, show(u), "");
54 inline void state_after(const char* when, const php::Program& program) {
55 TRACE_SET_MOD(hhbbc);
56 banner(when);
57 for (auto& u : program.units) {
58 Trace::Bump bumper{Trace::hhbbc, kSystemLibBump, is_systemlib_part(*u)};
59 FTRACE(4, "{}", show(*u));
61 banner("");
64 //////////////////////////////////////////////////////////////////////
68 #endif