Skip to content

Commit 1c944fe

Browse files
authored
llscan.cc: Add findjsinstances --verbose option (#125)
Add --verbose (-v) option to findjsinstances so that the output of v8 inspect is displayed for each instance of a type instead of v8 print output. This makes it quicker to view the contents of objects especially where there are few instances of the same kind. PR-URL: #125 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent e472e7e commit 1c944fe

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ The following subcommands are supported:
224224
dumped.
225225
226226
Syntax: v8 bt [number]
227-
findjsinstances -- List all objects which share the specified map.
227+
findjsinstances -- List every object with the specified type name.
228+
Use -v or --verbose to display detailed `v8 inspect` output for each object.
228229
Accepts the same options as `v8 inspect`
229230
findjsobjects -- List all object types and instance counts grouped by typename and sorted by instance count.
230231
Requires `LLNODE_RANGESFILE` environment variable to be set to a file containing memory ranges for the

src/llnode.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ char** CommandBase::ParseInspectOptions(char** cmd,
3838
{"length", required_argument, nullptr, 'l'},
3939
{"print-map", no_argument, nullptr, 'm'},
4040
{"print-source", no_argument, nullptr, 's'},
41+
{"verbose", no_argument, nullptr, 'v'},
4142
{nullptr, 0, nullptr, 0}};
4243

4344
int argc = 1;
@@ -55,7 +56,7 @@ char** CommandBase::ParseInspectOptions(char** cmd,
5556
optind = 0;
5657
opterr = 1;
5758
do {
58-
int arg = getopt_long(argc, args, "Fmsl:", opts, nullptr);
59+
int arg = getopt_long(argc, args, "Fmsvl:", opts, nullptr);
5960
if (arg == -1) break;
6061

6162
switch (arg) {
@@ -71,6 +72,9 @@ char** CommandBase::ParseInspectOptions(char** cmd,
7172
case 's':
7273
options->print_source = true;
7374
break;
75+
case 'v':
76+
options->detailed = true;
77+
break;
7478
default:
7579
continue;
7680
}
@@ -356,7 +360,9 @@ bool PluginInitialize(SBDebugger d) {
356360
"Alias for `v8 findjsobjects`");
357361

358362
v8.AddCommand("findjsinstances", new llnode::FindInstancesCmd(),
359-
"List all objects which share the specified map.\n"
363+
"List every object with the specified type name.\n"
364+
"Use -v or --verbose to display detailed `v8 inspect` output "
365+
"for each object.\n"
360366
"Accepts the same options as `v8 inspect`");
361367

362368
interpreter.AddCommand("findjsinstances", new llnode::FindInstancesCmd(),

src/llscan.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool FindObjectsCmd::DoExecute(SBDebugger d, char** cmd,
8181
bool FindInstancesCmd::DoExecute(SBDebugger d, char** cmd,
8282
SBCommandReturnObject& result) {
8383
if (cmd == nullptr || *cmd == nullptr) {
84-
result.SetError("USAGE: v8 findjsinstances [-Fm] instance_name\n");
84+
result.SetError("USAGE: v8 findjsinstances [flags] instance_name\n");
8585
return false;
8686
}
8787

test/usage-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tape('usage messages', (t) => {
2828
});
2929

3030
sess.stderr.linesUntil(/USAGE/, (lines) => {
31-
const re = /^error: USAGE: v8 findjsinstances \[-Fm\] instance_name$/;
31+
const re = /^error: USAGE: v8 findjsinstances \[flags\] instance_name$/;
3232

3333
t.ok(re.test(removeBlankLines(lines)[0]),
3434
'findjsinstances usage message');

0 commit comments

Comments
 (0)