Skip to content

Commit

Permalink
src: add recursive option to findrefs command
Browse files Browse the repository at this point in the history
Introduce a new command flag to `findrefs`, command --recursive
allow user to transverse the whole references tree for the given
object.

Refs: nodejs#115
  • Loading branch information
Drieger authored and mmarchini committed Feb 11, 2019
1 parent 51bf1f6 commit b438f27
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 57 deletions.
26 changes: 26 additions & 0 deletions src/llnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ bool SetPropertyColorCmd::DoExecute(SBDebugger d, char** cmd,
return false;
}

bool SetTreePaddingCmd::DoExecute(SBDebugger d, char** cmd,
SBCommandReturnObject& result) {

if (cmd == nullptr || *cmd == nullptr) {
result.SetError("USAGE: v8 settings set tree-padding [1..10]");
return false;
}
Settings* settings = Settings::GetSettings();
std::stringstream option(cmd[0]);
int padding;

if (!(option >> padding)) {
result.SetError("unable to convert provided value.");
return false;
};

if (padding < 1) padding = 1;
if (padding > 10) padding = 10;
padding = settings->SetTreePadding(padding);
result.Printf("Tree padding set to %u\n", padding);
return true;
}


bool PrintCmd::DoExecute(SBDebugger d, char** cmd,
SBCommandReturnObject& result) {
Expand Down Expand Up @@ -462,6 +485,8 @@ bool PluginInitialize(SBDebugger d) {

setPropertyCmd.AddCommand("color", new llnode::SetPropertyColorCmd(),
"Set color property value");
setPropertyCmd.AddCommand("tree-padding", new llnode::SetTreePaddingCmd(&llv8),
"Set tree-padding value");

interpreter.AddCommand("findjsobjects", new llnode::FindObjectsCmd(&llscan),
"Alias for `v8 findjsobjects`");
Expand Down Expand Up @@ -496,6 +521,7 @@ bool PluginInitialize(SBDebugger d) {
" * -n, --name name - all properties with the specified name\n"
" * -s, --string string - all properties that refer to the specified "
"JavaScript string value\n"
" * -r, --recursive - walk through references tree recursively\n"
"\n");

v8.AddCommand("getactivehandles",
Expand Down
12 changes: 12 additions & 0 deletions src/llnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class SetPropertyColorCmd : public CommandBase {
lldb::SBCommandReturnObject& result) override;
};

class SetTreePaddingCmd: public CommandBase {
public:
SetTreePaddingCmd(v8::LLV8* llv8) : llv8_(llv8) {}
~SetTreePaddingCmd() override {}

bool DoExecute(lldb::SBDebugger d, char** cmd,
lldb::SBCommandReturnObject& result) override;

private:
v8::LLV8* llv8_;
};

class PrintCmd : public CommandBase {
public:
PrintCmd(v8::LLV8* llv8, bool detailed) : llv8_(llv8), detailed_(detailed) {}
Expand Down
Loading

0 comments on commit b438f27

Please sign in to comment.