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

Commit daf727a0 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Binder: move Trace to OS module

Also, Trusty is not OS_android.

Test: mma in binder
Bug: 302723053
Change-Id: Ia9e05f11705694668d8c299e220ea19e27b55d1f
parent bde9346e
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -90,7 +90,6 @@ cc_defaults {
        "Stability.cpp",
        "Stability.cpp",
        "Status.cpp",
        "Status.cpp",
        "TextOutput.cpp",
        "TextOutput.cpp",
        "Trace.cpp",
        "Utils.cpp",
        "Utils.cpp",
        "file.cpp",
        "file.cpp",
    ],
    ],
@@ -251,7 +250,6 @@ cc_library_shared {


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


namespace android::binder::os {
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 setNonBlocking(borrowed_fd fd);


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


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


namespace android::binder::os {
namespace android::binder::os {
@@ -34,4 +35,12 @@ bool report_sysprop_change() {
    return true;
    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
} // namespace android::binder::os

libs/binder/Trace.cpp

deleted100644 → 0
+0 −32
Original line number Original line 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 Original line Diff line number Diff line
@@ -16,22 +16,36 @@


#pragma once
#pragma once


#include <cutils/trace.h>
#include <stdint.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 android {
namespace binder {
namespace binder {


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


class ScopedTrace {
class ScopedTrace {
public:
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:
private:
    uint64_t mTag;
    uint64_t mTag;
Loading