2323#include < spdlog/fmt/bin_to_hex.h>
2424
2525#include < chrono>
26+ #include < cstring>
2627#include < iostream>
2728#include < stdexcept>
29+ #include < string_view>
2830
2931constexpr u16 DNS_MAX_PACKET_LEN = 512 ;
3032
@@ -34,6 +36,16 @@ static BufferedPoller *singleton_ = nullptr;
3436
3537static constexpr u64 DNS_TIMEOUT_TIME_NS = 10'000'000'000ull ;
3638
39+ namespace {
40+
41+ std::string_view comm_to_string (std::uint8_t const (&comm)[16])
42+ {
43+ auto const length = strnlen (reinterpret_cast <char const *>(comm), sizeof (comm));
44+ return std::string_view (reinterpret_cast <char const *>(comm), length);
45+ }
46+
47+ } // namespace
48+
3749BufferedPoller::BufferedPoller (
3850 uv_loop_t &loop,
3951 PerfContainer &container,
@@ -1034,7 +1046,16 @@ void BufferedPoller::handle_pid_info(message_metadata const &metadata, jb_agent_
10341046{
10351047 pid_count_++;
10361048
1037- LOG::debug_in (AgentLogKind::PID, " {}: msg={} pid_count_={}" , __func__, msg, pid_count_);
1049+ const std::string_view comm = comm_to_string (msg.comm );
1050+ LOG::debug_in (
1051+ AgentLogKind::PID,
1052+ " {}: pid={} parent={} cgroup=0x{:x} comm='{}' pid_count_={}" ,
1053+ __func__,
1054+ msg.pid ,
1055+ msg.parent_pid ,
1056+ msg.cgroup ,
1057+ comm,
1058+ pid_count_);
10381059
10391060 cgroup_handler_.handle_pid_info (msg.pid , msg.cgroup , msg.comm );
10401061 process_handler_.on_new_process (std::chrono::nanoseconds{metadata.timestamp }, msg);
@@ -1057,23 +1078,25 @@ void BufferedPoller::handle_pid_close(message_metadata const &metadata, jb_agent
10571078{
10581079 pid_count_--;
10591080
1060- LOG::debug_in (AgentLogKind::PID, " {}: msg={} pid_count_={}" , __func__, msg, pid_count_);
1081+ const std::string_view comm = comm_to_string (msg.comm );
1082+ LOG::debug_in (AgentLogKind::PID, " {}: pid={} comm='{}' pid_count_={}" , __func__, msg.pid , comm, pid_count_);
10611083
10621084 process_handler_.on_process_end (std::chrono::nanoseconds{metadata.timestamp }, msg);
10631085 writer_.pid_close_info_tstamp (metadata.timestamp , msg.pid , msg.comm );
10641086}
10651087
10661088void BufferedPoller::handle_pid_set_comm (message_metadata const &metadata, jb_agent_internal__pid_set_comm &msg)
10671089{
1068- LOG::debug_in (AgentLogKind::PID, " {}: msg={}" , __func__, msg);
1090+ const std::string_view comm = comm_to_string (msg.comm );
1091+ LOG::debug_in (AgentLogKind::PID, " {}: pid={} comm='{}'" , __func__, msg.pid , comm);
10691092
10701093 process_handler_.set_process_command (std::chrono::nanoseconds{metadata.timestamp }, msg);
10711094 writer_.pid_set_comm_tstamp (metadata.timestamp , msg.pid , msg.comm );
10721095}
10731096
10741097void BufferedPoller::handle_pid_exit (message_metadata const &metadata, jb_agent_internal__pid_exit &msg)
10751098{
1076- LOG::debug_in (AgentLogKind::PID, " {}: msg ={}" , __func__, msg);
1099+ LOG::debug_in (AgentLogKind::PID, " {}: tgid ={} pid={} exit_code={} " , __func__, msg. tgid , msg. pid , msg. exit_code );
10771100
10781101 process_handler_.pid_exit (std::chrono::nanoseconds{metadata.timestamp }, msg);
10791102}
0 commit comments