-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: add commands to inspect the workqueue
Add two new commands: `v8 getactivehandles` and `v8 getactiverequests`. These comamnds will print all pending handles and requests. The result should be similar to running process._getActiveHandles() and process._getActiveRequests() on the living process. Fixes: #100
- Loading branch information
Matheus Marchini
committed
Mar 18, 2018
1 parent
cf25dd3
commit 9bad248
Showing
10 changed files
with
502 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
"src/llv8.cc", | ||
"src/llv8-constants.cc", | ||
"src/llscan.cc", | ||
"src/node.cc", | ||
"src/node-constants.cc", | ||
], | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "node.h" | ||
|
||
namespace llnode { | ||
namespace node { | ||
|
||
template <typename T, typename C> | ||
T Queue<T, C>::Iterator::operator*() const { | ||
return T::FromListNode(node_, current_); | ||
} | ||
|
||
template <typename T, typename C> | ||
const typename Queue<T, C>::Iterator Queue<T, C>::Iterator::operator++() { | ||
lldb::SBError sberr; | ||
|
||
addr_t current = current_ + constants_->kNextOffset; | ||
current = node_->process().ReadPointerFromMemory(current, sberr); | ||
current_ = current; | ||
return Iterator(node_, current, constants_); | ||
} | ||
|
||
template <typename T, typename C> | ||
bool Queue<T, C>::Iterator::operator!=(const Iterator& that) const { | ||
return current_ != that.current_; | ||
} | ||
|
||
template <typename T, typename C> | ||
typename Queue<T, C>::Iterator Queue<T, C>::begin() const { | ||
lldb::SBError sberr; | ||
addr_t currentNode = raw_ + constants_->kHeadOffset; | ||
|
||
currentNode = currentNode + constants_->kNextOffset; | ||
currentNode = node_->process().ReadPointerFromMemory(currentNode, sberr); | ||
|
||
return Iterator(node_, currentNode, constants_); | ||
} | ||
|
||
template <typename T, typename C> | ||
typename Queue<T, C>::Iterator Queue<T, C>::end() const { | ||
return Iterator(node_, raw_ + constants_->kHeadOffset, constants_); | ||
} | ||
} // namespace node | ||
} // namespace llnode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include "node.h" | ||
|
||
namespace llnode { | ||
namespace node { | ||
|
||
addr_t BaseObject::persistent_addr(Error& err) { | ||
lldb::SBError sberr; | ||
|
||
addr_t persistentHandlePtr = | ||
raw_ + node_->base_object()->kPersistentHandleOffset; | ||
addr_t persistentHandle = | ||
node_->process().ReadPointerFromMemory(persistentHandlePtr, sberr); | ||
if (sberr.Fail()) { | ||
err = Error::Failure("Failed to load persistent handle"); | ||
return 0; | ||
} | ||
return persistentHandle; | ||
} | ||
|
||
addr_t BaseObject::v8_object_addr(Error& err) { | ||
lldb::SBError sberr; | ||
|
||
addr_t persistentHandle = persistent_addr(err); | ||
addr_t obj = node_->process().ReadPointerFromMemory(persistentHandle, sberr); | ||
if (sberr.Fail()) { | ||
err = Error::Failure("Failed to load object from persistent handle"); | ||
return 0; | ||
} | ||
return obj; | ||
} | ||
|
||
HandleWrap HandleWrap::FromListNode(Node* node, addr_t list_node_addr) { | ||
return HandleWrap(node, | ||
list_node_addr - node->handle_wrap()->kListNodeOffset); | ||
} | ||
|
||
ReqWrap ReqWrap::FromListNode(Node* node, addr_t list_node_addr) { | ||
return ReqWrap(node, list_node_addr - node->req_wrap()->kListNodeOffset); | ||
} | ||
|
||
Environment Environment::GetCurrent(Node* node, Error& err) { | ||
addr_t envAddr = node->env()->kCurrentEnvironment; | ||
if (envAddr == 0) { | ||
err = Error::Failure("Couldn't get node's Environment"); | ||
} | ||
|
||
return Environment(node, envAddr); | ||
} | ||
|
||
HandleWrapQueue Environment::handle_wrap_queue() const { | ||
return HandleWrapQueue(node_, raw_ + node_->env()->kHandleWrapQueueOffset, | ||
node_->handle_wrap_queue()); | ||
} | ||
|
||
ReqWrapQueue Environment::req_wrap_queue() const { | ||
return ReqWrapQueue(node_, raw_ + node_->env()->kReqWrapQueueOffset, | ||
node_->req_wrap_queue()); | ||
} | ||
|
||
void Node::Load(SBTarget target) { | ||
// Reload process anyway | ||
process_ = target.GetProcess(); | ||
|
||
// No need to reload | ||
if (target_ == target) return; | ||
|
||
target_ = target; | ||
|
||
env.Assign(target); | ||
req_wrap_queue.Assign(target); | ||
req_wrap.Assign(target); | ||
handle_wrap_queue.Assign(target); | ||
handle_wrap.Assign(target); | ||
base_object.Assign(target); | ||
} | ||
} // namespace node | ||
} // namespace llnode |
Oops, something went wrong.