Skip to content

Commit

Permalink
Gator 8.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bengaineyarm committed Jun 23, 2022
1 parent e945656 commit 1ae0c4d
Show file tree
Hide file tree
Showing 210 changed files with 16,697 additions and 2,732 deletions.
147 changes: 147 additions & 0 deletions annotate/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#############
# As per https://releases.llvm.org/11.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/list.html
# the following items are aliases of some other check. We explicitly disable them here to avoid
# having the check run twice or having to emit NOLINT(ALIAS,REAL) when required
#############
# cert-con36-c -> bugprone-spuriously-wake-up-functions
# cert-con54-cpp -> bugprone-spuriously-wake-up-functions
# cert-dcl03-c -> misc-static-assert
# cert-dcl16-c -> readability-uppercase-literal-suffix
# cert-dcl37-c -> bugprone-reserved-identifier
# cert-dcl51-cpp -> bugprone-reserved-identifier
# cert-dcl54-cpp -> misc-new-delete-overloads
# cert-dcl59-cpp -> google-build-namespaces
# cert-err09-cpp -> misc-throw-by-value-catch-by-reference
# cert-err61-cpp -> misc-throw-by-value-catch-by-reference
# cert-fio38-c -> misc-non-copyable-objects
# cert-msc30-c -> cert-msc50-cpp
# cert-msc32-c -> cert-msc51-cpp
# cert-oop11-cpp -> performance-move-constructor-init
# cert-oop54-cpp -> bugprone-unhandled-self-assignment
# cert-pos44-c -> bugprone-bad-signal-to-kill-thread
# cert-str34-c -> bugprone-signed-char-misuse
# clang-analyzer-core.CallAndMessage -> ClangStaticAnalyzer
# clang-analyzer-core.DivideZero -> ClangStaticAnalyzer
# clang-analyzer-core.NonNullParamChecker -> ClangStaticAnalyzer
# clang-analyzer-core.NullDereference -> ClangStaticAnalyzer
# clang-analyzer-core.StackAddressEscape -> ClangStaticAnalyzer
# clang-analyzer-core.UndefinedBinaryOperatorResult -> ClangStaticAnalyzer
# clang-analyzer-core.VLASize -> ClangStaticAnalyzer
# clang-analyzer-core.uninitialized.ArraySubscript -> ClangStaticAnalyzer
# clang-analyzer-core.uninitialized.Assign -> ClangStaticAnalyzer
# clang-analyzer-core.uninitialized.Branch -> ClangStaticAnalyzer
# clang-analyzer-core.uninitialized.UndefReturn -> ClangStaticAnalyzer
# clang-analyzer-cplusplus.Move -> ClangStaticAnalyzer
# clang-analyzer-cplusplus.NewDelete -> ClangStaticAnalyzer
# clang-analyzer-cplusplus.NewDeleteLeaks -> ClangStaticAnalyzer
# clang-analyzer-deadcode.DeadStores -> ClangStaticAnalyzer
# clang-analyzer-nullability.NullPassedToNonnull -> ClangStaticAnalyzer
# clang-analyzer-nullability.NullReturnedFromNonnull -> ClangStaticAnalyzer
# clang-analyzer-nullability.NullableDereferenced -> ClangStaticAnalyzer
# clang-analyzer-nullability.NullablePassedToNonnull -> ClangStaticAnalyzer
# clang-analyzer-optin.cplusplus.UninitializedObject -> ClangStaticAnalyzer
# clang-analyzer-optin.cplusplus.VirtualCall -> ClangStaticAnalyzer
# clang-analyzer-optin.mpi.MPI-Checker -> ClangStaticAnalyzer
# clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker -> ClangStaticAnalyzer
# clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker -> ClangStaticAnalyzer
# clang-analyzer-osx.API -> ClangStaticAnalyzer
# clang-analyzer-osx.SecKeychainAPI -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.AtSync -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.ClassRelease -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.Dealloc -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.IncompatibleMethodTypes -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.NSAutoreleasePool -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.NSError -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.NilArg -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.ObjCGenerics -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.RetainCount -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.SelfInit -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.SuperDealloc -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.UnusedIvars -> ClangStaticAnalyzer
# clang-analyzer-osx.cocoa.VariadicMethodTypes -> ClangStaticAnalyzer
# clang-analyzer-osx.coreFoundation.CFError -> ClangStaticAnalyzer
# clang-analyzer-osx.coreFoundation.CFNumber -> ClangStaticAnalyzer
# clang-analyzer-osx.coreFoundation.CFRetainRelease -> ClangStaticAnalyzer
# clang-analyzer-osx.coreFoundation.containers.OutOfBounds -> ClangStaticAnalyzer
# clang-analyzer-osx.coreFoundation.containers.PointerSizedValues -> ClangStaticAnalyzer
# clang-analyzer-security.FloatLoopCounter -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.UncheckedReturn -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.bcmp -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.bcopy -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.bzero -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.getpw -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.gets -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.mkstemp -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.mktemp -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.rand -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.strcpy -> ClangStaticAnalyzer
# clang-analyzer-security.insecureAPI.vfork -> ClangStaticAnalyzer
# clang-analyzer-unix.API -> ClangStaticAnalyzer
# clang-analyzer-unix.Malloc -> ClangStaticAnalyzer
# clang-analyzer-unix.MallocSizeof -> ClangStaticAnalyzer
# clang-analyzer-unix.MismatchedDeallocator -> ClangStaticAnalyzer
# clang-analyzer-unix.Vfork -> ClangStaticAnalyzer
# clang-analyzer-unix.cstring.BadSizeArg -> ClangStaticAnalyzer
# clang-analyzer-unix.cstring.NullArg -> ClangStaticAnalyzer
# cppcoreguidelines-avoid-c-arrays -> modernize-avoid-c-arrays
# cppcoreguidelines-avoid-magic-numbers -> readability-magic-numbers
# cppcoreguidelines-c-copy-assignment-signature -> misc-unconventional-assign-operator
# cppcoreguidelines-explicit-virtual-functions -> modernize-use-override
# cppcoreguidelines-non-private-member-variables-in-classes -> misc-non-private-member-variables-in-classes
# fuchsia-header-anon-namespaces -> google-build-namespaces
# google-readability-braces-around-statements -> readability-braces-around-statements
# google-readability-function-size -> readability-function-size
# google-readability-namespace-comments -> llvm-namespace-comment
# hicpp-avoid-c-arrays -> modernize-avoid-c-arrays
# hicpp-braces-around-statements -> readability-braces-around-statements
# hicpp-deprecated-headers -> modernize-deprecated-headers
# hicpp-explicit-conversions -> google-explicit-constructor
# hicpp-function-size -> readability-function-size
# hicpp-invalid-access-moved -> bugprone-use-after-move
# hicpp-member-init -> cppcoreguidelines-pro-type-member-init
# hicpp-move-const-arg -> performance-move-const-arg
# hicpp-named-parameter -> readability-named-parameter
# hicpp-new-delete-operators -> misc-new-delete-overloads
# hicpp-no-array-decay -> cppcoreguidelines-pro-bounds-array-to-pointer-decay
# hicpp-no-malloc -> cppcoreguidelines-no-malloc
# hicpp-noexcept-move -> performance-noexcept-move-constructor
# hicpp-special-member-functions -> cppcoreguidelines-special-member-functions
# hicpp-static-assert -> misc-static-assert
# hicpp-undelegated-constructor -> bugprone-undelegated-constructor
# hicpp-uppercase-literal-suffix -> readability-uppercase-literal-suffix
# hicpp-use-auto -> modernize-use-auto
# hicpp-use-emplace -> modernize-use-emplace
# hicpp-use-equals-default -> modernize-use-equals-default
# hicpp-use-equals-delete -> modernize-use-equals-delete
# hicpp-use-noexcept -> modernize-use-noexcept
# hicpp-use-nullptr -> modernize-use-nullptr
# hicpp-use-override -> modernize-use-override
# hicpp-vararg -> cppcoreguidelines-pro-type-vararg
# llvm-else-after-return -> readability-else-after-return
# llvm-qualified-auto -> readability-qualified-auto
#
# Things we care about:
# android-*, bugprone-*, cert-*, clang-analyzer-*, clang-diagnostic-*, concurrency-*, cppcorequidelines-*, hicpp-*, misc-*, modernize-*, performance-*, portability-*, readability-*,
# Things we dont:
# -abseil-*, -altera-*, -boost-*, -clang-analyzer-osx.*, -clang-analyzer-optin.osx.*, -darwin, -fuchsia-*, -google-*, -linuxkernel-*, -llvm-*, -llvmlibc-*, -mpi-*, -objc-*, -openmp-*, -zircon
# Annoying things:
# -modernize-use-trailing-return-type,
# Thinks that should be on but can't due to legacy:
# -bugprone-narrowing-conversions, -hicpp-signed-bitwise, -misc-non-private-member-variables-in-classes, -misc-unconventional-assign-operator, -modernize-avoid-c-arrays, -readability-else-after-return, -readability-magic-numbers
# Aliases in the set of things we care about:
# -cert-con36-c, -cert-con54-cpp, -cert-dcl03-c, -cert-dcl16-c, -cert-dcl37-c, -cert-dcl51-cpp, -cert-dcl54-cpp, -cert-err09-cpp, -cert-err61-cpp, -cert-fio38-c, -cert-msc30-c, -cert-msc32-c, -cert-oop11-cpp, -cert-oop54-cpp, -cert-pos44-c, -cert-str34-c, -cppcoreguidelines-avoid-c-arrays, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-c-copy-assignment-signature, -cppcoreguidelines-explicit-virtual-functions, -cppcoreguidelines-non-private-member-variables-in-classes, -hicpp-avoid-c-arrays, -hicpp-braces-around-statements, -hicpp-deprecated-headers, -hicpp-function-size, -hicpp-invalid-access-moved, -hicpp-member-init, -hicpp-move-const-arg, -hicpp-named-parameter, -hicpp-new-delete-operators, -hicpp-no-array-decay, -hicpp-no-malloc, -hicpp-noexcept-move, -hicpp-special-member-functions, -hicpp-static-assert, -hicpp-undelegated-constructor, -hicpp-uppercase-literal-suffix, -hicpp-use-auto, -hicpp-use-emplace, -hicpp-use-equals-default, -hicpp-use-equals-delete, -hicpp-use-noexcept, -hicpp-use-nullptr, -hicpp-use-override, -hicpp-vararg

