Browse Source

[Pal/Linux] Remove unused TRACE_HEAP_LEAK macro and code

Dmitrii Kuvaiskii 4 years ago
parent
commit
098e2edf44
3 changed files with 0 additions and 116 deletions
  1. 0 46
      Pal/src/host/Linux/db_object.c
  2. 0 67
      Pal/src/host/Linux/pal_host.h
  3. 0 3
      Pal/src/pal_defs.h

+ 0 - 46
Pal/src/host/Linux/db_object.c

@@ -262,49 +262,3 @@ int _DkObjectsWaitAny(int count, PAL_HANDLE* handleArray, int64_t timeout_us,
     *polled = polled_hdl;
     return polled_hdl ? 0 : -PAL_ERROR_TRYAGAIN;
 }
-
-#if TRACE_HEAP_LEAK == 1
-
-PAL_HANDLE heap_alloc_head;
-PAL_LOCK   heap_alloc_trace_lock = LOCK_INIT;
-
-HEAP_ALLOC_RECORD * collect_heap_alloc_records (PAL_NUM max_records)
-{
-    HEAP_ALLOC_RECORD * records =
-            malloc(sizeof(HEAP_ALLOC_RECORD) * max_records);
-
-    if (!records)
-        return NULL;
-
-    memset(records, 0, sizeof(HEAP_ALLOC_RECORD) * max_records);
-
-    _DkInternalLock(&heap_alloc_trace_lock);
-
-    PAL_HANDLE ptr = heap_alloc_head;
-    int nrecords = 0, i;
-
-    for (; ptr ; ptr = ptr->hdr.heap_trace.next) {
-        assert(!ptr->hdr.heap_trace.next ||
-               ptr->hdr.heap_trace.next->hdr.heap_trace.pprev ==
-               &ptr->hdr.heap_trace.next);
-
-        for (i = 0 ; i < nrecords ; i++)
-            if (ptr->hdr.heap_trace.caller == records[i].caller) {
-                records[i].count++;
-                break;
-            }
-
-        if (i == nrecords) {
-            if (nrecords == max_records) break;
-            records[nrecords].caller = ptr->hdr.heap_trace.caller;
-            records[nrecords].count = 1;
-            nrecords++;
-        }
-    }
-
-    _DkInternalUnlock(&heap_alloc_trace_lock);
-
-    return records;
-}
-
-#endif /* TRACE_HEAP_LEAK == 0 */

+ 0 - 67
Pal/src/host/Linux/pal_host.h

@@ -57,14 +57,6 @@ int _DkMutexUnlock(struct mutex_handle* mut);
 
 typedef struct {
     PAL_HDR hdr;
-#if TRACE_HEAP_LEAK == 1
-    struct heap_trace_info {
-        /* maintaining a list of handles */
-        struct pal_handle ** pprev, * next;
-        /* trace the PC where the handle is created */
-        PAL_PTR caller;
-    } heap_trace;
-#endif
 } PAL_RESERVED_HDR;
 
 typedef struct pal_handle
@@ -194,63 +186,4 @@ extern void __check_pending_event (void);
 #define LEAVE_PAL_CALL_RETURN(retval) \
     do { __check_pending_event(); return (retval); } while (0)
 
-#if TRACE_HEAP_LEAK == 1
-
-/* The following code adds a piece of information
-   in each handle to trace heap leakage. */
-
-extern PAL_HANDLE heap_alloc_head;
-extern PAL_LOCK   heap_alloc_trace_lock;
-
-/* call the following function in GDB */
-typedef struct {
-    PAL_PTR caller;
-    PAL_NUM count;
-} HEAP_ALLOC_RECORD;
-
-extern HEAP_ALLOC_RECORD * collect_heap_alloc_records (PAL_NUM max_records);
-
-static inline
-void __trace_heap (PAL_HANDLE handle, struct pal_frame * frame)
-{
-    _DkInternalLock(&heap_alloc_trace_lock);
-
-    handle->hdr.heap_trace.caller = ((PAL_PTR *)frame->arch.rbp)[1];
-
-    /* Add the handle to the list */
-    if (heap_alloc_head)
-        heap_alloc_head->hdr.heap_trace.pprev
-                                    = &handle->hdr.heap_trace.next;
-    handle->hdr.heap_trace.next     = heap_alloc_head;
-    handle->hdr.heap_trace.pprev    = &heap_alloc_head;
-    heap_alloc_head                 = handle;
-
-    _DkInternalUnlock(&heap_alloc_trace_lock);
-}
-
-#define TRACE_HEAP(handle) \
-    do { if (handle) __trace_heap(handle, &frame); } while (0)
-
-static inline
-void __untrace_heap (PAL_HANDLE handle)
-{
-    _DkInternalLock(&heap_alloc_trace_lock);
-
-    /* remove the handle from the list */
-    *handle->hdr.heap_trace.pprev = handle->hdr.heap_trace.next;
-    if (handle->hdr.heap_trace.next)
-        handle->hdr.heap_trace.next->hdr.heap_trace.pprev
-            = handle->hdr.heap_trace.pprev;
-
-    handle->hdr.heap_trace.pprev = NULL;
-    handle->hdr.heap_trace.next  = NULL;
-
-    _DkInternalUnlock(&heap_alloc_trace_lock);
-}
-
-#define UNTRACE_HEAP(handle) \
-    do { if (handle) __untrace_heap(handle); } while (0)
-
-#endif /* TRACE_HEAP_LEAK == 1 */
-
 #endif /* PAL_HOST_H */

+ 0 - 3
Pal/src/pal_defs.h

@@ -14,7 +14,4 @@
 /* allow binding sockets to ANY addresses (e.g., 0.0.0.0:0) */
 #define ALLOW_BIND_ANY 1
 
-/* turn on the following option to trace heap memory leak */
-#define TRACE_HEAP_LEAK 0
-
 #endif /* PAL_DEFS_H */