From 58dec08b2909d69a1ab4636ec62e92e7eb81df14 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 12 Sep 2017 10:24:13 -0700 Subject: [PATCH] GCS_MAVLink: fix non static perf counter Commit b9877e0d3850223ae6c2df3a68c3d888ca5be628 (GCS_MAVLink: make per channel perf counter non-static) made the perf counters to be available per instance but missed the fact that the perf infra doesn't copy the string. Fix this by maintaining a the string inside the object. --- libraries/GCS_MAVLink/GCS.h | 2 ++ libraries/GCS_MAVLink/GCS_Common.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 9d117c862b..a5e42a782a 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -363,6 +363,8 @@ private: // perf counters AP_HAL::Util::perf_counter_t _perf_packet; AP_HAL::Util::perf_counter_t _perf_update; + char _perf_packet_name[16]; + char _perf_update_name[16]; // deferred message handling. We size the deferred_message // ringbuffer so we can defer every message type diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index a9244da62d..61a491653c 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -59,13 +59,11 @@ GCS_MAVLINK::init(AP_HAL::UARTDriver *port, mavlink_channel_t mav_chan) initialised = true; _queued_parameter = nullptr; - char perf_name[16]; + snprintf(_perf_packet_name, sizeof(_perf_packet_name), "GCS_Packet_%u", chan); + _perf_packet = hal.util->perf_alloc(AP_HAL::Util::PC_ELAPSED, _perf_packet_name); - snprintf(perf_name, sizeof(perf_name), "GCS_Packet_%u", chan); - _perf_packet = hal.util->perf_alloc(AP_HAL::Util::PC_ELAPSED, perf_name); - - snprintf(perf_name, sizeof(perf_name), "GCS_Update_%u", chan); - _perf_update = hal.util->perf_alloc(AP_HAL::Util::PC_ELAPSED, perf_name); + snprintf(_perf_update_name, sizeof(_perf_update_name), "GCS_Update_%u", chan); + _perf_update = hal.util->perf_alloc(AP_HAL::Util::PC_ELAPSED, _perf_update_name); }