summaryrefslogtreecommitdiff
path: root/xf86drm.c
diff options
context:
space:
mode:
authorMun, Gwan-gyeong <kk.moon@samsung.com>2017-04-11 13:22:06 +0900
committerMun, Gwan-gyeong <kk.moon@samsung.com>2017-04-11 13:22:06 +0900
commit7309821c220a6f845783923da1d9c7dcd0667a5f (patch)
treeaf0506eb8ce18f4afbf1667a5baacdb515f7400f /xf86drm.c
parentd71cbccb4890bd6c2cc71855ee655956ee204e56 (diff)
downloadlibdrm-sandbox/elongbug/test.tar.gz
libdrm-sandbox/elongbug/test.tar.bz2
libdrm-sandbox/elongbug/test.zip
Test: check leakage of vc4 gem memory.sandbox/elongbug/test
Change-Id: I2ef8bdb79fd08cf4e4542f9d202ad955185a0872
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/xf86drm.c b/xf86drm.c
index 88f86ed5..5d5effd2 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -182,14 +182,74 @@ void drmFree(void *pt)
/**
* Call ioctl, restarting if it is interupted
*/
+#include <execinfo.h>
+static void print_gnu_backtrace(void)
+{
+#if 0
+ void* frame_addrs[16];
+ char** frame_strings;
+ size_t backtrace_size;
+ int i;
+ backtrace_size = backtrace(frame_addrs, 16);
+ frame_strings = backtrace_symbols(frame_addrs, backtrace_size);
+
+ for (i = 0; i < backtrace_size; ++i)
+ {
+ printf("%d: [0x%x] %s\n", i, frame_addrs[i], frame_strings[i]);
+ }
+ free(frame_strings);
+#endif
+}
+
int
drmIoctl(int fd, unsigned long request, void *arg)
{
int ret;
+#if 0
+ if (request == DRM_IOCTL_GEM_CLOSE) {
+ struct drm_gem_close *args = arg;
+ fprintf(stderr, "drm_device_fd: %d, gem_close handle = %d\n", fd, args->handle);
+ print_gnu_backtrace();
+ }
+#endif
do {
ret = ioctl(fd, request, arg);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+
+#if 0
+ if (ret == -1) {
+ char buf[1024];
+ strerror_r(errno, buf, sizeof(buf));
+ fprintf(stderr, "drmIoctl error: %d(%s)\n", errno, buf);
+ }
+#endif
+
+#if 0
+struct drm_vc4_create_bo {
+ __u32 size;
+ __u32 flags;
+ /** Returned GEM handle for the BO. */
+ __u32 handle;
+ __u32 pad;
+};
+#define DRM_VC4_CREATE_BO 0x03
+#define DRM_IOCTL_VC4_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
+ if ( request == DRM_IOCTL_PRIME_FD_TO_HANDLE ) {
+ struct drm_prime_handle *args = arg;
+ fprintf(stderr, "drm_device_fd: %d, fdtohandle handle = %d\n", fd, args->handle);
+ print_gnu_backtrace();
+ } else if (request == DRM_IOCTL_GEM_OPEN ) {
+ struct drm_gem_open *args = arg;
+ fprintf(stderr, "drm_device_fd: %d, gemopen handle = %d\n", fd, args->handle);
+ print_gnu_backtrace();
+ } else if (request == DRM_IOCTL_VC4_CREATE_BO) {
+ struct drm_vc4_create_bo *args = arg;
+ fprintf(stderr, "drm_device_fd: %d, gemcreate handle = %d\n", fd, args->handle);
+ print_gnu_backtrace();
+ }
+ fflush(stderr);
+#endif
return ret;
}