summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Amith Yamasani <yamasani@google.com> 2016-08-29 17:42:37 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-08-29 17:42:40 +0000
commit81f876e7950a37f55ea5dc55a42d3950d6134a03 (patch)
tree9be7e358b937711469e9054aec4c0c89f1c908df
parent23784fd6d9845aac096a6df74b446e813128425f (diff)
parent0903ec501703b43af821b1f8e8bcf455ca719d35 (diff)
Merge "Add logging to CursorWindow JNI code to track #31046363" into nyc-mr1-dev
-rw-r--r--core/jni/android_database_CursorWindow.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp
index bb09d001037d..e96613b7d45b 100644
--- a/core/jni/android_database_CursorWindow.cpp
+++ b/core/jni/android_database_CursorWindow.cpp
@@ -16,6 +16,7 @@
#undef LOG_TAG
#define LOG_TAG "CursorWindow"
+#define LOG_NDEBUG 0
#include <inttypes.h>
#include <jni.h>
@@ -30,6 +31,11 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#undef LOG_NDEBUG
+#define LOG_NDEBUG 1
#include <androidfw/CursorWindow.h>
#include "android_os_Parcel.h"
@@ -61,6 +67,22 @@ static void throwUnknownTypeException(JNIEnv * env, jint type) {
jniThrowException(env, "java/lang/IllegalStateException", msg.string());
}
+static int getFdCount() {
+ char fdpath[PATH_MAX];
+ int count = 0;
+ snprintf(fdpath, PATH_MAX, "/proc/%d/fd", getpid());
+ DIR *dir = opendir(fdpath);
+ if (dir != NULL) {
+ struct dirent *dirent;
+ while ((dirent = readdir(dir))) {
+ count++;
+ }
+ count -= 2; // discount "." and ".."
+ closedir(dir);
+ }
+ return count;
+}
+
static jlong nativeCreate(JNIEnv* env, jclass clazz, jstring nameObj, jint cursorWindowSize) {
String8 name;
const char* nameStr = env->GetStringUTFChars(nameObj, NULL);
@@ -85,7 +107,8 @@ static jlong nativeCreateFromParcel(JNIEnv* env, jclass clazz, jobject parcelObj
CursorWindow* window;
status_t status = CursorWindow::createFromParcel(parcel, &window);
if (status || !window) {
- ALOGE("Could not create CursorWindow from Parcel due to error %d.", status);
+ ALOGE("Could not create CursorWindow from Parcel due to error %d, process fd count=%d",
+ status, getFdCount());
return 0;
}