From 29d7fd6bb85faa3b82218f343adf2e9fd1ed6aa8 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 3 Nov 2014 12:03:34 +0100 Subject: [PATCH] src: move debug agent from deps/ to src/ There is not much point in keeping it a separate project because it doesn't build standalone, plus it makes applying changes to core more difficult because of the implicit dependency on header files in src/. --- Makefile.build | 1 - deps/debugger-agent/debugger-agent.gyp | 24 ------- deps/debugger-agent/src/agent.h | 64 ------------------- .../_debugger_agent.js => lib/_debug_agent.js | 0 node.gyp | 5 +- .../src/agent.cc => src/debug-agent.cc | 3 +- .../debugger-agent.h => src/debug-agent.h | 44 ++++++++++--- src/env.h | 2 +- src/node.js | 2 +- 9 files changed, 42 insertions(+), 103 deletions(-) delete mode 100644 deps/debugger-agent/debugger-agent.gyp delete mode 100644 deps/debugger-agent/src/agent.h rename deps/debugger-agent/lib/_debugger_agent.js => lib/_debug_agent.js (100%) rename deps/debugger-agent/src/agent.cc => src/debug-agent.cc (99%) rename deps/debugger-agent/include/debugger-agent.h => src/debug-agent.h (79%) diff --git a/Makefile.build b/Makefile.build index 1aa5f56515d630..dad86cb517a9e6 100644 --- a/Makefile.build +++ b/Makefile.build @@ -233,7 +233,6 @@ NACL_ARCHES = nacl_ia32 nacl_x64 GYPFILES = \ common.gypi \ deps/cares/cares.gyp \ - deps/debugger-agent/debugger-agent.gyp \ deps/http_parser/http_parser.gyp \ deps/openssl/openssl.gyp \ deps/uv/uv.gyp \ diff --git a/deps/debugger-agent/debugger-agent.gyp b/deps/debugger-agent/debugger-agent.gyp deleted file mode 100644 index e98206849ab1aa..00000000000000 --- a/deps/debugger-agent/debugger-agent.gyp +++ /dev/null @@ -1,24 +0,0 @@ -{ - "targets": [{ - "target_name": "debugger-agent", - "type": "<(library)", - "include_dirs": [ - "src", - "include", - "../v8/include", - "../uv/include", - - # Private node.js folder and stuff needed to include from it - "../../src", - "../cares/include", - ], - "direct_dependent_settings": { - "include_dirs": [ - "include", - ], - }, - "sources": [ - "src/agent.cc", - ], - }], -} diff --git a/deps/debugger-agent/src/agent.h b/deps/debugger-agent/src/agent.h deleted file mode 100644 index 82db5e5e181d6a..00000000000000 --- a/deps/debugger-agent/src/agent.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright Fedor Indutny and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -#ifndef DEPS_DEBUGGER_AGENT_SRC_AGENT_H_ -#define DEPS_DEBUGGER_AGENT_SRC_AGENT_H_ - -#include "v8.h" -#include "v8-debug.h" -#include "queue.h" - -#include -#include - -namespace node { -namespace debugger { - -class AgentMessage { - public: - AgentMessage(uint16_t* val, int length) : length_(length) { - if (val == NULL) { - data_ = val; - } else { - data_ = new uint16_t[length]; - memcpy(data_, val, length * sizeof(*data_)); - } - } - - ~AgentMessage() { - delete[] data_; - data_ = NULL; - } - - inline const uint16_t* data() const { return data_; } - inline int length() const { return length_; } - - QUEUE member; - - private: - uint16_t* data_; - int length_; -}; - -} // namespace debugger -} // namespace node - -#endif // DEPS_DEBUGGER_AGENT_SRC_AGENT_H_ diff --git a/deps/debugger-agent/lib/_debugger_agent.js b/lib/_debug_agent.js similarity index 100% rename from deps/debugger-agent/lib/_debugger_agent.js rename to lib/_debug_agent.js diff --git a/node.gyp b/node.gyp index b1dc5f2ecac13f..21391e0e3bd359 100644 --- a/node.gyp +++ b/node.gyp @@ -16,6 +16,7 @@ 'node_v8_options%': '', 'library_files': [ 'src/node.js', + 'lib/_debug_agent.js', 'lib/_debugger.js', 'lib/_linklist.js', 'lib/assert.js', @@ -67,7 +68,6 @@ 'lib/util.js', 'lib/vm.js', 'lib/zlib.js', - 'deps/debugger-agent/lib/_debugger_agent.js', ], }, @@ -78,7 +78,6 @@ 'dependencies': [ 'node_js2c#host', - 'deps/debugger-agent/debugger-agent.gyp:debugger-agent', ], 'include_dirs': [ @@ -89,6 +88,7 @@ ], 'sources': [ + 'src/debug-agent.cc', 'src/fs_event_wrap.cc', 'src/cares_wrap.cc', 'src/handle_wrap.cc', @@ -124,6 +124,7 @@ 'src/async-wrap-inl.h', 'src/base-object.h', 'src/base-object-inl.h', + 'src/debug-agent.h', 'src/env.h', 'src/env-inl.h', 'src/handle_wrap.h', diff --git a/deps/debugger-agent/src/agent.cc b/src/debug-agent.cc similarity index 99% rename from deps/debugger-agent/src/agent.cc rename to src/debug-agent.cc index 335737ffe9e33f..78362afe96a86c 100644 --- a/deps/debugger-agent/src/agent.cc +++ b/src/debug-agent.cc @@ -19,8 +19,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -#include "agent.h" -#include "debugger-agent.h" +#include "debug-agent.h" #include "node.h" #include "node_internals.h" // ARRAY_SIZE diff --git a/deps/debugger-agent/include/debugger-agent.h b/src/debug-agent.h similarity index 79% rename from deps/debugger-agent/include/debugger-agent.h rename to src/debug-agent.h index 762a687a0a071c..d3c7fcc382db19 100644 --- a/deps/debugger-agent/include/debugger-agent.h +++ b/src/debug-agent.h @@ -19,21 +19,24 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. -#ifndef DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_ -#define DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_ +#ifndef SRC_DEBUG_AGENT_H_ +#define SRC_DEBUG_AGENT_H_ #include "uv.h" #include "v8.h" #include "v8-debug.h" +#include "queue.h" -namespace node { +#include -// Forward declaration +// Forward declaration to break recursive dependency chain with src/env.h. +namespace node { class Environment; +} // namespace node +namespace node { namespace debugger { -// Forward declaration class AgentMessage; class Agent { @@ -97,13 +100,38 @@ class Agent { uv_loop_t child_loop_; v8::Persistent api_; - // QUEUE - void* messages_[2]; + QUEUE messages_; DispatchHandler dispatch_handler_; }; +class AgentMessage { + public: + AgentMessage(uint16_t* val, int length) : length_(length) { + if (val == NULL) { + data_ = val; + } else { + data_ = new uint16_t[length]; + memcpy(data_, val, length * sizeof(*data_)); + } + } + + ~AgentMessage() { + delete[] data_; + data_ = NULL; + } + + inline const uint16_t* data() const { return data_; } + inline int length() const { return length_; } + + QUEUE member; + + private: + uint16_t* data_; + int length_; +}; + } // namespace debugger } // namespace node -#endif // DEPS_DEBUGGER_AGENT_INCLUDE_DEBUGGER_AGENT_H_ +#endif // SRC_DEBUG_AGENT_H_ diff --git a/src/env.h b/src/env.h index 77dbf33c86d147..5eac220ea16604 100644 --- a/src/env.h +++ b/src/env.h @@ -23,12 +23,12 @@ #define SRC_ENV_H_ #include "ares.h" +#include "debug-agent.h" #include "tree.h" #include "util.h" #include "uv.h" #include "v8.h" #include "queue.h" -#include "debugger-agent.h" #include diff --git a/src/node.js b/src/node.js index 19d9506446876e..0a82088893d1b9 100644 --- a/src/node.js +++ b/src/node.js @@ -85,7 +85,7 @@ } else if (process.argv[1] == '--debug-agent') { // Start the debugger agent - var d = NativeModule.require('_debugger_agent'); + var d = NativeModule.require('_debug_agent'); d.start(); } else if (process._eval != null) {