make (array) of ArrayObject return the contents
[hiphop-php.git] / hphp / util / disasm.h
blob7972cc2ac1c5a1bc3aa75d81d738755e76f2b285
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 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_UTIL_DISASM_H_
17 #define incl_HPHP_UTIL_DISASM_H_
19 #ifdef HAVE_LIBXED
20 extern "C" {
21 #include <xed-interface.h>
23 #endif // HAVE_LIBXED
25 #include <ostream>
27 #include <boost/noncopyable.hpp>
29 namespace HPHP {
31 class Disasm : private boost::noncopyable {
32 public:
33 struct Options {
34 Options()
35 : m_indentLevel(0)
36 , m_printEncoding(false)
37 , m_relativeOffset(false)
38 , m_addresses(true)
39 , m_forceAttSyntax(false)
42 Options& indent(int i) {
43 m_indentLevel = i;
44 return *this;
47 Options& printEncoding(bool pe) {
48 m_printEncoding = pe;
49 return *this;
52 Options& relativeOffset(bool re) {
53 m_relativeOffset = re;
54 return *this;
57 Options& color(std::string c) {
58 m_color = std::move(c);
59 return *this;
62 Options& addresses(bool b) {
63 m_addresses = b;
64 return *this;
67 Options& forceAttSyntax(bool b) {
68 m_forceAttSyntax = b;
69 return *this;
72 int m_indentLevel;
73 bool m_printEncoding;
74 bool m_relativeOffset;
75 bool m_addresses;
76 bool m_forceAttSyntax;
77 std::string m_color;
80 /* Create a Disasm object. indentLevel spaces will be put at the beginning of
81 * each line of disassembly. If printEncoding is true, the raw hex bytes of
82 * the instructions will also be in the output. */
83 explicit Disasm(const Options& opts = Options());
85 /* Disassemble instructions. start should be the first byte of the region to
86 * disassemble and end should be the first byte past the region to
87 * disassemble. */
88 void disasm(std::ostream& out, uint8_t* start, uint8_t* end);
90 private:
91 #ifdef HAVE_LIBXED
92 xed_state_t m_xedState;
93 #endif // HAVE_LIBXED
94 const Options m_opts;
97 } // namespace HPHP
99 #endif