@@ -78,6 +78,8 @@ jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the recei
7878{
7979 JERRY_DEBUGGER_RECEIVE_BUFFER_AS (jerry_debugger_receive_get_backtrace_t , get_backtrace_p );
8080
81+ uint32_t min_depth ;
82+ memcpy (& min_depth , get_backtrace_p -> min_depth , sizeof (uint32_t ));
8183 uint32_t max_depth ;
8284 memcpy (& max_depth , get_backtrace_p -> max_depth , sizeof (uint32_t ));
8385
@@ -96,35 +98,45 @@ jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the recei
9698 const size_t max_frame_count = JERRY_DEBUGGER_SEND_MAX (jerry_debugger_frame_t );
9799 const size_t max_message_size = JERRY_DEBUGGER_SEND_SIZE (max_frame_count , jerry_debugger_frame_t );
98100
99- while ( frame_ctx_p != NULL && max_depth > 0 )
101+ if ( min_depth <= max_depth )
100102 {
101- if (frame_ctx_p -> bytecode_header_p -> status_flags & CBC_CODE_FLAGS_DEBUGGER_IGNORE )
103+ uint32_t min_depth_offset = 0 ;
104+
105+ while (frame_ctx_p != NULL && min_depth_offset < min_depth )
102106 {
103107 frame_ctx_p = frame_ctx_p -> prev_context_p ;
104- continue ;
108+ min_depth_offset ++ ;
105109 }
106110
107- if ( current_frame >= max_frame_count )
111+ while ( frame_ctx_p != NULL && min_depth_offset ++ < max_depth )
108112 {
109- if (! jerry_debugger_send ( max_message_size ) )
113+ if (frame_ctx_p -> bytecode_header_p -> status_flags & CBC_CODE_FLAGS_DEBUGGER_IGNORE )
110114 {
111- return ;
115+ frame_ctx_p = frame_ctx_p -> prev_context_p ;
116+ continue ;
117+ }
118+
119+ if (current_frame >= max_frame_count )
120+ {
121+ if (!jerry_debugger_send (max_message_size ))
122+ {
123+ return ;
124+ }
125+ current_frame = 0 ;
112126 }
113- current_frame = 0 ;
114- }
115127
116- jerry_debugger_frame_t * frame_p = backtrace_p -> frames + current_frame ;
128+ jerry_debugger_frame_t * frame_p = backtrace_p -> frames + current_frame ;
117129
118- jmem_cpointer_t byte_code_cp ;
119- JMEM_CP_SET_NON_NULL_POINTER (byte_code_cp , frame_ctx_p -> bytecode_header_p );
120- memcpy (frame_p -> byte_code_cp , & byte_code_cp , sizeof (jmem_cpointer_t ));
130+ jmem_cpointer_t byte_code_cp ;
131+ JMEM_CP_SET_NON_NULL_POINTER (byte_code_cp , frame_ctx_p -> bytecode_header_p );
132+ memcpy (frame_p -> byte_code_cp , & byte_code_cp , sizeof (jmem_cpointer_t ));
121133
122- uint32_t offset = (uint32_t ) (frame_ctx_p -> byte_code_p - (uint8_t * ) frame_ctx_p -> bytecode_header_p );
123- memcpy (frame_p -> offset , & offset , sizeof (uint32_t ));
134+ uint32_t offset = (uint32_t ) (frame_ctx_p -> byte_code_p - (uint8_t * ) frame_ctx_p -> bytecode_header_p );
135+ memcpy (frame_p -> offset , & offset , sizeof (uint32_t ));
124136
125- frame_ctx_p = frame_ctx_p -> prev_context_p ;
126- current_frame ++ ;
127- max_depth -- ;
137+ frame_ctx_p = frame_ctx_p -> prev_context_p ;
138+ current_frame ++ ;
139+ }
128140 }
129141
130142 size_t message_size = current_frame * sizeof (jerry_debugger_frame_t );
0 commit comments