Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: zero out structure members #8536

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#endif

namespace node {
namespace inspector {
namespace {

const char TAG_CONNECT[] = "#connect";
Expand All @@ -51,7 +52,7 @@ void PrintDebuggerReadyMessage(int port) {
fflush(stderr);
}

bool AcceptsConnection(inspector_socket_t* socket, const std::string& path) {
bool AcceptsConnection(InspectorSocket* socket, const std::string& path) {
return StringEqualNoCaseN(path.c_str(), DEVTOOLS_PATH,
sizeof(DEVTOOLS_PATH) - 1);
}
Expand All @@ -62,11 +63,11 @@ void Escape(std::string* string) {
}
}

void DisposeInspector(inspector_socket_t* socket, int status) {
void DisposeInspector(InspectorSocket* socket, int status) {
delete socket;
}

void DisconnectAndDisposeIO(inspector_socket_t* socket) {
void DisconnectAndDisposeIO(InspectorSocket* socket) {
if (socket) {
inspector_close(socket, DisposeInspector);
}
Expand All @@ -77,7 +78,7 @@ void OnBufferAlloc(uv_handle_t* handle, size_t len, uv_buf_t* buf) {
buf->len = len;
}

void SendHttpResponse(inspector_socket_t* socket, const char* response,
void SendHttpResponse(InspectorSocket* socket, const char* response,
size_t len) {
const char HEADERS[] = "HTTP/1.0 200 OK\r\n"
"Content-Type: application/json; charset=UTF-8\r\n"
Expand All @@ -90,7 +91,7 @@ void SendHttpResponse(inspector_socket_t* socket, const char* response,
inspector_write(socket, response, len);
}

void SendVersionResponse(inspector_socket_t* socket) {
void SendVersionResponse(InspectorSocket* socket) {
const char VERSION_RESPONSE_TEMPLATE[] =
"[ {"
" \"Browser\": \"node.js/%s\","
Expand All @@ -117,7 +118,7 @@ std::string GetProcessTitle() {
}
}

void SendTargentsListResponse(inspector_socket_t* socket,
void SendTargentsListResponse(InspectorSocket* socket,
const std::string& script_name_,
const std::string& script_path_,
int port) {
Expand Down Expand Up @@ -169,7 +170,7 @@ const char* match_path_segment(const char* path, const char* expected) {
return nullptr;
}

bool RespondToGet(inspector_socket_t* socket, const std::string& script_name_,
bool RespondToGet(InspectorSocket* socket, const std::string& script_name_,
const std::string& script_path_, const std::string& path,
int port) {
const char* command = match_path_segment(path.c_str(), "/json");
Expand All @@ -192,8 +193,6 @@ bool RespondToGet(inspector_socket_t* socket, const std::string& script_name_,

} // namespace

namespace inspector {


class V8NodeInspector;

Expand All @@ -220,16 +219,16 @@ class AgentImpl {

static void ThreadCbIO(void* agent);
static void OnSocketConnectionIO(uv_stream_t* server, int status);
static bool OnInspectorHandshakeIO(inspector_socket_t* socket,
static bool OnInspectorHandshakeIO(InspectorSocket* socket,
enum inspector_handshake_event state,
const std::string& path);
static void WriteCbIO(uv_async_t* async);

void InstallInspectorOnProcess();

void WorkerRunIO();
void OnInspectorConnectionIO(inspector_socket_t* socket);
void OnRemoteDataIO(inspector_socket_t* stream, ssize_t read,
void OnInspectorConnectionIO(InspectorSocket* socket);
void OnRemoteDataIO(InspectorSocket* stream, ssize_t read,
const uv_buf_t* b);
void SetConnected(bool connected);
void DispatchMessages();
Expand All @@ -255,7 +254,7 @@ class AgentImpl {

uv_async_t* data_written_;
uv_async_t io_thread_req_;
inspector_socket_t* client_socket_;
InspectorSocket* client_socket_;
V8NodeInspector* inspector_;
v8::Platform* platform_;
MessageQueue incoming_message_queue_;
Expand All @@ -281,7 +280,7 @@ void InterruptCallback(v8::Isolate*, void* agent) {
}

void DataCallback(uv_stream_t* stream, ssize_t read, const uv_buf_t* buf) {
inspector_socket_t* socket = inspector_from_stream(stream);
InspectorSocket* socket = inspector_from_stream(stream);
static_cast<AgentImpl*>(socket->data)->OnRemoteDataIO(socket, read, buf);
}

Expand Down Expand Up @@ -594,7 +593,7 @@ void AgentImpl::ThreadCbIO(void* agent) {
// static
void AgentImpl::OnSocketConnectionIO(uv_stream_t* server, int status) {
if (status == 0) {
inspector_socket_t* socket = new inspector_socket_t();
InspectorSocket* socket = new InspectorSocket();
socket->data = server->data;
if (inspector_accept(server, socket,
AgentImpl::OnInspectorHandshakeIO) != 0) {
Expand All @@ -604,7 +603,7 @@ void AgentImpl::OnSocketConnectionIO(uv_stream_t* server, int status) {
}

// static
bool AgentImpl::OnInspectorHandshakeIO(inspector_socket_t* socket,
bool AgentImpl::OnInspectorHandshakeIO(InspectorSocket* socket,
enum inspector_handshake_event state,
const std::string& path) {
AgentImpl* agent = static_cast<AgentImpl*>(socket->data);
Expand All @@ -626,7 +625,7 @@ bool AgentImpl::OnInspectorHandshakeIO(inspector_socket_t* socket,
}
}

void AgentImpl::OnRemoteDataIO(inspector_socket_t* socket,
void AgentImpl::OnRemoteDataIO(InspectorSocket* socket,
ssize_t read,
const uv_buf_t* buf) {
Mutex::ScopedLock scoped_lock(pause_lock_);
Expand Down Expand Up @@ -660,7 +659,7 @@ void AgentImpl::OnRemoteDataIO(inspector_socket_t* socket,
// static
void AgentImpl::WriteCbIO(uv_async_t* async) {
AgentImpl* agent = static_cast<AgentImpl*>(async->data);
inspector_socket_t* socket = agent->client_socket_;
InspectorSocket* socket = agent->client_socket_;
if (socket) {
MessageQueue outgoing_messages;
agent->SwapBehindLock(&agent->outgoing_message_queue_, &outgoing_messages);
Expand Down Expand Up @@ -741,7 +740,7 @@ void AgentImpl::PostIncomingMessage(const String16& message) {
}
}

void AgentImpl::OnInspectorConnectionIO(inspector_socket_t* socket) {
void AgentImpl::OnInspectorConnectionIO(InspectorSocket* socket) {
if (client_socket_) {
DisconnectAndDisposeIO(socket);
return;
Expand Down
Loading