@@ -37,7 +37,7 @@ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 27
37
37
* Type cast the debugger send buffer into a specific type.
38
38
*/
39
39
#define JERRY_DEBUGGER_SEND_BUFFER_AS (type , name_p ) \
40
- type *name_p = (type *) (& JERRY_CONTEXT (debugger_send_buffer ))
40
+ type *name_p = (type *) (JERRY_CONTEXT (debugger_send_buffer_payload_p ))
41
41
42
42
/**
43
43
* Type cast the debugger receive buffer into a specific type.
@@ -88,13 +88,12 @@ jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the recei
88
88
89
89
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_backtrace_t , backtrace_p );
90
90
91
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (backtrace_p );
92
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (backtrace_p , jerry_debugger_send_backtrace_t );
93
91
backtrace_p -> type = JERRY_DEBUGGER_BACKTRACE ;
94
92
95
93
vm_frame_ctx_t * frame_ctx_p = JERRY_CONTEXT (vm_top_context_p );
96
94
97
95
uint32_t current_frame = 0 ;
96
+ uint32_t max_frame_count = (uint32_t ) JERRY_DEBUGGER_SEND_MAX (jerry_debugger_frame_t );
98
97
99
98
while (frame_ctx_p != NULL && max_depth > 0 )
100
99
{
@@ -104,9 +103,9 @@ jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the recei
104
103
continue ;
105
104
}
106
105
107
- if (current_frame >= JERRY_DEBUGGER_SEND_MAX ( jerry_debugger_frame_t ) )
106
+ if (current_frame >= max_frame_count )
108
107
{
109
- if (!jerry_debugger_send (sizeof (jerry_debugger_send_backtrace_t ) ))
108
+ if (!jerry_debugger_send (max_frame_count * sizeof (jerry_debugger_frame_t ) + 1 ))
110
109
{
111
110
return ;
112
111
}
@@ -129,7 +128,6 @@ jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the recei
129
128
130
129
size_t message_size = current_frame * sizeof (jerry_debugger_frame_t );
131
130
132
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (backtrace_p , 1 + message_size );
133
131
backtrace_p -> type = JERRY_DEBUGGER_BACKTRACE_END ;
134
132
135
133
jerry_debugger_send (sizeof (jerry_debugger_send_type_t ) + message_size );
@@ -536,7 +534,7 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer to the rece
536
534
memcpy (& eval_size , eval_first_p -> eval_size , sizeof (uint32_t ));
537
535
bool is_eval = (recv_buffer_p [0 ] == JERRY_DEBUGGER_EVAL );
538
536
539
- if (eval_size <= JERRY_DEBUGGER_MAX_RECEIVE_SIZE - sizeof (jerry_debugger_receive_eval_first_t ))
537
+ if (eval_size <= JERRY_CONTEXT ( debugger_max_receive_size ) - sizeof (jerry_debugger_receive_eval_first_t ))
540
538
{
541
539
if (eval_size != message_size - sizeof (jerry_debugger_receive_eval_first_t ))
542
540
{
@@ -593,8 +591,10 @@ jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer to the rece
593
591
uint32_t client_source_size ;
594
592
memcpy (& client_source_size , client_source_first_p -> code_size , sizeof (uint32_t ));
595
593
596
- if (client_source_size <= JERRY_DEBUGGER_MAX_RECEIVE_SIZE - sizeof (jerry_debugger_receive_client_source_first_t )
597
- && client_source_size != message_size - sizeof (jerry_debugger_receive_client_source_first_t ))
594
+ uint32_t header_size = sizeof (jerry_debugger_receive_client_source_first_t );
595
+
596
+ if (client_source_size <= JERRY_CONTEXT (debugger_max_receive_size ) - header_size
597
+ && client_source_size != message_size - header_size )
598
598
{
599
599
jerry_port_log (JERRY_LOG_LEVEL_ERROR , "Invalid message size\n" );
600
600
jerry_debugger_close_connection ();
@@ -686,8 +686,6 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
686
686
687
687
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_breakpoint_hit_t , breakpoint_hit_p );
688
688
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 );
691
689
breakpoint_hit_p -> type = message_type ;
692
690
693
691
vm_frame_ctx_t * frame_ctx_p = JERRY_CONTEXT (vm_top_context_p );
@@ -734,8 +732,6 @@ jerry_debugger_send_type (jerry_debugger_header_type_t type) /**< message type *
734
732
735
733
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t , message_type_p );
736
734
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 );
739
735
message_type_p -> type = (uint8_t ) type ;
740
736
741
737
jerry_debugger_send (sizeof (jerry_debugger_send_type_t ));
@@ -762,8 +758,6 @@ jerry_debugger_send_configuration (uint8_t max_message_size) /**< maximum messag
762
758
763
759
endian_data .uint16_value = 1 ;
764
760
765
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (configuration_p );
766
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (configuration_p , jerry_debugger_send_configuration_t );
767
761
configuration_p -> type = JERRY_DEBUGGER_CONFIGURATION ;
768
762
configuration_p -> max_message_size = max_message_size ;
769
763
configuration_p -> cpointer_size = sizeof (jmem_cpointer_t );
@@ -785,8 +779,6 @@ jerry_debugger_send_data (jerry_debugger_header_type_t type, /**< message type *
785
779
786
780
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t , message_type_p );
787
781
788
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_type_p );
789
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (message_type_p , 1 + size );
790
782
message_type_p -> type = type ;
791
783
memcpy (message_type_p + 1 , data , size );
792
784
@@ -811,15 +803,13 @@ jerry_debugger_send_string (uint8_t message_type, /**< message type */
811
803
812
804
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_string_t , message_string_p );
813
805
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 );
816
806
message_string_p -> type = message_type ;
817
807
818
808
while (string_length > max_fragment_len )
819
809
{
820
810
memcpy (message_string_p -> string , string_p , max_fragment_len );
821
811
822
- if (!jerry_debugger_send (sizeof (jerry_debugger_send_string_t ) ))
812
+ if (!jerry_debugger_send (sizeof (jerry_debugger_send_type_t ) + max_fragment_len ))
823
813
{
824
814
return false;
825
815
}
@@ -833,7 +823,6 @@ jerry_debugger_send_string (uint8_t message_type, /**< message type */
833
823
string_length += 1 ;
834
824
}
835
825
836
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (message_string_p , 1 + string_length );
837
826
message_string_p -> type = (uint8_t ) (message_type + 1 );
838
827
839
828
memcpy (message_string_p -> string , string_p , string_length );
@@ -859,8 +848,6 @@ jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, /**< message
859
848
860
849
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_byte_code_cp_t , byte_code_cp_p );
861
850
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 );
864
851
byte_code_cp_p -> type = (uint8_t ) type ;
865
852
866
853
jmem_cpointer_t compiled_code_cp ;
@@ -884,8 +871,6 @@ jerry_debugger_send_parse_function (uint32_t line, /**< line */
884
871
885
872
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_parse_function_t , message_parse_function_p );
886
873
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 );
889
874
message_parse_function_p -> type = JERRY_DEBUGGER_PARSE_FUNCTION ;
890
875
memcpy (message_parse_function_p -> line , & line , sizeof (uint32_t ));
891
876
memcpy (message_parse_function_p -> column , & column , sizeof (uint32_t ));
@@ -902,8 +887,6 @@ jerry_debugger_send_memstats (void)
902
887
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags ) & JERRY_DEBUGGER_CONNECTED );
903
888
904
889
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 );
907
890
908
891
memstats_p -> type = JERRY_DEBUGGER_MEMSTATS_RECEIVE ;
909
892
0 commit comments