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

Commit aa88f3be authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Add memory leak tracking/debugging code to drm server"

parents 9406eb13 ed73246b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ LOCAL_SRC_FILES:= \
    StringTokenizer.cpp

LOCAL_SHARED_LIBRARIES := \
    libmedia \
    libutils \
    libbinder

+29 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <utils/Log.h>

#include <private/android_filesystem_config.h>
#include <media/MemoryLeakTrackUtil.h>

#include <errno.h>
#include <utils/threads.h>
@@ -256,3 +257,31 @@ ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
    return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
}

status_t DrmManagerService::dump(int fd, const Vector<String16>& args)
{
    const size_t SIZE = 256;
    char buffer[SIZE];
    String8 result;
    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        snprintf(buffer, SIZE, "Permission Denial: "
                "can't dump DrmManagerService from pid=%d, uid=%d\n",
                IPCThreadState::self()->getCallingPid(),
                IPCThreadState::self()->getCallingUid());
        result.append(buffer);
    } else {
#if DRM_MEMORY_LEAK_TRACK
        bool dumpMem = false;
        for (size_t i = 0; i < args.size(); i++) {
            if (args[i] == String16("-m")) {
                dumpMem = true;
            }
        }
        if (dumpMem) {
            dumpMemoryAddresses(fd);
        }
#endif
    }
    write(fd, result.string(), result.size());
    return NO_ERROR;
}
+2 −0
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@ public:
    ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
            void* buffer, ssize_t numBytes, off64_t offset);

    virtual status_t dump(int fd, const Vector<String16>& args);

private:
    DrmManager* mDrmManager;
};
+28 −0
Original line number Diff line number Diff line

/*
 * Copyright 2011, 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.
 */
#ifndef MEMORY_LEAK_TRACK_UTIL_H
#define MEMORY_LEAK_TRACK_UTIL_H

namespace android {
/*
 * Dump the memory adddress of the calling process to the given fd.
 */
extern void dumpMemoryAddresses(int fd);

};

#endif  // MEMORY_LEAK_TRACK_UTIL_H
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ LOCAL_SRC_FILES:= \
    IEffectClient.cpp \
    AudioEffect.cpp \
    Visualizer.cpp \
    MemoryLeakTrackUtil.cpp \
    fixedfft.cpp.arm

LOCAL_SHARED_LIBRARIES := \
Loading