1 #ifndef DUK_DEBUGGER_H_INCLUDED 2 #define DUK_DEBUGGER_H_INCLUDED 3 4 /* Debugger protocol version is defined in the public API header. */ 5 6 /* Initial bytes for markers. */ 7 #define DUK_DBG_IB_EOM 0x00 8 #define DUK_DBG_IB_REQUEST 0x01 9 #define DUK_DBG_IB_REPLY 0x02 10 #define DUK_DBG_IB_ERROR 0x03 11 #define DUK_DBG_IB_NOTIFY 0x04 12 13 /* Other initial bytes. */ 14 #define DUK_DBG_IB_INT4 0x10 15 #define DUK_DBG_IB_STR4 0x11 16 #define DUK_DBG_IB_STR2 0x12 17 #define DUK_DBG_IB_BUF4 0x13 18 #define DUK_DBG_IB_BUF2 0x14 19 #define DUK_DBG_IB_UNUSED 0x15 20 #define DUK_DBG_IB_UNDEFINED 0x16 21 #define DUK_DBG_IB_NULL 0x17 22 #define DUK_DBG_IB_TRUE 0x18 23 #define DUK_DBG_IB_FALSE 0x19 24 #define DUK_DBG_IB_NUMBER 0x1a 25 #define DUK_DBG_IB_OBJECT 0x1b 26 #define DUK_DBG_IB_POINTER 0x1c 27 #define DUK_DBG_IB_LIGHTFUNC 0x1d 28 #define DUK_DBG_IB_HEAPPTR 0x1e 29 /* The short string/integer initial bytes starting from 0x60 don't have 30 * defines now. 31 */ 32 33 /* Error codes. */ 34 #define DUK_DBG_ERR_UNKNOWN 0x00 35 #define DUK_DBG_ERR_UNSUPPORTED 0x01 36 #define DUK_DBG_ERR_TOOMANY 0x02 37 #define DUK_DBG_ERR_NOTFOUND 0x03 38 #define DUK_DBG_ERR_APPLICATION 0x04 39 40 /* Commands and notifys initiated by Duktape. */ 41 #define DUK_DBG_CMD_STATUS 0x01 42 #define DUK_DBG_CMD_PRINT 0x02 43 #define DUK_DBG_CMD_ALERT 0x03 44 #define DUK_DBG_CMD_LOG 0x04 45 #define DUK_DBG_CMD_THROW 0x05 46 #define DUK_DBG_CMD_DETACHING 0x06 47 #define DUK_DBG_CMD_APPNOTIFY 0x07 48 49 /* Commands initiated by debug client. */ 50 #define DUK_DBG_CMD_BASICINFO 0x10 51 #define DUK_DBG_CMD_TRIGGERSTATUS 0x11 52 #define DUK_DBG_CMD_PAUSE 0x12 53 #define DUK_DBG_CMD_RESUME 0x13 54 #define DUK_DBG_CMD_STEPINTO 0x14 55 #define DUK_DBG_CMD_STEPOVER 0x15 56 #define DUK_DBG_CMD_STEPOUT 0x16 57 #define DUK_DBG_CMD_LISTBREAK 0x17 58 #define DUK_DBG_CMD_ADDBREAK 0x18 59 #define DUK_DBG_CMD_DELBREAK 0x19 60 #define DUK_DBG_CMD_GETVAR 0x1a 61 #define DUK_DBG_CMD_PUTVAR 0x1b 62 #define DUK_DBG_CMD_GETCALLSTACK 0x1c 63 #define DUK_DBG_CMD_GETLOCALS 0x1d 64 #define DUK_DBG_CMD_EVAL 0x1e 65 #define DUK_DBG_CMD_DETACH 0x1f 66 #define DUK_DBG_CMD_DUMPHEAP 0x20 67 #define DUK_DBG_CMD_GETBYTECODE 0x21 68 #define DUK_DBG_CMD_APPREQUEST 0x22 69 #define DUK_DBG_CMD_GETHEAPOBJINFO 0x23 70 #define DUK_DBG_CMD_GETOBJPROPDESC 0x24 71 #define DUK_DBG_CMD_GETOBJPROPDESCRANGE 0x25 72 73 /* The low 8 bits map directly to duk_hobject.h DUK_PROPDESC_FLAG_xxx. 74 * The remaining flags are specific to the debugger. 75 */ 76 #define DUK_DBG_PROPFLAG_INTERNAL (1 << 8) 77 78 #if defined(DUK_USE_DEBUGGER_SUPPORT) 79 DUK_INTERNAL_DECL void duk_debug_do_detach(duk_heap *heap); 80 81 DUK_INTERNAL_DECL duk_bool_t duk_debug_read_peek(duk_hthread *thr); 82 DUK_INTERNAL_DECL void duk_debug_write_flush(duk_hthread *thr); 83 84 DUK_INTERNAL_DECL void duk_debug_skip_bytes(duk_hthread *thr, duk_size_t length); 85 DUK_INTERNAL_DECL void duk_debug_skip_byte(duk_hthread *thr); 86 87 DUK_INTERNAL_DECL void duk_debug_read_bytes(duk_hthread *thr, duk_uint8_t *data, duk_size_t length); 88 DUK_INTERNAL_DECL duk_uint8_t duk_debug_read_byte(duk_hthread *thr); 89 DUK_INTERNAL_DECL duk_int32_t duk_debug_read_int(duk_hthread *thr); 90 DUK_INTERNAL_DECL duk_hstring *duk_debug_read_hstring(duk_hthread *thr); 91 /* XXX: exposed duk_debug_read_pointer */ 92 /* XXX: exposed duk_debug_read_buffer */ 93 /* XXX: exposed duk_debug_read_hbuffer */ 94 #if 0 95 DUK_INTERNAL_DECL duk_heaphdr *duk_debug_read_heapptr(duk_hthread *thr); 96 #endif 97 #if defined(DUK_USE_DEBUGGER_INSPECT) 98 DUK_INTERNAL_DECL duk_heaphdr *duk_debug_read_any_ptr(duk_hthread *thr); 99 #endif 100 DUK_INTERNAL_DECL duk_tval *duk_debug_read_tval(duk_hthread *thr); 101 102 DUK_INTERNAL_DECL void duk_debug_write_bytes(duk_hthread *thr, const duk_uint8_t *data, duk_size_t length); 103 DUK_INTERNAL_DECL void duk_debug_write_byte(duk_hthread *thr, duk_uint8_t x); 104 DUK_INTERNAL_DECL void duk_debug_write_unused(duk_hthread *thr); 105 DUK_INTERNAL_DECL void duk_debug_write_undefined(duk_hthread *thr); 106 #if defined(DUK_USE_DEBUGGER_INSPECT) 107 DUK_INTERNAL_DECL void duk_debug_write_null(duk_hthread *thr); 108 #endif 109 DUK_INTERNAL_DECL void duk_debug_write_boolean(duk_hthread *thr, duk_uint_t val); 110 DUK_INTERNAL_DECL void duk_debug_write_int(duk_hthread *thr, duk_int32_t x); 111 DUK_INTERNAL_DECL void duk_debug_write_uint(duk_hthread *thr, duk_uint32_t x); 112 DUK_INTERNAL_DECL void duk_debug_write_string(duk_hthread *thr, const char *data, duk_size_t length); 113 DUK_INTERNAL_DECL void duk_debug_write_cstring(duk_hthread *thr, const char *data); 114 DUK_INTERNAL_DECL void duk_debug_write_hstring(duk_hthread *thr, duk_hstring *h); 115 DUK_INTERNAL_DECL void duk_debug_write_buffer(duk_hthread *thr, const char *data, duk_size_t length); 116 DUK_INTERNAL_DECL void duk_debug_write_hbuffer(duk_hthread *thr, duk_hbuffer *h); 117 DUK_INTERNAL_DECL void duk_debug_write_pointer(duk_hthread *thr, void *ptr); 118 #if defined(DUK_USE_DEBUGGER_DUMPHEAP) || defined(DUK_USE_DEBUGGER_INSPECT) 119 DUK_INTERNAL_DECL void duk_debug_write_heapptr(duk_hthread *thr, duk_heaphdr *h); 120 #endif 121 DUK_INTERNAL_DECL void duk_debug_write_hobject(duk_hthread *thr, duk_hobject *obj); 122 DUK_INTERNAL_DECL void duk_debug_write_tval(duk_hthread *thr, duk_tval *tv); 123 #if 0 /* unused */ 124 DUK_INTERNAL_DECL void duk_debug_write_request(duk_hthread *thr, duk_small_uint_t command); 125 #endif 126 DUK_INTERNAL_DECL void duk_debug_write_reply(duk_hthread *thr); 127 DUK_INTERNAL_DECL void duk_debug_write_error_eom(duk_hthread *thr, duk_small_uint_t err_code, const char *msg); 128 DUK_INTERNAL_DECL void duk_debug_write_notify(duk_hthread *thr, duk_small_uint_t command); 129 DUK_INTERNAL_DECL void duk_debug_write_eom(duk_hthread *thr); 130 131 DUK_INTERNAL_DECL duk_uint_fast32_t duk_debug_curr_line(duk_hthread *thr); 132 DUK_INTERNAL_DECL void duk_debug_send_status(duk_hthread *thr); 133 #if defined(DUK_USE_DEBUGGER_THROW_NOTIFY) 134 DUK_INTERNAL_DECL void duk_debug_send_throw(duk_hthread *thr, duk_bool_t fatal); 135 #endif 136 137 DUK_INTERNAL_DECL void duk_debug_halt_execution(duk_hthread *thr, duk_bool_t use_prev_pc); 138 DUK_INTERNAL_DECL duk_bool_t duk_debug_process_messages(duk_hthread *thr, duk_bool_t no_block); 139 140 DUK_INTERNAL_DECL duk_small_int_t duk_debug_add_breakpoint(duk_hthread *thr, duk_hstring *filename, duk_uint32_t line); 141 DUK_INTERNAL_DECL duk_bool_t duk_debug_remove_breakpoint(duk_hthread *thr, duk_small_uint_t breakpoint_index); 142 #endif 143 144 #endif /* DUK_DEBUGGER_H_INCLUDED */ 145