From 719d854bfdf9eef0c58f9390c3f5250df491c53d Mon Sep 17 00:00:00 2001 From: Naseer Ahmed Date: Fri, 30 Dec 2011 19:13:28 +0530 Subject: [PATCH] display: Standardize debug logging for all memory types CRs-fixed: 331956 (cherry picked from commit fa7601fb06b265b4cb7c9aaaabea77e2a8d8c6e9) Change-Id: I1cc99760186aa4a70ebe2464f44b19e1fa91acdf --- libgralloc/ashmemalloc.cpp | 28 +++++++++++++--------------- libgralloc/ionalloc.cpp | 32 ++++++++++++-------------------- libgralloc/pmemalloc.cpp | 23 ++++++++++++++++------- 3 files changed, 41 insertions(+), 42 deletions(-) diff --git a/libgralloc/ashmemalloc.cpp b/libgralloc/ashmemalloc.cpp index 7102090..bb7b461 100644 --- a/libgralloc/ashmemalloc.cpp +++ b/libgralloc/ashmemalloc.cpp @@ -73,6 +73,9 @@ int AshmemAlloc::alloc_buffer(alloc_data& data) data.base = base; data.offset = offset; clean_buffer(base, data.size, offset, fd); + LOGD("ashmem: Allocated buffer base:%p size:%d fd:%d", + base, data.size, fd); + } return err; @@ -80,8 +83,8 @@ int AshmemAlloc::alloc_buffer(alloc_data& data) int AshmemAlloc::free_buffer(void* base, size_t size, int offset, int fd) { - LOGD("%s:Freeing buffer size=%d base=%p fd=%d PID=%d", - __FUNCTION__, size, base, fd, getpid()); + LOGD("ashmem: Freeing buffer base:%p size:%d fd:%d", + base, size, fd); int err = 0; if(!base) { @@ -95,44 +98,39 @@ int AshmemAlloc::free_buffer(void* base, size_t size, int offset, int fd) int AshmemAlloc::map_buffer(void **pBase, size_t size, int offset, int fd) { - LOGD("%s: Mapping buffer fd=%d size=%d PID=%d", __FUNCTION__, - fd, size, getpid()); int err = 0; void *base = 0; - if (err) - return err; base = mmap(0, size, PROT_READ| PROT_WRITE, MAP_SHARED|MAP_POPULATE, fd, 0); *pBase = base; if(base == MAP_FAILED) { - LOGD("%s: Failed to map memory in the client: %s", - __FUNCTION__, strerror(errno)); + LOGE("ashmem: Failed to map memory in the client: %s", + strerror(errno)); err = -errno; } else { - LOGD("%s: Successfully mapped %d bytes", __FUNCTION__, size); + LOGD("ashmem: Mapped buffer base:%p size:%d fd:%d", + base, size, fd); } return err; } int AshmemAlloc::unmap_buffer(void *base, size_t size, int offset) { - LOGD("%s: Unmapping buffer at address %p", __FUNCTION__, base); + LOGD("ashmem: Unmapping buffer base: %p size: %d", base, size); int err = munmap(base, size); if(err) { - LOGE("%s: Failed to unmap memory at %p: %s", - __FUNCTION__, base, strerror(errno)); + LOGE("ashmem: Failed to unmap memory at %p: %s", + base, strerror(errno)); } return err; } int AshmemAlloc::clean_buffer(void *base, size_t size, int offset, int fd) { - // LOGD("%s: Clean buffer fd=%d base = %p size=%d PID=%d", __FUNCTION__, - // fd, base, size, getpid()); int err = 0; if (ioctl(fd, ASHMEM_CACHE_FLUSH_RANGE, NULL)) { - LOGE("ASHMEM_CACHE_FLUSH_RANGE failed fd = %d", fd); + LOGE("ashmem: ASHMEM_CACHE_FLUSH_RANGE failed fd = %d", fd); } return err; diff --git a/libgralloc/ionalloc.cpp b/libgralloc/ionalloc.cpp index d1d3ce8..ee14e90 100644 --- a/libgralloc/ionalloc.cpp +++ b/libgralloc/ionalloc.cpp @@ -107,10 +107,6 @@ int IonAlloc::alloc_buffer(alloc_data& data) fd_data.handle = ionAllocData.handle; handle_data.handle = ionAllocData.handle; - LOGD("%s: Trying ION_IOC_MAP pid=%d handle=%p size=%d mIonFd=%d flags=%x", - __FUNCTION__, getpid(), ionAllocData.handle, - ionAllocData.len, mIonFd, ionAllocData.flags); - err = ioctl(iFd, ION_IOC_MAP, &fd_data); if(err) { LOGE("%s: ION_IOC_MAP failed with error - %s", @@ -128,7 +124,7 @@ int IonAlloc::alloc_buffer(alloc_data& data) base = mmap(0, ionAllocData.len, PROT_READ|PROT_WRITE, MAP_SHARED, fd_data.fd, 0); if(base == MAP_FAILED) { - LOGD("%s: Failed to map the allocated memory: %s", + LOGE("%s: Failed to map the allocated memory: %s", __FUNCTION__, strerror(errno)); err = -errno; ioctl(mIonFd, ION_IOC_FREE, &handle_data); @@ -149,17 +145,16 @@ int IonAlloc::alloc_buffer(alloc_data& data) data.base = base; data.fd = fd_data.fd; ioctl(mIonFd, ION_IOC_FREE, &handle_data); - LOGD("%s: ION alloc succeeded - mIonFd=%d, SharedFD=%d PID=%d size=%d" - " ionHandle=%p", __FUNCTION__, mIonFd, fd_data.fd, getpid(), - ionAllocData.len, ionAllocData.handle); + LOGD("ion: Allocated buffer base:%p size:%d fd:%d", + data.base, ionAllocData.len, data.fd); return err; } int IonAlloc::free_buffer(void* base, size_t size, int offset, int fd) { - LOGD("%s:Freeing buffer size=%d base=%p mIonFd=%d fd=%d PID=%d", - __FUNCTION__, size, base, mIonFd, fd, getpid()); + LOGD("ion: Freeing buffer base:%p size:%d fd:%d", + base, size, fd); int err = 0; err = open_device(); if (err) @@ -173,8 +168,6 @@ int IonAlloc::free_buffer(void* base, size_t size, int offset, int fd) int IonAlloc::map_buffer(void **pBase, size_t size, int offset, int fd) { - LOGD("%s: Mapping buffer fd=%d size=%d PID=%d", __FUNCTION__, - fd, size, getpid()); int err = 0; void *base = 0; // It is a (quirky) requirement of ION to have opened the @@ -187,30 +180,29 @@ int IonAlloc::map_buffer(void **pBase, size_t size, int offset, int fd) MAP_SHARED, fd, 0); *pBase = base; if(base == MAP_FAILED) { - LOGD("%s: Failed to map memory in the client: %s", - __FUNCTION__, strerror(errno)); + LOGD("ion: Failed to map memory in the client: %s", + strerror(errno)); err = -errno; } else { - LOGD("%s: Successfully mapped %d bytes", __FUNCTION__, size); + LOGD("ion: Mapped buffer base:%p size:%d offset:%d fd:%d", + base, size, offset, fd); } return err; } int IonAlloc::unmap_buffer(void *base, size_t size, int offset) { - LOGD("%s: Unmapping buffer at address %p", __FUNCTION__, base); + LOGD("ion: Unmapping buffer base:%p size:%d", base, size); int err = munmap(base, size); if(err) { - LOGE("%s: Failed to unmap memory at %p: %s", - __FUNCTION__, base, strerror(errno)); + LOGE("ion: Failed to unmap memory at %p : %s", + base, strerror(errno)); } return err; } int IonAlloc::clean_buffer(void *base, size_t size, int offset, int fd) { - // LOGD("%s: Clean buffer fd=%d base = %p size=%d PID=%d", __FUNCTION__, - // fd, base, size, getpid()); struct ion_flush_data flush_data; struct ion_fd_data fd_data; struct ion_handle_data handle_data; diff --git a/libgralloc/pmemalloc.cpp b/libgralloc/pmemalloc.cpp index d7ed2e6..19a2ea8 100644 --- a/libgralloc/pmemalloc.cpp +++ b/libgralloc/pmemalloc.cpp @@ -245,8 +245,8 @@ int PmemUserspaceAlloc::map_buffer(void **pBase, size_t size, int offset, int fd MAP_SHARED, fd, 0); *pBase = base; if(base == MAP_FAILED) { - LOGD("%s: Failed to map memory in the client: %s", - mPmemDev, strerror(errno)); + LOGE("%s: Failed to map buffer size:%d offset:%d fd:%d Error: %s", + mPmemDev, size, offset, fd, strerror(errno)); err = -errno; } else { LOGD("%s: Mapped buffer base:%p size:%d offset:%d fd:%d", @@ -265,7 +265,9 @@ int PmemUserspaceAlloc::unmap_buffer(void *base, size_t size, int offset) LOGD("%s: Unmapping buffer base:%p size:%d offset:%d", mPmemDev , base, size, offset); if (munmap(base, size) < 0) { - LOGE("Could not unmap %s", strerror(errno)); + LOGE("%s: Failed to unmap memory at %p :%s", + mPmemDev, base, strerror(errno)); + err = -errno; } @@ -323,12 +325,17 @@ int PmemKernelAlloc::alloc_buffer(alloc_data& data) data.base = base; data.offset = 0; data.fd = fd; + LOGD("%s: Allocated buffer base:%p size:%d fd:%d", + mPmemDev, base, size, fd); return 0; } int PmemKernelAlloc::free_buffer(void* base, size_t size, int offset, int fd) { + LOGD("%s: Freeing buffer base:%p size:%d fd:%d", + mPmemDev, base, size, fd); + int err = unmap_buffer(base, size, offset); close(fd); return err; @@ -341,11 +348,12 @@ int PmemKernelAlloc::map_buffer(void **pBase, size_t size, int offset, int fd) MAP_SHARED, fd, 0); *pBase = base; if(base == MAP_FAILED) { - LOGD("%s: Failed to map memory in the client: %s", - __func__, strerror(errno)); + LOGE("%s: Failed to map memory in the client: %s", + mPmemDev, strerror(errno)); err = -errno; } else { - LOGD("%s: Mapped %d bytes", __func__, size); + LOGD("%s: Mapped buffer base:%p size:%d, fd:%d", + mPmemDev, base, size, fd); } return err; @@ -357,7 +365,8 @@ int PmemKernelAlloc::unmap_buffer(void *base, size_t size, int offset) munmap(base, size); if (err < 0) { err = -errno; - LOGW("Error unmapping pmem fd: %s", strerror(err)); + LOGW("%s: Error unmapping memory at %p: %s", + mPmemDev, base, strerror(err)); } return err;