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

Commit ab682e47 authored by Stephane Gasparini's avatar Stephane Gasparini Committed by android-build-merger
Browse files

Merge "Atrace:use ReadFileToString to read file"

am: 3cebac75

* commit '3cebac75':
  Atrace:use ReadFileToString to read file

Change-Id: Ib5b32935ea42321dc3566655cb875ed04161b7cb
parents 512926e2 3cebac75
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ LOCAL_SHARED_LIBRARIES := \
    libcutils \
    libutils \
    libz \
    libbase

LOCAL_INIT_RC := atrace.rc

+6 −16
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include <utils/Timers.h>
#include <utils/Tokenizer.h>
#include <utils/Trace.h>
#include <android-base/file.h>

using namespace android;

@@ -525,24 +526,14 @@ static bool disableKernelTraceEvents() {
// kernel.
static bool verifyKernelTraceFuncs(const char* funcs)
{
    int fd = open(k_ftraceFilterPath, O_RDONLY);
    if (fd == -1) {
    std::string buf;
    if (!android::base::ReadFileToString(k_ftraceFilterPath, &buf)) {
         fprintf(stderr, "error opening %s: %s (%d)\n", k_ftraceFilterPath,
            strerror(errno), errno);
         return false;
    }

    char buf[4097];
    ssize_t n = read(fd, buf, 4096);
    close(fd);
    if (n == -1) {
        fprintf(stderr, "error reading %s: %s (%d)\n", k_ftraceFilterPath,
            strerror(errno), errno);
        return false;
    }

    buf[n] = '\0';
    String8 funcList = String8::format("\n%s", buf);
    String8 funcList = String8::format("\n%s",buf.c_str());

    // Make sure that every function listed in funcs is in the list we just
    // read from the kernel, except for wildcard inputs.
@@ -562,7 +553,6 @@ static bool verifyKernelTraceFuncs(const char* funcs)
        func = strtok(NULL, ",");
    }
    free(myFuncs);

    return ok;
}