@@ -27,8 +27,6 @@ using lldb::SBValue;
27
27
using lldb::eReturnStatusFailed;
28
28
using lldb::eReturnStatusSuccessFinishResult;
29
29
30
- v8::LLV8 llv8;
31
-
32
30
char ** CommandBase::ParseInspectOptions (char ** cmd,
33
31
v8::Value::InspectOptions* options) {
34
32
static struct option opts[] = {
@@ -105,7 +103,7 @@ bool BacktraceCmd::DoExecute(SBDebugger d, char** cmd,
105
103
}
106
104
107
105
// Load V8 constants from postmortem data
108
- llv8. Load (target);
106
+ llv8_-> Load (target);
109
107
110
108
{
111
109
SBStream desc;
@@ -124,7 +122,7 @@ bool BacktraceCmd::DoExecute(SBDebugger d, char** cmd,
124
122
125
123
if (!frame.GetSymbol ().IsValid ()) {
126
124
v8::Error err;
127
- v8::JSFrame v8_frame (&llv8 , static_cast <int64_t >(frame.GetFP ()));
125
+ v8::JSFrame v8_frame (llv8_ , static_cast <int64_t >(frame.GetFP ()));
128
126
std::string res = v8_frame.Inspect (true , err);
129
127
if (err.Success ()) {
130
128
result.Printf (" %c frame #%u: 0x%016" PRIx64 " %s\n " , star, i, pc,
@@ -196,9 +194,9 @@ bool PrintCmd::DoExecute(SBDebugger d, char** cmd,
196
194
}
197
195
198
196
// Load V8 constants from postmortem data
199
- llv8. Load (target);
197
+ llv8_-> Load (target);
200
198
201
- v8::Value v8_value (&llv8 , value.GetValueAsSigned ());
199
+ v8::Value v8_value (llv8_ , value.GetValueAsSigned ());
202
200
v8::Error err;
203
201
std::string res = v8_value.Inspect (&inspect_options, err);
204
202
if (err.Fail ()) {
@@ -255,7 +253,7 @@ bool ListCmd::DoExecute(SBDebugger d, char** cmd,
255
253
}
256
254
257
255
// Load V8 constants from postmortem data
258
- llv8. Load (target);
256
+ llv8_-> Load (target);
259
257
SBFrame frame = thread.GetSelectedFrame ();
260
258
SBSymbol symbol = frame.GetSymbol ();
261
259
@@ -279,7 +277,7 @@ bool ListCmd::DoExecute(SBDebugger d, char** cmd,
279
277
280
278
// V8 frame
281
279
v8::Error err;
282
- v8::JSFrame v8_frame (&llv8 , static_cast <int64_t >(frame.GetFP ()));
280
+ v8::JSFrame v8_frame (llv8_ , static_cast <int64_t >(frame.GetFP ()));
283
281
284
282
const static uint32_t kDisplayLines = 4 ;
285
283
std::string* lines = new std::string[kDisplayLines ];
@@ -319,26 +317,29 @@ namespace lldb {
319
317
bool PluginInitialize (SBDebugger d) {
320
318
llnode::InitDebugMode ();
321
319
320
+ static llnode::v8::LLV8 llv8;
321
+ static llnode::LLScan llscan = llnode::LLScan (&llv8);
322
+
322
323
SBCommandInterpreter interpreter = d.GetCommandInterpreter ();
323
324
324
325
SBCommand v8 = interpreter.AddMultiwordCommand (" v8" , " Node.js helpers" );
325
326
326
327
v8.AddCommand (
327
- " bt" , new llnode::BacktraceCmd (),
328
+ " bt" , new llnode::BacktraceCmd (&llv8 ),
328
329
" Show a backtrace with node.js JavaScript functions and their args. "
329
330
" An optional argument is accepted; if that argument is a number, it "
330
331
" specifies the number of frames to display. Otherwise all frames will "
331
332
" be dumped.\n\n "
332
333
" Syntax: v8 bt [number]\n " );
333
- interpreter.AddCommand (" jsstack" , new llnode::BacktraceCmd (),
334
+ interpreter.AddCommand (" jsstack" , new llnode::BacktraceCmd (&llv8 ),
334
335
" Alias for `v8 bt`" );
335
336
336
- v8.AddCommand (" print" , new llnode::PrintCmd (false ),
337
+ v8.AddCommand (" print" , new llnode::PrintCmd (&llv8, false ),
337
338
" Print short description of the JavaScript value.\n\n "
338
339
" Syntax: v8 print expr\n " );
339
340
340
341
v8.AddCommand (
341
- " inspect" , new llnode::PrintCmd (true ),
342
+ " inspect" , new llnode::PrintCmd (&llv8, true ),
342
343
" Print detailed description and contents of the JavaScript value.\n\n "
343
344
" Possible flags (all optional):\n\n "
344
345
" * -F, --full-string - print whole string without adding ellipsis\n "
@@ -348,18 +349,18 @@ bool PluginInitialize(SBDebugger d) {
348
349
" string/array\n "
349
350
" \n "
350
351
" Syntax: v8 inspect [flags] expr\n " );
351
- interpreter.AddCommand (" jsprint" , new llnode::PrintCmd (true ),
352
+ interpreter.AddCommand (" jsprint" , new llnode::PrintCmd (&llv8, true ),
352
353
" Alias for `v8 inspect`" );
353
354
354
355
SBCommand source =
355
356
v8.AddMultiwordCommand (" source" , " Source code information" );
356
- source.AddCommand (" list" , new llnode::ListCmd (),
357
+ source.AddCommand (" list" , new llnode::ListCmd (&llv8 ),
357
358
" Print source lines around a selected JavaScript frame.\n\n "
358
359
" Syntax: v8 source list\n " );
359
- interpreter.AddCommand (" jssource" , new llnode::ListCmd (),
360
+ interpreter.AddCommand (" jssource" , new llnode::ListCmd (&llv8 ),
360
361
" Alias for `v8 source list`" );
361
362
362
- v8.AddCommand (" findjsobjects" , new llnode::FindObjectsCmd (),
363
+ v8.AddCommand (" findjsobjects" , new llnode::FindObjectsCmd (&llscan ),
363
364
" List all object types and instance counts grouped by type "
364
365
" name and sorted by instance count. Use -d or --detailed to "
365
366
" get an output grouped by type name, properties, and array "
@@ -373,23 +374,24 @@ bool PluginInitialize(SBDebugger d) {
373
374
#endif // LLDB_SBMemoryRegionInfoList_h_
374
375
);
375
376
376
- interpreter.AddCommand (" findjsobjects" , new llnode::FindObjectsCmd (),
377
+ interpreter.AddCommand (" findjsobjects" , new llnode::FindObjectsCmd (&llscan ),
377
378
" Alias for `v8 findjsobjects`" );
378
379
379
- v8.AddCommand (" findjsinstances" , new llnode::FindInstancesCmd (),
380
+ v8.AddCommand (" findjsinstances" , new llnode::FindInstancesCmd (&llscan, false ),
380
381
" List every object with the specified type name.\n "
381
382
" Use -v or --verbose to display detailed `v8 inspect` output "
382
383
" for each object.\n "
383
384
" Accepts the same options as `v8 inspect`" );
384
385
385
- interpreter.AddCommand (" findjsinstances" , new llnode::FindInstancesCmd (),
386
+ interpreter.AddCommand (" findjsinstances" ,
387
+ new llnode::FindInstancesCmd (&llscan, false ),
386
388
" List all objects which share the specified map.\n " );
387
389
388
- v8.AddCommand (" nodeinfo" , new llnode::NodeInfoCmd (),
390
+ v8.AddCommand (" nodeinfo" , new llnode::NodeInfoCmd (&llscan ),
389
391
" Print information about Node.js\n " );
390
392
391
393
v8.AddCommand (
392
- " findrefs" , new llnode::FindReferencesCmd (),
394
+ " findrefs" , new llnode::FindReferencesCmd (&llscan ),
393
395
" Finds all the object properties which meet the search criteria.\n "
394
396
" The default is to list all the object properties that reference the "
395
397
" specified value.\n "
0 commit comments