From 1d1560f713c988aae5fa304c128b5aa17c7b2569 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Fri, 6 Dec 2024 17:18:50 +0100 Subject: [PATCH] src,agents: add support for source code collection The runtime now stores the `scriptId` and `url` or `path` of all the loaded cjs and esm modules. A new grpc command has been added to retrieve the source code for any `scriptId`-`url|path` pair by reading the source code from file. In case the specific `scriptId`-`url|path` pair wasn't stored, it returns an error. In the rare case where a ESM is not loaded from a file URL, the code would be stored on loading time. PR-URL: https://github.com/nodesource/nsolid/pull/240 Reviewed-By: Rafael Gonzaga --- agents/grpc/proto/command.proto | 2 + agents/grpc/proto/nsolid_service.proto | 2 + agents/grpc/proto/source_code.proto | 19 + agents/grpc/src/grpc_agent.cc | 52 ++ agents/grpc/src/grpc_agent.h | 2 + agents/grpc/src/grpc_client.cc | 19 + agents/grpc/src/grpc_client.h | 10 + agents/grpc/src/grpc_errors.h | 3 +- agents/grpc/src/proto/command.pb.cc | 97 ++- agents/grpc/src/proto/command.pb.h | 89 ++ .../grpc/src/proto/nsolid_service.grpc.pb.cc | 44 +- .../grpc/src/proto/nsolid_service.grpc.pb.h | 183 +++- agents/grpc/src/proto/nsolid_service.pb.cc | 53 +- agents/grpc/src/proto/nsolid_service.pb.h | 1 + agents/grpc/src/proto/source_code.grpc.pb.cc | 25 + agents/grpc/src/proto/source_code.grpc.pb.h | 33 + agents/grpc/src/proto/source_code.pb.cc | 759 +++++++++++++++++ agents/grpc/src/proto/source_code.pb.h | 791 ++++++++++++++++++ node.gyp | 4 + src/module_wrap.cc | 4 + src/node_contextify.cc | 6 + src/nsolid/nsolid_api.cc | 64 ++ src/nsolid/nsolid_api.h | 17 + test/agents/test-grpc-source-code.mjs | 340 ++++++++ test/common/nsolid-grpc-agent/client.js | 25 + test/common/nsolid-grpc-agent/index.js | 31 + test/common/nsolid-grpc-agent/server.mjs | 17 + test/fixtures/nsolid-source-code/common.js | 8 + test/fixtures/nsolid-source-code/data.mjs | 18 + test/fixtures/nsolid-source-code/esm.mjs | 7 + test/fixtures/nsolid-source-code/index.mjs | 7 + 31 files changed, 2679 insertions(+), 53 deletions(-) create mode 100644 agents/grpc/proto/source_code.proto create mode 100644 agents/grpc/src/proto/source_code.grpc.pb.cc create mode 100644 agents/grpc/src/proto/source_code.grpc.pb.h create mode 100644 agents/grpc/src/proto/source_code.pb.cc create mode 100644 agents/grpc/src/proto/source_code.pb.h create mode 100644 test/agents/test-grpc-source-code.mjs create mode 100644 test/fixtures/nsolid-source-code/common.js create mode 100644 test/fixtures/nsolid-source-code/data.mjs create mode 100644 test/fixtures/nsolid-source-code/esm.mjs create mode 100644 test/fixtures/nsolid-source-code/index.mjs diff --git a/agents/grpc/proto/command.proto b/agents/grpc/proto/command.proto index 7f4a51c5c1..8843899478 100644 --- a/agents/grpc/proto/command.proto +++ b/agents/grpc/proto/command.proto @@ -7,6 +7,7 @@ syntax = "proto3"; import "profile.proto"; import "reconfigure.proto"; +import "source_code.proto"; package grpcagent; @@ -14,6 +15,7 @@ message CommandArgs { oneof args { ReconfigureBody reconfigure = 1; ProfileArgs profile = 2; + SourceCodeArgs source_code = 3; } } diff --git a/agents/grpc/proto/nsolid_service.proto b/agents/grpc/proto/nsolid_service.proto index 8a35162d38..5a850fe953 100644 --- a/agents/grpc/proto/nsolid_service.proto +++ b/agents/grpc/proto/nsolid_service.proto @@ -8,6 +8,7 @@ import "info.proto"; import "metrics.proto"; import "packages.proto"; import "reconfigure.proto"; +import "source_code.proto"; import "startup_times.proto"; package grpcagent; @@ -22,6 +23,7 @@ service NSolidService { rpc ExportBlockedLoop (BlockedLoopEvent) returns (EventResponse) {} rpc ExportUnblockedLoop (UnblockedLoopEvent) returns (EventResponse) {} rpc ExportReconfigure (ReconfigureEvent) returns (EventResponse) {} + rpc ExportSourceCode (SourceCodeEvent) returns (EventResponse) {} rpc ExportStartupTimes (StartupTimesEvent) returns (EventResponse) {} } diff --git a/agents/grpc/proto/source_code.proto b/agents/grpc/proto/source_code.proto new file mode 100644 index 0000000000..d0b294aa92 --- /dev/null +++ b/agents/grpc/proto/source_code.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +import "common.proto"; + +package grpcagent; + +message SourceCodeArgs { + int64 thread_id = 1; + int32 script_id = 2; + string path = 3; +} + +message SourceCodeEvent { + CommonResponse common = 1; + int64 thread_id = 2; + string path = 3; + string code = 4; + bool is_esm = 5; +} diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 6d19a1a3eb..27a5f623c6 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -1440,6 +1440,8 @@ void GrpcAgent::handle_command_request(CommandRequestStor&& req) { start_heap_sampling(request); } else if (cmd == "snapshot") { start_heap_snapshot(request); + } else if (cmd == "source_code") { + send_source_code_event(request); } else if (cmd == "startup_times") { send_startup_times_event(request.requestid().c_str()); } else { @@ -1725,6 +1727,56 @@ void GrpcAgent::send_reconfigure_event(const char* req_id) { }); } +void GrpcAgent::send_source_code_event(const grpcagent::CommandRequest& req) { + const grpcagent::SourceCodeArgs& args = req.args().source_code(); + uint64_t thread_id = args.thread_id(); + int script_id = args.script_id(); + const std::string path = args.path(); + + ArenaOptions arena_options; + arena_options.initial_block_size = 1024; + arena_options.max_block_size = 65536; + std::unique_ptr arena{new Arena{arena_options}}; + + auto source_code_event = + Arena::Create(arena.get()); + PopulateCommon(source_code_event->mutable_common(), + "source_code", + req.requestid().c_str()); + + source_code_event->set_thread_id(thread_id); + source_code_event->set_path(path); + + + auto envinst_sp = EnvInst::GetInst(thread_id); + if (envinst_sp == nullptr) { + Debug("Error getting EnvInst for thread: %ld\n", thread_id); + PopulateError(source_code_event->mutable_common(), + ErrorType::EThreadGoneError); + } else { + int r = envinst_sp->GetSourceCode(script_id, + path, + source_code_event->mutable_code()); + if (r != 0) { + Debug("Error reading file from: %s. Error: %d.\n", path.c_str(), r); + PopulateError(source_code_event->mutable_common(), + ErrorType::ESourceCodeFileError); + } + } + + auto context = GrpcClient::MakeClientContext(agent_id_, saas_); + + GrpcClient::DelegateAsyncExport( + nsolid_service_stub_.get(), std::move(context), std::move(arena), + std::move(*source_code_event), + [](::grpc::Status, + std::unique_ptr&&, + const grpcagent::SourceCodeEvent& info_event, + grpcagent::EventResponse*) { + return true; + }); +} + void GrpcAgent::send_startup_times_event(const char* req_id) { ArenaOptions arena_options; arena_options.initial_block_size = 1024; diff --git a/agents/grpc/src/grpc_agent.h b/agents/grpc/src/grpc_agent.h index 07a59fc269..13192cca0f 100644 --- a/agents/grpc/src/grpc_agent.h +++ b/agents/grpc/src/grpc_agent.h @@ -267,6 +267,8 @@ class GrpcAgent: public std::enable_shared_from_this, void send_reconfigure_event(const char* req_id); + void send_source_code_event(const grpcagent::CommandRequest& req); + void send_startup_times_event(const char* req_id); void send_unblocked_loop_event(BlockedLoopStor&& stor); diff --git a/agents/grpc/src/grpc_client.cc b/agents/grpc/src/grpc_client.cc index 36a22ee593..064581e3aa 100644 --- a/agents/grpc/src/grpc_client.cc +++ b/agents/grpc/src/grpc_client.cc @@ -273,6 +273,25 @@ int GrpcClient::DelegateAsyncExport( } +int GrpcClient::DelegateAsyncExport( + NSolidService::StubInterface* stub, + std::unique_ptr&& context, + std::unique_ptr&& arena, + grpcagent::SourceCodeEvent&& event, + std::function &&, + const grpcagent::SourceCodeEvent&, + grpcagent::EventResponse*)>&& result_callback) noexcept { + return InternalDelegateAsyncExport( + stub, + &NSolidService::StubInterface::async_interface::ExportSourceCode, + std::move(context), + std::move(arena), + std::move(event), + std::move(result_callback)); +} + + int GrpcClient::DelegateAsyncExport( NSolidService::StubInterface* stub, std::unique_ptr&& context, diff --git a/agents/grpc/src/grpc_client.h b/agents/grpc/src/grpc_client.h index 2a2d54b308..8c710d223f 100644 --- a/agents/grpc/src/grpc_client.h +++ b/agents/grpc/src/grpc_client.h @@ -113,6 +113,16 @@ class GrpcClient { const grpcagent::ReconfigureEvent&, grpcagent::EventResponse*)>&& result_callback) noexcept; + static int DelegateAsyncExport( + grpcagent::NSolidService::StubInterface* stub, + std::unique_ptr<::grpc::ClientContext>&& context, + std::unique_ptr&& arena, + grpcagent::SourceCodeEvent&& event, + std::function &&, + const grpcagent::SourceCodeEvent&, + grpcagent::EventResponse*)>&& result_callback) noexcept; + static int DelegateAsyncExport( grpcagent::NSolidService::StubInterface* stub, std::unique_ptr<::grpc::ClientContext>&& context, diff --git a/agents/grpc/src/grpc_errors.h b/agents/grpc/src/grpc_errors.h index e8163057a4..84db558eab 100644 --- a/agents/grpc/src/grpc_errors.h +++ b/agents/grpc/src/grpc_errors.h @@ -8,7 +8,8 @@ X(EProfSnapshotError, 500, "Profile/Snapshot creation failure", 1003) \ X(ESnapshotDisabled, 500, "Heap Snapshots disabled", 1004) \ X(ENoMemory, 500, "Internal Runtime Error", 1005) \ - X(ENotAvailable, 404, "Resource not available", 1006) + X(ENotAvailable, 404, "Resource not available", 1006) \ + X(ESourceCodeFileError, 500, "Internal Runtime Error", 1007) namespace node { namespace nsolid { diff --git a/agents/grpc/src/proto/command.pb.cc b/agents/grpc/src/proto/command.pb.cc index 85a3cbe804..f50cf0cd5a 100644 --- a/agents/grpc/src/proto/command.pb.cc +++ b/agents/grpc/src/proto/command.pb.cc @@ -79,6 +79,7 @@ const uint32_t TableStruct_command_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( ~0u, // no _inlined_string_donated_ ::_pbi::kInvalidFieldOffsetTag, ::_pbi::kInvalidFieldOffsetTag, + ::_pbi::kInvalidFieldOffsetTag, PROTOBUF_FIELD_OFFSET(::grpcagent::CommandArgs, _impl_.args_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::grpcagent::CommandRequest, _internal_metadata_), @@ -101,8 +102,8 @@ const uint32_t TableStruct_command_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::grpcagent::CommandArgs)}, - { 9, -1, -1, sizeof(::grpcagent::CommandRequest)}, - { 19, -1, -1, sizeof(::grpcagent::CommandResponse)}, + { 10, -1, -1, sizeof(::grpcagent::CommandRequest)}, + { 20, -1, -1, sizeof(::grpcagent::CommandResponse)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -113,24 +114,27 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_command_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\rcommand.proto\022\tgrpcagent\032\rprofile.prot" - "o\032\021reconfigure.proto\"s\n\013CommandArgs\0221\n\013r" - "econfigure\030\001 \001(\0132\032.grpcagent.Reconfigure" - "BodyH\000\022)\n\007profile\030\002 \001(\0132\026.grpcagent.Prof" - "ileArgsH\000B\006\n\004args\"f\n\016CommandRequest\022\021\n\tr" - "equestId\030\001 \001(\t\022\n\n\002id\030\002 \001(\t\022\017\n\007command\030\003 " - "\001(\t\022$\n\004args\030\004 \001(\0132\026.grpcagent.CommandArg" - "s\"0\n\017CommandResponse\022\014\n\004code\030\001 \001(\r\022\017\n\007me" - "ssage\030\002 \001(\tb\006proto3" + "o\032\021reconfigure.proto\032\021source_code.proto\"" + "\245\001\n\013CommandArgs\0221\n\013reconfigure\030\001 \001(\0132\032.g" + "rpcagent.ReconfigureBodyH\000\022)\n\007profile\030\002 " + "\001(\0132\026.grpcagent.ProfileArgsH\000\0220\n\013source_" + "code\030\003 \001(\0132\031.grpcagent.SourceCodeArgsH\000B" + "\006\n\004args\"f\n\016CommandRequest\022\021\n\trequestId\030\001" + " \001(\t\022\n\n\002id\030\002 \001(\t\022\017\n\007command\030\003 \001(\t\022$\n\004arg" + "s\030\004 \001(\0132\026.grpcagent.CommandArgs\"0\n\017Comma" + "ndResponse\022\014\n\004code\030\001 \001(\r\022\017\n\007message\030\002 \001(" + "\tb\006proto3" ; -static const ::_pbi::DescriptorTable* const descriptor_table_command_2eproto_deps[2] = { +static const ::_pbi::DescriptorTable* const descriptor_table_command_2eproto_deps[3] = { &::descriptor_table_profile_2eproto, &::descriptor_table_reconfigure_2eproto, + &::descriptor_table_source_5fcode_2eproto, }; static ::_pbi::once_flag descriptor_table_command_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_command_2eproto = { - false, false, 339, descriptor_table_protodef_command_2eproto, + false, false, 409, descriptor_table_protodef_command_2eproto, "command.proto", - &descriptor_table_command_2eproto_once, descriptor_table_command_2eproto_deps, 2, 3, + &descriptor_table_command_2eproto_once, descriptor_table_command_2eproto_deps, 3, 3, schemas, file_default_instances, TableStruct_command_2eproto::offsets, file_level_metadata_command_2eproto, file_level_enum_descriptors_command_2eproto, file_level_service_descriptors_command_2eproto, @@ -149,6 +153,7 @@ class CommandArgs::_Internal { public: static const ::grpcagent::ReconfigureBody& reconfigure(const CommandArgs* msg); static const ::grpcagent::ProfileArgs& profile(const CommandArgs* msg); + static const ::grpcagent::SourceCodeArgs& source_code(const CommandArgs* msg); }; const ::grpcagent::ReconfigureBody& @@ -159,6 +164,10 @@ const ::grpcagent::ProfileArgs& CommandArgs::_Internal::profile(const CommandArgs* msg) { return *msg->_impl_.args_.profile_; } +const ::grpcagent::SourceCodeArgs& +CommandArgs::_Internal::source_code(const CommandArgs* msg) { + return *msg->_impl_.args_.source_code_; +} void CommandArgs::set_allocated_reconfigure(::grpcagent::ReconfigureBody* reconfigure) { ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); clear_args(); @@ -207,6 +216,30 @@ void CommandArgs::clear_profile() { clear_has_args(); } } +void CommandArgs::set_allocated_source_code(::grpcagent::SourceCodeArgs* source_code) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + clear_args(); + if (source_code) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(source_code)); + if (message_arena != submessage_arena) { + source_code = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, source_code, submessage_arena); + } + set_has_source_code(); + _impl_.args_.source_code_ = source_code; + } + // @@protoc_insertion_point(field_set_allocated:grpcagent.CommandArgs.source_code) +} +void CommandArgs::clear_source_code() { + if (_internal_has_source_code()) { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.args_.source_code_; + } + clear_has_args(); + } +} CommandArgs::CommandArgs(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned) : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { @@ -234,6 +267,11 @@ CommandArgs::CommandArgs(const CommandArgs& from) from._internal_profile()); break; } + case kSourceCode: { + _this->_internal_mutable_source_code()->::grpcagent::SourceCodeArgs::MergeFrom( + from._internal_source_code()); + break; + } case ARGS_NOT_SET: { break; } @@ -288,6 +326,12 @@ void CommandArgs::clear_args() { } break; } + case kSourceCode: { + if (GetArenaForAllocation() == nullptr) { + delete _impl_.args_.source_code_; + } + break; + } case ARGS_NOT_SET: { break; } @@ -328,6 +372,14 @@ const char* CommandArgs::_InternalParse(const char* ptr, ::_pbi::ParseContext* c } else goto handle_unusual; continue; + // .grpcagent.SourceCodeArgs source_code = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + ptr = ctx->ParseMessage(_internal_mutable_source_code(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; default: goto handle_unusual; } // switch @@ -371,6 +423,13 @@ uint8_t* CommandArgs::_InternalSerialize( _Internal::profile(this).GetCachedSize(), target, stream); } + // .grpcagent.SourceCodeArgs source_code = 3; + if (_internal_has_source_code()) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(3, _Internal::source_code(this), + _Internal::source_code(this).GetCachedSize(), target, stream); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -402,6 +461,13 @@ size_t CommandArgs::ByteSizeLong() const { *_impl_.args_.profile_); break; } + // .grpcagent.SourceCodeArgs source_code = 3; + case kSourceCode: { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.args_.source_code_); + break; + } case ARGS_NOT_SET: { break; } @@ -435,6 +501,11 @@ void CommandArgs::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PR from._internal_profile()); break; } + case kSourceCode: { + _this->_internal_mutable_source_code()->::grpcagent::SourceCodeArgs::MergeFrom( + from._internal_source_code()); + break; + } case ARGS_NOT_SET: { break; } diff --git a/agents/grpc/src/proto/command.pb.h b/agents/grpc/src/proto/command.pb.h index f1d6c879ba..20bb6d9487 100644 --- a/agents/grpc/src/proto/command.pb.h +++ b/agents/grpc/src/proto/command.pb.h @@ -32,6 +32,7 @@ #include #include "profile.pb.h" #include "reconfigure.pb.h" +#include "source_code.pb.h" // @@protoc_insertion_point(includes) #include #define PROTOBUF_INTERNAL_EXPORT_command_2eproto @@ -112,6 +113,7 @@ class CommandArgs final : enum ArgsCase { kReconfigure = 1, kProfile = 2, + kSourceCode = 3, ARGS_NOT_SET = 0, }; @@ -195,6 +197,7 @@ class CommandArgs final : enum : int { kReconfigureFieldNumber = 1, kProfileFieldNumber = 2, + kSourceCodeFieldNumber = 3, }; // .grpcagent.ReconfigureBody reconfigure = 1; bool has_reconfigure() const; @@ -232,6 +235,24 @@ class CommandArgs final : ::grpcagent::ProfileArgs* profile); ::grpcagent::ProfileArgs* unsafe_arena_release_profile(); + // .grpcagent.SourceCodeArgs source_code = 3; + bool has_source_code() const; + private: + bool _internal_has_source_code() const; + public: + void clear_source_code(); + const ::grpcagent::SourceCodeArgs& source_code() const; + PROTOBUF_NODISCARD ::grpcagent::SourceCodeArgs* release_source_code(); + ::grpcagent::SourceCodeArgs* mutable_source_code(); + void set_allocated_source_code(::grpcagent::SourceCodeArgs* source_code); + private: + const ::grpcagent::SourceCodeArgs& _internal_source_code() const; + ::grpcagent::SourceCodeArgs* _internal_mutable_source_code(); + public: + void unsafe_arena_set_allocated_source_code( + ::grpcagent::SourceCodeArgs* source_code); + ::grpcagent::SourceCodeArgs* unsafe_arena_release_source_code(); + void clear_args(); ArgsCase args_case() const; // @@protoc_insertion_point(class_scope:grpcagent.CommandArgs) @@ -239,6 +260,7 @@ class CommandArgs final : class _Internal; void set_has_reconfigure(); void set_has_profile(); + void set_has_source_code(); inline bool has_args() const; inline void clear_has_args(); @@ -252,6 +274,7 @@ class CommandArgs final : ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; ::grpcagent::ReconfigureBody* reconfigure_; ::grpcagent::ProfileArgs* profile_; + ::grpcagent::SourceCodeArgs* source_code_; } args_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; uint32_t _oneof_case_[1]; @@ -772,6 +795,72 @@ inline ::grpcagent::ProfileArgs* CommandArgs::mutable_profile() { return _msg; } +// .grpcagent.SourceCodeArgs source_code = 3; +inline bool CommandArgs::_internal_has_source_code() const { + return args_case() == kSourceCode; +} +inline bool CommandArgs::has_source_code() const { + return _internal_has_source_code(); +} +inline void CommandArgs::set_has_source_code() { + _impl_._oneof_case_[0] = kSourceCode; +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::release_source_code() { + // @@protoc_insertion_point(field_release:grpcagent.CommandArgs.source_code) + if (_internal_has_source_code()) { + clear_has_args(); + ::grpcagent::SourceCodeArgs* temp = _impl_.args_.source_code_; + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + _impl_.args_.source_code_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline const ::grpcagent::SourceCodeArgs& CommandArgs::_internal_source_code() const { + return _internal_has_source_code() + ? *_impl_.args_.source_code_ + : reinterpret_cast< ::grpcagent::SourceCodeArgs&>(::grpcagent::_SourceCodeArgs_default_instance_); +} +inline const ::grpcagent::SourceCodeArgs& CommandArgs::source_code() const { + // @@protoc_insertion_point(field_get:grpcagent.CommandArgs.source_code) + return _internal_source_code(); +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::unsafe_arena_release_source_code() { + // @@protoc_insertion_point(field_unsafe_arena_release:grpcagent.CommandArgs.source_code) + if (_internal_has_source_code()) { + clear_has_args(); + ::grpcagent::SourceCodeArgs* temp = _impl_.args_.source_code_; + _impl_.args_.source_code_ = nullptr; + return temp; + } else { + return nullptr; + } +} +inline void CommandArgs::unsafe_arena_set_allocated_source_code(::grpcagent::SourceCodeArgs* source_code) { + clear_args(); + if (source_code) { + set_has_source_code(); + _impl_.args_.source_code_ = source_code; + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:grpcagent.CommandArgs.source_code) +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::_internal_mutable_source_code() { + if (!_internal_has_source_code()) { + clear_args(); + set_has_source_code(); + _impl_.args_.source_code_ = CreateMaybeMessage< ::grpcagent::SourceCodeArgs >(GetArenaForAllocation()); + } + return _impl_.args_.source_code_; +} +inline ::grpcagent::SourceCodeArgs* CommandArgs::mutable_source_code() { + ::grpcagent::SourceCodeArgs* _msg = _internal_mutable_source_code(); + // @@protoc_insertion_point(field_mutable:grpcagent.CommandArgs.source_code) + return _msg; +} + inline bool CommandArgs::has_args() const { return args_case() != ARGS_NOT_SET; } diff --git a/agents/grpc/src/proto/nsolid_service.grpc.pb.cc b/agents/grpc/src/proto/nsolid_service.grpc.pb.cc index a3056a65c3..ede9326f8e 100644 --- a/agents/grpc/src/proto/nsolid_service.grpc.pb.cc +++ b/agents/grpc/src/proto/nsolid_service.grpc.pb.cc @@ -31,6 +31,7 @@ static const char* NSolidService_method_names[] = { "/grpcagent.NSolidService/ExportBlockedLoop", "/grpcagent.NSolidService/ExportUnblockedLoop", "/grpcagent.NSolidService/ExportReconfigure", + "/grpcagent.NSolidService/ExportSourceCode", "/grpcagent.NSolidService/ExportStartupTimes", }; @@ -50,7 +51,8 @@ NSolidService::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& chan , rpcmethod_ExportBlockedLoop_(NSolidService_method_names[6], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) , rpcmethod_ExportUnblockedLoop_(NSolidService_method_names[7], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) , rpcmethod_ExportReconfigure_(NSolidService_method_names[8], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportStartupTimes_(NSolidService_method_names[9], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportSourceCode_(NSolidService_method_names[9], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportStartupTimes_(NSolidService_method_names[10], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) {} ::grpc::ClientReaderWriter< ::grpcagent::CommandResponse, ::grpcagent::CommandRequest>* NSolidService::Stub::CommandRaw(::grpc::ClientContext* context) { @@ -246,6 +248,29 @@ ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* NSolidService::S return result; } +::grpc::Status NSolidService::Stub::ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpcagent::EventResponse* response) { + return ::grpc::internal::BlockingUnaryCall< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_ExportSourceCode_, context, request, response); +} + +void NSolidService::Stub::async::ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, std::function f) { + ::grpc::internal::CallbackUnaryCall< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_ExportSourceCode_, context, request, response, std::move(f)); +} + +void NSolidService::Stub::async::ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) { + ::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_ExportSourceCode_, context, request, response, reactor); +} + +::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* NSolidService::Stub::PrepareAsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::grpcagent::EventResponse, ::grpcagent::SourceCodeEvent, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_ExportSourceCode_, context, request); +} + +::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* NSolidService::Stub::AsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + auto* result = + this->PrepareAsyncExportSourceCodeRaw(context, request, cq); + result->StartCall(); + return result; +} + ::grpc::Status NSolidService::Stub::ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpcagent::EventResponse* response) { return ::grpc::internal::BlockingUnaryCall< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_ExportStartupTimes_, context, request, response); } @@ -363,6 +388,16 @@ NSolidService::Service::Service() { AddMethod(new ::grpc::internal::RpcServiceMethod( NSolidService_method_names[9], ::grpc::internal::RpcMethod::NORMAL_RPC, + new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( + [](NSolidService::Service* service, + ::grpc::ServerContext* ctx, + const ::grpcagent::SourceCodeEvent* req, + ::grpcagent::EventResponse* resp) { + return service->ExportSourceCode(ctx, req, resp); + }, this))); + AddMethod(new ::grpc::internal::RpcServiceMethod( + NSolidService_method_names[10], + ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, ::grpc::ServerContext* ctx, @@ -437,6 +472,13 @@ ::grpc::Status NSolidService::Service::ExportReconfigure(::grpc::ServerContext* return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } +::grpc::Status NSolidService::Service::ExportSourceCode(::grpc::ServerContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response) { + (void) context; + (void) request; + (void) response; + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); +} + ::grpc::Status NSolidService::Service::ExportStartupTimes(::grpc::ServerContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response) { (void) context; (void) request; diff --git a/agents/grpc/src/proto/nsolid_service.grpc.pb.h b/agents/grpc/src/proto/nsolid_service.grpc.pb.h index bca84ece8a..aee2f39dbb 100644 --- a/agents/grpc/src/proto/nsolid_service.grpc.pb.h +++ b/agents/grpc/src/proto/nsolid_service.grpc.pb.h @@ -102,6 +102,13 @@ class NSolidService final { std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> PrepareAsyncExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(PrepareAsyncExportReconfigureRaw(context, request, cq)); } + virtual ::grpc::Status ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpcagent::EventResponse* response) = 0; + std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> AsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(AsyncExportSourceCodeRaw(context, request, cq)); + } + std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> PrepareAsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(PrepareAsyncExportSourceCodeRaw(context, request, cq)); + } virtual ::grpc::Status ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpcagent::EventResponse* response) = 0; std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> AsyncExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(AsyncExportStartupTimesRaw(context, request, cq)); @@ -128,6 +135,8 @@ class NSolidService final { virtual void ExportUnblockedLoop(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; virtual void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; virtual void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; + virtual void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; + virtual void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; virtual void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; virtual void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; }; @@ -155,6 +164,8 @@ class NSolidService final { virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportUnblockedLoopRaw(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) = 0; }; @@ -228,6 +239,13 @@ class NSolidService final { std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> PrepareAsyncExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(PrepareAsyncExportReconfigureRaw(context, request, cq)); } + ::grpc::Status ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpcagent::EventResponse* response) override; + std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> AsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(AsyncExportSourceCodeRaw(context, request, cq)); + } + std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> PrepareAsyncExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) { + return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(PrepareAsyncExportSourceCodeRaw(context, request, cq)); + } ::grpc::Status ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpcagent::EventResponse* response) override; std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> AsyncExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(AsyncExportStartupTimesRaw(context, request, cq)); @@ -254,6 +272,8 @@ class NSolidService final { void ExportUnblockedLoop(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, std::function) override; void ExportReconfigure(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; + void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, std::function) override; + void ExportSourceCode(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, std::function) override; void ExportStartupTimes(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; private: @@ -287,6 +307,8 @@ class NSolidService final { ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportUnblockedLoopRaw(::grpc::ClientContext* context, const ::grpcagent::UnblockedLoopEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportReconfigureRaw(::grpc::ClientContext* context, const ::grpcagent::ReconfigureEvent& request, ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportSourceCodeRaw(::grpc::ClientContext* context, const ::grpcagent::SourceCodeEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) override; const ::grpc::internal::RpcMethod rpcmethod_Command_; @@ -298,6 +320,7 @@ class NSolidService final { const ::grpc::internal::RpcMethod rpcmethod_ExportBlockedLoop_; const ::grpc::internal::RpcMethod rpcmethod_ExportUnblockedLoop_; const ::grpc::internal::RpcMethod rpcmethod_ExportReconfigure_; + const ::grpc::internal::RpcMethod rpcmethod_ExportSourceCode_; const ::grpc::internal::RpcMethod rpcmethod_ExportStartupTimes_; }; static std::unique_ptr NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions()); @@ -315,6 +338,7 @@ class NSolidService final { virtual ::grpc::Status ExportBlockedLoop(::grpc::ServerContext* context, const ::grpcagent::BlockedLoopEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportUnblockedLoop(::grpc::ServerContext* context, const ::grpcagent::UnblockedLoopEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportReconfigure(::grpc::ServerContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response); + virtual ::grpc::Status ExportSourceCode(::grpc::ServerContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportStartupTimes(::grpc::ServerContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response); }; template @@ -498,12 +522,32 @@ class NSolidService final { } }; template + class WithAsyncMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithAsyncMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodAsync(9); + } + ~WithAsyncMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestExportSourceCode(::grpc::ServerContext* context, ::grpcagent::SourceCodeEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + } + }; + template class WithAsyncMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodAsync(9); + ::grpc::Service::MarkMethodAsync(10); } ~WithAsyncMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -514,10 +558,10 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportStartupTimes(::grpc::ServerContext* context, ::grpcagent::StartupTimesEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); } }; - typedef WithAsyncMethod_Command > > > > > > > > > AsyncService; + typedef WithAsyncMethod_Command > > > > > > > > > > AsyncService; template class WithCallbackMethod_Command : public BaseClass { private: @@ -753,18 +797,45 @@ class NSolidService final { ::grpc::CallbackServerContext* /*context*/, const ::grpcagent::ReconfigureEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } }; template + class WithCallbackMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithCallbackMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodCallback(9, + new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>( + [this]( + ::grpc::CallbackServerContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response) { return this->ExportSourceCode(context, request, response); }));} + void SetMessageAllocatorFor_ExportSourceCode( + ::grpc::MessageAllocator< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>* allocator) { + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(9); + static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>*>(handler) + ->SetMessageAllocator(allocator); + } + ~WithCallbackMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + virtual ::grpc::ServerUnaryReactor* ExportSourceCode( + ::grpc::CallbackServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } + }; + template class WithCallbackMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodCallback(9, + ::grpc::Service::MarkMethodCallback(10, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response) { return this->ExportStartupTimes(context, request, response); }));} void SetMessageAllocatorFor_ExportStartupTimes( ::grpc::MessageAllocator< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(9); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(10); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -779,7 +850,7 @@ class NSolidService final { virtual ::grpc::ServerUnaryReactor* ExportStartupTimes( ::grpc::CallbackServerContext* /*context*/, const ::grpcagent::StartupTimesEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } }; - typedef WithCallbackMethod_Command > > > > > > > > > CallbackService; + typedef WithCallbackMethod_Command > > > > > > > > > > CallbackService; typedef CallbackService ExperimentalCallbackService; template class WithGenericMethod_Command : public BaseClass { @@ -935,12 +1006,29 @@ class NSolidService final { } }; template + class WithGenericMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithGenericMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodGeneric(9); + } + ~WithGenericMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + }; + template class WithGenericMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodGeneric(9); + ::grpc::Service::MarkMethodGeneric(10); } ~WithGenericMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -1132,12 +1220,32 @@ class NSolidService final { } }; template + class WithRawMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithRawMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodRaw(9); + } + ~WithRawMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + void RequestExportSourceCode(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { + ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + } + }; + template class WithRawMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodRaw(9); + ::grpc::Service::MarkMethodRaw(10); } ~WithRawMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -1148,7 +1256,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportStartupTimes(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1351,12 +1459,34 @@ class NSolidService final { ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; } }; template + class WithRawCallbackMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithRawCallbackMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodRawCallback(9, + new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + [this]( + ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportSourceCode(context, request, response); })); + } + ~WithRawCallbackMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable synchronous version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + virtual ::grpc::ServerUnaryReactor* ExportSourceCode( + ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; } + }; + template class WithRawCallbackMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodRawCallback(9, + ::grpc::Service::MarkMethodRawCallback(10, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportStartupTimes(context, request, response); })); @@ -1562,12 +1692,39 @@ class NSolidService final { virtual ::grpc::Status StreamedExportReconfigure(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpcagent::ReconfigureEvent,::grpcagent::EventResponse>* server_unary_streamer) = 0; }; template + class WithStreamedUnaryMethod_ExportSourceCode : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} + public: + WithStreamedUnaryMethod_ExportSourceCode() { + ::grpc::Service::MarkMethodStreamed(9, + new ::grpc::internal::StreamedUnaryHandler< + ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>( + [this](::grpc::ServerContext* context, + ::grpc::ServerUnaryStreamer< + ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>* streamer) { + return this->StreamedExportSourceCode(context, + streamer); + })); + } + ~WithStreamedUnaryMethod_ExportSourceCode() override { + BaseClassMustBeDerivedFromService(this); + } + // disable regular version of this method + ::grpc::Status ExportSourceCode(::grpc::ServerContext* /*context*/, const ::grpcagent::SourceCodeEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) override { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + // replace default version of method with streamed unary + virtual ::grpc::Status StreamedExportSourceCode(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpcagent::SourceCodeEvent,::grpcagent::EventResponse>* server_unary_streamer) = 0; + }; + template class WithStreamedUnaryMethod_ExportStartupTimes : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodStreamed(9, + ::grpc::Service::MarkMethodStreamed(10, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1588,9 +1745,9 @@ class NSolidService final { // replace default version of method with streamed unary virtual ::grpc::Status StreamedExportStartupTimes(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpcagent::StartupTimesEvent,::grpcagent::EventResponse>* server_unary_streamer) = 0; }; - typedef WithStreamedUnaryMethod_ExportExit > > > > > > > StreamedUnaryService; + typedef WithStreamedUnaryMethod_ExportExit > > > > > > > > StreamedUnaryService; typedef Service SplitStreamedService; - typedef WithStreamedUnaryMethod_ExportExit > > > > > > > StreamedService; + typedef WithStreamedUnaryMethod_ExportExit > > > > > > > > StreamedService; }; } // namespace grpcagent diff --git a/agents/grpc/src/proto/nsolid_service.pb.cc b/agents/grpc/src/proto/nsolid_service.pb.cc index 2c7ed41bf9..ed4780ba7b 100644 --- a/agents/grpc/src/proto/nsolid_service.pb.cc +++ b/agents/grpc/src/proto/nsolid_service.pb.cc @@ -60,30 +60,32 @@ const char descriptor_table_protodef_nsolid_5fservice_2eproto[] PROTOBUF_SECTION "\n\024nsolid_service.proto\022\tgrpcagent\032\013asset" ".proto\032\022blocked_loop.proto\032\rcommand.prot" "o\032\nexit.proto\032\ninfo.proto\032\rmetrics.proto" - "\032\016packages.proto\032\021reconfigure.proto\032\023sta" - "rtup_times.proto\"&\n\rEventResponse\022\025\n\rerr" - "or_message\030\001 \001(\t2\342\005\n\rNSolidService\022F\n\007Co" - "mmand\022\032.grpcagent.CommandResponse\032\031.grpc" - "agent.CommandRequest\"\000(\0010\001\022=\n\013ExportAsse" - "t\022\020.grpcagent.Asset\032\030.grpcagent.EventRes" - "ponse\"\000(\001\022>\n\nExportExit\022\024.grpcagent.Exit" - "Event\032\030.grpcagent.EventResponse\"\000\022>\n\nExp" - "ortInfo\022\024.grpcagent.InfoEvent\032\030.grpcagen" - "t.EventResponse\"\000\022D\n\rExportMetrics\022\027.grp" - "cagent.MetricsEvent\032\030.grpcagent.EventRes" - "ponse\"\000\022F\n\016ExportPackages\022\030.grpcagent.Pa" - "ckagesEvent\032\030.grpcagent.EventResponse\"\000\022" - "L\n\021ExportBlockedLoop\022\033.grpcagent.Blocked" - "LoopEvent\032\030.grpcagent.EventResponse\"\000\022P\n" - "\023ExportUnblockedLoop\022\035.grpcagent.Unblock" - "edLoopEvent\032\030.grpcagent.EventResponse\"\000\022" - "L\n\021ExportReconfigure\022\033.grpcagent.Reconfi" - "gureEvent\032\030.grpcagent.EventResponse\"\000\022N\n" - "\022ExportStartupTimes\022\034.grpcagent.StartupT" - "imesEvent\032\030.grpcagent.EventResponse\"\000b\006p" - "roto3" + "\032\016packages.proto\032\021reconfigure.proto\032\021sou" + "rce_code.proto\032\023startup_times.proto\"&\n\rE" + "ventResponse\022\025\n\rerror_message\030\001 \001(\t2\256\006\n\r" + "NSolidService\022F\n\007Command\022\032.grpcagent.Com" + "mandResponse\032\031.grpcagent.CommandRequest\"" + "\000(\0010\001\022=\n\013ExportAsset\022\020.grpcagent.Asset\032\030" + ".grpcagent.EventResponse\"\000(\001\022>\n\nExportEx" + "it\022\024.grpcagent.ExitEvent\032\030.grpcagent.Eve" + "ntResponse\"\000\022>\n\nExportInfo\022\024.grpcagent.I" + "nfoEvent\032\030.grpcagent.EventResponse\"\000\022D\n\r" + "ExportMetrics\022\027.grpcagent.MetricsEvent\032\030" + ".grpcagent.EventResponse\"\000\022F\n\016ExportPack" + "ages\022\030.grpcagent.PackagesEvent\032\030.grpcage" + "nt.EventResponse\"\000\022L\n\021ExportBlockedLoop\022" + "\033.grpcagent.BlockedLoopEvent\032\030.grpcagent" + ".EventResponse\"\000\022P\n\023ExportUnblockedLoop\022" + "\035.grpcagent.UnblockedLoopEvent\032\030.grpcage" + "nt.EventResponse\"\000\022L\n\021ExportReconfigure\022" + "\033.grpcagent.ReconfigureEvent\032\030.grpcagent" + ".EventResponse\"\000\022J\n\020ExportSourceCode\022\032.g" + "rpcagent.SourceCodeEvent\032\030.grpcagent.Eve" + "ntResponse\"\000\022N\n\022ExportStartupTimes\022\034.grp" + "cagent.StartupTimesEvent\032\030.grpcagent.Eve" + "ntResponse\"\000b\006proto3" ; -static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2eproto_deps[9] = { +static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2eproto_deps[10] = { &::descriptor_table_asset_2eproto, &::descriptor_table_blocked_5floop_2eproto, &::descriptor_table_command_2eproto, @@ -92,13 +94,14 @@ static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2e &::descriptor_table_metrics_2eproto, &::descriptor_table_packages_2eproto, &::descriptor_table_reconfigure_2eproto, + &::descriptor_table_source_5fcode_2eproto, &::descriptor_table_startup_5ftimes_2eproto, }; static ::_pbi::once_flag descriptor_table_nsolid_5fservice_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_nsolid_5fservice_2eproto = { - false, false, 965, descriptor_table_protodef_nsolid_5fservice_2eproto, + false, false, 1060, descriptor_table_protodef_nsolid_5fservice_2eproto, "nsolid_service.proto", - &descriptor_table_nsolid_5fservice_2eproto_once, descriptor_table_nsolid_5fservice_2eproto_deps, 9, 1, + &descriptor_table_nsolid_5fservice_2eproto_once, descriptor_table_nsolid_5fservice_2eproto_deps, 10, 1, schemas, file_default_instances, TableStruct_nsolid_5fservice_2eproto::offsets, file_level_metadata_nsolid_5fservice_2eproto, file_level_enum_descriptors_nsolid_5fservice_2eproto, file_level_service_descriptors_nsolid_5fservice_2eproto, diff --git a/agents/grpc/src/proto/nsolid_service.pb.h b/agents/grpc/src/proto/nsolid_service.pb.h index 5df81a6c46..65a4450741 100644 --- a/agents/grpc/src/proto/nsolid_service.pb.h +++ b/agents/grpc/src/proto/nsolid_service.pb.h @@ -38,6 +38,7 @@ #include "metrics.pb.h" #include "packages.pb.h" #include "reconfigure.pb.h" +#include "source_code.pb.h" #include "startup_times.pb.h" // @@protoc_insertion_point(includes) #include diff --git a/agents/grpc/src/proto/source_code.grpc.pb.cc b/agents/grpc/src/proto/source_code.grpc.pb.cc new file mode 100644 index 0000000000..7e2ba7001b --- /dev/null +++ b/agents/grpc/src/proto/source_code.grpc.pb.cc @@ -0,0 +1,25 @@ +// Generated by the gRPC C++ plugin. +// If you make any local change, they will be lost. +// source: source_code.proto + +#include "source_code.pb.h" +#include "source_code.grpc.pb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace grpcagent { + +} // namespace grpcagent + diff --git a/agents/grpc/src/proto/source_code.grpc.pb.h b/agents/grpc/src/proto/source_code.grpc.pb.h new file mode 100644 index 0000000000..31fb5e47c8 --- /dev/null +++ b/agents/grpc/src/proto/source_code.grpc.pb.h @@ -0,0 +1,33 @@ +// Generated by the gRPC C++ plugin. +// If you make any local change, they will be lost. +// source: source_code.proto +#ifndef GRPC_source_5fcode_2eproto__INCLUDED +#define GRPC_source_5fcode_2eproto__INCLUDED + +#include "source_code.pb.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace grpcagent { + +} // namespace grpcagent + + +#endif // GRPC_source_5fcode_2eproto__INCLUDED diff --git a/agents/grpc/src/proto/source_code.pb.cc b/agents/grpc/src/proto/source_code.pb.cc new file mode 100644 index 0000000000..c2aab9a101 --- /dev/null +++ b/agents/grpc/src/proto/source_code.pb.cc @@ -0,0 +1,759 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: source_code.proto + +#include "source_code.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) +#include + +PROTOBUF_PRAGMA_INIT_SEG + +namespace _pb = ::PROTOBUF_NAMESPACE_ID; +namespace _pbi = _pb::internal; + +namespace grpcagent { +PROTOBUF_CONSTEXPR SourceCodeArgs::SourceCodeArgs( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.path_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.thread_id_)*/int64_t{0} + , /*decltype(_impl_.script_id_)*/0 + , /*decltype(_impl_._cached_size_)*/{}} {} +struct SourceCodeArgsDefaultTypeInternal { + PROTOBUF_CONSTEXPR SourceCodeArgsDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~SourceCodeArgsDefaultTypeInternal() {} + union { + SourceCodeArgs _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeArgsDefaultTypeInternal _SourceCodeArgs_default_instance_; +PROTOBUF_CONSTEXPR SourceCodeEvent::SourceCodeEvent( + ::_pbi::ConstantInitialized): _impl_{ + /*decltype(_impl_.path_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.code_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}} + , /*decltype(_impl_.common_)*/nullptr + , /*decltype(_impl_.thread_id_)*/int64_t{0} + , /*decltype(_impl_.is_esm_)*/false + , /*decltype(_impl_._cached_size_)*/{}} {} +struct SourceCodeEventDefaultTypeInternal { + PROTOBUF_CONSTEXPR SourceCodeEventDefaultTypeInternal() + : _instance(::_pbi::ConstantInitialized{}) {} + ~SourceCodeEventDefaultTypeInternal() {} + union { + SourceCodeEvent _instance; + }; +}; +PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 SourceCodeEventDefaultTypeInternal _SourceCodeEvent_default_instance_; +} // namespace grpcagent +static ::_pb::Metadata file_level_metadata_source_5fcode_2eproto[2]; +static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_source_5fcode_2eproto = nullptr; +static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_source_5fcode_2eproto = nullptr; + +const uint32_t TableStruct_source_5fcode_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _impl_.thread_id_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _impl_.script_id_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeArgs, _impl_.path_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + ~0u, // no _inlined_string_donated_ + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.common_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.thread_id_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.path_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.code_), + PROTOBUF_FIELD_OFFSET(::grpcagent::SourceCodeEvent, _impl_.is_esm_), +}; +static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + { 0, -1, -1, sizeof(::grpcagent::SourceCodeArgs)}, + { 9, -1, -1, sizeof(::grpcagent::SourceCodeEvent)}, +}; + +static const ::_pb::Message* const file_default_instances[] = { + &::grpcagent::_SourceCodeArgs_default_instance_._instance, + &::grpcagent::_SourceCodeEvent_default_instance_._instance, +}; + +const char descriptor_table_protodef_source_5fcode_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = + "\n\021source_code.proto\022\tgrpcagent\032\014common.p" + "roto\"D\n\016SourceCodeArgs\022\021\n\tthread_id\030\001 \001(" + "\003\022\021\n\tscript_id\030\002 \001(\005\022\014\n\004path\030\003 \001(\t\"{\n\017So" + "urceCodeEvent\022)\n\006common\030\001 \001(\0132\031.grpcagen" + "t.CommonResponse\022\021\n\tthread_id\030\002 \001(\003\022\014\n\004p" + "ath\030\003 \001(\t\022\014\n\004code\030\004 \001(\t\022\016\n\006is_esm\030\005 \001(\010b" + "\006proto3" + ; +static const ::_pbi::DescriptorTable* const descriptor_table_source_5fcode_2eproto_deps[1] = { + &::descriptor_table_common_2eproto, +}; +static ::_pbi::once_flag descriptor_table_source_5fcode_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_source_5fcode_2eproto = { + false, false, 247, descriptor_table_protodef_source_5fcode_2eproto, + "source_code.proto", + &descriptor_table_source_5fcode_2eproto_once, descriptor_table_source_5fcode_2eproto_deps, 1, 2, + schemas, file_default_instances, TableStruct_source_5fcode_2eproto::offsets, + file_level_metadata_source_5fcode_2eproto, file_level_enum_descriptors_source_5fcode_2eproto, + file_level_service_descriptors_source_5fcode_2eproto, +}; +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_source_5fcode_2eproto_getter() { + return &descriptor_table_source_5fcode_2eproto; +} + +// Force running AddDescriptors() at dynamic initialization time. +PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_source_5fcode_2eproto(&descriptor_table_source_5fcode_2eproto); +namespace grpcagent { + +// =================================================================== + +class SourceCodeArgs::_Internal { + public: +}; + +SourceCodeArgs::SourceCodeArgs(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:grpcagent.SourceCodeArgs) +} +SourceCodeArgs::SourceCodeArgs(const SourceCodeArgs& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + SourceCodeArgs* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.thread_id_){} + , decltype(_impl_.script_id_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_path().empty()) { + _this->_impl_.path_.Set(from._internal_path(), + _this->GetArenaForAllocation()); + } + ::memcpy(&_impl_.thread_id_, &from._impl_.thread_id_, + static_cast(reinterpret_cast(&_impl_.script_id_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.script_id_)); + // @@protoc_insertion_point(copy_constructor:grpcagent.SourceCodeArgs) +} + +inline void SourceCodeArgs::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.thread_id_){int64_t{0}} + , decltype(_impl_.script_id_){0} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +SourceCodeArgs::~SourceCodeArgs() { + // @@protoc_insertion_point(destructor:grpcagent.SourceCodeArgs) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void SourceCodeArgs::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.path_.Destroy(); +} + +void SourceCodeArgs::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void SourceCodeArgs::Clear() { +// @@protoc_insertion_point(message_clear_start:grpcagent.SourceCodeArgs) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.path_.ClearToEmpty(); + ::memset(&_impl_.thread_id_, 0, static_cast( + reinterpret_cast(&_impl_.script_id_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.script_id_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* SourceCodeArgs::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // int64 thread_id = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) { + _impl_.thread_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // int32 script_id = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _impl_.script_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // string path = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_path(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "grpcagent.SourceCodeArgs.path")); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* SourceCodeArgs::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:grpcagent.SourceCodeArgs) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // int64 thread_id = 1; + if (this->_internal_thread_id() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(1, this->_internal_thread_id(), target); + } + + // int32 script_id = 2; + if (this->_internal_script_id() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_script_id(), target); + } + + // string path = 3; + if (!this->_internal_path().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_path().data(), static_cast(this->_internal_path().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "grpcagent.SourceCodeArgs.path"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_path(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:grpcagent.SourceCodeArgs) + return target; +} + +size_t SourceCodeArgs::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:grpcagent.SourceCodeArgs) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string path = 3; + if (!this->_internal_path().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_path()); + } + + // int64 thread_id = 1; + if (this->_internal_thread_id() != 0) { + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_thread_id()); + } + + // int32 script_id = 2; + if (this->_internal_script_id() != 0) { + total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_script_id()); + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SourceCodeArgs::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + SourceCodeArgs::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeArgs::GetClassData() const { return &_class_data_; } + + +void SourceCodeArgs::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:grpcagent.SourceCodeArgs) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_path().empty()) { + _this->_internal_set_path(from._internal_path()); + } + if (from._internal_thread_id() != 0) { + _this->_internal_set_thread_id(from._internal_thread_id()); + } + if (from._internal_script_id() != 0) { + _this->_internal_set_script_id(from._internal_script_id()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void SourceCodeArgs::CopyFrom(const SourceCodeArgs& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpcagent.SourceCodeArgs) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool SourceCodeArgs::IsInitialized() const { + return true; +} + +void SourceCodeArgs::InternalSwap(SourceCodeArgs* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.path_, lhs_arena, + &other->_impl_.path_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(SourceCodeArgs, _impl_.script_id_) + + sizeof(SourceCodeArgs::_impl_.script_id_) + - PROTOBUF_FIELD_OFFSET(SourceCodeArgs, _impl_.thread_id_)>( + reinterpret_cast(&_impl_.thread_id_), + reinterpret_cast(&other->_impl_.thread_id_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeArgs::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_source_5fcode_2eproto_getter, &descriptor_table_source_5fcode_2eproto_once, + file_level_metadata_source_5fcode_2eproto[0]); +} + +// =================================================================== + +class SourceCodeEvent::_Internal { + public: + static const ::grpcagent::CommonResponse& common(const SourceCodeEvent* msg); +}; + +const ::grpcagent::CommonResponse& +SourceCodeEvent::_Internal::common(const SourceCodeEvent* msg) { + return *msg->_impl_.common_; +} +void SourceCodeEvent::clear_common() { + if (GetArenaForAllocation() == nullptr && _impl_.common_ != nullptr) { + delete _impl_.common_; + } + _impl_.common_ = nullptr; +} +SourceCodeEvent::SourceCodeEvent(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned) + : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) { + SharedCtor(arena, is_message_owned); + // @@protoc_insertion_point(arena_constructor:grpcagent.SourceCodeEvent) +} +SourceCodeEvent::SourceCodeEvent(const SourceCodeEvent& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + SourceCodeEvent* const _this = this; (void)_this; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.code_){} + , decltype(_impl_.common_){nullptr} + , decltype(_impl_.thread_id_){} + , decltype(_impl_.is_esm_){} + , /*decltype(_impl_._cached_size_)*/{}}; + + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_path().empty()) { + _this->_impl_.path_.Set(from._internal_path(), + _this->GetArenaForAllocation()); + } + _impl_.code_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.code_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (!from._internal_code().empty()) { + _this->_impl_.code_.Set(from._internal_code(), + _this->GetArenaForAllocation()); + } + if (from._internal_has_common()) { + _this->_impl_.common_ = new ::grpcagent::CommonResponse(*from._impl_.common_); + } + ::memcpy(&_impl_.thread_id_, &from._impl_.thread_id_, + static_cast(reinterpret_cast(&_impl_.is_esm_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.is_esm_)); + // @@protoc_insertion_point(copy_constructor:grpcagent.SourceCodeEvent) +} + +inline void SourceCodeEvent::SharedCtor( + ::_pb::Arena* arena, bool is_message_owned) { + (void)arena; + (void)is_message_owned; + new (&_impl_) Impl_{ + decltype(_impl_.path_){} + , decltype(_impl_.code_){} + , decltype(_impl_.common_){nullptr} + , decltype(_impl_.thread_id_){int64_t{0}} + , decltype(_impl_.is_esm_){false} + , /*decltype(_impl_._cached_size_)*/{} + }; + _impl_.path_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.path_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.code_.InitDefault(); + #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + _impl_.code_.Set("", GetArenaForAllocation()); + #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING +} + +SourceCodeEvent::~SourceCodeEvent() { + // @@protoc_insertion_point(destructor:grpcagent.SourceCodeEvent) + if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) { + (void)arena; + return; + } + SharedDtor(); +} + +inline void SourceCodeEvent::SharedDtor() { + GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); + _impl_.path_.Destroy(); + _impl_.code_.Destroy(); + if (this != internal_default_instance()) delete _impl_.common_; +} + +void SourceCodeEvent::SetCachedSize(int size) const { + _impl_._cached_size_.Set(size); +} + +void SourceCodeEvent::Clear() { +// @@protoc_insertion_point(message_clear_start:grpcagent.SourceCodeEvent) + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + _impl_.path_.ClearToEmpty(); + _impl_.code_.ClearToEmpty(); + if (GetArenaForAllocation() == nullptr && _impl_.common_ != nullptr) { + delete _impl_.common_; + } + _impl_.common_ = nullptr; + ::memset(&_impl_.thread_id_, 0, static_cast( + reinterpret_cast(&_impl_.is_esm_) - + reinterpret_cast(&_impl_.thread_id_)) + sizeof(_impl_.is_esm_)); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* SourceCodeEvent::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + while (!ctx->Done(&ptr)) { + uint32_t tag; + ptr = ::_pbi::ReadTag(ptr, &tag); + switch (tag >> 3) { + // .grpcagent.CommonResponse common = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 10)) { + ptr = ctx->ParseMessage(_internal_mutable_common(), ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // int64 thread_id = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { + _impl_.thread_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + // string path = 3; + case 3: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 26)) { + auto str = _internal_mutable_path(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "grpcagent.SourceCodeEvent.path")); + } else + goto handle_unusual; + continue; + // string code = 4; + case 4: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 34)) { + auto str = _internal_mutable_code(); + ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); + CHK_(ptr); + CHK_(::_pbi::VerifyUTF8(str, "grpcagent.SourceCodeEvent.code")); + } else + goto handle_unusual; + continue; + // bool is_esm = 5; + case 5: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) { + _impl_.is_esm_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + CHK_(ptr); + } else + goto handle_unusual; + continue; + default: + goto handle_unusual; + } // switch + handle_unusual: + if ((tag == 0) || ((tag & 7) == 4)) { + CHK_(ptr); + ctx->SetLastTag(tag); + goto message_done; + } + ptr = UnknownFieldParse( + tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + } // while +message_done: + return ptr; +failure: + ptr = nullptr; + goto message_done; +#undef CHK_ +} + +uint8_t* SourceCodeEvent::_InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:grpcagent.SourceCodeEvent) + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + // .grpcagent.CommonResponse common = 1; + if (this->_internal_has_common()) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage(1, _Internal::common(this), + _Internal::common(this).GetCachedSize(), target, stream); + } + + // int64 thread_id = 2; + if (this->_internal_thread_id() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_thread_id(), target); + } + + // string path = 3; + if (!this->_internal_path().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_path().data(), static_cast(this->_internal_path().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "grpcagent.SourceCodeEvent.path"); + target = stream->WriteStringMaybeAliased( + 3, this->_internal_path(), target); + } + + // string code = 4; + if (!this->_internal_code().empty()) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_code().data(), static_cast(this->_internal_code().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "grpcagent.SourceCodeEvent.code"); + target = stream->WriteStringMaybeAliased( + 4, this->_internal_code(), target); + } + + // bool is_esm = 5; + if (this->_internal_is_esm() != 0) { + target = stream->EnsureSpace(target); + target = ::_pbi::WireFormatLite::WriteBoolToArray(5, this->_internal_is_esm(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:grpcagent.SourceCodeEvent) + return target; +} + +size_t SourceCodeEvent::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:grpcagent.SourceCodeEvent) + size_t total_size = 0; + + uint32_t cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string path = 3; + if (!this->_internal_path().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_path()); + } + + // string code = 4; + if (!this->_internal_code().empty()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_code()); + } + + // .grpcagent.CommonResponse common = 1; + if (this->_internal_has_common()) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *_impl_.common_); + } + + // int64 thread_id = 2; + if (this->_internal_thread_id() != 0) { + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_thread_id()); + } + + // bool is_esm = 5; + if (this->_internal_is_esm() != 0) { + total_size += 1 + 1; + } + + return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); +} + +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData SourceCodeEvent::_class_data_ = { + ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck, + SourceCodeEvent::MergeImpl +}; +const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*SourceCodeEvent::GetClassData() const { return &_class_data_; } + + +void SourceCodeEvent::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) { + auto* const _this = static_cast(&to_msg); + auto& from = static_cast(from_msg); + // @@protoc_insertion_point(class_specific_merge_from_start:grpcagent.SourceCodeEvent) + GOOGLE_DCHECK_NE(&from, _this); + uint32_t cached_has_bits = 0; + (void) cached_has_bits; + + if (!from._internal_path().empty()) { + _this->_internal_set_path(from._internal_path()); + } + if (!from._internal_code().empty()) { + _this->_internal_set_code(from._internal_code()); + } + if (from._internal_has_common()) { + _this->_internal_mutable_common()->::grpcagent::CommonResponse::MergeFrom( + from._internal_common()); + } + if (from._internal_thread_id() != 0) { + _this->_internal_set_thread_id(from._internal_thread_id()); + } + if (from._internal_is_esm() != 0) { + _this->_internal_set_is_esm(from._internal_is_esm()); + } + _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); +} + +void SourceCodeEvent::CopyFrom(const SourceCodeEvent& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:grpcagent.SourceCodeEvent) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool SourceCodeEvent::IsInitialized() const { + return true; +} + +void SourceCodeEvent::InternalSwap(SourceCodeEvent* other) { + using std::swap; + auto* lhs_arena = GetArenaForAllocation(); + auto* rhs_arena = other->GetArenaForAllocation(); + _internal_metadata_.InternalSwap(&other->_internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.path_, lhs_arena, + &other->_impl_.path_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( + &_impl_.code_, lhs_arena, + &other->_impl_.code_, rhs_arena + ); + ::PROTOBUF_NAMESPACE_ID::internal::memswap< + PROTOBUF_FIELD_OFFSET(SourceCodeEvent, _impl_.is_esm_) + + sizeof(SourceCodeEvent::_impl_.is_esm_) + - PROTOBUF_FIELD_OFFSET(SourceCodeEvent, _impl_.common_)>( + reinterpret_cast(&_impl_.common_), + reinterpret_cast(&other->_impl_.common_)); +} + +::PROTOBUF_NAMESPACE_ID::Metadata SourceCodeEvent::GetMetadata() const { + return ::_pbi::AssignDescriptors( + &descriptor_table_source_5fcode_2eproto_getter, &descriptor_table_source_5fcode_2eproto_once, + file_level_metadata_source_5fcode_2eproto[1]); +} + +// @@protoc_insertion_point(namespace_scope) +} // namespace grpcagent +PROTOBUF_NAMESPACE_OPEN +template<> PROTOBUF_NOINLINE ::grpcagent::SourceCodeArgs* +Arena::CreateMaybeMessage< ::grpcagent::SourceCodeArgs >(Arena* arena) { + return Arena::CreateMessageInternal< ::grpcagent::SourceCodeArgs >(arena); +} +template<> PROTOBUF_NOINLINE ::grpcagent::SourceCodeEvent* +Arena::CreateMaybeMessage< ::grpcagent::SourceCodeEvent >(Arena* arena) { + return Arena::CreateMessageInternal< ::grpcagent::SourceCodeEvent >(arena); +} +PROTOBUF_NAMESPACE_CLOSE + +// @@protoc_insertion_point(global_scope) +#include diff --git a/agents/grpc/src/proto/source_code.pb.h b/agents/grpc/src/proto/source_code.pb.h new file mode 100644 index 0000000000..eb1f2a2a95 --- /dev/null +++ b/agents/grpc/src/proto/source_code.pb.h @@ -0,0 +1,791 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: source_code.proto + +#ifndef GOOGLE_PROTOBUF_INCLUDED_source_5fcode_2eproto +#define GOOGLE_PROTOBUF_INCLUDED_source_5fcode_2eproto + +#include +#include + +#include +#if PROTOBUF_VERSION < 3021000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 3021012 < PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include // IWYU pragma: export +#include // IWYU pragma: export +#include +#include "common.pb.h" +// @@protoc_insertion_point(includes) +#include +#define PROTOBUF_INTERNAL_EXPORT_source_5fcode_2eproto +PROTOBUF_NAMESPACE_OPEN +namespace internal { +class AnyMetadata; +} // namespace internal +PROTOBUF_NAMESPACE_CLOSE + +// Internal implementation detail -- do not use these members. +struct TableStruct_source_5fcode_2eproto { + static const uint32_t offsets[]; +}; +extern const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_source_5fcode_2eproto; +namespace grpcagent { +class SourceCodeArgs; +struct SourceCodeArgsDefaultTypeInternal; +extern SourceCodeArgsDefaultTypeInternal _SourceCodeArgs_default_instance_; +class SourceCodeEvent; +struct SourceCodeEventDefaultTypeInternal; +extern SourceCodeEventDefaultTypeInternal _SourceCodeEvent_default_instance_; +} // namespace grpcagent +PROTOBUF_NAMESPACE_OPEN +template<> ::grpcagent::SourceCodeArgs* Arena::CreateMaybeMessage<::grpcagent::SourceCodeArgs>(Arena*); +template<> ::grpcagent::SourceCodeEvent* Arena::CreateMaybeMessage<::grpcagent::SourceCodeEvent>(Arena*); +PROTOBUF_NAMESPACE_CLOSE +namespace grpcagent { + +// =================================================================== + +class SourceCodeArgs final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:grpcagent.SourceCodeArgs) */ { + public: + inline SourceCodeArgs() : SourceCodeArgs(nullptr) {} + ~SourceCodeArgs() override; + explicit PROTOBUF_CONSTEXPR SourceCodeArgs(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + SourceCodeArgs(const SourceCodeArgs& from); + SourceCodeArgs(SourceCodeArgs&& from) noexcept + : SourceCodeArgs() { + *this = ::std::move(from); + } + + inline SourceCodeArgs& operator=(const SourceCodeArgs& from) { + CopyFrom(from); + return *this; + } + inline SourceCodeArgs& operator=(SourceCodeArgs&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const SourceCodeArgs& default_instance() { + return *internal_default_instance(); + } + static inline const SourceCodeArgs* internal_default_instance() { + return reinterpret_cast( + &_SourceCodeArgs_default_instance_); + } + static constexpr int kIndexInFileMessages = + 0; + + friend void swap(SourceCodeArgs& a, SourceCodeArgs& b) { + a.Swap(&b); + } + inline void Swap(SourceCodeArgs* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SourceCodeArgs* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + SourceCodeArgs* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const SourceCodeArgs& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const SourceCodeArgs& from) { + SourceCodeArgs::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(SourceCodeArgs* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "grpcagent.SourceCodeArgs"; + } + protected: + explicit SourceCodeArgs(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPathFieldNumber = 3, + kThreadIdFieldNumber = 1, + kScriptIdFieldNumber = 2, + }; + // string path = 3; + void clear_path(); + const std::string& path() const; + template + void set_path(ArgT0&& arg0, ArgT... args); + std::string* mutable_path(); + PROTOBUF_NODISCARD std::string* release_path(); + void set_allocated_path(std::string* path); + private: + const std::string& _internal_path() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_path(const std::string& value); + std::string* _internal_mutable_path(); + public: + + // int64 thread_id = 1; + void clear_thread_id(); + int64_t thread_id() const; + void set_thread_id(int64_t value); + private: + int64_t _internal_thread_id() const; + void _internal_set_thread_id(int64_t value); + public: + + // int32 script_id = 2; + void clear_script_id(); + int32_t script_id() const; + void set_script_id(int32_t value); + private: + int32_t _internal_script_id() const; + void _internal_set_script_id(int32_t value); + public: + + // @@protoc_insertion_point(class_scope:grpcagent.SourceCodeArgs) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr path_; + int64_t thread_id_; + int32_t script_id_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_source_5fcode_2eproto; +}; +// ------------------------------------------------------------------- + +class SourceCodeEvent final : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:grpcagent.SourceCodeEvent) */ { + public: + inline SourceCodeEvent() : SourceCodeEvent(nullptr) {} + ~SourceCodeEvent() override; + explicit PROTOBUF_CONSTEXPR SourceCodeEvent(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized); + + SourceCodeEvent(const SourceCodeEvent& from); + SourceCodeEvent(SourceCodeEvent&& from) noexcept + : SourceCodeEvent() { + *this = ::std::move(from); + } + + inline SourceCodeEvent& operator=(const SourceCodeEvent& from) { + CopyFrom(from); + return *this; + } + inline SourceCodeEvent& operator=(SourceCodeEvent&& from) noexcept { + if (this == &from) return *this; + if (GetOwningArena() == from.GetOwningArena() + #ifdef PROTOBUF_FORCE_COPY_IN_MOVE + && GetOwningArena() != nullptr + #endif // !PROTOBUF_FORCE_COPY_IN_MOVE + ) { + InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return default_instance().GetMetadata().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return default_instance().GetMetadata().reflection; + } + static const SourceCodeEvent& default_instance() { + return *internal_default_instance(); + } + static inline const SourceCodeEvent* internal_default_instance() { + return reinterpret_cast( + &_SourceCodeEvent_default_instance_); + } + static constexpr int kIndexInFileMessages = + 1; + + friend void swap(SourceCodeEvent& a, SourceCodeEvent& b) { + a.Swap(&b); + } + inline void Swap(SourceCodeEvent* other) { + if (other == this) return; + #ifdef PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() != nullptr && + GetOwningArena() == other->GetOwningArena()) { + #else // PROTOBUF_FORCE_COPY_IN_SWAP + if (GetOwningArena() == other->GetOwningArena()) { + #endif // !PROTOBUF_FORCE_COPY_IN_SWAP + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(SourceCodeEvent* other) { + if (other == this) return; + GOOGLE_DCHECK(GetOwningArena() == other->GetOwningArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + SourceCodeEvent* New(::PROTOBUF_NAMESPACE_ID::Arena* arena = nullptr) const final { + return CreateMaybeMessage(arena); + } + using ::PROTOBUF_NAMESPACE_ID::Message::CopyFrom; + void CopyFrom(const SourceCodeEvent& from); + using ::PROTOBUF_NAMESPACE_ID::Message::MergeFrom; + void MergeFrom( const SourceCodeEvent& from) { + SourceCodeEvent::MergeImpl(*this, from); + } + private: + static void MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg); + public: + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + uint8_t* _InternalSerialize( + uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _impl_._cached_size_.Get(); } + + private: + void SharedCtor(::PROTOBUF_NAMESPACE_ID::Arena* arena, bool is_message_owned); + void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(SourceCodeEvent* other); + + private: + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "grpcagent.SourceCodeEvent"; + } + protected: + explicit SourceCodeEvent(::PROTOBUF_NAMESPACE_ID::Arena* arena, + bool is_message_owned = false); + public: + + static const ClassData _class_data_; + const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*GetClassData() const final; + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kPathFieldNumber = 3, + kCodeFieldNumber = 4, + kCommonFieldNumber = 1, + kThreadIdFieldNumber = 2, + kIsEsmFieldNumber = 5, + }; + // string path = 3; + void clear_path(); + const std::string& path() const; + template + void set_path(ArgT0&& arg0, ArgT... args); + std::string* mutable_path(); + PROTOBUF_NODISCARD std::string* release_path(); + void set_allocated_path(std::string* path); + private: + const std::string& _internal_path() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_path(const std::string& value); + std::string* _internal_mutable_path(); + public: + + // string code = 4; + void clear_code(); + const std::string& code() const; + template + void set_code(ArgT0&& arg0, ArgT... args); + std::string* mutable_code(); + PROTOBUF_NODISCARD std::string* release_code(); + void set_allocated_code(std::string* code); + private: + const std::string& _internal_code() const; + inline PROTOBUF_ALWAYS_INLINE void _internal_set_code(const std::string& value); + std::string* _internal_mutable_code(); + public: + + // .grpcagent.CommonResponse common = 1; + bool has_common() const; + private: + bool _internal_has_common() const; + public: + void clear_common(); + const ::grpcagent::CommonResponse& common() const; + PROTOBUF_NODISCARD ::grpcagent::CommonResponse* release_common(); + ::grpcagent::CommonResponse* mutable_common(); + void set_allocated_common(::grpcagent::CommonResponse* common); + private: + const ::grpcagent::CommonResponse& _internal_common() const; + ::grpcagent::CommonResponse* _internal_mutable_common(); + public: + void unsafe_arena_set_allocated_common( + ::grpcagent::CommonResponse* common); + ::grpcagent::CommonResponse* unsafe_arena_release_common(); + + // int64 thread_id = 2; + void clear_thread_id(); + int64_t thread_id() const; + void set_thread_id(int64_t value); + private: + int64_t _internal_thread_id() const; + void _internal_set_thread_id(int64_t value); + public: + + // bool is_esm = 5; + void clear_is_esm(); + bool is_esm() const; + void set_is_esm(bool value); + private: + bool _internal_is_esm() const; + void _internal_set_is_esm(bool value); + public: + + // @@protoc_insertion_point(class_scope:grpcagent.SourceCodeEvent) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + struct Impl_ { + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr path_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr code_; + ::grpcagent::CommonResponse* common_; + int64_t thread_id_; + bool is_esm_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + }; + union { Impl_ _impl_; }; + friend struct ::TableStruct_source_5fcode_2eproto; +}; +// =================================================================== + + +// =================================================================== + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ +// SourceCodeArgs + +// int64 thread_id = 1; +inline void SourceCodeArgs::clear_thread_id() { + _impl_.thread_id_ = int64_t{0}; +} +inline int64_t SourceCodeArgs::_internal_thread_id() const { + return _impl_.thread_id_; +} +inline int64_t SourceCodeArgs::thread_id() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeArgs.thread_id) + return _internal_thread_id(); +} +inline void SourceCodeArgs::_internal_set_thread_id(int64_t value) { + + _impl_.thread_id_ = value; +} +inline void SourceCodeArgs::set_thread_id(int64_t value) { + _internal_set_thread_id(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeArgs.thread_id) +} + +// int32 script_id = 2; +inline void SourceCodeArgs::clear_script_id() { + _impl_.script_id_ = 0; +} +inline int32_t SourceCodeArgs::_internal_script_id() const { + return _impl_.script_id_; +} +inline int32_t SourceCodeArgs::script_id() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeArgs.script_id) + return _internal_script_id(); +} +inline void SourceCodeArgs::_internal_set_script_id(int32_t value) { + + _impl_.script_id_ = value; +} +inline void SourceCodeArgs::set_script_id(int32_t value) { + _internal_set_script_id(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeArgs.script_id) +} + +// string path = 3; +inline void SourceCodeArgs::clear_path() { + _impl_.path_.ClearToEmpty(); +} +inline const std::string& SourceCodeArgs::path() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeArgs.path) + return _internal_path(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeArgs::set_path(ArgT0&& arg0, ArgT... args) { + + _impl_.path_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeArgs.path) +} +inline std::string* SourceCodeArgs::mutable_path() { + std::string* _s = _internal_mutable_path(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeArgs.path) + return _s; +} +inline const std::string& SourceCodeArgs::_internal_path() const { + return _impl_.path_.Get(); +} +inline void SourceCodeArgs::_internal_set_path(const std::string& value) { + + _impl_.path_.Set(value, GetArenaForAllocation()); +} +inline std::string* SourceCodeArgs::_internal_mutable_path() { + + return _impl_.path_.Mutable(GetArenaForAllocation()); +} +inline std::string* SourceCodeArgs::release_path() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeArgs.path) + return _impl_.path_.Release(); +} +inline void SourceCodeArgs::set_allocated_path(std::string* path) { + if (path != nullptr) { + + } else { + + } + _impl_.path_.SetAllocated(path, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.path_.IsDefault()) { + _impl_.path_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeArgs.path) +} + +// ------------------------------------------------------------------- + +// SourceCodeEvent + +// .grpcagent.CommonResponse common = 1; +inline bool SourceCodeEvent::_internal_has_common() const { + return this != internal_default_instance() && _impl_.common_ != nullptr; +} +inline bool SourceCodeEvent::has_common() const { + return _internal_has_common(); +} +inline const ::grpcagent::CommonResponse& SourceCodeEvent::_internal_common() const { + const ::grpcagent::CommonResponse* p = _impl_.common_; + return p != nullptr ? *p : reinterpret_cast( + ::grpcagent::_CommonResponse_default_instance_); +} +inline const ::grpcagent::CommonResponse& SourceCodeEvent::common() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.common) + return _internal_common(); +} +inline void SourceCodeEvent::unsafe_arena_set_allocated_common( + ::grpcagent::CommonResponse* common) { + if (GetArenaForAllocation() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.common_); + } + _impl_.common_ = common; + if (common) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:grpcagent.SourceCodeEvent.common) +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::release_common() { + + ::grpcagent::CommonResponse* temp = _impl_.common_; + _impl_.common_ = nullptr; +#ifdef PROTOBUF_FORCE_COPY_IN_RELEASE + auto* old = reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(temp); + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + if (GetArenaForAllocation() == nullptr) { delete old; } +#else // PROTOBUF_FORCE_COPY_IN_RELEASE + if (GetArenaForAllocation() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } +#endif // !PROTOBUF_FORCE_COPY_IN_RELEASE + return temp; +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::unsafe_arena_release_common() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeEvent.common) + + ::grpcagent::CommonResponse* temp = _impl_.common_; + _impl_.common_ = nullptr; + return temp; +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::_internal_mutable_common() { + + if (_impl_.common_ == nullptr) { + auto* p = CreateMaybeMessage<::grpcagent::CommonResponse>(GetArenaForAllocation()); + _impl_.common_ = p; + } + return _impl_.common_; +} +inline ::grpcagent::CommonResponse* SourceCodeEvent::mutable_common() { + ::grpcagent::CommonResponse* _msg = _internal_mutable_common(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeEvent.common) + return _msg; +} +inline void SourceCodeEvent::set_allocated_common(::grpcagent::CommonResponse* common) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation(); + if (message_arena == nullptr) { + delete reinterpret_cast< ::PROTOBUF_NAMESPACE_ID::MessageLite*>(_impl_.common_); + } + if (common) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena( + reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(common)); + if (message_arena != submessage_arena) { + common = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, common, submessage_arena); + } + + } else { + + } + _impl_.common_ = common; + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeEvent.common) +} + +// int64 thread_id = 2; +inline void SourceCodeEvent::clear_thread_id() { + _impl_.thread_id_ = int64_t{0}; +} +inline int64_t SourceCodeEvent::_internal_thread_id() const { + return _impl_.thread_id_; +} +inline int64_t SourceCodeEvent::thread_id() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.thread_id) + return _internal_thread_id(); +} +inline void SourceCodeEvent::_internal_set_thread_id(int64_t value) { + + _impl_.thread_id_ = value; +} +inline void SourceCodeEvent::set_thread_id(int64_t value) { + _internal_set_thread_id(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.thread_id) +} + +// string path = 3; +inline void SourceCodeEvent::clear_path() { + _impl_.path_.ClearToEmpty(); +} +inline const std::string& SourceCodeEvent::path() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.path) + return _internal_path(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeEvent::set_path(ArgT0&& arg0, ArgT... args) { + + _impl_.path_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.path) +} +inline std::string* SourceCodeEvent::mutable_path() { + std::string* _s = _internal_mutable_path(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeEvent.path) + return _s; +} +inline const std::string& SourceCodeEvent::_internal_path() const { + return _impl_.path_.Get(); +} +inline void SourceCodeEvent::_internal_set_path(const std::string& value) { + + _impl_.path_.Set(value, GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::_internal_mutable_path() { + + return _impl_.path_.Mutable(GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::release_path() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeEvent.path) + return _impl_.path_.Release(); +} +inline void SourceCodeEvent::set_allocated_path(std::string* path) { + if (path != nullptr) { + + } else { + + } + _impl_.path_.SetAllocated(path, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.path_.IsDefault()) { + _impl_.path_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeEvent.path) +} + +// string code = 4; +inline void SourceCodeEvent::clear_code() { + _impl_.code_.ClearToEmpty(); +} +inline const std::string& SourceCodeEvent::code() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.code) + return _internal_code(); +} +template +inline PROTOBUF_ALWAYS_INLINE +void SourceCodeEvent::set_code(ArgT0&& arg0, ArgT... args) { + + _impl_.code_.Set(static_cast(arg0), args..., GetArenaForAllocation()); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.code) +} +inline std::string* SourceCodeEvent::mutable_code() { + std::string* _s = _internal_mutable_code(); + // @@protoc_insertion_point(field_mutable:grpcagent.SourceCodeEvent.code) + return _s; +} +inline const std::string& SourceCodeEvent::_internal_code() const { + return _impl_.code_.Get(); +} +inline void SourceCodeEvent::_internal_set_code(const std::string& value) { + + _impl_.code_.Set(value, GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::_internal_mutable_code() { + + return _impl_.code_.Mutable(GetArenaForAllocation()); +} +inline std::string* SourceCodeEvent::release_code() { + // @@protoc_insertion_point(field_release:grpcagent.SourceCodeEvent.code) + return _impl_.code_.Release(); +} +inline void SourceCodeEvent::set_allocated_code(std::string* code) { + if (code != nullptr) { + + } else { + + } + _impl_.code_.SetAllocated(code, GetArenaForAllocation()); +#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING + if (_impl_.code_.IsDefault()) { + _impl_.code_.Set("", GetArenaForAllocation()); + } +#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING + // @@protoc_insertion_point(field_set_allocated:grpcagent.SourceCodeEvent.code) +} + +// bool is_esm = 5; +inline void SourceCodeEvent::clear_is_esm() { + _impl_.is_esm_ = false; +} +inline bool SourceCodeEvent::_internal_is_esm() const { + return _impl_.is_esm_; +} +inline bool SourceCodeEvent::is_esm() const { + // @@protoc_insertion_point(field_get:grpcagent.SourceCodeEvent.is_esm) + return _internal_is_esm(); +} +inline void SourceCodeEvent::_internal_set_is_esm(bool value) { + + _impl_.is_esm_ = value; +} +inline void SourceCodeEvent::set_is_esm(bool value) { + _internal_set_is_esm(value); + // @@protoc_insertion_point(field_set:grpcagent.SourceCodeEvent.is_esm) +} + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ +// ------------------------------------------------------------------- + + +// @@protoc_insertion_point(namespace_scope) + +} // namespace grpcagent + +// @@protoc_insertion_point(global_scope) + +#include +#endif // GOOGLE_PROTOBUF_INCLUDED_GOOGLE_PROTOBUF_INCLUDED_source_5fcode_2eproto diff --git a/node.gyp b/node.gyp index b58598b785..577fadd78d 100644 --- a/node.gyp +++ b/node.gyp @@ -452,6 +452,8 @@ 'agents/grpc/src/proto/profile.pb.cc', 'agents/grpc/src/proto/reconfigure.grpc.pb.cc', 'agents/grpc/src/proto/reconfigure.pb.cc', + 'agents/grpc/src/proto/source_code.grpc.pb.cc', + 'agents/grpc/src/proto/source_code.pb.cc', 'agents/grpc/src/proto/startup_times.grpc.pb.cc', 'agents/grpc/src/proto/startup_times.pb.cc', 'agents/grpc/src/proto/nsolid_service.grpc.pb.h', @@ -476,6 +478,8 @@ 'agents/grpc/src/proto/profile.pb.h', 'agents/grpc/src/proto/reconfigure.grpc.pb.h', 'agents/grpc/src/proto/reconfigure.pb.h', + 'agents/grpc/src/proto/source_code.grpc.pb.h', + 'agents/grpc/src/proto/source_code.pb.h', 'agents/grpc/src/proto/startup_times.grpc.pb.h', 'agents/grpc/src/proto/startup_times.pb.h', 'agents/otlp/src/datadog_metrics.cc', diff --git a/src/module_wrap.cc b/src/module_wrap.cc index e2252639cf..f005d4f1aa 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -9,6 +9,7 @@ #include "node_process-inl.h" #include "node_watchdog.h" #include "util-inl.h" +#include "nsolid/nsolid_api.h" #include // S_IFDIR @@ -397,6 +398,9 @@ MaybeLocal ModuleWrap::CompileSourceTextModule( cache_entry, module, *cache_rejected); } + auto envinst = nsolid::EnvInst::GetCurrent(isolate); + envinst->StoreSourceCode(module->ScriptId(), url, source_text, true); + return scope.Escape(module); } diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 5f4529262a..a26b1f838a 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -34,6 +34,7 @@ #include "node_url.h" #include "node_watchdog.h" #include "util-inl.h" +#include "nsolid/nsolid_api.h" namespace node { namespace contextify { @@ -1672,6 +1673,10 @@ static MaybeLocal CompileFunctionForCJSLoader( if (cache_entry != nullptr) { env->compile_cache_handler()->MaybeSave(cache_entry, fn, *cache_rejected); } + + auto envinst = nsolid::EnvInst::GetCurrent(isolate); + envinst->StoreSourceCode(fn->ScriptId(), filename, code, false); + return scope.Escape(fn); } @@ -1792,6 +1797,7 @@ static void CompileFunctionForCJSLoader( }; Local result = Object::New( isolate, v8::Null(isolate), names.data(), values.data(), names.size()); + args.GetReturnValue().Set(result); } diff --git a/src/nsolid/nsolid_api.cc b/src/nsolid/nsolid_api.cc index 6982ae7b56..75847a11b6 100644 --- a/src/nsolid/nsolid_api.cc +++ b/src/nsolid/nsolid_api.cc @@ -121,6 +121,8 @@ EnvInst::EnvInst(Environment* env) CHECK_EQ(er, 0); er = custom_command_stor_map_lock_.init(true); CHECK_EQ(er, 0); + er = source_files_lock_.init(true); + CHECK_EQ(er, 0); eloop_cmds_msg_.unref(); interrupt_msg_.unref(); @@ -766,6 +768,67 @@ int EnvInst::CustomCommandResponse(const std::string& req_id, } +int EnvInst::GetSourceCode(int script_id, + const std::string& path, + std::string* code) { + SourceCodeInfo info; + { + ns_mutex::scoped_lock lock(source_files_lock_); + auto it = source_files_.find(script_id); + if (it == source_files_.end()) { + return UV_ENOENT; + } + + info = it->second; + } + + if (info.url != path) { + return UV_ENOENT; + } + + if (!info.code.empty()) { + *code = info.code; + return 0; + } + + std::string real_path; + if (info.is_esm && path.find("file://") == 0) { + real_path = path.substr(7); + } else { + real_path = path; + } + + return ReadFileSync(code, real_path.c_str());; +} + + +void EnvInst::StoreSourceCode(int script_id, + v8::Local url, + v8::Local code, + bool is_esm) { + if (url.IsEmpty() || code.IsEmpty()) { + return; + } + + // fprintf(stderr, "[%d][%ld] StoreSourceCode: %s\n", script_id, thread_id_, + // *Utf8Value(isolate_, url)); + ns_mutex::scoped_lock lock(source_files_lock_); + auto pair = source_files_.try_emplace(script_id, SourceCodeInfo{}); + if (!pair.second) { + return; + } + + SourceCodeInfo& info = pair.first->second; + info.url = *Utf8Value(isolate_, url); + if (is_esm && info.url.find("file://") != 0) { + // If the URL is not a file URL, store the code. + info.code = *Utf8Value(isolate_, code); + } + + info.is_esm = is_esm; +} + + EnvList::EnvList(): info_(nlohmann::json()) { int er; // Create event loop and new thread to run EnvList commands. @@ -2695,6 +2758,7 @@ static void HeapSampling(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(ret); } + static void HeapSamplingEnd(const FunctionCallbackInfo& args) { CHECK(args[0]->IsNumber()); // thread_id uint64_t thread_id = args[0].As()->Value(); diff --git a/src/nsolid/nsolid_api.h b/src/nsolid/nsolid_api.h index 55fd6cfb91..0822d72d91 100644 --- a/src/nsolid/nsolid_api.h +++ b/src/nsolid/nsolid_api.h @@ -229,6 +229,14 @@ class EnvInst { std::string GetThreadName() const; void SetThreadName(const std::string& name); + int GetSourceCode(int script_id, + const std::string& path, + std::string* code); + void StoreSourceCode(int script_id, + v8::Local url, + v8::Local code, + bool is_esm); + void inc_fs_handles_closed() { fs_handles_closed_++; } void inc_fs_handles_opened() { fs_handles_opened_++; } @@ -286,6 +294,12 @@ class EnvInst { friend class ThreadMetrics; friend class std::shared_ptr; + struct SourceCodeInfo { + std::string url; + std::string code; + bool is_esm; + }; + explicit EnvInst(Environment* env); ~EnvInst() = default; @@ -398,6 +412,9 @@ class EnvInst { std::string thread_name_; uint32_t trace_flags_; bool has_metrics_stream_hooks_; + + nsuv::ns_mutex source_files_lock_; + std::map source_files_; }; /** diff --git a/test/agents/test-grpc-source-code.mjs b/test/agents/test-grpc-source-code.mjs new file mode 100644 index 0000000000..8c891fd4da --- /dev/null +++ b/test/agents/test-grpc-source-code.mjs @@ -0,0 +1,340 @@ +// Flags: --expose-internals +import { mustCall, mustSucceed } from '../common/index.mjs'; +import { fixturesDir } from '../common/fixtures.mjs'; +import assert from 'node:assert'; +import fs from 'node:fs'; +import path from 'node:path'; +import validators from 'internal/validators'; +import { + GRPCServer, + TestClient, +} from '../common/nsolid-grpc-agent/index.js'; + +const { + validateArray, + validateObject, + validateString, +} = validators; + +function checkSourceCodeData(sourceCode, metadata, requestId, agentId, options) { + // console.dir(sourceCode, { depth: null }); + validateString(sourceCode.common.requestId, 'requestId'); + assert.ok(sourceCode.common.requestId.length > 0); + if (requestId) { + assert.strictEqual(sourceCode.common.requestId, requestId); + } + + assert.strictEqual(sourceCode.common.command, 'source_code'); + // From here check at least that all the fields are present + validateObject(sourceCode.common.recorded, 'recorded'); + const recSeconds = BigInt(sourceCode.common.recorded.seconds); + assert.ok(recSeconds); + const recNanoSecs = BigInt(sourceCode.common.recorded.nanoseconds); + assert.ok(recNanoSecs); + + assert.toString(sourceCode.threadId, options.threadId); + assert.strictEqual(sourceCode.path, options.path); + let realPath = options.path; + if (realPath.startsWith('file://')) { + realPath = realPath.substring(7); + } + + if (realPath.startsWith('data:text/javascript,')) { + assert.strictEqual(sourceCode.code, realPath.substring(21)); + } else { + assert.strictEqual(fs.readFileSync(realPath).toString(), sourceCode.code); + } + + + validateArray(metadata['user-agent'], 'metadata.user-agent'); + validateString(metadata['user-agent'][0], 'metadata.user-agent[0]'); + assert.strictEqual(metadata['nsolid-agent-id'][0], agentId); +} + +function checkSourceCodeError(sourceCode, metadata, requestId, agentId, code, msg) { + console.dir(sourceCode, { depth: null }); + assert.strictEqual(sourceCode.common.requestId, requestId); + assert.strictEqual(sourceCode.common.command, 'source_code'); + // From here check at least that all the fields are present + validateObject(sourceCode.common.recorded, 'recorded'); + const recSeconds = BigInt(sourceCode.common.recorded.seconds); + assert.ok(recSeconds); + const recNanoSecs = BigInt(sourceCode.common.recorded.nanoseconds); + assert.ok(recNanoSecs); + + validateObject(sourceCode.common.error, 'error'); + assert.strictEqual(sourceCode.common.error.code, code); + assert.strictEqual(sourceCode.common.error.message, msg); + + validateArray(metadata['user-agent'], 'metadata.user-agent'); + validateString(metadata['user-agent'][0], 'metadata.user-agent[0]'); + assert.strictEqual(metadata['nsolid-agent-id'][0], agentId); +} + +const tests = []; + +tests.push({ + name: 'should work for both cjs and esm scripts and fail for non-existent scripts on the main thread', + test: async () => { + return new Promise((resolve) => { + const importPath = path.join(fixturesDir, 'nsolid-source-code', 'index.mjs'); + const esmPath = path.join(fixturesDir, 'nsolid-source-code', 'esm.mjs'); + const commonPath = path.join(fixturesDir, 'nsolid-source-code', 'common.js'); + const grpcServer = new GRPCServer(); + grpcServer.start(mustSucceed(async (port) => { + grpcServer.on('loop_blocked', mustCall(async (data) => { + console.dir(data.msg, { depth: null }); + const scripts = []; + for (const frame of data.msg.body.stack) { + if (frame.scriptName.includes('client.js') || + frame.scriptName.includes(importPath) || + frame.scriptName.includes(esmPath) || + frame.scriptName.includes(commonPath)) { + scripts.push({ + scriptId: frame.scriptId, + path: frame.scriptName, + }); + } + } + + assert.strictEqual(scripts.length, 4); + for (const { scriptId, path } of scripts) { + const options = { + threadId: 0, + scriptId, + path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeData(ret.data.msg, ret.data.metadata, ret.requestId, agentId, options); + } + + // It should fail for a non-existent script + { + const options = { + threadId: 0, + scriptId: 0, + path: 'non-existent', + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + // It should also fail for a non-existent scriptId + { + const options = { + threadId: 0, + scriptId: 10000, + path: scripts[0].path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + // It should also fail for a non-existent thread + { + const options = { + threadId: 23, + scriptId: 10000, + path: scripts[0].path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 410, + 'Thread already gone(1002)'); + } + + await child.shutdown(0); + grpcServer.close(); + resolve(); + })); + + const env = { + NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', + NSOLID_GRPC_INSECURE: 1, + NSOLID_GRPC: `localhost:${port}`, + }; + + const opts = { + stdio: ['inherit', 'inherit', 'inherit', 'ipc'], + env, + }; + const child = new TestClient([], opts); + const agentId = await child.id(); + await child.importURL(importPath, 0); + })); + }); + }, +}); + +tests.push({ + name: 'should work for both cjs and esm scripts and fail for non-existent scripts on a worker thread', + test: async () => { + return new Promise((resolve) => { + const importPath = path.join(fixturesDir, 'nsolid-source-code', 'index.mjs'); + const esmPath = path.join(fixturesDir, 'nsolid-source-code', 'esm.mjs'); + const commonPath = path.join(fixturesDir, 'nsolid-source-code', 'common.js'); + const grpcServer = new GRPCServer(); + grpcServer.start(mustSucceed(async (port) => { + grpcServer.on('loop_blocked', mustCall(async (data) => { + console.dir(data.msg, { depth: null }); + const scripts = []; + for (const frame of data.msg.body.stack) { + if (frame.scriptName.includes('client.js') || + frame.scriptName.includes(importPath) || + frame.scriptName.includes(esmPath) || + frame.scriptName.includes(commonPath)) { + scripts.push({ + scriptId: frame.scriptId, + path: frame.scriptName, + }); + } + } + + assert.strictEqual(scripts.length, 4); + for (const { scriptId, path } of scripts) { + const options = { + threadId: wid, + scriptId, + path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeData(ret.data.msg, ret.data.metadata, ret.requestId, agentId, options); + } + + // It should fail for a non-existent script + { + const options = { + threadId: wid, + scriptId: 0, + path: 'non-existent', + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + // It should also fail for a non-existent scriptId + { + const options = { + threadId: wid, + scriptId: 10000, + path: scripts[0].path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeError(ret.data.msg, + ret.data.metadata, + ret.requestId, + agentId, + 500, + 'Internal Runtime Error(1007)'); + } + + await child.shutdown(0); + grpcServer.close(); + resolve(); + })); + + const env = { + NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', + NSOLID_GRPC_INSECURE: 1, + NSOLID_GRPC: `localhost:${port}`, + }; + + const opts = { + stdio: ['inherit', 'inherit', 'inherit', 'ipc'], + env, + }; + const child = new TestClient([ '-w', 1 ], opts); + const agentId = await child.id(); + const workers = await child.workers(); + const wid = workers[0]; + await child.importURL(importPath, wid); + })); + }); + }, +}); + +tests.push({ + name: 'should also work for imported data urls', + test: async () => { + return new Promise((resolve) => { + const importPath = path.join(fixturesDir, 'nsolid-source-code', 'data.mjs'); + const grpcServer = new GRPCServer(); + grpcServer.start(mustSucceed(async (port) => { + grpcServer.on('loop_blocked', mustCall(async (data) => { + console.dir(data.msg, { depth: null }); + const scripts = []; + for (const frame of data.msg.body.stack) { + if (frame.scriptName.includes(importPath) || + frame.scriptName.startsWith('data:text/javascript,')) { + scripts.push({ + scriptId: frame.scriptId, + path: frame.scriptName, + }); + } + } + + assert.strictEqual(scripts.length, 2); + for (const { scriptId, path } of scripts) { + const options = { + threadId: 0, + scriptId, + path, + }; + + const ret = await grpcServer.sourceCode(agentId, options); + checkSourceCodeData(ret.data.msg, ret.data.metadata, ret.requestId, agentId, options); + } + + await child.shutdown(0); + grpcServer.close(); + resolve(); + })); + + const env = { + NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', + NSOLID_GRPC_INSECURE: 1, + NSOLID_GRPC: `localhost:${port}`, + }; + + const opts = { + stdio: ['inherit', 'inherit', 'inherit', 'ipc'], + env, + }; + const child = new TestClient([], opts); + const agentId = await child.id(); + await child.importURL(importPath, 0); + })); + }); + }, +}); + + +for (const { name, test } of tests) { + console.log(`[source code] ${name}`); + await test(); +} diff --git a/test/common/nsolid-grpc-agent/client.js b/test/common/nsolid-grpc-agent/client.js index 713ce8a67b..5aef9633d6 100644 --- a/test/common/nsolid-grpc-agent/client.js +++ b/test/common/nsolid-grpc-agent/client.js @@ -78,6 +78,12 @@ function blockFor(duration) { while (Date.now() - start < duration); } +async function handleImport(msg) { + const { url } = msg; + const { blockFor } = await import(url); + blockFor(500); +} + function handleTrace(msg) { if (msg.type === 'trace') { switch (msg.kind) { @@ -111,6 +117,20 @@ if (isMainThread) { nsolid.heapSampling(msg.duration); } else if (msg.type === 'id') { process.send({ type: 'id', id: nsolid.id }); + } else if (msg.type === 'import') { + console.log(msg); + if (threadId === msg.threadId) { + handleImport(msg).then(() => { + process.send(msg); + }); + } else { + const worker = workers.get(msg.threadId); + worker.on('message', (msg) => { + process.send(msg); + }); + + worker.postMessage(msg); + } } else if (msg.type === 'log') { if (threadId === msg.threadId) { nsolid.logger[msg.level](msg.message); @@ -187,6 +207,11 @@ if (isMainThread) { case 'block': blockFor(msg.duration); break; + case 'import': + handleImport(msg).then(() => { + parentPort.postMessage(msg); + }); + break; case 'log': nsolid.logger[msg.level](msg.message); break; diff --git a/test/common/nsolid-grpc-agent/index.js b/test/common/nsolid-grpc-agent/index.js index 7273649c78..eb2abcbc0f 100644 --- a/test/common/nsolid-grpc-agent/index.js +++ b/test/common/nsolid-grpc-agent/index.js @@ -245,6 +245,22 @@ class GRPCServer extends EventEmitter { }); } + async sourceCode(agentId, options) { + return new Promise((resolve) => { + if (this.#server) { + const requestId = randomUUID(); + this.#server.send({ type: 'source_code', agentId, requestId, options }); + this.#server.on('message', (msg) => { + if (msg.type === 'source_code') { + resolve({ requestId, data: msg.data }); + } + }); + } else { + resolve(null); + } + }); + } + async startupTimes(agentId) { return new Promise((resolve) => { if (this.#server) { @@ -367,6 +383,21 @@ class TestClient { }); } + async importURL(url, threadId) { + return new Promise((resolve) => { + if (this.#child) { + this.#child.send({ type: 'import', url, threadId }); + this.#child.on('message', (msg) => { + if (msg.type === 'import') { + resolve(); + } + }); + } else { + resolve(null); + } + }); + } + async kill(signal) { return new Promise((resolve) => { let done = false; diff --git a/test/common/nsolid-grpc-agent/server.mjs b/test/common/nsolid-grpc-agent/server.mjs index 91fea6b10e..c67aa183f0 100644 --- a/test/common/nsolid-grpc-agent/server.mjs +++ b/test/common/nsolid-grpc-agent/server.mjs @@ -152,6 +152,13 @@ async function startServer(cb) { console.dir(call.metadata, { depth: null }); callback(null, {}); }, + ExportSourceCode: (call, callback) => { + // Extract data from the request object + console.dir(call.request, { depth: null }); + console.dir(call.metadata, { depth: null }); + callback(null, {}); + process.send({ type: 'source_code', data: { msg: call.request, metadata: call.metadata } }); + }, ExportStartupTimes: (call, callback) => { // Extract data from the request object console.dir(call.request, { depth: null }); @@ -198,6 +205,8 @@ process.on('message', (message) => { sendPackages(message.agentId, message.requestId); } else if (message.type === 'snapshot') { sendHeapSnapshot(message.agentId, message.requestId, message.options); + } else if (message.type === 'source_code') { + sendSourceCode(message.agentId, message.requestId, message.options); } else if (message.type === 'startup_times') { sendStartupTimes(message.agentId, message.requestId); } else if (message.type === 'close') { @@ -272,6 +281,14 @@ async function sendPackages(agentId, requestId) { return sendCommand('packages', agentId, requestId); } +async function sendSourceCode(agentId, requestId, options) { + const args = { + sourceCode: options, + }; + + return sendCommand('source_code', agentId, requestId, args); +} + async function sendStartupTimes(agentId, requestId) { return sendCommand('startup_times', agentId, requestId); } diff --git a/test/fixtures/nsolid-source-code/common.js b/test/fixtures/nsolid-source-code/common.js new file mode 100644 index 0000000000..82095f7bc9 --- /dev/null +++ b/test/fixtures/nsolid-source-code/common.js @@ -0,0 +1,8 @@ +'use strict'; + +function blockFor(duration) { + const start = Date.now(); + while (Date.now() - start < duration); +} + +module.exports = { blockFor }; \ No newline at end of file diff --git a/test/fixtures/nsolid-source-code/data.mjs b/test/fixtures/nsolid-source-code/data.mjs new file mode 100644 index 0000000000..97d046aee7 --- /dev/null +++ b/test/fixtures/nsolid-source-code/data.mjs @@ -0,0 +1,18 @@ +// Define the JavaScript code as a string +const moduleCode = ` +export function blockFor(duration) { + const start = Date.now(); + while (Date.now() - start < duration); +} +`; + +const dataUrl = `data:text/javascript,${moduleCode}`; + +async function blockFor(duration) { + // Dynamically import the module + const module = await import(dataUrl); + // Call the blockFor function from the imported module + module.blockFor(duration); +} + +export { blockFor, moduleCode }; diff --git a/test/fixtures/nsolid-source-code/esm.mjs b/test/fixtures/nsolid-source-code/esm.mjs new file mode 100644 index 0000000000..2e94caca71 --- /dev/null +++ b/test/fixtures/nsolid-source-code/esm.mjs @@ -0,0 +1,7 @@ +import * as common from './common.js'; + +function blockFor(duration) { + return common.blockFor(duration); +} + +export { blockFor }; \ No newline at end of file diff --git a/test/fixtures/nsolid-source-code/index.mjs b/test/fixtures/nsolid-source-code/index.mjs new file mode 100644 index 0000000000..fbcb07fb07 --- /dev/null +++ b/test/fixtures/nsolid-source-code/index.mjs @@ -0,0 +1,7 @@ +import * as esm from './esm.mjs'; + +function blockFor(duration) { + return esm.blockFor(duration); +} + +export { blockFor }; \ No newline at end of file