#
# is appended to the end of the check list

---
Checks: '-*,android-*,bugprone-*,cert-*-c,clang-analyzer-*,concurrency-*,portability-*,readability-*,-clang-analyzer-cplusplus.*,-clang-analyzer-osx.*,-clang-analyzer-optin.osx.*'
FormatStyle: file
CheckOptions:
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
value: '0'
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
value: '1'
- key: hicpp-signed-bitwise.IgnorePositiveIntegerLiterals
value: '1'
8 changes: 5 additions & 3 deletions build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ checkout_vcpkg() {
git submodule update --init
# checkout manually?
elif [ ! -d "${root}/vcpkg/.git" ]; then
echo "Cloning vcpkg git repo"
echo "Cloning vcpkg git repo into '${root}/vcpkg/'"
git clone https://github.com/microsoft/vcpkg.git "${root}/vcpkg/"
git --git-dir="${root}/vcpkg/.git" reset --hard "${vcpkg_commit}"
echo "Switching to correct commit"
git -C "${root}/vcpkg/" clean -ffxd
git -C "${root}/vcpkg/" reset --hard "${vcpkg_commit}"
fi
# Now bootstrap it?
if [ ! -f "${exe_path}" ] || [ ! -r "${exe_path}" ] || [ ! -x "${exe_path}" ]; then
Expand All @@ -95,7 +97,7 @@ checkout_vcpkg() {
export VCPKG_FORCE_SYSTEM_BINARIES=1
fi
"${root}/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
last_result = $?
last_result=$?
if [[ $last_result -ne 0 ]]; then
echo "Bootstrapping of vcpkg failed. Build cannot continue."
exit $last_result
Expand Down
14 changes: 6 additions & 8 deletions daemon/AtraceDriver.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* Copyright (C) 2014-2021 by Arm Limited. All rights reserved. */
/* Copyright (C) 2014-2022 by Arm Limited. All rights reserved. */

#include "AtraceDriver.h"

#include "FtraceDriver.h"
#include "Logging.h"
#include "OlyUtility.h"
#include "lib/String.h"

#include <unistd.h>

Expand Down Expand Up @@ -93,13 +94,10 @@ void AtraceDriver::setAtrace(const int flags)
handleException();
}
else if (pid == 0) {
char buf[1 << 10];
snprintf(buf,
sizeof(buf),
"setprop debug.atrace.tags.enableflags %i; "
"CLASSPATH=%s app_process /system/bin Notify",
flags,
mNotifyPath);
lib::printf_str_t<1 << 10> buf {"setprop debug.atrace.tags.enableflags %i; "
"CLASSPATH=%s app_process /system/bin Notify",
flags,
mNotifyPath};
execlp("sh", "sh", "-c", buf, nullptr);
exit(0);
}
Expand Down
4 changes: 2 additions & 2 deletions daemon/BlockCounterFrameBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2020 by Arm Limited. All rights reserved. */
/* Copyright (C) 2020-2022 by Arm Limited. All rights reserved. */

#include "BlockCounterFrameBuilder.h"

Expand Down Expand Up @@ -80,7 +80,7 @@ bool BlockCounterFrameBuilder::event64(int key, int64_t value)

bool BlockCounterFrameBuilder::check(const uint64_t time)
{
if ((*flushIsNeeded)(time, rawBuilder.needsFlush())) {
if ((flushIsNeeded != nullptr) && ((*flushIsNeeded)(time, rawBuilder.needsFlush()))) {
return flush();
}
return false;
Expand Down
15 changes: 10 additions & 5 deletions daemon/Buffer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2013-2021 by Arm Limited. All rights reserved. */
/* Copyright (C) 2013-2022 by Arm Limited. All rights reserved. */

#include "Buffer.h"

Expand All @@ -9,6 +9,7 @@
#include "lib/Assert.h"

#include <cstring>
#include <limits>

#define mask (mSize - 1)
#define FRAME_HEADER_SIZE 1 // single byte of FrameType
Expand Down Expand Up @@ -169,11 +170,15 @@ void Buffer::writeBytes(const void * const data, std::size_t count)
mWritePos = (mWritePos + i) & mask;
}

void Buffer::writeString(const char * const str)
void Buffer::writeString(std::string_view str)
{
const int len = strlen(str);
packInt(len);
writeBytes(str, len);
auto len = str.size();
if (len > std::numeric_limits<int>::max()) {
len = std::numeric_limits<int>::max();
}

packInt(static_cast<int32_t>(len));
writeBytes(str.data(), len);
}

void Buffer::beginFrame(FrameType frameType)
Expand Down
28 changes: 17 additions & 11 deletions daemon/Buffer.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/* Copyright (C) 2013-2021 by Arm Limited. All rights reserved. */
/* Copyright (C) 2013-2022 by Arm Limited. All rights reserved. */

#ifndef BUFFER_H
#define BUFFER_H

#include "IBufferControl.h"
#include "IRawFrameBuilder.h"
#ifdef BUFFER_USE_SESSION_DATA
#include "SessionData.h"
#endif

#include "IBufferControl.h"
#include "IRawFrameBuilder.h"

#include <atomic>
#include <cstdint>
#include <string_view>

#include <semaphore.h>

Expand All @@ -32,24 +34,28 @@ class Buffer : public IBufferControl, public IRawFrameBuilderWithDirectAccess {

bool write(ISender & sender) override;

int bytesAvailable() const override;
bool isFull() const override { return bytesAvailable() <= 0; }
int contiguousSpaceAvailable() const;
int size() const { return mSize; }
[[nodiscard]] int bytesAvailable() const override;
[[nodiscard]] bool isFull() const override { return bytesAvailable() <= 0; }
[[nodiscard]] int contiguousSpaceAvailable() const;
[[nodiscard]] int size() const { return mSize; }

void setDone() override;

// Prefer a new member to using these functions if possible
char * getWritePos() { return mBuf + mWritePos; }
[[nodiscard]] char * getWritePos() { return mBuf + mWritePos; }

int getWriteIndex() const override;
[[nodiscard]] int getWriteIndex() const override;
void advanceWrite(int bytes) override;
void writeDirect(int index, const void * data, std::size_t count) override;

// bring in the unsigned aliases
using IRawFrameBuilder::packInt;
using IRawFrameBuilder::packInt64;

int packInt(int32_t x) override;
int packInt64(int64_t x) override;
void writeBytes(const void * data, std::size_t count) override;
void writeString(const char * str) override;
void writeString(std::string_view str) override;

void beginFrame(FrameType frameType) override;
void abortFrame() override;
Expand All @@ -59,7 +65,7 @@ class Buffer : public IBufferControl, public IRawFrameBuilderWithDirectAccess {
void flush() override;

void waitForSpace(int bytes) override;
bool supportsWriteOfSize(int bytes) const override;
[[nodiscard]] bool supportsWriteOfSize(int bytes) const override;

private:
char * const mBuf;
Expand Down
Loading

0 comments on commit 1ae0c4d

Please sign in to comment.