#else
-#define IF_LOG_WINDOW() IF_LOG(LOG_DEBUG, "CursorWindow")
-#define LOG_WINDOW(...) LOG(LOG_DEBUG, "CursorWindow", __VA_ARGS__)
+#define IF_LOG_WINDOW() IF_ALOG(LOG_DEBUG, "CursorWindow")
+#define LOG_WINDOW(...) ALOG(LOG_DEBUG, "CursorWindow", __VA_ARGS__)
#endif
// ----------------------------------------------------------------------------
class Parcel;
-class SensorChannel : public RefBase
+class BitTube : public RefBase
{
public:
- SensorChannel();
- SensorChannel(const Parcel& data);
- virtual ~SensorChannel();
+ BitTube();
+ BitTube(const Parcel& data);
+ virtual ~BitTube();
+ status_t initCheck() const;
int getFd() const;
ssize_t write(void const* vaddr, size_t size);
ssize_t read(void* vaddr, size_t size);
namespace android {
// ----------------------------------------------------------------------------
-class SensorChannel;
+class BitTube;
class ISensorEventConnection : public IInterface
{
public:
DECLARE_META_INTERFACE(SensorEventConnection);
- virtual sp<SensorChannel> getSensorChannel() const = 0;
+ virtual sp<BitTube> getSensorChannel() const = 0;
virtual status_t enableDisable(int handle, bool enabled) = 0;
virtual status_t setEventRate(int handle, nsecs_t ns) = 0;
};
#include <utils/RefBase.h>
#include <utils/Timers.h>
-#include <gui/SensorChannel.h>
+#include <gui/BitTube.h>
// ----------------------------------------------------------------------------
private:
sp<Looper> getLooper() const;
sp<ISensorEventConnection> mSensorEventConnection;
- sp<SensorChannel> mSensorChannel;
+ sp<BitTube> mSensorChannel;
mutable Mutex mLock;
mutable sp<Looper> mLooper;
};
#include <sys/types.h>
#include <utils/String8.h>
+#include <corkscrew/backtrace.h>
// ---------------------------------------------------------------------------
size_t size() const { return mCount; }
private:
- // Internal helper function
- String8 toStringSingleLevel(const char* prefix, int32_t level) const;
-
- size_t mCount;
- const void* mStack[MAX_DEPTH];
+ size_t mCount;
+ backtrace_frame_t mStack[MAX_DEPTH];
};
}; // namespace android
#include <stdio.h>
-//#undef LOGV
-//#define LOGV(...) fprintf(stderr, __VA_ARGS__)
+//#undef ALOGV
+//#define ALOGV(...) fprintf(stderr, __VA_ARGS__)
namespace android {
void BpBinder::ObjectManager::kill()
{
const size_t N = mObjects.size();
- LOGV("Killing %d objects in manager %p", N, this);
+ ALOGV("Killing %d objects in manager %p", N, this);
for (size_t i=0; i<N; i++) {
const entry_t& e = mObjects.valueAt(i);
if (e.func != NULL) {
, mObitsSent(0)
, mObituaries(NULL)
{
- LOGV("Creating BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("Creating BpBinder %p handle %d\n", this, mHandle);
extendObjectLifetime(OBJECT_LIFETIME_WEAK);
IPCThreadState::self()->incWeakHandle(handle);
if (!mObituaries) {
return NO_MEMORY;
}
- LOGV("Requesting death notification: %p handle %d\n", this, mHandle);
+ ALOGV("Requesting death notification: %p handle %d\n", this, mHandle);
getWeakRefs()->incWeak(this);
IPCThreadState* self = IPCThreadState::self();
self->requestDeathNotification(mHandle, this);
}
mObituaries->removeAt(i);
if (mObituaries->size() == 0) {
- LOGV("Clearing death notification: %p handle %d\n", this, mHandle);
+ ALOGV("Clearing death notification: %p handle %d\n", this, mHandle);
IPCThreadState* self = IPCThreadState::self();
self->clearDeathNotification(mHandle, this);
self->flushCommands();
void BpBinder::sendObituary()
{
- LOGV("Sending obituary for proxy %p handle %d, mObitsSent=%s\n",
+ ALOGV("Sending obituary for proxy %p handle %d, mObitsSent=%s\n",
this, mHandle, mObitsSent ? "true" : "false");
mAlive = 0;
mLock.lock();
Vector<Obituary>* obits = mObituaries;
if(obits != NULL) {
- LOGV("Clearing sent death notification: %p handle %d\n", this, mHandle);
+ ALOGV("Clearing sent death notification: %p handle %d\n", this, mHandle);
IPCThreadState* self = IPCThreadState::self();
self->clearDeathNotification(mHandle, this);
self->flushCommands();
mObitsSent = 1;
mLock.unlock();
- LOGV("Reporting death of proxy %p for %d recipients\n",
+ ALOGV("Reporting death of proxy %p for %d recipients\n",
this, obits ? obits->size() : 0);
if (obits != NULL) {
void BpBinder::reportOneDeath(const Obituary& obit)
{
sp<DeathRecipient> recipient = obit.recipient.promote();
- LOGV("Reporting death to recipient: %p\n", recipient.get());
+ ALOGV("Reporting death to recipient: %p\n", recipient.get());
if (recipient == NULL) return;
recipient->binderDied(this);
object_cleanup_func func)
{
AutoMutex _l(mLock);
- LOGV("Attaching object %p to binder %p (manager=%p)", object, this, &mObjects);
+ ALOGV("Attaching object %p to binder %p (manager=%p)", object, this, &mObjects);
mObjects.attach(objectID, object, cleanupCookie, func);
}
BpBinder::~BpBinder()
{
- LOGV("Destroying BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("Destroying BpBinder %p handle %d\n", this, mHandle);
IPCThreadState* ipc = IPCThreadState::self();
void BpBinder::onFirstRef()
{
- LOGV("onFirstRef BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("onFirstRef BpBinder %p handle %d\n", this, mHandle);
IPCThreadState* ipc = IPCThreadState::self();
if (ipc) ipc->incStrongHandle(mHandle);
}
void BpBinder::onLastStrongRef(const void* id)
{
- LOGV("onLastStrongRef BpBinder %p handle %d\n", this, mHandle);
- IF_LOGV() {
+ ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, mHandle);
+ IF_ALOGV() {
printRefs();
}
IPCThreadState* ipc = IPCThreadState::self();
bool BpBinder::onIncStrongAttempted(uint32_t flags, const void* id)
{
- LOGV("onIncStrongAttempted BpBinder %p handle %d\n", this, mHandle);
+ ALOGV("onIncStrongAttempted BpBinder %p handle %d\n", this, mHandle);
IPCThreadState* ipc = IPCThreadState::self();
return ipc ? ipc->attemptIncStrongHandle(mHandle) == NO_ERROR : false;
}
#else
-#define IF_LOG_TRANSACTIONS() IF_LOG(LOG_VERBOSE, "transact")
-#define IF_LOG_COMMANDS() IF_LOG(LOG_VERBOSE, "ipc")
-#define LOG_REMOTEREFS(...) LOG(LOG_DEBUG, "remoterefs", __VA_ARGS__)
-#define IF_LOG_REMOTEREFS() IF_LOG(LOG_DEBUG, "remoterefs")
-#define LOG_THREADPOOL(...) LOG(LOG_DEBUG, "threadpool", __VA_ARGS__)
-#define LOG_ONEWAY(...) LOG(LOG_DEBUG, "ipc", __VA_ARGS__)
+#define IF_LOG_TRANSACTIONS() IF_ALOG(LOG_VERBOSE, "transact")
+#define IF_LOG_COMMANDS() IF_ALOG(LOG_VERBOSE, "ipc")
+#define LOG_REMOTEREFS(...) ALOG(LOG_DEBUG, "remoterefs", __VA_ARGS__)
+#define IF_LOG_REMOTEREFS() IF_ALOG(LOG_DEBUG, "remoterefs")
+#define LOG_THREADPOOL(...) ALOG(LOG_DEBUG, "threadpool", __VA_ARGS__)
+#define LOG_ONEWAY(...) ALOG(LOG_DEBUG, "ipc", __VA_ARGS__)
#endif
#endif
#define LOG_REFS(...)
-//#define LOG_REFS(...) LOG(LOG_DEBUG, "Parcel", __VA_ARGS__)
+//#define LOG_REFS(...) ALOG(LOG_DEBUG, "Parcel", __VA_ARGS__)
// ---------------------------------------------------------------------------
err = continueWrite(size);
if (err == NO_ERROR) {
mDataSize = size;
- LOGV("setDataSize Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("setDataSize Setting data size of %p to %d\n", this, mDataSize);
}
return err;
}
{
//printf("Finish write of %d\n", len);
mDataPos += len;
- LOGV("finishWrite Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("finishWrite Setting data pos of %p to %d\n", this, mDataPos);
if (mDataPos > mDataSize) {
mDataSize = mDataPos;
- LOGV("finishWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("finishWrite Setting data size of %p to %d\n", this, mDataSize);
}
//printf("New pos=%d, size=%d\n", mDataPos, mDataSize);
return NO_ERROR;
status_t status;
if (!mAllowFds || len <= IN_PLACE_BLOB_LIMIT) {
- LOGV("writeBlob: write in place");
+ ALOGV("writeBlob: write in place");
status = writeInt32(0);
if (status) return status;
return NO_ERROR;
}
- LOGV("writeBlob: write to ashmem");
+ ALOGV("writeBlob: write to ashmem");
int fd = ashmem_create_region("Parcel Blob", len);
if (fd < 0) return NO_MEMORY;
if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
memcpy(outData, mData+mDataPos, len);
mDataPos += PAD_SIZE(len);
- LOGV("read Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("read Setting data pos of %p to %d\n", this, mDataPos);
return NO_ERROR;
}
return NOT_ENOUGH_DATA;
if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
const void* data = mData+mDataPos;
mDataPos += PAD_SIZE(len);
- LOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
return data;
}
return NULL;
if (eos) {
const size_t len = eos - str;
mDataPos += PAD_SIZE(len+1);
- LOGV("readCString Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readCString Setting data pos of %p to %d\n", this, mDataPos);
return str;
}
}
if (status) return status;
if (!useAshmem) {
- LOGV("readBlob: read in place");
+ ALOGV("readBlob: read in place");
const void* ptr = readInplace(len);
if (!ptr) return BAD_VALUE;
return NO_ERROR;
}
- LOGV("readBlob: read from ashmem");
+ ALOGV("readBlob: read from ashmem");
int fd = readFileDescriptor();
if (fd == int(BAD_TYPE)) return BAD_VALUE;
// When transferring a NULL object, we don't write it into
// the object list, so we don't want to check for it when
// reading.
- LOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
return obj;
}
size_t opos = mNextObjectHint;
if (N > 0) {
- LOGV("Parcel %p looking for obj at %d, hint=%d\n",
+ ALOGV("Parcel %p looking for obj at %d, hint=%d\n",
this, DPOS, opos);
// Start at the current hint position, looking for an object at
}
if (OBJS[opos] == DPOS) {
// Found it!
- LOGV("Parcel found obj %d at index %d with forward search",
+ ALOGV("Parcel found obj %d at index %d with forward search",
this, DPOS, opos);
mNextObjectHint = opos+1;
- LOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
return obj;
}
}
if (OBJS[opos] == DPOS) {
// Found it!
- LOGV("Parcel found obj %d at index %d with backward search",
+ ALOGV("Parcel found obj %d at index %d with backward search",
this, DPOS, opos);
mNextObjectHint = opos+1;
- LOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("readObject Setting data pos of %p to %d\n", this, mDataPos);
return obj;
}
}
mDataSize = mDataCapacity = dataSize;
//LOGI("setDataReference Setting data size of %p to %lu (pid=%d)\n", this, mDataSize, getpid());
mDataPos = 0;
- LOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("setDataReference Setting data pos of %p to %d\n", this, mDataPos);
mObjects = const_cast<size_t*>(objects);
mObjectsSize = mObjectsCapacity = objectsCount;
mNextObjectHint = 0;
}
mDataSize = mDataPos = 0;
- LOGV("restartWrite Setting data size of %p to %d\n", this, mDataSize);
- LOGV("restartWrite Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("restartWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("restartWrite Setting data pos of %p to %d\n", this, mDataPos);
free(mObjects);
mObjects = NULL;
mData = data;
mObjects = objects;
mDataSize = (mDataSize < desired) ? mDataSize : desired;
- LOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
mDataCapacity = desired;
mObjectsSize = mObjectsCapacity = objectsSize;
mNextObjectHint = 0;
} else {
if (mDataSize > desired) {
mDataSize = desired;
- LOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
}
if (mDataPos > desired) {
mDataPos = desired;
- LOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
}
}
mData = data;
mDataSize = mDataPos = 0;
- LOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
- LOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("continueWrite Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("continueWrite Setting data pos of %p to %d\n", this, mDataPos);
mDataCapacity = desired;
}
mDataSize = 0;
mDataCapacity = 0;
mDataPos = 0;
- LOGV("initState Setting data size of %p to %d\n", this, mDataSize);
- LOGV("initState Setting data pos of %p to %d\n", this, mDataPos);
+ ALOGV("initState Setting data size of %p to %d\n", this, mDataSize);
+ ALOGV("initState Setting data pos of %p to %d\n", this, mDataPos);
mObjects = NULL;
mObjectsSize = 0;
mObjectsCapacity = 0;
int32_t s = android_atomic_add(1, &mThreadPoolSeq);
char buf[32];
sprintf(buf, "Binder Thread #%d", s);
- LOGV("Spawning new pooled thread, name=%s\n", buf);
+ ALOGV("Spawning new pooled thread, name=%s\n", buf);
sp<Thread> t = new PoolThread(isMain);
t->run(buf);
}
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
+ BitTube.cpp \
ISensorEventConnection.cpp \
ISensorServer.cpp \
ISurfaceTexture.cpp \
Sensor.cpp \
- SensorChannel.cpp \
SensorEventQueue.cpp \
SensorManager.cpp \
SurfaceTexture.cpp \
#include <binder/Parcel.h>
-#include <gui/SensorChannel.h>
+#include <gui/BitTube.h>
namespace android {
// ----------------------------------------------------------------------------
-SensorChannel::SensorChannel()
+BitTube::BitTube()
: mSendFd(-1), mReceiveFd(-1)
{
int fds[2];
mSendFd = fds[1];
fcntl(mReceiveFd, F_SETFL, O_NONBLOCK);
fcntl(mSendFd, F_SETFL, O_NONBLOCK);
+ } else {
+ mReceiveFd = -errno;
+ LOGE("BitTube: pipe creation failed (%s)", strerror(-mReceiveFd));
}
}
-SensorChannel::SensorChannel(const Parcel& data)
+BitTube::BitTube(const Parcel& data)
: mSendFd(-1), mReceiveFd(-1)
{
mReceiveFd = dup(data.readFileDescriptor());
- fcntl(mReceiveFd, F_SETFL, O_NONBLOCK);
+ if (mReceiveFd >= 0) {
+ fcntl(mReceiveFd, F_SETFL, O_NONBLOCK);
+ } else {
+ mReceiveFd = -errno;
+ LOGE("BitTube(Parcel): can't dup filedescriptor (%s)",
+ strerror(-mReceiveFd));
+ }
}
-SensorChannel::~SensorChannel()
+BitTube::~BitTube()
{
if (mSendFd >= 0)
close(mSendFd);
close(mReceiveFd);
}
-int SensorChannel::getFd() const
+status_t BitTube::initCheck() const
+{
+ if (mReceiveFd < 0) {
+ return status_t(mReceiveFd);
+ }
+ return NO_ERROR;
+}
+
+int BitTube::getFd() const
{
return mReceiveFd;
}
-ssize_t SensorChannel::write(void const* vaddr, size_t size)
+ssize_t BitTube::write(void const* vaddr, size_t size)
{
- ssize_t len = ::write(mSendFd, vaddr, size);
- if (len < 0)
- return -errno;
- return len;
+ ssize_t err, len;
+ do {
+ len = ::write(mSendFd, vaddr, size);
+ err = len < 0 ? errno : 0;
+ } while (err == EINTR);
+ return err == 0 ? len : -err;
+
}
-ssize_t SensorChannel::read(void* vaddr, size_t size)
+ssize_t BitTube::read(void* vaddr, size_t size)
{
- ssize_t len = ::read(mReceiveFd, vaddr, size);
- if (len < 0)
- return -errno;
- return len;
+ ssize_t err, len;
+ do {
+ len = ::read(mReceiveFd, vaddr, size);
+ err = len < 0 ? errno : 0;
+ } while (err == EINTR);
+ return err == 0 ? len : -err;
}
-status_t SensorChannel::writeToParcel(Parcel* reply) const
+status_t BitTube::writeToParcel(Parcel* reply) const
{
if (mReceiveFd < 0)
return -EINVAL;
#include <binder/IInterface.h>
#include <gui/ISensorEventConnection.h>
-#include <gui/SensorChannel.h>
+#include <gui/BitTube.h>
namespace android {
// ----------------------------------------------------------------------------
{
}
- virtual sp<SensorChannel> getSensorChannel() const
+ virtual sp<BitTube> getSensorChannel() const
{
Parcel data, reply;
data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
remote()->transact(GET_SENSOR_CHANNEL, data, &reply);
- return new SensorChannel(reply);
+ return new BitTube(reply);
}
virtual status_t enableDisable(int handle, bool enabled)
switch(code) {
case GET_SENSOR_CHANNEL: {
CHECK_INTERFACE(ISensorEventConnection, data, reply);
- sp<SensorChannel> channel(getSensorChannel());
+ sp<BitTube> channel(getSensorChannel());
channel->writeToParcel(reply);
return NO_ERROR;
} break;
#include <utils/Looper.h>
#include <gui/Sensor.h>
-#include <gui/SensorChannel.h>
+#include <gui/BitTube.h>
#include <gui/SensorEventQueue.h>
#include <gui/ISensorEventConnection.h>
do {
result = looper->pollOnce(-1);
if (result == ALOOPER_EVENT_ERROR) {
- LOGE("SensorChannel::waitForEvent error (errno=%d)", errno);
+ LOGE("SensorEventQueue::waitForEvent error (errno=%d)", errno);
result = -EPIPE; // unknown error, so we make up one
break;
}
#define ALLOW_DEQUEUE_CURRENT_BUFFER false
// Macros for including the SurfaceTexture name in log messages
-#define ST_LOGV(x, ...) LOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
#define ST_LOGD(x, ...) LOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
#define ST_LOGI(x, ...) LOGI("[%s] "x, mName.string(), ##__VA_ARGS__)
#define ST_LOGW(x, ...) LOGW("[%s] "x, mName.string(), ##__VA_ARGS__)
}
int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer) {
- LOGV("SurfaceTextureClient::dequeueBuffer");
+ ALOGV("SurfaceTextureClient::dequeueBuffer");
Mutex::Autolock lock(mMutex);
int buf = -1;
status_t result = mSurfaceTexture->dequeueBuffer(&buf, mReqWidth, mReqHeight,
mReqFormat, mReqUsage);
if (result < 0) {
- LOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)"
+ ALOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)"
"failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage,
result);
return result;
}
int SurfaceTextureClient::cancelBuffer(android_native_buffer_t* buffer) {
- LOGV("SurfaceTextureClient::cancelBuffer");
+ ALOGV("SurfaceTextureClient::cancelBuffer");
Mutex::Autolock lock(mMutex);
int i = getSlotFromBufferLocked(buffer);
if (i < 0) {
}
int SurfaceTextureClient::lockBuffer(android_native_buffer_t* buffer) {
- LOGV("SurfaceTextureClient::lockBuffer");
+ ALOGV("SurfaceTextureClient::lockBuffer");
Mutex::Autolock lock(mMutex);
return OK;
}
int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer) {
- LOGV("SurfaceTextureClient::queueBuffer");
+ ALOGV("SurfaceTextureClient::queueBuffer");
Mutex::Autolock lock(mMutex);
int64_t timestamp;
if (mTimestamp == NATIVE_WINDOW_TIMESTAMP_AUTO) {
timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
- LOGV("SurfaceTextureClient::queueBuffer making up timestamp: %.2f ms",
+ ALOGV("SurfaceTextureClient::queueBuffer making up timestamp: %.2f ms",
timestamp / 1000000.f);
} else {
timestamp = mTimestamp;
}
int SurfaceTextureClient::query(int what, int* value) const {
- LOGV("SurfaceTextureClient::query");
+ ALOGV("SurfaceTextureClient::query");
{ // scope for the lock
Mutex::Autolock lock(mMutex);
switch (what) {
int SurfaceTextureClient::connect(int api) {
- LOGV("SurfaceTextureClient::connect");
+ ALOGV("SurfaceTextureClient::connect");
Mutex::Autolock lock(mMutex);
int err = mSurfaceTexture->connect(api,
&mDefaultWidth, &mDefaultHeight, &mTransformHint);
}
int SurfaceTextureClient::disconnect(int api) {
- LOGV("SurfaceTextureClient::disconnect");
+ ALOGV("SurfaceTextureClient::disconnect");
Mutex::Autolock lock(mMutex);
freeAllBuffers();
int err = mSurfaceTexture->disconnect(api);
int SurfaceTextureClient::setUsage(uint32_t reqUsage)
{
- LOGV("SurfaceTextureClient::setUsage");
+ ALOGV("SurfaceTextureClient::setUsage");
Mutex::Autolock lock(mMutex);
mReqUsage = reqUsage;
return OK;
int SurfaceTextureClient::setCrop(Rect const* rect)
{
- LOGV("SurfaceTextureClient::setCrop");
+ ALOGV("SurfaceTextureClient::setCrop");
Mutex::Autolock lock(mMutex);
Rect realRect;
int SurfaceTextureClient::setBufferCount(int bufferCount)
{
- LOGV("SurfaceTextureClient::setBufferCount");
+ ALOGV("SurfaceTextureClient::setBufferCount");
Mutex::Autolock lock(mMutex);
status_t err = mSurfaceTexture->setBufferCount(bufferCount);
int SurfaceTextureClient::setBuffersDimensions(int w, int h)
{
- LOGV("SurfaceTextureClient::setBuffersDimensions");
+ ALOGV("SurfaceTextureClient::setBuffersDimensions");
Mutex::Autolock lock(mMutex);
if (w<0 || h<0)
int SurfaceTextureClient::setBuffersFormat(int format)
{
- LOGV("SurfaceTextureClient::setBuffersFormat");
+ ALOGV("SurfaceTextureClient::setBuffersFormat");
Mutex::Autolock lock(mMutex);
if (format<0)
int SurfaceTextureClient::setScalingMode(int mode)
{
- LOGV("SurfaceTextureClient::setScalingMode(%d)", mode);
+ ALOGV("SurfaceTextureClient::setScalingMode(%d)", mode);
Mutex::Autolock lock(mMutex);
// mode is validated on the server
status_t err = mSurfaceTexture->setScalingMode(mode);
int SurfaceTextureClient::setBuffersTransform(int transform)
{
- LOGV("SurfaceTextureClient::setBuffersTransform");
+ ALOGV("SurfaceTextureClient::setBuffersTransform");
Mutex::Autolock lock(mMutex);
status_t err = mSurfaceTexture->setTransform(transform);
return err;
int SurfaceTextureClient::setBuffersTimestamp(int64_t timestamp)
{
- LOGV("SurfaceTextureClient::setBuffersTimestamp");
+ ALOGV("SurfaceTextureClient::setBuffersTimestamp");
Mutex::Autolock lock(mMutex);
mTimestamp = timestamp;
return NO_ERROR;
// test.
void waitForFrame() {
Mutex::Autolock lock(mMutex);
- LOGV("+waitForFrame");
+ ALOGV("+waitForFrame");
while (!mFrameAvailable) {
mFrameAvailableCondition.wait(mMutex);
}
mFrameAvailable = false;
- LOGV("-waitForFrame");
+ ALOGV("-waitForFrame");
}
// Allow the producer to return from its swapBuffers call and continue
// thread once for every frame expected by the test.
void finishFrame() {
Mutex::Autolock lock(mMutex);
- LOGV("+finishFrame");
+ ALOGV("+finishFrame");
mFrameFinished = true;
mFrameFinishCondition.signal();
- LOGV("-finishFrame");
+ ALOGV("-finishFrame");
}
// This should be called by SurfaceTexture on the producer thread.
virtual void onFrameAvailable() {
Mutex::Autolock lock(mMutex);
- LOGV("+onFrameAvailable");
+ ALOGV("+onFrameAvailable");
mFrameAvailable = true;
mFrameAvailableCondition.signal();
while (!mFrameFinished) {
mFrameFinishCondition.wait(mMutex);
}
mFrameFinished = false;
- LOGV("-onFrameAvailable");
+ ALOGV("-onFrameAvailable");
}
protected:
for (int i = 0; i < NUM_ITERATIONS; i++) {
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
- LOGV("+swapBuffers");
+ ALOGV("+swapBuffers");
swapBuffers();
- LOGV("-swapBuffers");
+ ALOGV("-swapBuffers");
}
}
};
for (int i = 0; i < NUM_ITERATIONS; i++) {
mFC->waitForFrame();
- LOGV("+updateTexImage");
+ ALOGV("+updateTexImage");
mST->updateTexImage();
- LOGV("-updateTexImage");
+ ALOGV("-updateTexImage");
mFC->finishFrame();
// TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
for (int i = 0; i < NUM_ITERATIONS; i++) {
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
- LOGV("+swapBuffers");
+ ALOGV("+swapBuffers");
swapBuffers();
- LOGV("-swapBuffers");
+ ALOGV("-swapBuffers");
}
}
};
for (int i = 0; i < NUM_ITERATIONS; i++) {
mFC->waitForFrame();
mFC->finishFrame();
- LOGV("+updateTexImage");
+ ALOGV("+updateTexImage");
mST->updateTexImage();
- LOGV("-updateTexImage");
+ ALOGV("-updateTexImage");
// TODO: Add frame verification once RGB TEX_EXTERNAL_OES is supported!
}
for (int i = 0; i < NUM_ITERATIONS; i++) {
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
- LOGV("+swapBuffers");
+ ALOGV("+swapBuffers");
swapBuffers();
- LOGV("-swapBuffers");
+ ALOGV("-swapBuffers");
}
}
};
for (int i = 0; i < NUM_ITERATIONS-3; i++) {
mFC->waitForFrame();
mFC->finishFrame();
- LOGV("+updateTexImage");
+ ALOGV("+updateTexImage");
mST->updateTexImage();
- LOGV("-updateTexImage");
+ ALOGV("-updateTexImage");
}
}
libz \
liblog \
libcutils \
- libdl
+ libdl \
+ libcorkscrew
LOCAL_MODULE:= libutils
include $(BUILD_SHARED_LIBRARY)
return NULL;
}
- LOGV("Asset %p allocating buffer size %d (smaller than threshold)", this, (int)allocLen);
+ ALOGV("Asset %p allocating buffer size %d (smaller than threshold)", this, (int)allocLen);
if (mLength > 0) {
long oldPosn = ftell(mFp);
fseek(mFp, mStart, SEEK_SET);
fseek(mFp, oldPosn, SEEK_SET);
}
- LOGV(" getBuffer: loaded into buffer\n");
+ ALOGV(" getBuffer: loaded into buffer\n");
mBuf = buf;
return mBuf;
return NULL;
}
- LOGV(" getBuffer: mapped\n");
+ ALOGV(" getBuffer: mapped\n");
mMap = map;
if (!wordAligned) {
if ((((size_t)data)&0x3) == 0) {
// We can return this directly if it is aligned on a word
// boundary.
- LOGV("Returning aligned FileAsset %p (%s).", this,
+ ALOGV("Returning aligned FileAsset %p (%s).", this,
getAssetSource());
return data;
}
// If not aligned on a word boundary, then we need to copy it into
// our own buffer.
- LOGV("Copying FileAsset %p (%s) to buffer size %d to make it aligned.", this,
+ ALOGV("Copying FileAsset %p (%s) to buffer size %d to make it aligned.", this,
getAssetSource(), (int)mLength);
unsigned char* buf = new unsigned char[mLength];
if (buf == NULL) {
}
}
- LOGV("In %p Asset %s path: %s", this,
+ ALOGV("In %p Asset %s path: %s", this,
ap.type == kFileTypeDirectory ? "dir" : "zip", ap.path.string());
mAssetPaths.add(ap);
size_t i = mAssetPaths.size();
while (i > 0) {
i--;
- LOGV("Looking for asset '%s' in '%s'\n",
+ ALOGV("Looking for asset '%s' in '%s'\n",
assetName.string(), mAssetPaths.itemAt(i).path.string());
Asset* pAsset = openNonAssetInPathLocked(assetName.string(), mode, mAssetPaths.itemAt(i));
if (pAsset != NULL) {
size_t i = mAssetPaths.size();
while (i > 0) {
i--;
- LOGV("Looking for non-asset '%s' in '%s'\n", fileName, mAssetPaths.itemAt(i).path.string());
+ ALOGV("Looking for non-asset '%s' in '%s'\n", fileName, mAssetPaths.itemAt(i).path.string());
Asset* pAsset = openNonAssetInPathLocked(
fileName, mode, mAssetPaths.itemAt(i));
if (pAsset != NULL) {
loadFileNameCacheLocked();
if (which < mAssetPaths.size()) {
- LOGV("Looking for non-asset '%s' in '%s'\n", fileName,
+ ALOGV("Looking for non-asset '%s' in '%s'\n", fileName,
mAssetPaths.itemAt(which).path.string());
Asset* pAsset = openNonAssetInPathLocked(
fileName, mode, mAssetPaths.itemAt(which));
bool shared = true;
const asset_path& ap = mAssetPaths.itemAt(i);
Asset* idmap = openIdmapLocked(ap);
- LOGV("Looking for resource asset in '%s'\n", ap.path.string());
+ ALOGV("Looking for resource asset in '%s'\n", ap.path.string());
if (ap.type != kFileTypeDirectory) {
if (i == 0) {
// The first item is typically the framework resources,
ass = const_cast<AssetManager*>(this)->
mZipSet.getZipResourceTableAsset(ap.path);
if (ass == NULL) {
- LOGV("loading resource table %s\n", ap.path.string());
+ ALOGV("loading resource table %s\n", ap.path.string());
ass = const_cast<AssetManager*>(this)->
openNonAssetInPathLocked("resources.arsc",
Asset::ACCESS_BUFFER,
// If this is the first resource table in the asset
// manager, then we are going to cache it so that we
// can quickly copy it out for others.
- LOGV("Creating shared resources for %s", ap.path.string());
+ ALOGV("Creating shared resources for %s", ap.path.string());
sharedRes = new ResTable();
sharedRes->add(ass, (void*)(i+1), false, idmap);
sharedRes = const_cast<AssetManager*>(this)->
}
}
} else {
- LOGV("loading resource table %s\n", ap.path.string());
+ ALOGV("loading resource table %s\n", ap.path.string());
Asset* ass = const_cast<AssetManager*>(this)->
openNonAssetInPathLocked("resources.arsc",
Asset::ACCESS_BUFFER,
mResources = rt = new ResTable();
updateResourceParamsLocked();
}
- LOGV("Installing resource asset %p in to table %p\n", ass, mResources);
+ ALOGV("Installing resource asset %p in to table %p\n", ass, mResources);
if (sharedRes != NULL) {
- LOGV("Copying existing resources for %s", ap.path.string());
+ ALOGV("Copying existing resources for %s", ap.path.string());
rt->add(sharedRes);
} else {
- LOGV("Parsing resources for %s", ap.path.string());
+ ALOGV("Parsing resources for %s", ap.path.string());
rt->add(ass, (void*)(i+1), !shared, idmap);
}
ass = const_cast<AssetManager*>(this)->
openAssetFromFileLocked(ap.idmap, Asset::ACCESS_BUFFER);
if (ass) {
- LOGV("loading idmap %s\n", ap.idmap.string());
+ ALOGV("loading idmap %s\n", ap.idmap.string());
} else {
LOGW("failed to load idmap %s\n", ap.idmap.string());
}
*/
ZipFileRO* AssetManager::getZipFileLocked(const asset_path& ap)
{
- LOGV("getZipFileLocked() in %p\n", this);
+ ALOGV("getZipFileLocked() in %p\n", this);
return mZipSet.getZip(ap.path);
}
if (method == ZipFileRO::kCompressStored) {
pAsset = Asset::createFromUncompressedMap(dataMap, mode);
- LOGV("Opened uncompressed entry %s in zip %s mode %d: %p", entryName.string(),
+ ALOGV("Opened uncompressed entry %s in zip %s mode %d: %p", entryName.string(),
dataMap->getFileName(), mode, pAsset);
} else {
pAsset = Asset::createFromCompressedMap(dataMap, method,
uncompressedLen, mode);
- LOGV("Opened compressed entry %s in zip %s mode %d: %p", entryName.string(),
+ ALOGV("Opened compressed entry %s in zip %s mode %d: %p", entryName.string(),
dataMap->getFileName(), mode, pAsset);
}
if (pAsset == NULL) {
i--;
const asset_path& ap = mAssetPaths.itemAt(i);
if (ap.type == kFileTypeRegular) {
- LOGV("Adding directory %s from zip %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from zip %s", dirName, ap.path.string());
scanAndMergeZipLocked(pMergedInfo, ap, kAssetsRoot, dirName);
} else {
- LOGV("Adding directory %s from dir %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from dir %s", dirName, ap.path.string());
scanAndMergeDirLocked(pMergedInfo, ap, kAssetsRoot, dirName);
}
}
if (which < mAssetPaths.size()) {
const asset_path& ap = mAssetPaths.itemAt(which);
if (ap.type == kFileTypeRegular) {
- LOGV("Adding directory %s from zip %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from zip %s", dirName, ap.path.string());
scanAndMergeZipLocked(pMergedInfo, ap, NULL, dirName);
} else {
- LOGV("Adding directory %s from dir %s", dirName, ap.path.string());
+ ALOGV("Adding directory %s from dir %s", dirName, ap.path.string());
scanAndMergeDirLocked(pMergedInfo, ap, NULL, dirName);
}
}
matchIdx = AssetDir::FileInfo::findEntry(pMergedInfo, match);
if (matchIdx > 0) {
- LOGV("Excluding '%s' [%s]\n",
+ ALOGV("Excluding '%s' [%s]\n",
pMergedInfo->itemAt(matchIdx).getFileName().string(),
pMergedInfo->itemAt(matchIdx).getSourceName().string());
pMergedInfo->removeAt(matchIdx);
struct dirent* entry;
FileType fileType;
- LOGV("Scanning dir '%s'\n", path.string());
+ ALOGV("Scanning dir '%s'\n", path.string());
dir = opendir(path.string());
if (dir == NULL)
{
//LOGI("Creating SharedZip %p %s\n", this, (const char*)mPath);
mZipFile = new ZipFileRO;
- LOGV("+++ opening zip '%s'\n", mPath.string());
+ ALOGV("+++ opening zip '%s'\n", mPath.string());
if (mZipFile->open(mPath.string()) != NO_ERROR) {
LOGD("failed to open Zip archive '%s'\n", mPath.string());
delete mZipFile;
Asset* AssetManager::SharedZip::getResourceTableAsset()
{
- LOGV("Getting from SharedZip %p resource asset %p\n", this, mResourceTableAsset);
+ ALOGV("Getting from SharedZip %p resource asset %p\n", this, mResourceTableAsset);
return mResourceTableAsset;
}
ResTable* AssetManager::SharedZip::getResourceTable()
{
- LOGV("Getting from SharedZip %p resource table %p\n", this, mResourceTable);
+ ALOGV("Getting from SharedZip %p resource table %p\n", this, mResourceTable);
return mResourceTable;
}
}
if (mZipFile != NULL) {
delete mZipFile;
- LOGV("Closed '%s'\n", mPath.string());
+ ALOGV("Closed '%s'\n", mPath.string());
}
}
mRandState[1] = (now >> 16) & 0xFFFF;
mRandState[2] = (now >> 32) & 0xFFFF;
#endif
- LOGV("initializing random seed using %lld", now);
+ ALOGV("initializing random seed using %lld", now);
}
void BlobCache::set(const void* key, size_t keySize, const void* value,
size_t valueSize) {
if (mMaxKeySize < keySize) {
- LOGV("set: not caching because the key is too large: %d (limit: %d)",
+ ALOGV("set: not caching because the key is too large: %d (limit: %d)",
keySize, mMaxKeySize);
return;
}
if (mMaxValueSize < valueSize) {
- LOGV("set: not caching because the value is too large: %d (limit: %d)",
+ ALOGV("set: not caching because the value is too large: %d (limit: %d)",
valueSize, mMaxValueSize);
return;
}
if (mMaxTotalSize < keySize + valueSize) {
- LOGV("set: not caching because the combined key/value size is too "
+ ALOGV("set: not caching because the combined key/value size is too "
"large: %d (limit: %d)", keySize + valueSize, mMaxTotalSize);
return;
}
clean();
continue;
} else {
- LOGV("set: not caching new key/value pair because the "
+ ALOGV("set: not caching new key/value pair because the "
"total cache size limit would be exceeded: %d "
"(limit: %d)",
keySize + valueSize, mMaxTotalSize);
}
mCacheEntries.add(CacheEntry(keyBlob, valueBlob));
mTotalSize = newTotalSize;
- LOGV("set: created new cache entry with %d byte key and %d byte value",
+ ALOGV("set: created new cache entry with %d byte key and %d byte value",
keySize, valueSize);
} else {
// Update the existing cache entry.
clean();
continue;
} else {
- LOGV("set: not caching new value because the total cache "
+ ALOGV("set: not caching new value because the total cache "
"size limit would be exceeded: %d (limit: %d)",
keySize + valueSize, mMaxTotalSize);
break;
}
mCacheEntries.editItemAt(index).setValue(valueBlob);
mTotalSize = newTotalSize;
- LOGV("set: updated existing cache entry with %d byte key and %d byte "
+ ALOGV("set: updated existing cache entry with %d byte key and %d byte "
"value", keySize, valueSize);
}
break;
size_t BlobCache::get(const void* key, size_t keySize, void* value,
size_t valueSize) {
if (mMaxKeySize < keySize) {
- LOGV("get: not searching because the key is too large: %d (limit %d)",
+ ALOGV("get: not searching because the key is too large: %d (limit %d)",
keySize, mMaxKeySize);
return 0;
}
CacheEntry dummyEntry(dummyKey, NULL);
ssize_t index = mCacheEntries.indexOf(dummyEntry);
if (index < 0) {
- LOGV("get: no cache entry found for key of size %d", keySize);
+ ALOGV("get: no cache entry found for key of size %d", keySize);
return 0;
}
sp<Blob> valueBlob(mCacheEntries[index].getValue());
size_t valueBlobSize = valueBlob->getSize();
if (valueBlobSize <= valueSize) {
- LOGV("get: copying %d bytes to caller's buffer", valueBlobSize);
+ ALOGV("get: copying %d bytes to caller's buffer", valueBlobSize);
memcpy(value, valueBlob->getData(), valueBlobSize);
} else {
- LOGV("get: caller's buffer is too small for value: %d (needs %d)",
+ ALOGV("get: caller's buffer is too small for value: %d (needs %d)",
valueSize, valueBlobSize);
}
return valueBlobSize;
#define LOG_TAG "CallStack"
#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#if HAVE_DLADDR
-#include <dlfcn.h>
-#endif
-
-#if HAVE_CXXABI
-#include <cxxabi.h>
-#endif
-
-#include <unwind.h>
#include <utils/Log.h>
#include <utils/Errors.h>
#include <utils/CallStack.h>
-#include <utils/threads.h>
-
+#include <corkscrew/backtrace.h>
/*****************************************************************************/
namespace android {
-
-typedef struct {
- size_t count;
- size_t ignore;
- const void** addrs;
-} stack_crawl_state_t;
-
-static
-_Unwind_Reason_Code trace_function(_Unwind_Context *context, void *arg)
-{
- stack_crawl_state_t* state = (stack_crawl_state_t*)arg;
- if (state->count) {
- void* ip = (void*)_Unwind_GetIP(context);
- if (ip) {
- if (state->ignore) {
- state->ignore--;
- } else {
- state->addrs[0] = ip;
- state->addrs++;
- state->count--;
- }
- }
- }
- return _URC_NO_REASON;
-}
-
-static
-int backtrace(const void** addrs, size_t ignore, size_t size)
-{
- stack_crawl_state_t state;
- state.count = size;
- state.ignore = ignore;
- state.addrs = addrs;
- _Unwind_Backtrace(trace_function, (void*)&state);
- return size - state.count;
-}
-
-/*****************************************************************************/
-
-static
-const char *lookup_symbol(const void* addr, void **offset, char* name, size_t bufSize)
-{
-#if HAVE_DLADDR
- Dl_info info;
- if (dladdr(addr, &info)) {
- *offset = info.dli_saddr;
- return info.dli_sname;
- }
-#endif
- return NULL;
+CallStack::CallStack() :
+ mCount(0) {
}
-static
-int32_t linux_gcc_demangler(const char *mangled_name, char *unmangled_name, size_t buffersize)
-{
- size_t out_len = 0;
-#if HAVE_CXXABI
- int status = 0;
- char *demangled = abi::__cxa_demangle(mangled_name, 0, &out_len, &status);
- if (status == 0) {
- // OK
- if (out_len < buffersize) memcpy(unmangled_name, demangled, out_len);
- else out_len = 0;
- free(demangled);
- } else {
- out_len = 0;
- }
-#endif
- return out_len;
-}
-
-/*****************************************************************************/
-
-class MapInfo {
- struct mapinfo {
- struct mapinfo *next;
- uint64_t start;
- uint64_t end;
- char name[];
- };
-
- const char *map_to_name(uint64_t pc, const char* def, uint64_t* start) {
- mapinfo* mi = getMapInfoList();
- while(mi) {
- if ((pc >= mi->start) && (pc < mi->end)) {
- if (start)
- *start = mi->start;
- return mi->name;
- }
- mi = mi->next;
- }
- if (start)
- *start = 0;
- return def;
- }
-
- mapinfo *parse_maps_line(char *line) {
- mapinfo *mi;
- int len = strlen(line);
- if (len < 1) return 0;
- line[--len] = 0;
- if (len < 50) return 0;
- if (line[20] != 'x') return 0;
- mi = (mapinfo*)malloc(sizeof(mapinfo) + (len - 47));
- if (mi == 0) return 0;
- mi->start = strtoull(line, 0, 16);
- mi->end = strtoull(line + 9, 0, 16);
- mi->next = 0;
- strcpy(mi->name, line + 49);
- return mi;
- }
-
- mapinfo* getMapInfoList() {
- Mutex::Autolock _l(mLock);
- if (milist == 0) {
- char data[1024];
- FILE *fp;
- sprintf(data, "/proc/%d/maps", getpid());
- fp = fopen(data, "r");
- if (fp) {
- while(fgets(data, 1024, fp)) {
- mapinfo *mi = parse_maps_line(data);
- if(mi) {
- mi->next = milist;
- milist = mi;
- }
- }
- fclose(fp);
- }
- }
- return milist;
- }
- mapinfo* milist;
- Mutex mLock;
- static MapInfo sMapInfo;
-
-public:
- MapInfo()
- : milist(0) {
- }
-
- ~MapInfo() {
- while (milist) {
- mapinfo *next = milist->next;
- free(milist);
- milist = next;
- }
- }
-
- static const char *mapAddressToName(const void* pc, const char* def,
- void const** start)
- {
- uint64_t s;
- char const* name = sMapInfo.map_to_name(uint64_t(uintptr_t(pc)), def, &s);
- if (start) {
- *start = (void*)s;
- }
- return name;
- }
-
-};
-
-/*****************************************************************************/
-
-MapInfo MapInfo::sMapInfo;
-
-/*****************************************************************************/
-
-CallStack::CallStack()
- : mCount(0)
-{
-}
-
-CallStack::CallStack(const CallStack& rhs)
- : mCount(rhs.mCount)
-{
+CallStack::CallStack(const CallStack& rhs) :
+ mCount(rhs.mCount) {
if (mCount) {
- memcpy(mStack, rhs.mStack, mCount*sizeof(void*));
+ memcpy(mStack, rhs.mStack, mCount * sizeof(backtrace_frame_t));
}
}
-CallStack::~CallStack()
-{
+CallStack::~CallStack() {
}
-CallStack& CallStack::operator = (const CallStack& rhs)
-{
+CallStack& CallStack::operator = (const CallStack& rhs) {
mCount = rhs.mCount;
if (mCount) {
- memcpy(mStack, rhs.mStack, mCount*sizeof(void*));
+ memcpy(mStack, rhs.mStack, mCount * sizeof(backtrace_frame_t));
}
return *this;
}
bool CallStack::operator == (const CallStack& rhs) const {
if (mCount != rhs.mCount)
return false;
- return !mCount || (memcmp(mStack, rhs.mStack, mCount*sizeof(void*)) == 0);
+ return !mCount || memcmp(mStack, rhs.mStack, mCount * sizeof(backtrace_frame_t)) == 0;
}
bool CallStack::operator != (const CallStack& rhs) const {
bool CallStack::operator < (const CallStack& rhs) const {
if (mCount != rhs.mCount)
return mCount < rhs.mCount;
- return memcmp(mStack, rhs.mStack, mCount*sizeof(void*)) < 0;
+ return memcmp(mStack, rhs.mStack, mCount * sizeof(backtrace_frame_t)) < 0;
}
bool CallStack::operator >= (const CallStack& rhs) const {
bool CallStack::operator > (const CallStack& rhs) const {
if (mCount != rhs.mCount)
return mCount > rhs.mCount;
- return memcmp(mStack, rhs.mStack, mCount*sizeof(void*)) > 0;
+ return memcmp(mStack, rhs.mStack, mCount * sizeof(backtrace_frame_t)) > 0;
}
bool CallStack::operator <= (const CallStack& rhs) const {
const void* CallStack::operator [] (int index) const {
if (index >= int(mCount))
return 0;
- return mStack[index];
+ return reinterpret_cast<const void*>(mStack[index].absolute_pc);
}
-
-void CallStack::clear()
-{
+void CallStack::clear() {
mCount = 0;
}
-void CallStack::update(int32_t ignoreDepth, int32_t maxDepth)
-{
- if (maxDepth > MAX_DEPTH)
+void CallStack::update(int32_t ignoreDepth, int32_t maxDepth) {
+ if (maxDepth > MAX_DEPTH) {
maxDepth = MAX_DEPTH;
- mCount = backtrace(mStack, ignoreDepth, maxDepth);
-}
-
-// Return the stack frame name on the designated level
-String8 CallStack::toStringSingleLevel(const char* prefix, int32_t level) const
-{
- String8 res;
- char namebuf[1024];
- char tmp[256];
- char tmp1[32];
- char tmp2[32];
- void *offs;
-
- const void* ip = mStack[level];
- if (!ip) return res;
-
- if (prefix) res.append(prefix);
- snprintf(tmp1, 32, "#%02d ", level);
- res.append(tmp1);
-
- const char* name = lookup_symbol(ip, &offs, namebuf, sizeof(namebuf));
- if (name) {
- if (linux_gcc_demangler(name, tmp, 256) != 0)
- name = tmp;
- snprintf(tmp1, 32, "0x%p: <", ip);
- snprintf(tmp2, 32, ">+0x%p", offs);
- res.append(tmp1);
- res.append(name);
- res.append(tmp2);
- } else {
- void const* start = 0;
- name = MapInfo::mapAddressToName(ip, "<unknown>", &start);
- snprintf(tmp, 256, "pc %08lx %s",
- long(uintptr_t(ip)-uintptr_t(start)), name);
- res.append(tmp);
}
- res.append("\n");
-
- return res;
-}
-
-// Dump a stack trace to the log
-void CallStack::dump(const char* prefix) const
-{
- /*
- * Sending a single long log may be truncated since the stack levels can
- * get very deep. So we request function names of each frame individually.
- */
- for (int i=0; i<int(mCount); i++) {
- LOGD("%s", toStringSingleLevel(prefix, i).string());
+ ssize_t count = unwind_backtrace(mStack, ignoreDepth + 1, maxDepth);
+ mCount = count > 0 ? count : 0;
+}
+
+void CallStack::dump(const char* prefix) const {
+ backtrace_symbol_t symbols[mCount];
+
+ get_backtrace_symbols(mStack, mCount, symbols);
+ for (size_t i = 0; i < mCount; i++) {
+ const backtrace_frame_t& frame = mStack[i];
+ const backtrace_symbol_t& symbol = symbols[i];
+ const char* mapName = symbol.map_info ? symbol.map_info->name : "<unknown>";
+ const char* symbolName = symbol.demangled_name ? symbol.demangled_name : symbol.name;
+ if (symbolName) {
+ LOGD("%s#%02d pc %08x %s (%s)\n", prefix,
+ int(i), uint32_t(symbol.relative_pc), mapName, symbolName);
+ } else {
+ LOGD("%s#%02d pc %08x %s\n", prefix,
+ int(i), uint32_t(symbol.relative_pc), mapName);
+ }
}
-}
-
-// Return a string (possibly very long) containing the complete stack trace
-String8 CallStack::toString(const char* prefix) const
-{
- String8 res;
-
- for (int i=0; i<int(mCount); i++) {
- res.append(toStringSingleLevel(prefix, i).string());
+ free_backtrace_symbols(symbols, mCount);
+}
+
+String8 CallStack::toString(const char* prefix) const {
+ String8 str;
+ backtrace_symbol_t symbols[mCount];
+
+ get_backtrace_symbols(mStack, mCount, symbols);
+ for (size_t i = 0; i < mCount; i++) {
+ const backtrace_frame_t& frame = mStack[i];
+ const backtrace_symbol_t& symbol = symbols[i];
+ const char* mapName = symbol.map_info ? symbol.map_info->name : "<unknown>";
+ const char* symbolName = symbol.demangled_name ? symbol.demangled_name : symbol.name;
+ if (symbolName) {
+ str.appendFormat("%s#%02d pc %08x %s (%s)\n", prefix,
+ int(i), uint32_t(symbol.relative_pc), mapName, symbolName);
+ } else {
+ str.appendFormat("%s#%02d pc %08x %s\n", prefix,
+ int(i), uint32_t(symbol.relative_pc), mapName);
+ }
}
-
- return res;
+ free_backtrace_symbols(symbols, mCount);
+ return str;
}
-/*****************************************************************************/
-
}; // namespace android
assert(mBasePtr != NULL);
- LOGV("MAP: base %p/%d data %p/%d\n",
+ ALOGV("MAP: base %p/%d data %p/%d\n",
mBasePtr, (int) mBaseLength, mDataPtr, (int) mDataLength);
return true;
// destroy the object now.
delete impl->mBase;
} else {
- // LOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase);
+ // ALOGV("Freeing refs %p of old RefBase %p\n", this, impl->mBase);
delete impl;
}
} else {
static void printToLogFunc(void* cookie, const char* txt)
{
- LOGV("%s", txt);
+ ALOGV("%s", txt);
}
// Standard C isspace() is only required to look at the low byte of its input, so
const bool notDeviceEndian = htods(0xf0) != 0xf0;
LOAD_TABLE_NOISY(
- LOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%p, asset=%p, copy=%d "
+ ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%p, asset=%p, copy=%d "
"idmap=%p\n", data, size, cookie, asset, copyData, idmap));
if (copyData || notDeviceEndian) {
resID, &overlayResID);
if (retval == NO_ERROR && overlayResID != 0x0) {
// for this loop iteration, this is the type and entry we really want
- LOGV("resource map 0x%08x -> 0x%08x\n", resID, overlayResID);
+ ALOGV("resource map 0x%08x -> 0x%08x\n", resID, overlayResID);
T = Res_GETTYPE(overlayResID);
E = Res_GETENTRY(overlayResID);
} else {
resID, &overlayResID);
if (retval == NO_ERROR && overlayResID != 0x0) {
// for this loop iteration, this is the type and entry we really want
- LOGV("resource map 0x%08x -> 0x%08x\n", resID, overlayResID);
+ ALOGV("resource map 0x%08x -> 0x%08x\n", resID, overlayResID);
T = Res_GETTYPE(overlayResID);
E = Res_GETENTRY(overlayResID);
} else {
const ResTable_type* type;
const ResTable_entry* entry;
const Type* typeClass;
- LOGV("Getting entry pkg=%p, t=%d, e=%d\n", package, T, E);
+ ALOGV("Getting entry pkg=%p, t=%d, e=%d\n", package, T, E);
ssize_t offset = getEntry(package, T, E, &mParams, &type, &entry, &typeClass);
- LOGV("Resulting offset=%d\n", offset);
+ ALOGV("Resulting offset=%d\n", offset);
if (offset <= 0) {
// No {entry, appropriate config} pair found in package. If this
// package is an overlay package (ip != 0), this simply means the
void ResTable::getLocales(Vector<String8>* locales) const
{
Vector<ResTable_config> configs;
- LOGV("calling getConfigurations");
+ ALOGV("calling getConfigurations");
getConfigurations(&configs);
- LOGV("called getConfigurations size=%d", (int)configs.size());
+ ALOGV("called getConfigurations size=%d", (int)configs.size());
const size_t I = configs.size();
for (size_t i=0; i<I; i++) {
char locale[6];
const ResTable_type** outType, const ResTable_entry** outEntry,
const Type** outTypeClass) const
{
- LOGV("Getting entry from package %p\n", package);
+ ALOGV("Getting entry from package %p\n", package);
const ResTable_package* const pkg = package->package;
const Type* allTypes = package->getType(typeIndex);
- LOGV("allTypes=%p\n", allTypes);
+ ALOGV("allTypes=%p\n", allTypes);
if (allTypes == NULL) {
- LOGV("Skipping entry type index 0x%02x because type is NULL!\n", typeIndex);
+ ALOGV("Skipping entry type index 0x%02x because type is NULL!\n", typeIndex);
return 0;
}
}
void StreamingZipInflater::initInflateState() {
- LOGV("Initializing inflate state");
+ ALOGV("Initializing inflate state");
memset(&mInflateState, 0, sizeof(mInflateState));
mInflateState.zalloc = Z_NULL;
mInflateState.avail_out = mOutBufSize;
/*
- LOGV("Inflating to outbuf: avail_in=%u avail_out=%u next_in=%p next_out=%p",
+ ALOGV("Inflating to outbuf: avail_in=%u avail_out=%u next_in=%p next_out=%p",
mInflateState.avail_in, mInflateState.avail_out,
mInflateState.next_in, mInflateState.next_out);
*/
int result = Z_OK;
if (mStreamNeedsInit) {
- LOGV("Initializing zlib to inflate");
+ ALOGV("Initializing zlib to inflate");
result = inflateInit2(&mInflateState, -MAX_WBITS);
mStreamNeedsInit = false;
}
size_t toRead = min_of(mInBufSize, mInTotalSize - mInNextChunkOffset);
if (toRead > 0) {
ssize_t didRead = ::read(mFd, mInBuf, toRead);
- //LOGV("Reading input chunk, size %08x didread %08x", toRead, didRead);
+ //ALOGV("Reading input chunk, size %08x didread %08x", toRead, didRead);
if (didRead < 0) {
// TODO: error
LOGE("Error reading asset data");
delete pDetails;
- LOG(LOG_VERBOSE, "thread", "thread exiting\n");
+ ALOG(LOG_VERBOSE, "thread", "thread exiting\n");
return (unsigned int) result;
}
if (hThread == NULL)
#endif
{
- LOG(LOG_WARN, "thread", "WARNING: thread create failed\n");
+ ALOG(LOG_WARN, "thread", "WARNING: thread create failed\n");
return false;
}
void Mutex::unlock()
{
if (!ReleaseMutex((HANDLE) mState))
- LOG(LOG_WARN, "thread", "WARNING: bad result from unlocking mutex\n");
+ ALOG(LOG_WARN, "thread", "WARNING: bad result from unlocking mutex\n");
}
status_t Mutex::tryLock()
dwWaitResult = WaitForSingleObject((HANDLE) mState, 0);
if (dwWaitResult != WAIT_OBJECT_0 && dwWaitResult != WAIT_TIMEOUT)
- LOG(LOG_WARN, "thread", "WARNING: bad result from try-locking mutex\n");
+ ALOG(LOG_WARN, "thread", "WARNING: bad result from try-locking mutex\n");
return (dwWaitResult == WAIT_OBJECT_0) ? 0 : -1;
}
/*static*/ void DurationTimer::addToTimeval(struct timeval* ptv, long usec)
{
if (usec < 0) {
- LOG(LOG_WARN, "", "Negative values not supported in addToTimeval\n");
+ ALOG(LOG_WARN, "", "Negative values not supported in addToTimeval\n");
return;
}
void* VectorImpl::_grow(size_t where, size_t amount)
{
-// LOGV("_grow(this=%p, where=%d, amount=%d) count=%d, capacity=%d",
+// ALOGV("_grow(this=%p, where=%d, amount=%d) count=%d, capacity=%d",
// this, (int)where, (int)amount, (int)mCount, (int)capacity());
LOG_ASSERT(where <= mCount,
const size_t new_size = mCount + amount;
if (capacity() < new_size) {
const size_t new_capacity = max(kMinVectorCapacity, ((new_size*3)+1)/2);
-// LOGV("grow vector %p, new_capacity=%d", this, (int)new_capacity);
+// ALOGV("grow vector %p, new_capacity=%d", this, (int)new_capacity);
if ((mStorage) &&
(mCount==where) &&
(mFlags & HAS_TRIVIAL_COPY) &&
if (!mStorage)
return;
-// LOGV("_shrink(this=%p, where=%d, amount=%d) count=%d, capacity=%d",
+// ALOGV("_shrink(this=%p, where=%d, amount=%d) count=%d, capacity=%d",
// this, (int)where, (int)amount, (int)mCount, (int)capacity());
LOG_ASSERT(where + amount <= mCount,
const size_t new_size = mCount - amount;
if (new_size*3 < capacity()) {
const size_t new_capacity = max(kMinVectorCapacity, new_size*2);
-// LOGV("shrink vector %p, new_capacity=%d", this, (int)new_capacity);
+// ALOGV("shrink vector %p, new_capacity=%d", this, (int)new_capacity);
if ((where == new_size) &&
(mFlags & HAS_TRIVIAL_COPY) &&
(mFlags & HAS_TRIVIAL_DTOR))
free(scanBuf);
return false;
} else if (header != kLFHSignature) {
- LOGV("Not a Zip archive (found 0x%08x)\n", header);
+ ALOGV("Not a Zip archive (found 0x%08x)\n", header);
free(scanBuf);
return false;
}
int i;
for (i = readAmount - kEOCDLen; i >= 0; i--) {
if (scanBuf[i] == 0x50 && get4LE(&scanBuf[i]) == kEOCDSignature) {
- LOGV("+++ Found EOCD at buf+%d\n", i);
+ ALOGV("+++ Found EOCD at buf+%d\n", i);
break;
}
}
return false;
}
- LOGV("+++ numEntries=%d dirSize=%d dirOffset=%d\n",
+ ALOGV("+++ numEntries=%d dirSize=%d dirOffset=%d\n",
numEntries, dirSize, dirOffset);
mDirectoryMap = new FileMap();
goto bail;
}
}
- LOGV("+++ zip good scan %d entries\n", numEntries);
+ ALOGV("+++ zip good scan %d entries\n", numEntries);
result = true;
bail:
if (zstream.avail_in == 0) {
getSize = (compRemaining > kReadBufSize) ?
kReadBufSize : compRemaining;
- LOGV("+++ reading %ld bytes (%ld left)\n",
+ ALOGV("+++ reading %ld bytes (%ld left)\n",
getSize, compRemaining);
int cc = read(fd, readBuf, getSize);
if (zstream.avail_in == 0) {
getSize = (compRemaining > kReadBufSize) ?
kReadBufSize : compRemaining;
- LOGV("+++ reading %ld bytes (%ld left)\n",
+ ALOGV("+++ reading %ld bytes (%ld left)\n",
getSize, compRemaining);
int cc = fread(readBuf, 1, getSize, fp);