Skip to content

Commit

Permalink
Gator 8.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bengaineyarm committed Apr 25, 2023
1 parent 75662ba commit 0eef320
Show file tree
Hide file tree
Showing 339 changed files with 4,525 additions and 43,158 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The rest of this document refers to `gatord` and related tools.

* `daemon`, and `notify` are provided under GPL-2.0-only. See
[daemon/COPYING], and [notify/COPYING] respectively.
* `annotate`, `barman` and `gator_me.py` are provided under the BSD-3-Clause
* `annotate`, `barman` and `gator_me.py` are provided under the BSD-3-Clause
license. See [annotate/LICENSE].

This project contains code from other projects listed below. The original license
Expand Down
19 changes: 15 additions & 4 deletions annotate/streamline_annotate.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2014-2021 by Arm Limited. All rights reserved.
* Copyright (C) 2014-2023 by Arm Limited. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -608,7 +608,7 @@ static void * gator_func(void * arg)
if (!gator_send(thread, write_pos)) {
LOG(LOG_ERROR,
"Failed to send bytes, " //
"gator_thread = (exited:%s, fd:%d, oob_length:%ld, read_pos:%d, tid:%d), " //
"gator_thread = (exited:%s, fd:%d, oob_length:%zu, read_pos:%d, tid:%d), " //
"write_pos = %u", //
thread->exited ? "true" : "false",
thread->fd,
Expand Down Expand Up @@ -1142,7 +1142,8 @@ void gator_annotate_counter(const uint32_t id,
free(counter);
}

void gator_annotate_counter_value(const uint32_t core, const uint32_t id, const int64_t value)
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters, readability-identifier-length)
void gator_annotate_counter_time_value(const uint32_t core, const uint32_t id, const uint64_t time, const int64_t value)
{
struct gator_thread * const thread = gator_get_thread();
if (thread == NULL) {
Expand All @@ -1156,14 +1157,23 @@ void gator_annotate_counter_value(const uint32_t core, const uint32_t id, const
uint32_t length;
gator_msg_begin(HEADER_COUNTER_VALUE, thread, &write_pos, &size_pos, &length);

length += gator_buf_write_time(thread->buf, &write_pos);
// NOLINTNEXTLINE(bugprone-narrowing-conversions)
length += gator_buf_write_long(thread->buf, &write_pos, time);
length += gator_buf_write_int(thread->buf, &write_pos, core);
length += gator_buf_write_int(thread->buf, &write_pos, id);
length += gator_buf_write_long(thread->buf, &write_pos, value);

gator_msg_end(thread, write_pos, size_pos, length);
}

// NOLINTNEXTLINE(readability-identifier-length)
void gator_annotate_counter_value(const uint32_t core, const uint32_t id, const int64_t value)
{
const uint64_t current_time = gator_get_time();
gator_annotate_counter_time_value(core, id, current_time, value);
}

// NOLINTNEXTLINE(readability-identifier-length)
void gator_annotate_activity_switch(const uint32_t core, const uint32_t id, const uint32_t activity, const uint32_t tid)
{
struct gator_thread * const thread = gator_get_thread();
Expand Down Expand Up @@ -1267,6 +1277,7 @@ void gator_cam_job(const uint32_t view_uid,
length += gator_buf_write_long(thread->buf, &write_pos, start_time);
length += gator_buf_write_long(thread->buf, &write_pos, duration);
length += gator_buf_write_color(thread->buf, &write_pos, color);
// NOLINTNEXTLINE(bugprone-narrowing-conversions)
length += gator_buf_write_int(thread->buf, &write_pos, primary_dependency);
length += gator_buf_write_int(thread->buf, &write_pos, dependency_count);
size_t i;
Expand Down
9 changes: 8 additions & 1 deletion annotate/streamline_annotate.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2014-2021 by Arm Limited. All rights reserved.
/* Copyright (C) 2014-2023 by Arm Limited. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -156,6 +156,7 @@ void gator_annotate_counter(uint32_t id,
uint32_t color,
const char * description);
void gator_annotate_counter_value(uint32_t core, uint32_t id, int64_t value);
void gator_annotate_counter_time_value(uint32_t core, uint32_t id, uint64_t time, int64_t value);
void gator_annotate_activity_switch(uint32_t core, uint32_t id, uint32_t activity, uint32_t tid);
void gator_cam_track(uint32_t view_uid, uint32_t track_uid, uint32_t parent_track, const char * name);
void gator_cam_job(uint32_t view_uid,
Expand Down Expand Up @@ -291,6 +292,12 @@ void gator_cam_view_name(uint32_t view_uid, const char * name);
gator_annotate_counter_value(0, id, __scaledvalue); \
} while (0)

#define ANNOTATE_COUNTER_TIME_VALUE_SCALE(id, time, value, modifier) \
do { \
uint64_t __scaledvalue = (uint64_t) ((value) * (modifier) + 0.5f); \
gator_annotate_counter_time_value(0, id, time, __scaledvalue); \
} while (0)

#define CAM_TRACK(view_uid, track_uid, parent_track, name) gator_cam_track(view_uid, track_uid, parent_track, name)
#define CAM_JOB(view_uid, job_uid, name, track, start_time, duration, color) \
gator_cam_job(view_uid, job_uid, name, track, start_time, duration, color, -1, 0, 0)
Expand Down
10 changes: 9 additions & 1 deletion build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ show_help() {
echo " The default is 21, meaning the binary is "
echo " compatible with Android L and later."
echo " -t <target> - Specify the target architecture. Must be one of"
echo " arm64, arm, or x86_64. The default is arm64."
echo " arm64, arm-neon, arm, or x86_64. The default is arm64."
echo " -g <generator> - Specify the CMake generator to use. Defaults to Ninja if"
echo " it is available, otherwise to whatever the CMake default"
echo " is."
Expand Down Expand Up @@ -95,6 +95,10 @@ if [ "${target}" = "arm64" ]; then
abi="arm64-v8a"
toolchain="aarch64-linux-android-clang"
triplet="arm64-android"
elif [ "${target}" = "arm-neon" ]; then
abi="armeabi-v7a"
toolchain="arm-linux-androideabi-clang"
triplet="arm-neon-android"
elif [ "${target}" = "arm" ]; then
abi="armeabi-v7a"
toolchain="arm-linux-androideabi-clang"
Expand Down Expand Up @@ -142,6 +146,10 @@ fi

build_args+=( -DVCPKG_TARGET_TRIPLET="${triplet}" -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="${gator_dir}/cmake/android.toolchain.cmake" -DCMAKE_BUILD_TYPE="${build_type}" -DANDROID_NDK="${ndk_path}" -DANDROID_ABI="${abi}" -DANDROID_TOOLCHAIN_NAME="${toolchain}" -DANDROID_PLATFORM="${api_level}" -DCONFIG_SUPPORT_PROC_POLLING=OFF -DCONFIG_PREFER_SYSTEM_WIDE_MODE=OFF -DCONFIG_ASSUME_PERF_HIGH_PARANOIA=OFF )

if [ "${target}" = "arm-neon" ]; then
build_args+=( -DANDROID_ARM_NEON=ON )
fi

echo "Running cmake build for api_level=${api_level} with target=${target}:"
run_cmake "${cmake_exe}" "${cmake_generator}" "${src_path}" "${build_path}" "${use_system_binaries}" "${verbose}" "${build_args[@]}"

2 changes: 1 addition & 1 deletion build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ run_cmake() {

# Fetch vcpkg
checkout_vcpkg() {
local vcpkg_commit="501db0f17ef6df184fcdbfbe0f87cde2313b6ab1" # upstream/2023.04.15
local vcpkg_commit="5568f110b509a9fd90711978a7cb76bae75bb092" # upstream/2021.05.12
local root="${1}"
local use_system_binaries="${2}"
local exe_path="${root}/vcpkg/vcpkg"
Expand Down
3 changes: 2 additions & 1 deletion daemon/AtraceDriver.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* Copyright (C) 2015-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2015-2023 by Arm Limited. All rights reserved. */

#ifndef ATRACEDRIVER_H
#define ATRACEDRIVER_H

#include "SimpleDriver.h"

#include <mxml.h>

class FtraceDriver;
Expand Down
67 changes: 56 additions & 11 deletions daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2010-2022 by Arm Limited. All rights reserved.
# Copyright (C) 2010-2023 by Arm Limited. All rights reserved.
CMAKE_MINIMUM_REQUIRED(VERSION 3.16 FATAL_ERROR)

OPTION(ENABLE_VCPKG "Pull in dependencies using vcpkg" ON)
Expand All @@ -20,6 +20,7 @@ SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Configuration options
OPTION(GATORD_WERROR "Build with -Werror set" ON)
OPTION(CONFIG_USE_PERFETTO "Build gator with Perfetto support (Mali Timeline support)." ON)
OPTION(CLANG_TIDY_FIX "Enable --fix with clang-tidy" OFF)
OPTION(CONFIG_PREFER_SYSTEM_WIDE_MODE "Enable system-wide capture by default" ON)
OPTION(CONFIG_ASSUME_PERF_HIGH_PARANOIA "Assume perf_event_paranoid is 2 if it cannot be read" ON)
Expand Down Expand Up @@ -95,7 +96,7 @@ ENDIF()

FIND_PACKAGE(Threads REQUIRED)
SET(Boost_USE_MULTITHREADED ON)
FIND_PACKAGE(Boost 1.78 REQUIRED COMPONENTS
FIND_PACKAGE(Boost 1.75 REQUIRED COMPONENTS
filesystem
regex
)
Expand Down Expand Up @@ -597,7 +598,7 @@ SET(GATORD_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AnnotateListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/xml/PmuXMLParser.h
)

if(ANDROID)
IF(CONFIG_USE_PERFETTO)
SET(GATORD_SRC_FILES ${GATORD_SRC_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/agents/perfetto/perfetto_agent.h
${CMAKE_CURRENT_SOURCE_DIR}/agents/perfetto/perfetto_agent_main.cpp
Expand All @@ -609,7 +610,7 @@ if(ANDROID)
SET(GATORD_3RD_PARTY_SOURCES ${GATORD_3RD_PARTY_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/../ext/perfetto/sdk/perfetto.cc
${CMAKE_CURRENT_SOURCE_DIR}/../ext/perfetto/sdk/perfetto.h)
endif()
ENDIF()

# Create a list of files to hash for the generated hash file
SET(GLOB FILES_TO_HASH
Expand Down Expand Up @@ -708,6 +709,12 @@ IF(NOT ANDROID)
)
ENDIF()

IF(CONFIG_USE_PERFETTO)
TARGET_COMPILE_DEFINITIONS(gatord
PRIVATE CONFIG_USE_PERFETTO
)
ENDIF()

# Strip binary
IF(NOT((${CMAKE_BUILD_TYPE} STREQUAL "Debug") OR(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")))
ADD_CUSTOM_COMMAND(TARGET gatord POST_BUILD
Expand Down Expand Up @@ -746,10 +753,21 @@ FIND_FILE(CLANG_TIDY NAMES "clang-tidy${CMAKE_EXECUTABLE_SUFFIX}"
# Add a custom targets for running clang-format and clang tidy
# ###
IF(EXISTS ${CLANG_FORMAT})
FOREACH(file ${GATORD_SRC_FILES})
# run clang tidy
SET(item "${CMAKE_BINARY_DIR}/clang-format-${TARGET_NAME}/${file}")
ADD_CUSTOM_COMMAND(OUTPUT ${item}
COMMAND ${CLANG_FORMAT} -i ${file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${file} ${ALL_XML_HEADERS} ipcproto
COMMENT "Running clang-format on ${item}")
SET(outputs ${outputs} ${item})
SET_SOURCE_FILES_PROPERTIES(${item} PROPERTIES SYMBOLIC ON)
ENDFOREACH()

ADD_CUSTOM_TARGET(clang-format
COMMAND ${CLANG_FORMAT} -i ${GATORD_SRC_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${ALL_XML_HEADERS}
DEPENDS ${outputs}
SOURCES ${GATORD_SRC_FILES}
COMMENT "Run clang-format on the sources")
ENDIF()
Expand All @@ -766,10 +784,37 @@ IF(EXISTS ${CLANG_TIDY})
CXX_CLANG_TIDY "${CLANG_TIDY};-p;${CMAKE_BINARY_DIR}")
ENDIF()

SET(outputs )
SET(outputs_fix )
FOREACH(file ${GATORD_SRC_FILES})
IF ("${file}" MATCHES "\.(cpp|cc|c)$")
# run clang tidy
SET(item "${CMAKE_BINARY_DIR}/clang-tidy-${TARGET_NAME}/${file}")
ADD_CUSTOM_COMMAND(OUTPUT ${item}
COMMAND ${CLANG_TIDY} -p ${CMAKE_BINARY_DIR} ${file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${file} ${ALL_XML_HEADERS} ipcproto
COMMENT "Running clang-tidy on ${item}")
SET(outputs ${outputs} ${item})
SET_SOURCE_FILES_PROPERTIES(${item} PROPERTIES SYMBOLIC ON)
# run clang tidy --fix
SET(item "${CMAKE_BINARY_DIR}/clang-tidy-fix-${TARGET_NAME}/${file}")
ADD_CUSTOM_COMMAND(OUTPUT ${item}
COMMAND ${CLANG_TIDY} --fix -p ${CMAKE_BINARY_DIR} ${file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${file} ${ALL_XML_HEADERS} ipcproto
COMMENT "Running clang-tidy on ${item}")
SET(outputs_fix ${outputs_fix} ${item})
SET_SOURCE_FILES_PROPERTIES(${item} PROPERTIES SYMBOLIC ON)
ENDIF()
ENDFOREACH(file)

ADD_CUSTOM_TARGET(clang-tidy
COMMAND ${CLANG_TIDY} -p ${CMAKE_BINARY_DIR} $<$<BOOL:${CLANG_TIDY_FIX}>:--fix> ${GATORD_SRC_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${ALL_XML_HEADERS}
SOURCES ${GATORD_SRC_FILES}
COMMENT "Run clang-tidy on the sources")
DEPENDS ${outputs}
SOURCES ${GATORD_SRC_FILES}
COMMENT "Run clang-tidy on the sources")
ADD_CUSTOM_TARGET(clang-tidy-fix
DEPENDS ${outputs_fix}
SOURCES ${GATORD_SRC_FILES}
COMMENT "Run clang-tidy --fix on the sources")
ENDIF()
4 changes: 2 additions & 2 deletions daemon/CapturedXML.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */

#include "CapturedXML.h"

Expand Down Expand Up @@ -168,7 +168,7 @@ static mxml_node_t * getTree(bool includeTime,

mxml_node_t * counters = nullptr;
for (const auto & counter : gSessionData.mCounters) {
if(counter.excludeFromCapturedXml()) {
if (counter.excludeFromCapturedXml()) {
continue;
}

Expand Down
10 changes: 5 additions & 5 deletions daemon/Child.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */

#include "Child.h"

Expand Down Expand Up @@ -323,7 +323,7 @@ void Child::run()
LOG_DEBUG("Started ext_source agent");
}
});
#if defined(ANDROID) || defined(__ANDROID__)
#ifdef CONFIG_USE_PERFETTO
if (enablePerfettoAgent) {
this->agent_workers_process.async_add_perfetto_source(
source,
Expand Down Expand Up @@ -358,6 +358,9 @@ void Child::run()
LOG_DEBUG("Waiting for agents complete");
}

// Sender thread shall be halted until it is signaled for one shot mode
sem_init(&haltPipeline, 0, gSessionData.mOneShot ? 0 : 2);

// create the primary source last as it will launch the process, which may lead to a race receiving external messages
auto newPrimarySource = primarySourceProvider.createPrimarySource(
senderSem,
Expand Down Expand Up @@ -385,9 +388,6 @@ void Child::run()
}
}

// Sender thread shall be halted until it is signaled for one shot mode
sem_init(&haltPipeline, 0, gSessionData.mOneShot ? 0 : 2);

// Create the duration and sender threads
lib::Waiter waitTillEnd;

Expand Down
17 changes: 10 additions & 7 deletions daemon/ConfigurationXML.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */

#include "ConfigurationXML.h"

Expand Down Expand Up @@ -259,12 +259,15 @@ namespace configuration_xml {
}
// the counter is not in events.xml. This usually means it is a PMU slot counter, but since
// the user has not specified an event code, this is probably incorrect.
else if (strcasestr(counterName, "_cnt") != nullptr) {
LOG_WARNING("Counter '%s' does not have an event code specified, PMU slot counters require an event code",
counterName);
}
else {
LOG_WARNING("Counter '%s' was not recognized", counterName);
else if (printWarningIfUnclaimed) {
if (strcasestr(counterName, "_cnt") != nullptr) {
LOG_WARNING(
"Counter '%s' does not have an event code specified, PMU slot counters require an event code",
counterName);
}
else {
LOG_WARNING("Counter '%s' was not recognized", counterName);
}
}
counter.setCount(count);
counter.setCores(cores);
Expand Down
5 changes: 3 additions & 2 deletions daemon/ConfigurationXMLParser.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/* Copyright (C) 2010-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */

#ifndef CONFIGURATIONXMLPARSER_H_
#define CONFIGURATIONXMLPARSER_H_

#include "Configuration.h"
#include "Logging.h"
#include "OlyUtility.h"
#include <mxml.h>

#include <regex>
#include <string>
#include <vector>

#include <mxml.h>

static const int PARSER_ERROR = -1;
static const int VERSION_ERROR = -2;

Expand Down
4 changes: 2 additions & 2 deletions daemon/CounterXML.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2010-2022 by Arm Limited. All rights reserved. */
/* Copyright (C) 2010-2023 by Arm Limited. All rights reserved. */

#include "CounterXML.h"

Expand All @@ -9,14 +9,14 @@
#include "SessionData.h"
#include "lib/String.h"
#include "logging/global_log.h"
#include <mxml.h>
#include "xml/MxmlUtils.h"
#include "xml/PmuXML.h"

#include <cstdlib>
#include <cstring>

#include <dirent.h>
#include <mxml.h>

static mxml_node_t * getTree(bool supportsMultiEbs,
lib::Span<const Driver * const> drivers,
Expand Down
Loading

0 comments on commit 0eef320

Please sign in to comment.