-
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. PR-URL: #210 Fixes: #100 Reviewed-By: Joyee Cheung <[email protected]>
- Loading branch information
Matheus Marchini
committed
Jul 9, 2018
1 parent
775dd6c
commit baf4cae
Showing
11 changed files
with
482 additions
and
4 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
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
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,38 @@ | ||
#include "node.h" | ||
|
||
namespace llnode { | ||
namespace node { | ||
|
||
template <typename T, typename C> | ||
T Queue<T, C>::Iterator::operator*() const { | ||
return T::GetItemFromList(node_, current_); | ||
} | ||
|
||
template <typename T, typename C> | ||
const typename Queue<T, C>::Iterator Queue<T, C>::Iterator::operator++() { | ||
lldb::SBError sberr; | ||
|
||
current_ = node_->process().ReadPointerFromMemory( | ||
current_ + constants_->kNextOffset, sberr); | ||
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 first = node_->process().ReadPointerFromMemory(next(head()), sberr); | ||
return Iterator(node_, first, constants_); | ||
} | ||
|
||
template <typename T, typename C> | ||
typename Queue<T, C>::Iterator Queue<T, C>::end() const { | ||
return Iterator(node_, head(), 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,76 @@ | ||
#include "node.h" | ||
|
||
namespace llnode { | ||
namespace node { | ||
|
||
addr_t BaseObject::Persistent(Error& err) { | ||
lldb::SBError sberr; | ||
|
||
addr_t persistent_ptr = raw_ + node_->base_object()->kPersistentHandleOffset; | ||
addr_t persistent = | ||
node_->process().ReadPointerFromMemory(persistent_ptr, sberr); | ||
if (sberr.Fail()) { | ||
err = Error::Failure("Failed to load persistent handle"); | ||
return 0; | ||
} | ||
return persistent; | ||
} | ||
|
||
addr_t BaseObject::Object(Error& err) { | ||
lldb::SBError sberr; | ||
|
||
addr_t persistent = Persistent(err); | ||
addr_t obj = node_->process().ReadPointerFromMemory(persistent, sberr); | ||
if (sberr.Fail()) { | ||
err = Error::Failure("Failed to load object from persistent handle"); | ||
return 0; | ||
} | ||
return obj; | ||
} | ||
|
||
HandleWrap HandleWrap::GetItemFromList(Node* node, addr_t list_node_addr) { | ||
return HandleWrap(node, | ||
list_node_addr - node->handle_wrap()->kListNodeOffset); | ||
} | ||
|
||
ReqWrap ReqWrap::GetItemFromList(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.