1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation 2425bb815Sopenharmony_ci * 3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci * You may obtain a copy of the License at 6425bb815Sopenharmony_ci * 7425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci * 9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci * limitations under the License. 14425bb815Sopenharmony_ci */ 15425bb815Sopenharmony_ci 16425bb815Sopenharmony_ci#ifndef DEBUGGER_H 17425bb815Sopenharmony_ci#define DEBUGGER_H 18425bb815Sopenharmony_ci 19425bb815Sopenharmony_ci#include "ecma-globals.h" 20425bb815Sopenharmony_ci#include "jerryscript-debugger-transport.h" 21425bb815Sopenharmony_ci 22425bb815Sopenharmony_ci#if ENABLED (JERRY_DEBUGGER) 23425bb815Sopenharmony_ci 24425bb815Sopenharmony_ci/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */ 25425bb815Sopenharmony_ci 26425bb815Sopenharmony_ci/** 27425bb815Sopenharmony_ci * Frequency of calling jerry_debugger_receive() by the VM. 28425bb815Sopenharmony_ci */ 29425bb815Sopenharmony_ci#define JERRY_DEBUGGER_MESSAGE_FREQUENCY 5 30425bb815Sopenharmony_ci 31425bb815Sopenharmony_ci/** 32425bb815Sopenharmony_ci * This constant represents that the string to be sent has no subtype. 33425bb815Sopenharmony_ci */ 34425bb815Sopenharmony_ci#define JERRY_DEBUGGER_NO_SUBTYPE 0 35425bb815Sopenharmony_ci 36425bb815Sopenharmony_ci/** 37425bb815Sopenharmony_ci * Limited resources available for the engine, so it is important to 38425bb815Sopenharmony_ci * check the maximum buffer size. It needs to be between 64 and 256 bytes. 39425bb815Sopenharmony_ci */ 40425bb815Sopenharmony_ci#if JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE < 64 || JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE > 256 41425bb815Sopenharmony_ci#error Please define the MAX_BUFFER_SIZE between 64 and 256 bytes. 42425bb815Sopenharmony_ci#endif /* JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE < 64 || JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE > 256 */ 43425bb815Sopenharmony_ci 44425bb815Sopenharmony_ci/** 45425bb815Sopenharmony_ci * Calculate the maximum number of items for a given type 46425bb815Sopenharmony_ci * which can be transmitted in one message. 47425bb815Sopenharmony_ci */ 48425bb815Sopenharmony_ci#define JERRY_DEBUGGER_SEND_MAX(type) \ 49425bb815Sopenharmony_ci ((size_t) ((JERRY_CONTEXT (debugger_max_send_size) - sizeof (jerry_debugger_send_type_t)) / sizeof (type))) 50425bb815Sopenharmony_ci 51425bb815Sopenharmony_ci/** 52425bb815Sopenharmony_ci * Calculate the size of a message when a count number of items transmitted. 53425bb815Sopenharmony_ci */ 54425bb815Sopenharmony_ci#define JERRY_DEBUGGER_SEND_SIZE(count, type) \ 55425bb815Sopenharmony_ci ((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t))) 56425bb815Sopenharmony_ci 57425bb815Sopenharmony_ci/** 58425bb815Sopenharmony_ci * Debugger operation modes: 59425bb815Sopenharmony_ci * 60425bb815Sopenharmony_ci * The debugger has two operation modes: run mode and breakpoint mode. 61425bb815Sopenharmony_ci * 62425bb815Sopenharmony_ci * In run mode the debugger server accepts only a limited number of message 63425bb815Sopenharmony_ci * types from the debugger client (e.g. stop execution, set breakpoint). 64425bb815Sopenharmony_ci * 65425bb815Sopenharmony_ci * In breakpoint mode the JavaScript execution is stopped at a breakpoint and 66425bb815Sopenharmony_ci * more message types are accepted (e.g. get backtrace, evaluate expression). 67425bb815Sopenharmony_ci * 68425bb815Sopenharmony_ci * Switching between modes: 69425bb815Sopenharmony_ci * 70425bb815Sopenharmony_ci * When the JavaScript execution stops at a breakpoint the server sends a 71425bb815Sopenharmony_ci * JERRY_DEBUGGER_BREAKPOINT_HIT message to the client. The client can only 72425bb815Sopenharmony_ci * issue breakpoint mode commands after this message is received. 73425bb815Sopenharmony_ci * 74425bb815Sopenharmony_ci * Certain breakpoint mode commands (e.g. continue) resumes the JavaScript 75425bb815Sopenharmony_ci * execution and the client must not send any breakpoint mode messages 76425bb815Sopenharmony_ci * until the JERRY_DEBUGGER_BREAKPOINT_HIT is received again. 77425bb815Sopenharmony_ci * 78425bb815Sopenharmony_ci * The debugger server starts in run mode but stops at the first available 79425bb815Sopenharmony_ci * breakpoint. 80425bb815Sopenharmony_ci */ 81425bb815Sopenharmony_ci 82425bb815Sopenharmony_ci/** 83425bb815Sopenharmony_ci * Debugger option flags. 84425bb815Sopenharmony_ci */ 85425bb815Sopenharmony_citypedef enum 86425bb815Sopenharmony_ci{ 87425bb815Sopenharmony_ci JERRY_DEBUGGER_CONNECTED = 1u << 0, /**< debugger is connected */ 88425bb815Sopenharmony_ci JERRY_DEBUGGER_BREAKPOINT_MODE = 1u << 1, /**< debugger waiting at a breakpoint */ 89425bb815Sopenharmony_ci JERRY_DEBUGGER_VM_STOP = 1u << 2, /**< stop at the next breakpoint even if disabled */ 90425bb815Sopenharmony_ci JERRY_DEBUGGER_VM_IGNORE = 1u << 3, /**< ignore all breakpoints */ 91425bb815Sopenharmony_ci JERRY_DEBUGGER_VM_IGNORE_EXCEPTION = 1u << 4, /**< debugger doesn't stop at any exception */ 92425bb815Sopenharmony_ci JERRY_DEBUGGER_VM_EXCEPTION_THROWN = 1u << 5, /**< no need to stop for this exception */ 93425bb815Sopenharmony_ci JERRY_DEBUGGER_PARSER_WAIT = 1u << 6, /**< debugger should wait after parsing is completed */ 94425bb815Sopenharmony_ci JERRY_DEBUGGER_PARSER_WAIT_MODE = 1u << 7, /**< debugger is waiting after parsing is completed */ 95425bb815Sopenharmony_ci JERRY_DEBUGGER_CLIENT_SOURCE_MODE = 1u << 8, /**< debugger waiting for client code */ 96425bb815Sopenharmony_ci JERRY_DEBUGGER_CLIENT_NO_SOURCE = 1u << 9, /**< debugger leaving the client source loop */ 97425bb815Sopenharmony_ci JERRY_DEBUGGER_CONTEXT_RESET_MODE = 1u << 10, /**< debugger and engine reinitialization mode */ 98425bb815Sopenharmony_ci#ifdef ACE_DEBUGGER_CUSTOM 99425bb815Sopenharmony_ci JERRY_DEBUGGER_TRANSPORT_STARTED = 1u << 11, /**< only can send data to client after this flag set */ 100425bb815Sopenharmony_ci#endif 101425bb815Sopenharmony_ci} jerry_debugger_flags_t; 102425bb815Sopenharmony_ci 103425bb815Sopenharmony_ci/** 104425bb815Sopenharmony_ci * Set debugger flags. 105425bb815Sopenharmony_ci */ 106425bb815Sopenharmony_ci#define JERRY_DEBUGGER_SET_FLAGS(flags) \ 107425bb815Sopenharmony_ci JERRY_CONTEXT (debugger_flags) = (JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags)) 108425bb815Sopenharmony_ci 109425bb815Sopenharmony_ci/** 110425bb815Sopenharmony_ci * Clear debugger flags. 111425bb815Sopenharmony_ci */ 112425bb815Sopenharmony_ci#define JERRY_DEBUGGER_CLEAR_FLAGS(flags) \ 113425bb815Sopenharmony_ci JERRY_CONTEXT (debugger_flags) = (JERRY_CONTEXT (debugger_flags) & (uint32_t) ~(flags)) 114425bb815Sopenharmony_ci 115425bb815Sopenharmony_ci/** 116425bb815Sopenharmony_ci * Set and clear debugger flags. 117425bb815Sopenharmony_ci */ 118425bb815Sopenharmony_ci#define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \ 119425bb815Sopenharmony_ci JERRY_CONTEXT (debugger_flags) = ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) \ 120425bb815Sopenharmony_ci & (uint32_t) ~(flags_to_clear)) 121425bb815Sopenharmony_ci 122425bb815Sopenharmony_ci/** 123425bb815Sopenharmony_ci * Types for the package. 124425bb815Sopenharmony_ci */ 125425bb815Sopenharmony_citypedef enum 126425bb815Sopenharmony_ci{ 127425bb815Sopenharmony_ci /* Messages sent by the server to client. */ 128425bb815Sopenharmony_ci /* This is a handshake message, sent once during initialization. */ 129425bb815Sopenharmony_ci JERRY_DEBUGGER_CONFIGURATION = 1, /**< debugger configuration */ 130425bb815Sopenharmony_ci /* These messages are sent by the parser. */ 131425bb815Sopenharmony_ci JERRY_DEBUGGER_PARSE_ERROR = 2, /**< parse error */ 132425bb815Sopenharmony_ci JERRY_DEBUGGER_BYTE_CODE_CP = 3, /**< byte code compressed pointer */ 133425bb815Sopenharmony_ci JERRY_DEBUGGER_PARSE_FUNCTION = 4, /**< parsing a new function */ 134425bb815Sopenharmony_ci JERRY_DEBUGGER_BREAKPOINT_LIST = 5, /**< list of line offsets */ 135425bb815Sopenharmony_ci JERRY_DEBUGGER_BREAKPOINT_OFFSET_LIST = 6, /**< list of byte code offsets */ 136425bb815Sopenharmony_ci JERRY_DEBUGGER_SOURCE_CODE = 7, /**< source code fragment */ 137425bb815Sopenharmony_ci JERRY_DEBUGGER_SOURCE_CODE_END = 8, /**< source code last fragment */ 138425bb815Sopenharmony_ci JERRY_DEBUGGER_SOURCE_CODE_NAME = 9, /**< source code name fragment */ 139425bb815Sopenharmony_ci JERRY_DEBUGGER_SOURCE_CODE_NAME_END = 10, /**< source code name last fragment */ 140425bb815Sopenharmony_ci JERRY_DEBUGGER_FUNCTION_NAME = 11, /**< function name fragment */ 141425bb815Sopenharmony_ci JERRY_DEBUGGER_FUNCTION_NAME_END = 12, /**< function name last fragment */ 142425bb815Sopenharmony_ci JERRY_DEBUGGER_WAITING_AFTER_PARSE = 13, /**< engine waiting for a parser resume */ 143425bb815Sopenharmony_ci /* These messages are generic messages. */ 144425bb815Sopenharmony_ci JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 14, /**< invalidate byte code compressed pointer */ 145425bb815Sopenharmony_ci JERRY_DEBUGGER_MEMSTATS_RECEIVE = 15, /**< memstats sent to the client */ 146425bb815Sopenharmony_ci JERRY_DEBUGGER_BREAKPOINT_HIT = 16, /**< notify breakpoint hit */ 147425bb815Sopenharmony_ci JERRY_DEBUGGER_EXCEPTION_HIT = 17, /**< notify exception hit */ 148425bb815Sopenharmony_ci JERRY_DEBUGGER_EXCEPTION_STR = 18, /**< exception string fragment */ 149425bb815Sopenharmony_ci JERRY_DEBUGGER_EXCEPTION_STR_END = 19, /**< exception string last fragment */ 150425bb815Sopenharmony_ci JERRY_DEBUGGER_BACKTRACE_TOTAL = 20, /**< number of total frames */ 151425bb815Sopenharmony_ci JERRY_DEBUGGER_BACKTRACE = 21, /**< backtrace data */ 152425bb815Sopenharmony_ci JERRY_DEBUGGER_BACKTRACE_END = 22, /**< last backtrace data */ 153425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_RESULT = 23, /**< eval result */ 154425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_RESULT_END = 24, /**< last part of eval result */ 155425bb815Sopenharmony_ci JERRY_DEBUGGER_WAIT_FOR_SOURCE = 25, /**< engine waiting for source code */ 156425bb815Sopenharmony_ci JERRY_DEBUGGER_OUTPUT_RESULT = 26, /**< output sent by the program to the debugger */ 157425bb815Sopenharmony_ci JERRY_DEBUGGER_OUTPUT_RESULT_END = 27, /**< last output result data */ 158425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_CHAIN = 28, /**< scope chain */ 159425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_CHAIN_END = 29, /**< last output of scope chain */ 160425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_VARIABLES = 30, /**< scope variables */ 161425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_VARIABLES_END = 31, /**< last output of scope variables */ 162425bb815Sopenharmony_ci JERRY_DEBUGGER_CLOSE_CONNECTION = 32, /**< close connection with the client */ 163425bb815Sopenharmony_ci JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT, /**< number of different type of output messages by the debugger */ 164425bb815Sopenharmony_ci 165425bb815Sopenharmony_ci /* Messages sent by the client to server. */ 166425bb815Sopenharmony_ci 167425bb815Sopenharmony_ci /* The following messages are accepted in both run and breakpoint modes. */ 168425bb815Sopenharmony_ci JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1, /**< free byte code compressed pointer */ 169425bb815Sopenharmony_ci JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2, /**< update breakpoint status */ 170425bb815Sopenharmony_ci JERRY_DEBUGGER_EXCEPTION_CONFIG = 3, /**< exception handler config */ 171425bb815Sopenharmony_ci JERRY_DEBUGGER_PARSER_CONFIG = 4, /**< parser config */ 172425bb815Sopenharmony_ci JERRY_DEBUGGER_MEMSTATS = 5, /**< list memory statistics */ 173425bb815Sopenharmony_ci JERRY_DEBUGGER_STOP = 6, /**< stop execution */ 174425bb815Sopenharmony_ci /* The following message is only available in waiting after parse mode. */ 175425bb815Sopenharmony_ci JERRY_DEBUGGER_PARSER_RESUME = 7, /**< stop waiting after parse */ 176425bb815Sopenharmony_ci /* The following four messages are only available in client switch mode. */ 177425bb815Sopenharmony_ci JERRY_DEBUGGER_CLIENT_SOURCE = 8, /**< first message of client source */ 178425bb815Sopenharmony_ci JERRY_DEBUGGER_CLIENT_SOURCE_PART = 9, /**< next message of client source */ 179425bb815Sopenharmony_ci JERRY_DEBUGGER_NO_MORE_SOURCES = 10, /**< no more sources notification */ 180425bb815Sopenharmony_ci JERRY_DEBUGGER_CONTEXT_RESET = 11, /**< context reset request */ 181425bb815Sopenharmony_ci /* The following messages are only available in breakpoint 182425bb815Sopenharmony_ci * mode and they switch the engine to run mode. */ 183425bb815Sopenharmony_ci JERRY_DEBUGGER_CONTINUE = 12, /**< continue execution */ 184425bb815Sopenharmony_ci JERRY_DEBUGGER_STEP = 13, /**< next breakpoint, step into functions */ 185425bb815Sopenharmony_ci JERRY_DEBUGGER_NEXT = 14, /**< next breakpoint in the same context */ 186425bb815Sopenharmony_ci JERRY_DEBUGGER_FINISH = 15, /**< Continue running just after the function in the current stack frame returns */ 187425bb815Sopenharmony_ci /* The following messages are only available in breakpoint 188425bb815Sopenharmony_ci * mode and this mode is kept after the message is processed. */ 189425bb815Sopenharmony_ci JERRY_DEBUGGER_GET_BACKTRACE = 16, /**< get backtrace */ 190425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL = 17, /**< first message of evaluating a string */ 191425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_PART = 18, /**< next message of evaluating a string */ 192425bb815Sopenharmony_ci JERRY_DEBUGGER_GET_SCOPE_CHAIN = 19, /**< get type names of the scope chain */ 193425bb815Sopenharmony_ci JERRY_DEBUGGER_GET_SCOPE_VARIABLES = 20, /**< get variables of a scope */ 194425bb815Sopenharmony_ci JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */ 195425bb815Sopenharmony_ci} jerry_debugger_header_type_t; 196425bb815Sopenharmony_ci 197425bb815Sopenharmony_ci/** 198425bb815Sopenharmony_ci * Debugger option flags. 199425bb815Sopenharmony_ci */ 200425bb815Sopenharmony_citypedef enum 201425bb815Sopenharmony_ci{ 202425bb815Sopenharmony_ci JERRY_DEBUGGER_LITTLE_ENDIAN = 1u << 0, /**< little endian */ 203425bb815Sopenharmony_ci} jerry_debugger_configuration_flags_t; 204425bb815Sopenharmony_ci 205425bb815Sopenharmony_ci/** 206425bb815Sopenharmony_ci * Subtypes of eval. 207425bb815Sopenharmony_ci */ 208425bb815Sopenharmony_citypedef enum 209425bb815Sopenharmony_ci{ 210425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_EVAL = 0, /**< evaluate expression */ 211425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_THROW = 1, /**< evaluate expression and throw the result */ 212425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_ABORT = 2, /**< evaluate expression and abrot with the result */ 213425bb815Sopenharmony_ci} jerry_debugger_eval_type_t; 214425bb815Sopenharmony_ci 215425bb815Sopenharmony_ci/** 216425bb815Sopenharmony_ci * Subtypes of eval_result. 217425bb815Sopenharmony_ci */ 218425bb815Sopenharmony_citypedef enum 219425bb815Sopenharmony_ci{ 220425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_OK = 1, /**< eval result, no error */ 221425bb815Sopenharmony_ci JERRY_DEBUGGER_EVAL_ERROR = 2, /**< eval result when an error has occurred */ 222425bb815Sopenharmony_ci} jerry_debugger_eval_result_type_t; 223425bb815Sopenharmony_ci 224425bb815Sopenharmony_ci/** 225425bb815Sopenharmony_ci * Subtypes of output_result. 226425bb815Sopenharmony_ci * 227425bb815Sopenharmony_ci * Note: 228425bb815Sopenharmony_ci * This enum has to be kept in sync with jerry_log_level_t with an offset 229425bb815Sopenharmony_ci * of +2. 230425bb815Sopenharmony_ci */ 231425bb815Sopenharmony_citypedef enum 232425bb815Sopenharmony_ci{ 233425bb815Sopenharmony_ci JERRY_DEBUGGER_OUTPUT_OK = 1, /**< output result, no error */ 234425bb815Sopenharmony_ci JERRY_DEBUGGER_OUTPUT_ERROR = 2, /**< output result, error */ 235425bb815Sopenharmony_ci JERRY_DEBUGGER_OUTPUT_WARNING = 3, /**< output result, warning */ 236425bb815Sopenharmony_ci JERRY_DEBUGGER_OUTPUT_DEBUG = 4, /**< output result, debug */ 237425bb815Sopenharmony_ci JERRY_DEBUGGER_OUTPUT_TRACE = 5, /**< output result, trace */ 238425bb815Sopenharmony_ci} jerry_debugger_output_subtype_t; 239425bb815Sopenharmony_ci 240425bb815Sopenharmony_ci/** 241425bb815Sopenharmony_ci * Types of scopes. 242425bb815Sopenharmony_ci */ 243425bb815Sopenharmony_citypedef enum 244425bb815Sopenharmony_ci{ 245425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_WITH = 1, /**< with */ 246425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_LOCAL = 2, /**< local */ 247425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_CLOSURE = 3, /**< closure */ 248425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_GLOBAL = 4, /**< global */ 249425bb815Sopenharmony_ci JERRY_DEBUGGER_SCOPE_NON_CLOSURE = 5 /**< non closure */ 250425bb815Sopenharmony_ci} jerry_debugger_scope_chain_type_t; 251425bb815Sopenharmony_ci 252425bb815Sopenharmony_ci/** 253425bb815Sopenharmony_ci * Type of scope variables. 254425bb815Sopenharmony_ci */ 255425bb815Sopenharmony_citypedef enum 256425bb815Sopenharmony_ci{ 257425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_NONE = 1, 258425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_UNDEFINED = 2, 259425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_NULL = 3, 260425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_BOOLEAN = 4, 261425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_NUMBER = 5, 262425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_STRING = 6, 263425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_FUNCTION = 7, 264425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_ARRAY = 8, 265425bb815Sopenharmony_ci JERRY_DEBUGGER_VALUE_OBJECT = 9 266425bb815Sopenharmony_ci} jerry_debugger_scope_variable_type_t; 267425bb815Sopenharmony_ci 268425bb815Sopenharmony_ci/** 269425bb815Sopenharmony_ci * Byte data for evaluating expressions and receiving client source. 270425bb815Sopenharmony_ci */ 271425bb815Sopenharmony_citypedef struct 272425bb815Sopenharmony_ci{ 273425bb815Sopenharmony_ci uint32_t uint8_size; /**< total size of the client source */ 274425bb815Sopenharmony_ci uint32_t uint8_offset; /**< current offset in the client source */ 275425bb815Sopenharmony_ci} jerry_debugger_uint8_data_t; 276425bb815Sopenharmony_ci 277425bb815Sopenharmony_ci/** 278425bb815Sopenharmony_ci * Delayed free of byte code data. 279425bb815Sopenharmony_ci */ 280425bb815Sopenharmony_citypedef struct 281425bb815Sopenharmony_ci{ 282425bb815Sopenharmony_ci uint16_t size; /**< size of the byte code header divided by JMEM_ALIGNMENT */ 283425bb815Sopenharmony_ci jmem_cpointer_t prev_cp; /**< previous byte code data to be freed */ 284425bb815Sopenharmony_ci} jerry_debugger_byte_code_free_t; 285425bb815Sopenharmony_ci 286425bb815Sopenharmony_ci/** 287425bb815Sopenharmony_ci * Outgoing message: JerryScript configuration. 288425bb815Sopenharmony_ci */ 289425bb815Sopenharmony_citypedef struct 290425bb815Sopenharmony_ci{ 291425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 292425bb815Sopenharmony_ci uint8_t configuration; /**< configuration option bits */ 293425bb815Sopenharmony_ci uint8_t version[sizeof (uint32_t)]; /**< debugger version */ 294425bb815Sopenharmony_ci uint8_t max_message_size; /**< maximum incoming message size */ 295425bb815Sopenharmony_ci uint8_t cpointer_size; /**< size of compressed pointers */ 296425bb815Sopenharmony_ci} jerry_debugger_send_configuration_t; 297425bb815Sopenharmony_ci 298425bb815Sopenharmony_ci/** 299425bb815Sopenharmony_ci * Outgoing message: message without arguments. 300425bb815Sopenharmony_ci */ 301425bb815Sopenharmony_citypedef struct 302425bb815Sopenharmony_ci{ 303425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 304425bb815Sopenharmony_ci} jerry_debugger_send_type_t; 305425bb815Sopenharmony_ci 306425bb815Sopenharmony_ci/** 307425bb815Sopenharmony_ci * Incoming message: message without arguments. 308425bb815Sopenharmony_ci */ 309425bb815Sopenharmony_citypedef struct 310425bb815Sopenharmony_ci{ 311425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 312425bb815Sopenharmony_ci} jerry_debugger_receive_type_t; 313425bb815Sopenharmony_ci 314425bb815Sopenharmony_ci/** 315425bb815Sopenharmony_ci * Outgoing message: string (Source file name or function name). 316425bb815Sopenharmony_ci */ 317425bb815Sopenharmony_citypedef struct 318425bb815Sopenharmony_ci{ 319425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 320425bb815Sopenharmony_ci uint8_t string[]; /**< string data */ 321425bb815Sopenharmony_ci} jerry_debugger_send_string_t; 322425bb815Sopenharmony_ci 323425bb815Sopenharmony_ci/** 324425bb815Sopenharmony_ci * Outgoing message: uint32 value. 325425bb815Sopenharmony_ci */ 326425bb815Sopenharmony_citypedef struct 327425bb815Sopenharmony_ci{ 328425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 329425bb815Sopenharmony_ci uint8_t line[sizeof (uint32_t)]; /**< value data */ 330425bb815Sopenharmony_ci uint8_t column[sizeof (uint32_t)]; /**< value data */ 331425bb815Sopenharmony_ci} jerry_debugger_send_parse_function_t; 332425bb815Sopenharmony_ci 333425bb815Sopenharmony_ci/** 334425bb815Sopenharmony_ci * Outgoing message: byte code compressed pointer. 335425bb815Sopenharmony_ci */ 336425bb815Sopenharmony_citypedef struct 337425bb815Sopenharmony_ci{ 338425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 339425bb815Sopenharmony_ci uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */ 340425bb815Sopenharmony_ci} jerry_debugger_send_byte_code_cp_t; 341425bb815Sopenharmony_ci 342425bb815Sopenharmony_ci/** 343425bb815Sopenharmony_ci * Incoming message: byte code compressed pointer. 344425bb815Sopenharmony_ci */ 345425bb815Sopenharmony_citypedef struct 346425bb815Sopenharmony_ci{ 347425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 348425bb815Sopenharmony_ci uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */ 349425bb815Sopenharmony_ci} jerry_debugger_receive_byte_code_cp_t; 350425bb815Sopenharmony_ci 351425bb815Sopenharmony_ci/** 352425bb815Sopenharmony_ci * Incoming message: update (enable/disable) breakpoint status. 353425bb815Sopenharmony_ci */ 354425bb815Sopenharmony_citypedef struct 355425bb815Sopenharmony_ci{ 356425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 357425bb815Sopenharmony_ci uint8_t is_set_breakpoint; /**< set or clear breakpoint */ 358425bb815Sopenharmony_ci uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */ 359425bb815Sopenharmony_ci uint8_t offset[sizeof (uint32_t)]; /**< breakpoint offset */ 360425bb815Sopenharmony_ci} jerry_debugger_receive_update_breakpoint_t; 361425bb815Sopenharmony_ci 362425bb815Sopenharmony_ci/** 363425bb815Sopenharmony_ci * Outgoing message: send memory statistics 364425bb815Sopenharmony_ci */ 365425bb815Sopenharmony_citypedef struct 366425bb815Sopenharmony_ci{ 367425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 368425bb815Sopenharmony_ci uint8_t allocated_bytes[sizeof (uint32_t)]; /**< allocated bytes */ 369425bb815Sopenharmony_ci uint8_t byte_code_bytes[sizeof (uint32_t)]; /**< byte code bytes */ 370425bb815Sopenharmony_ci uint8_t string_bytes[sizeof (uint32_t)]; /**< string bytes */ 371425bb815Sopenharmony_ci uint8_t object_bytes[sizeof (uint32_t)]; /**< object bytes */ 372425bb815Sopenharmony_ci uint8_t property_bytes[sizeof (uint32_t)]; /**< property bytes */ 373425bb815Sopenharmony_ci} jerry_debugger_send_memstats_t; 374425bb815Sopenharmony_ci 375425bb815Sopenharmony_ci/** 376425bb815Sopenharmony_ci * Outgoing message: notify breakpoint hit. 377425bb815Sopenharmony_ci */ 378425bb815Sopenharmony_citypedef struct 379425bb815Sopenharmony_ci{ 380425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 381425bb815Sopenharmony_ci uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */ 382425bb815Sopenharmony_ci uint8_t offset[sizeof (uint32_t)]; /**< breakpoint offset */ 383425bb815Sopenharmony_ci} jerry_debugger_send_breakpoint_hit_t; 384425bb815Sopenharmony_ci 385425bb815Sopenharmony_ci/** 386425bb815Sopenharmony_ci * Stack frame descriptor for sending backtrace information. 387425bb815Sopenharmony_ci */ 388425bb815Sopenharmony_citypedef struct 389425bb815Sopenharmony_ci{ 390425bb815Sopenharmony_ci uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */ 391425bb815Sopenharmony_ci uint8_t offset[sizeof (uint32_t)]; /**< last breakpoint offset */ 392425bb815Sopenharmony_ci} jerry_debugger_frame_t; 393425bb815Sopenharmony_ci 394425bb815Sopenharmony_ci/** 395425bb815Sopenharmony_ci * Outgoing message: backtrace information. 396425bb815Sopenharmony_ci */ 397425bb815Sopenharmony_citypedef struct 398425bb815Sopenharmony_ci{ 399425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 400425bb815Sopenharmony_ci jerry_debugger_frame_t frames[]; /**< frames */ 401425bb815Sopenharmony_ci} jerry_debugger_send_backtrace_t; 402425bb815Sopenharmony_ci 403425bb815Sopenharmony_ci/** 404425bb815Sopenharmony_ci * Outgoing message: scope chain. 405425bb815Sopenharmony_ci */ 406425bb815Sopenharmony_citypedef struct 407425bb815Sopenharmony_ci{ 408425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 409425bb815Sopenharmony_ci uint8_t scope_types[]; /**< scope types */ 410425bb815Sopenharmony_ci} jerry_debugger_send_scope_chain_t; 411425bb815Sopenharmony_ci 412425bb815Sopenharmony_ci/** 413425bb815Sopenharmony_ci * Outgoing message: number of total frames in backtrace. 414425bb815Sopenharmony_ci */ 415425bb815Sopenharmony_citypedef struct 416425bb815Sopenharmony_ci{ 417425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 418425bb815Sopenharmony_ci uint8_t frame_count[sizeof (uint32_t)]; /**< total number of frames */ 419425bb815Sopenharmony_ci} jerry_debugger_send_backtrace_total_t; 420425bb815Sopenharmony_ci 421425bb815Sopenharmony_ci/** 422425bb815Sopenharmony_ci * Incoming message: set behaviour when exception occures. 423425bb815Sopenharmony_ci */ 424425bb815Sopenharmony_citypedef struct 425425bb815Sopenharmony_ci{ 426425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 427425bb815Sopenharmony_ci uint8_t enable; /**< non-zero: enable stop at exception */ 428425bb815Sopenharmony_ci} jerry_debugger_receive_exception_config_t; 429425bb815Sopenharmony_ci 430425bb815Sopenharmony_ci/** 431425bb815Sopenharmony_ci * Incoming message: set parser configuration. 432425bb815Sopenharmony_ci */ 433425bb815Sopenharmony_citypedef struct 434425bb815Sopenharmony_ci{ 435425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 436425bb815Sopenharmony_ci uint8_t enable_wait; /**< non-zero: wait after parsing is completed */ 437425bb815Sopenharmony_ci} jerry_debugger_receive_parser_config_t; 438425bb815Sopenharmony_ci 439425bb815Sopenharmony_ci/** 440425bb815Sopenharmony_ci * Incoming message: get backtrace. 441425bb815Sopenharmony_ci */ 442425bb815Sopenharmony_citypedef struct 443425bb815Sopenharmony_ci{ 444425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 445425bb815Sopenharmony_ci uint8_t min_depth[sizeof (uint32_t)]; /**< minimum depth*/ 446425bb815Sopenharmony_ci uint8_t max_depth[sizeof (uint32_t)]; /**< maximum depth (0 - unlimited) */ 447425bb815Sopenharmony_ci uint8_t get_total_frame_count; /**< non-zero: if total frame count is also requested */ 448425bb815Sopenharmony_ci} jerry_debugger_receive_get_backtrace_t; 449425bb815Sopenharmony_ci 450425bb815Sopenharmony_ci/** 451425bb815Sopenharmony_ci * Incoming message: first message of evaluating expression. 452425bb815Sopenharmony_ci */ 453425bb815Sopenharmony_citypedef struct 454425bb815Sopenharmony_ci{ 455425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 456425bb815Sopenharmony_ci uint8_t eval_size[sizeof (uint32_t)]; /**< total size of the message */ 457425bb815Sopenharmony_ci} jerry_debugger_receive_eval_first_t; 458425bb815Sopenharmony_ci 459425bb815Sopenharmony_ci/** 460425bb815Sopenharmony_ci * Incoming message: get scope variables 461425bb815Sopenharmony_ci*/ 462425bb815Sopenharmony_citypedef struct 463425bb815Sopenharmony_ci{ 464425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 465425bb815Sopenharmony_ci uint8_t chain_index[sizeof (uint32_t)]; /**< index element of the scope */ 466425bb815Sopenharmony_ci} jerry_debugger_receive_get_scope_variables_t; 467425bb815Sopenharmony_ci 468425bb815Sopenharmony_ci/** 469425bb815Sopenharmony_ci * Incoming message: first message of client source. 470425bb815Sopenharmony_ci */ 471425bb815Sopenharmony_citypedef struct 472425bb815Sopenharmony_ci{ 473425bb815Sopenharmony_ci uint8_t type; /**< type of the message */ 474425bb815Sopenharmony_ci uint8_t code_size[sizeof (uint32_t)]; /**< total size of the message */ 475425bb815Sopenharmony_ci} jerry_debugger_receive_client_source_first_t; 476425bb815Sopenharmony_ci 477425bb815Sopenharmony_civoid jerry_debugger_free_unreferenced_byte_code (void); 478425bb815Sopenharmony_ci 479425bb815Sopenharmony_cibool jerry_debugger_receive (jerry_debugger_uint8_data_t **message_data_p); 480425bb815Sopenharmony_ci 481425bb815Sopenharmony_civoid jerry_debugger_breakpoint_hit (uint8_t message_type); 482425bb815Sopenharmony_ci 483425bb815Sopenharmony_civoid jerry_debugger_send_type (jerry_debugger_header_type_t type); 484425bb815Sopenharmony_cibool jerry_debugger_send_configuration (uint8_t max_message_size); 485425bb815Sopenharmony_civoid jerry_debugger_send_data (jerry_debugger_header_type_t type, const void *data, size_t size); 486425bb815Sopenharmony_cibool jerry_debugger_send_string (uint8_t message_type, uint8_t sub_type, const uint8_t *string_p, size_t string_length); 487425bb815Sopenharmony_cibool jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, ecma_compiled_code_t *compiled_code_p); 488425bb815Sopenharmony_cibool jerry_debugger_send_parse_function (uint32_t line, uint32_t column); 489425bb815Sopenharmony_civoid jerry_debugger_send_memstats (void); 490425bb815Sopenharmony_cibool jerry_debugger_send_exception_string (ecma_value_t exception_value); 491425bb815Sopenharmony_ci 492425bb815Sopenharmony_ci#endif /* ENABLED (JERRY_DEBUGGER) */ 493425bb815Sopenharmony_ci 494425bb815Sopenharmony_ci#endif /* !DEBUGGER_H */ 495