Add getHwBinderKernelReferences
Add a wrapper for the new BINDER_GET_NODE_DEBUG_INFO ioctl for use by
libmemunreachable.
Test: memunreachable_binder_test
Bug: 28275695
Change-Id: I66337691d4e00a81159a8ca4856c8f5c5cf493ee
Merged-In: I66337691d4e00a81159a8ca4856c8f5c5cf493ee
(cherry picked from commit 85966ba503e89311ad92c1047b6067020f347488)
diff --git a/include/hwbinder/Debug.h b/include/hwbinder/Debug.h
index 2848d5d..03127cb 100644
--- a/include/hwbinder/Debug.h
+++ b/include/hwbinder/Debug.h
@@ -18,15 +18,14 @@
#define ANDROID_HARDWARE_BINDER_DEBUG_H
#include <stdint.h>
+#include <sys/cdefs.h>
#include <sys/types.h>
namespace android {
namespace hardware {
// ---------------------------------------------------------------------------
-#ifdef __cplusplus
-extern "C" {
-#endif
+__BEGIN_DECLS
const char* stringForIndent(int32_t indentLevel);
@@ -40,9 +39,9 @@
size_t alignment=0, bool cArrayStyle=false,
debugPrintFunc func = 0, void* cookie = 0);
-#ifdef __cplusplus
-}
-#endif
+ssize_t getHWBinderKernelReferences(size_t count, uintptr_t* buf);
+
+__END_DECLS
// ---------------------------------------------------------------------------
}; // namespace hardware
diff --git a/include/hwbinder/ProcessState.h b/include/hwbinder/ProcessState.h
index 2ed1304..5441b75 100644
--- a/include/hwbinder/ProcessState.h
+++ b/include/hwbinder/ProcessState.h
@@ -36,6 +36,7 @@
{
public:
static sp<ProcessState> self();
+ static sp<ProcessState> selfOrNull();
void setContextObject(const sp<IBinder>& object);
sp<IBinder> getContextObject(const sp<IBinder>& caller);
@@ -65,6 +66,8 @@
status_t setThreadPoolConfiguration(size_t maxThreads, bool callerJoinsPool);
void giveThreadPoolName();
+ ssize_t getKernelReferences(size_t count, uintptr_t* buf);
+
private:
friend class IPCThreadState;
diff --git a/include/hwbinder/binder_kernel.h b/include/hwbinder/binder_kernel.h
index c288ba2..2adbf23 100644
--- a/include/hwbinder/binder_kernel.h
+++ b/include/hwbinder/binder_kernel.h
@@ -111,5 +111,13 @@
FLAT_BINDER_FLAG_SCHEDPOLICY_SHIFT = 9,
};
+struct binder_node_debug_info {
+ binder_uintptr_t ptr;
+ binder_uintptr_t cookie;
+ __u32 has_strong_ref;
+ __u32 has_weak_ref;
+};
+
+#define BINDER_GET_NODE_DEBUG_INFO _IOWR('b', 11, struct binder_node_debug_info)
#endif // ANDROID_HARDWARE_BINDER_KERNEL_H