@@ -226,32 +226,33 @@ static void js_send_stopped_event(JSDebuggerInfo* info, const char* reason) {
226
226
js_transport_send_event (info , (Event * ) event );
227
227
}
228
228
229
- static Scope * js_get_scopes (JSContext * ctx , int64_t frame ) {
229
+ static void js_get_scopes (JSContext * ctx , int64_t frame , ScopesResponseBody * body ) {
230
230
// for now this is always the same.
231
231
// global, local, closure. may change in the future. can check if closure is empty.
232
- Scope * scope = js_malloc (ctx , sizeof (Scope ) * 3 );
232
+ Scope * scopes = js_malloc (ctx , sizeof (Scope ) * 3 );
233
233
234
234
// Init scopes
235
235
for (int i = 0 ; i < 3 ; i ++ ) {
236
- init_scope (& scope [i ]);
236
+ init_scope (& scopes [i ]);
237
237
}
238
238
239
239
// Get local scope
240
- scope [0 ].name = "Local" ;
241
- scope [0 ].variablesReference = (frame << 2 ) + 1 ;
242
- scope [0 ].expensive = 0 ;
240
+ scopes [0 ].name = "Local" ;
241
+ scopes [0 ].variablesReference = (frame << 2 ) + 1 ;
242
+ scopes [0 ].expensive = 0 ;
243
243
244
244
// Get closure
245
- scope [1 ].name = "Closure" ;
246
- scope [1 ].variablesReference = (frame << 2 ) + 2 ;
247
- scope [1 ].expensive = 0 ;
245
+ scopes [1 ].name = "Closure" ;
246
+ scopes [1 ].variablesReference = (frame << 2 ) + 2 ;
247
+ scopes [1 ].expensive = 0 ;
248
248
249
249
// Get global
250
- scope [2 ].name = "Global" ;
251
- scope [2 ].variablesReference = (frame << 2 ) + 0 ;
252
- scope [2 ].expensive = 0 ;
250
+ scopes [2 ].name = "Global" ;
251
+ scopes [2 ].variablesReference = (frame << 2 ) + 0 ;
252
+ scopes [2 ].expensive = 0 ;
253
253
254
- return scope ;
254
+ body -> scopes = scopes ;
255
+ body -> scopesLen = 3 ;
255
256
}
256
257
257
258
static inline JS_BOOL JS_IsInteger (JSValueConst v ) {
@@ -419,7 +420,7 @@ static void process_request(JSDebuggerInfo* info, struct DebuggerSuspendedState*
419
420
ScopesArguments * arguments = (ScopesArguments * )request -> arguments ;
420
421
int64_t frame = arguments -> frameId ;
421
422
ScopesResponse * response = initialize_response (ctx , request , "scopes" );
422
- response -> body -> scopes = js_get_scopes (ctx , frame );
423
+ js_get_scopes (ctx , frame , response -> body );
423
424
js_transport_send_response (info , ctx , (Response * )response );
424
425
} else if (strcmp (command , "setBreakpoints" ) == 0 ) {
425
426
SetBreakpointsArguments * arguments = (SetBreakpointsArguments * )request -> arguments ;
0 commit comments