diff --git a/build-common.sh b/build-common.sh index 999fe827..49c28d5f 100644 --- a/build-common.sh +++ b/build-common.sh @@ -74,7 +74,7 @@ run_cmake() { # Fetch vcpkg checkout_vcpkg() { - local vcpkg_commit="501db0f17ef6df184fcdbfbe0f87cde2313b6ab1" # upstream/2023.04.15 + local vcpkg_commit="74e6536215718009aae747d86d84b78376bf9e09" # upstream/2023.04.15 local root="${1}" local use_system_binaries="${2}" local exe_path="${root}/vcpkg/vcpkg" diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 9e79c17d..ef924bc3 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -57,6 +57,9 @@ ENDIF() IF(GATORD_WERROR) SET(GATORD_C_CXX_FLAGS "${GATORD_C_CXX_FLAGS} -Werror") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(GATORD_C_CXX_FLAGS "${GATORD_C_CXX_FLAGS} -Wno-error=maybe-uninitialized") + endif() ENDIF() IF(GATORD_BUILD_STATIC) diff --git a/daemon/agents/common/polling_cpu_monitor.h b/daemon/agents/common/polling_cpu_monitor.h index 326ce9f2..3fe76c97 100644 --- a/daemon/agents/common/polling_cpu_monitor.h +++ b/daemon/agents/common/polling_cpu_monitor.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022-2024 by Arm Limited. All rights reserved. */ +/* Copyright (C) 2022-2025 by Arm Limited. All rights reserved. */ #pragma once @@ -99,7 +99,7 @@ namespace agents { return start_on(st->strand) // | then([st]() { return st->on_strand_do_poll(); }) // | then([st](bool any_offline) { - st->timer.expires_from_now(any_offline ? short_poll_interval : long_poll_interval); + st->timer.expires_after(any_offline ? short_poll_interval : long_poll_interval); }) // | st->timer.async_wait(use_continuation) // | post_on(st->strand) // diff --git a/daemon/agents/perf/async_perf_ringbuffer_monitor.hpp b/daemon/agents/perf/async_perf_ringbuffer_monitor.hpp index 437fee10..22d91b6a 100644 --- a/daemon/agents/perf/async_perf_ringbuffer_monitor.hpp +++ b/daemon/agents/perf/async_perf_ringbuffer_monitor.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -645,7 +646,7 @@ namespace agents::perf { }); }, // [st]() { - st->timer.expires_from_now(st->live_mode ? live_poll_interval : local_poll_interval); + st->timer.expires_after(st->live_mode ? live_poll_interval : local_poll_interval); return st->timer.async_wait(use_continuation) // | post_on(st->strand) // diff --git a/daemon/agents/perf/perf_capture_cpu_monitor.h b/daemon/agents/perf/perf_capture_cpu_monitor.h index 076f0f4c..e249d1f3 100644 --- a/daemon/agents/perf/perf_capture_cpu_monitor.h +++ b/daemon/agents/perf/perf_capture_cpu_monitor.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2022-2024 by Arm Limited. All rights reserved. */ +/* Copyright (C) 2022-2025 by Arm Limited. All rights reserved. */ #pragma once @@ -17,9 +17,9 @@ #include #include -#include #include #include +#include #include namespace agents::perf { diff --git a/daemon/agents/perf/perf_capture_helper.h b/daemon/agents/perf/perf_capture_helper.h index 0e5c2b71..58b447d5 100644 --- a/daemon/agents/perf/perf_capture_helper.h +++ b/daemon/agents/perf/perf_capture_helper.h @@ -34,11 +34,11 @@ #include #include -#include #include #include #include #include +#include #include #include @@ -827,8 +827,10 @@ namespace agents::perf { void terminate(bool defer = false) { boost::asio::post(strand, [defer, st = this->shared_from_this()]() { + using namespace std::chrono_literals; + // delay to use when deferring shutdown - constexpr auto defer_delay_ms = boost::posix_time::milliseconds(1000); + constexpr auto defer_delay_ms = 1000ms; // only perform the terminate once auto timer = std::exchange(st->terminate_delay_timer, nullptr); @@ -865,7 +867,7 @@ namespace agents::perf { // defer the terminate() call to allow the async_perf_ringbuffer_monitor to receive any closed() events for the event fds it monitors if (defer) { LOG_FINE("Terminating pid monitoring... starting termination countdown."); - timer->expires_from_now(defer_delay_ms); + timer->expires_after(defer_delay_ms); timer->async_wait(std::move(handler)); } // otherwise, call the handler directly @@ -903,7 +905,7 @@ namespace agents::perf { return; } - auto poll_delay_timer = std::make_shared(st->strand.context()); + auto poll_delay_timer = std::make_shared(st->strand.context()); spawn("process scanner", repeatedly( @@ -960,10 +962,12 @@ namespace agents::perf { | st->async_read_process_maps(use_continuation); }) // | then([poll_delay_timer]() { + using namespace std::chrono_literals; + // delay to use when deferring scanning - constexpr auto defer_delay_ms = boost::posix_time::milliseconds(100); + constexpr auto defer_delay_ms = 100ms; - poll_delay_timer->expires_from_now(defer_delay_ms); + poll_delay_timer->expires_after(defer_delay_ms); return poll_delay_timer->async_wait(use_continuation); }) | then([](auto /*ec*/) { @@ -988,8 +992,9 @@ namespace agents::perf { std::shared_ptr> waiter {}; std::shared_ptr async_perf_ringbuffer_monitor; std::shared_ptr forked_command; - std::shared_ptr terminate_delay_timer { - new boost::asio::deadline_timer(strand.context())}; + std::shared_ptr terminate_delay_timer { + new boost::asio::system_timer(strand.context()), + }; perf_capture_events_helper_t perf_capture_events_helper; bool terminate_requested {false}; diff --git a/daemon/async/async_byte_reader.hpp b/daemon/async/async_byte_reader.hpp index 877db6a9..3c2bc88b 100644 --- a/daemon/async/async_byte_reader.hpp +++ b/daemon/async/async_byte_reader.hpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2022-2023 by Arm Limited. All rights reserved. */ +/* Copyright (C) 2022-2025 by Arm Limited. All rights reserved. */ #pragma once @@ -25,9 +25,6 @@ namespace async { public: static constexpr std::size_t default_read_chunk_size = 65536; - // assumes that data returns a single item - static_assert(std::is_same_v); - /** Constructor */ explicit async_byte_reader_t(boost::asio::posix::stream_descriptor && sd, std::size_t read_chunk_size = default_read_chunk_size) diff --git a/daemon/async/async_line_reader.hpp b/daemon/async/async_line_reader.hpp index fcb4f162..fab53bb2 100644 --- a/daemon/async/async_line_reader.hpp +++ b/daemon/async/async_line_reader.hpp @@ -1,7 +1,8 @@ -/* Copyright (C) 2022-2023 by Arm Limited. All rights reserved. */ +/* Copyright (C) 2022-2025 by Arm Limited. All rights reserved. */ #pragma once +#include "Logging.h" #include "async/continuations/async_initiate.h" #include "async/continuations/continuation.h" #include "async/continuations/continuation_of.h" @@ -12,9 +13,11 @@ #include #include +#include #include #include #include +#include #include namespace async { @@ -34,64 +37,57 @@ namespace async { template auto async_read_line(CompletionToken && token) { - using namespace async::continuations; - - return async_initiate_cont( - [st = shared_from_this()]() { + return boost::asio::async_initiate( + [st = shared_from_this()](auto handler) { // consume the bytes from the buffer, ready for the next loop st->buffer.consume(std::exchange(st->n_to_consume, 0)); - return boost::asio::async_read_until(st->stream_descriptor, - st->buffer, - '\n', - use_continuation) // - | then([st](boost::system::error_code const & ec, std::size_t n) { - // assumes that data returns a single item - static_assert(std::is_same_v); - - auto const is_eof = (ec == boost::asio::error::eof); - - // handle errors - if ((!is_eof) && ec) { - LOG_DEBUG("Read failed with %s", ec.message().c_str()); - return std::pair {ec, std::string_view()}; - } - - // process line of text - - // find the modified buffer chunk - auto const input_area = st->buffer.data(); - auto const read_area_length = std::min(n, input_area.size()); - - // first find the substr containing up-to the first '\n' marker - auto const read_area = - std::string_view(reinterpret_cast(input_area.data()), - read_area_length); - - auto const message = find_end_of_line(read_area); - st->n_to_consume = message.size(); - - // only report EOF once buffer is drained of complete lines - if (is_eof && message.empty()) { - // if there is some trailing, unterminated (by EOL) text, send it - if (input_area.size() > 0) { - st->n_to_consume = input_area.size(); - return std::pair { - boost::system::error_code {}, - std::string_view(reinterpret_cast(input_area.data()), - input_area.size())}; - } - - // otherwise report the EOF - return std::pair {boost::system::error_code {boost::asio::error::eof}, - std::string_view {}}; - } - - // report the line - return std::pair {boost::system::error_code {}, message}; - }) // - | unpack_tuple(); + return boost::asio::async_read_until( + st->stream_descriptor, + st->buffer, + '\n', + [st, handler = std::move(handler)](boost::system::error_code ec, + std::size_t n) mutable -> void { + // assumes that data returns a single item + auto const is_eof = (ec == boost::asio::error::eof); + + // handle errors + if ((!is_eof) && ec) { + LOG_DEBUG("Read failed with %s", ec.message().c_str()); + return handler(ec, std::string_view()); + } + + // process line of text + + // find the modified buffer chunk + auto const input_area = st->buffer.data(); + auto const read_area_length = std::min(n, input_area.size()); + + // first find the substr containing up-to the first '\n' marker + auto const read_area = + std::string_view(reinterpret_cast(input_area.data()), read_area_length); + + auto const message = find_end_of_line(read_area); + st->n_to_consume = message.size(); + + // only report EOF once buffer is drained of complete lines + if (is_eof && message.empty()) { + // if there is some trailing, unterminated (by EOL) text, send it + if (input_area.size() > 0) { + st->n_to_consume = input_area.size(); + return handler(boost::system::error_code {}, + std::string_view(reinterpret_cast(input_area.data()), + input_area.size())); + } + + // otherwise report the EOF + return handler(boost::system::error_code {boost::asio::error::eof}, + std::string_view {}); + } + + // report the line + return handler(boost::system::error_code {}, message); + }); }, std::forward(token)); } diff --git a/daemon/cmake/compiler-flags.cmake b/daemon/cmake/compiler-flags.cmake index bfbbf2df..14977e9a 100644 --- a/daemon/cmake/compiler-flags.cmake +++ b/daemon/cmake/compiler-flags.cmake @@ -64,7 +64,7 @@ endif() # Add strict warning settings for C++ # ### IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(GCC_STRICT_WARNING_FLAGS_CXX "-Wall -Wextra -Wno-shadow -Wno-psabi") + set(GCC_STRICT_WARNING_FLAGS_CXX "-Wall -Wextra -Wno-shadow -Wno-psabi -Wno-error=maybe-uninitialized") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_STRICT_WARNING_FLAGS_CXX}") ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # disable this until the hwcpipe2 submodule is changed to a vcpkg port diff --git a/daemon/ipc/proto/CMakeLists.txt b/daemon/ipc/proto/CMakeLists.txt index e45a5648..594334aa 100644 --- a/daemon/ipc/proto/CMakeLists.txt +++ b/daemon/ipc/proto/CMakeLists.txt @@ -1,6 +1,6 @@ -# Copyright (C) 2022 by Arm Limited. All rights reserved. +# Copyright (C) 2022-2025 by Arm Limited. All rights reserved. -find_package(Protobuf REQUIRED) +find_package(Protobuf CONFIG REQUIRED) set(Protobuf_IMPORT_DIRS ${CMAKE_CURRENT_LIST_DIR}) @@ -18,7 +18,7 @@ target_include_directories(ipcproto ) target_link_libraries(ipcproto - PRIVATE ${Protobuf_LITE_LIBRARIES} + PRIVATE ${Protobuf_LITE_LIBRARIES} protobuf::libprotobuf-lite ) target_compile_options(ipcproto PRIVATE "-Wno-error") diff --git a/daemon/lib/Process.cpp b/daemon/lib/Process.cpp index 92c83ff6..1d442774 100644 --- a/daemon/lib/Process.cpp +++ b/daemon/lib/Process.cpp @@ -10,18 +10,25 @@ #include #include +#include + +#if BOOST_VERSION >= (108600) +#include +#include +namespace boost_process = boost::process::v1; +#else #include #include +namespace boost_process = boost::process; +#endif #include -namespace bp = boost::process; - namespace gator::process { - int system(const std::string & cmd) + int system(const std::string & process_with_args) { // TODO: replace with Boost::Process once the dependency mechanism is agreed - return std::system(cmd.c_str()); + return std::system(process_with_args.c_str()); } void set_parent_death_signal(int signal) @@ -38,8 +45,9 @@ namespace gator::process { int runCommandAndRedirectOutput(const std::string & cmdToExecWithArgs, const std::optional & targetFile) { - auto child = targetFile.has_value() ? bp::child(cmdToExecWithArgs, bp::std_out > targetFile.value()) - : bp::child(cmdToExecWithArgs); + auto child = targetFile.has_value() + ? boost_process::child(cmdToExecWithArgs, boost_process::std_out > targetFile.value()) + : boost_process::child(cmdToExecWithArgs); std::error_code ec; child.wait(ec); diff --git a/daemon/lib/String.h b/daemon/lib/String.h index bde377e2..2063f85b 100644 --- a/daemon/lib/String.h +++ b/daemon/lib/String.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018-2024 by Arm Limited. All rights reserved. */ +/* Copyright (C) 2018-2025 by Arm Limited. All rights reserved. */ #pragma once @@ -13,6 +13,7 @@ #include #include #include +#include #include diff --git a/daemon/vcpkg-configuration.json b/daemon/vcpkg-configuration.json index 62b5b639..27494c3b 100644 --- a/daemon/vcpkg-configuration.json +++ b/daemon/vcpkg-configuration.json @@ -1,14 +1,13 @@ { "default-registry": { "kind": "builtin", - "baseline": "501db0f17ef6df184fcdbfbe0f87cde2313b6ab1" + "baseline": "74e6536215718009aae747d86d84b78376bf9e09" }, "registries": [ { "kind": "filesystem", "path": "../vcpkg_registry", "packages": [ - "boost-filesystem", "mxml" ] } diff --git a/vcpkg b/vcpkg index 501db0f1..74e65362 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 501db0f17ef6df184fcdbfbe0f87cde2313b6ab1 +Subproject commit 74e6536215718009aae747d86d84b78376bf9e09