Skip to content

Commit bc9e7f7

Browse files
committed
Remove websocket message macros in debugger
JERRY_DEBUGGER_INIT_SEND_MESSAGE JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE JerryScript-DCO-1.0-Signed-off-by: Jimmy Huang [email protected]
1 parent 8af89d9 commit bc9e7f7

File tree

3 files changed

+11
-44
lines changed

3 files changed

+11
-44
lines changed

jerry-core/debugger/debugger-ws.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
#include <fcntl.h>
2525
#include <unistd.h>
2626

27+
/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
28+
29+
/**
30+
* Last fragment of a Websocket package.
31+
*/
32+
#define JERRY_DEBUGGER_WEBSOCKET_FIN_BIT 0x80
33+
2734
/**
2835
* Masking-key is available.
2936
*/
@@ -420,9 +427,12 @@ jerry_debugger_close_connection (void)
420427
* @return true - if the data was sent successfully to the debugger client,
421428
* false - otherwise
422429
*/
423-
inline bool __attr_always_inline___
430+
bool
424431
jerry_debugger_send (size_t data_size) /**< data size */
425432
{
433+
jerry_debugger_send_type_t *message_p = (jerry_debugger_send_type_t *) JERRY_CONTEXT (debugger_send_buffer);
434+
message_p->header.ws_opcode = JERRY_DEBUGGER_WEBSOCKET_FIN_BIT | JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME;
435+
message_p->header.size = (uint8_t) (data_size - sizeof (jerry_debugger_send_header_t));
426436
return jerry_debugger_send_tcp (JERRY_CONTEXT (debugger_send_buffer), data_size);
427437
} /* jerry_debugger_send */
428438

jerry-core/debugger/debugger-ws.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
*/
3838
#define JERRY_DEBUGGER_MAX_RECEIVE_SIZE (JERRY_DEBUGGER_MAX_BUFFER_SIZE - 6)
3939

40-
/**
41-
* Last fragment of a Websocket package.
42-
*/
43-
#define JERRY_DEBUGGER_WEBSOCKET_FIN_BIT 0x80
44-
4540
/**
4641
* WebSocket opcode types.
4742
*/
@@ -80,24 +75,6 @@ typedef struct
8075
uint32_t uint8_offset; /**< current offset in the client source */
8176
} jerry_debugger_uint8_data_t;
8277

83-
/**
84-
* Initialize the header of an outgoing message.
85-
*/
86-
#define JERRY_DEBUGGER_INIT_SEND_MESSAGE(message_p) \
87-
(message_p)->header.ws_opcode = JERRY_DEBUGGER_WEBSOCKET_FIN_BIT | JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME
88-
89-
/**
90-
* Set the size of an outgoing message from type.
91-
*/
92-
#define JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE(message_p, type) \
93-
(message_p)->header.size = (uint8_t) (sizeof (type) - sizeof (jerry_debugger_send_header_t))
94-
95-
/**
96-
* Set the size of an outgoing message.
97-
*/
98-
#define JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE(message_p, byte_size) \
99-
(message_p)->header.size = (uint8_t) (byte_size)
100-
10178
bool jerry_debugger_accept_connection (void);
10279
void jerry_debugger_close_connection (void);
10380

jerry-core/debugger/debugger.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the recei
8888

8989
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_backtrace_t, backtrace_p);
9090

91-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (backtrace_p);
92-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (backtrace_p, jerry_debugger_send_backtrace_t);
9391
backtrace_p->type = JERRY_DEBUGGER_BACKTRACE;
9492

9593
vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p);
@@ -129,7 +127,6 @@ jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the recei
129127

130128
size_t message_size = current_frame * sizeof (jerry_debugger_frame_t);
131129

132-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (backtrace_p, 1 + message_size);
133130
backtrace_p->type = JERRY_DEBUGGER_BACKTRACE_END;
134131

135132
jerry_debugger_send (sizeof (jerry_debugger_send_type_t) + message_size);
@@ -686,8 +683,6 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
686683

687684
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_breakpoint_hit_t, breakpoint_hit_p);
688685

689-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (breakpoint_hit_p);
690-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (breakpoint_hit_p, jerry_debugger_send_breakpoint_hit_t);
691686
breakpoint_hit_p->type = message_type;
692687

693688
vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p);
@@ -734,8 +729,6 @@ jerry_debugger_send_type (jerry_debugger_header_type_t type) /**< message type *
734729

735730
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t, message_type_p);
736731

737-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_type_p);
738-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_type_p, jerry_debugger_send_type_t);
739732
message_type_p->type = (uint8_t) type;
740733

741734
jerry_debugger_send (sizeof (jerry_debugger_send_type_t));
@@ -762,8 +755,6 @@ jerry_debugger_send_configuration (uint8_t max_message_size) /**< maximum messag
762755

763756
endian_data.uint16_value = 1;
764757

765-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (configuration_p);
766-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (configuration_p, jerry_debugger_send_configuration_t);
767758
configuration_p->type = JERRY_DEBUGGER_CONFIGURATION;
768759
configuration_p->max_message_size = max_message_size;
769760
configuration_p->cpointer_size = sizeof (jmem_cpointer_t);
@@ -785,8 +776,6 @@ jerry_debugger_send_data (jerry_debugger_header_type_t type, /**< message type *
785776

786777
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t, message_type_p);
787778

788-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_type_p);
789-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (message_type_p, 1 + size);
790779
message_type_p->type = type;
791780
memcpy (message_type_p + 1, data, size);
792781

@@ -811,8 +800,6 @@ jerry_debugger_send_string (uint8_t message_type, /**< message type */
811800

812801
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_string_t, message_string_p);
813802

814-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_string_p);
815-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_string_p, jerry_debugger_send_string_t);
816803
message_string_p->type = message_type;
817804

818805
while (string_length > max_fragment_len)
@@ -833,7 +820,6 @@ jerry_debugger_send_string (uint8_t message_type, /**< message type */
833820
string_length += 1;
834821
}
835822

836-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (message_string_p, 1 + string_length);
837823
message_string_p->type = (uint8_t) (message_type + 1);
838824

839825
memcpy (message_string_p->string, string_p, string_length);
@@ -859,8 +845,6 @@ jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, /**< message
859845

860846
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_byte_code_cp_t, byte_code_cp_p);
861847

862-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (byte_code_cp_p);
863-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (byte_code_cp_p, jerry_debugger_send_byte_code_cp_t);
864848
byte_code_cp_p->type = (uint8_t) type;
865849

866850
jmem_cpointer_t compiled_code_cp;
@@ -884,8 +868,6 @@ jerry_debugger_send_parse_function (uint32_t line, /**< line */
884868

885869
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_parse_function_t, message_parse_function_p);
886870

887-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_parse_function_p);
888-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_parse_function_p, jerry_debugger_send_parse_function_t);
889871
message_parse_function_p->type = JERRY_DEBUGGER_PARSE_FUNCTION;
890872
memcpy (message_parse_function_p->line, &line, sizeof (uint32_t));
891873
memcpy (message_parse_function_p->column, &column, sizeof (uint32_t));
@@ -902,8 +884,6 @@ jerry_debugger_send_memstats (void)
902884
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
903885

904886
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_memstats_t, memstats_p);
905-
JERRY_DEBUGGER_INIT_SEND_MESSAGE (memstats_p);
906-
JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (memstats_p, jerry_debugger_send_memstats_t);
907887

908888
memstats_p->type = JERRY_DEBUGGER_MEMSTATS_RECEIVE;
909889

0 commit comments

Comments
 (0)