Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7ad3405 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Automerger Merge Worker
Browse files

Merge "Binder: move Trace to OS module" into main am: 7f6332c1

parents 40729a14 7f6332c1
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ cc_defaults {
        "Stability.cpp",
        "Status.cpp",
        "TextOutput.cpp",
        "Trace.cpp",
        "Utils.cpp",
        "file.cpp",
    ],
@@ -251,7 +250,6 @@ cc_library_shared {

    srcs: [
        // Trusty-specific files
        "OS_android.cpp",
        "trusty/OS.cpp",
        "trusty/RpcServerTrusty.cpp",
        "trusty/RpcTransportTipcTrusty.cpp",
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@

namespace android::binder::os {

void trace_begin(uint64_t tag, const char* name);
void trace_end(uint64_t tag);

status_t setNonBlocking(borrowed_fd fd);

status_t getRandomBytes(uint8_t* data, size_t size);
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "OS.h"

#include <android-base/threads.h>
#include <cutils/trace.h>
#include <utils/misc.h>

namespace android::binder::os {
@@ -34,4 +35,12 @@ bool report_sysprop_change() {
    return true;
}

void trace_begin(uint64_t tag, const char* name) {
    atrace_begin(tag, name);
}

void trace_end(uint64_t tag) {
    atrace_end(tag);
}

} // namespace android::binder::os

libs/binder/Trace.cpp

deleted100644 → 0
+0 −32
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <binder/Trace.h>
#include <cutils/trace.h>

namespace android {
namespace binder {

void atrace_begin(uint64_t tag, const char* name) {
    ::atrace_begin(tag, name);
}

void atrace_end(uint64_t tag) {
    ::atrace_end(tag);
}

} // namespace binder
} // namespace android
+19 −5
Original line number Diff line number Diff line
@@ -16,22 +16,36 @@

#pragma once

#include <cutils/trace.h>
#include <stdint.h>

#if __has_include(<cutils/trace.h>)
#include <cutils/trace.h>
#endif

#ifdef ATRACE_TAG_AIDL
#if ATRACE_TAG_AIDL != (1 << 24)
#error "Mismatched ATRACE_TAG_AIDL definitions"
#endif
#else
#define ATRACE_TAG_AIDL (1 << 24)
#endif

namespace android {
namespace binder {

// Forward declarations from internal OS.h
namespace os {
// Trampoline functions allowing generated aidls to trace binder transactions without depending on
// libcutils/libutils
void atrace_begin(uint64_t tag, const char* name);
void atrace_end(uint64_t tag);
void trace_begin(uint64_t tag, const char* name);
void trace_end(uint64_t tag);
} // namespace os

class ScopedTrace {
public:
    inline ScopedTrace(uint64_t tag, const char* name) : mTag(tag) { atrace_begin(mTag, name); }
    inline ScopedTrace(uint64_t tag, const char* name) : mTag(tag) { os::trace_begin(mTag, name); }

    inline ~ScopedTrace() { atrace_end(mTag); }
    inline ~ScopedTrace() { os::trace_end(mTag); }

private:
    uint64_t mTag;
Loading