VirtualBox

Changeset 7032 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
Feb 20, 2008 12:26:22 PM (17 years ago)
Author:
vboxsync
Message:

Ring-0 semaphore debugging aid (linux).

Location:
trunk/src/VBox/Runtime/r0drv/linux
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/semevent-r0drv-linux.c

    r5999 r7032  
    2424 * terms and conditions of either the GPL or the CDDL or both.
    2525 */
    26 
    2726
    2827
     
    139138    int     rc       = VINF_SUCCESS;
    140139    long    lTimeout = cMillies == RT_INDEFINITE_WAIT ? MAX_SCHEDULE_TIMEOUT : msecs_to_jiffies(cMillies);
     140#ifdef IPRT_DEBUG_SEMS
     141    snprintf(current->comm, TASK_COMM_LEN, "e%lx", IPRT_DEBUG_SEMS_ADDRESS(pEventInt));
     142#endif
    141143    for (;;)
    142144    {
     
    174176
    175177    finish_wait(&pEventInt->Head, &Wait);
     178#ifdef IPRT_DEBUG_SEMS
     179    snprintf(current->comm, TASK_COMM_LEN, "e%lx:%d", IPRT_DEBUG_SEMS_ADDRESS(pEventInt), rc);
     180#endif
    176181    return rc;
    177182}
  • trunk/src/VBox/Runtime/r0drv/linux/semeventmulti-r0drv-linux.c

    r5999 r7032  
    2424 * terms and conditions of either the GPL or the CDDL or both.
    2525 */
    26 
    2726
    2827
     
    150149    int     rc       = VINF_SUCCESS;
    151150    long    lTimeout = cMillies == RT_INDEFINITE_WAIT ? MAX_SCHEDULE_TIMEOUT : msecs_to_jiffies(cMillies);
     151#ifdef IPRT_DEBUG_SEMS
     152    snprintf(current->comm, TASK_COMM_LEN, "E%lx", IPRT_DEBUG_SEMS_ADDRESS(pThis));
     153#endif
    152154    for (;;)
    153155    {
     
    185187
    186188    finish_wait(&pThis->Head, &Wait);
     189#ifdef IPRT_DEBUG_SEMS
     190    snprintf(current->comm, TASK_COMM_LEN, "E%lx:%d", IPRT_DEBUG_SEMS_ADDRESS(pThis), rc);
     191#endif
    187192    return rc;
    188193}
  • trunk/src/VBox/Runtime/r0drv/linux/semfastmutex-r0drv-linux.c

    r5999 r7032  
    3636#include <iprt/asm.h>
    3737#include <iprt/err.h>
     38#ifdef IPRT_DEBUG_SEMS
     39# include <iprt/thread.h>
     40#endif
    3841
    3942#include "internal/magics.h"
     
    5255    /** the linux semaphore. */
    5356    struct semaphore    Semaphore;
     57#ifdef IPRT_DEBUG_SEMS
     58    /** For check. */
     59    RTNATIVETHREAD volatile Owner;
     60#endif
    5461} RTSEMFASTMUTEXINTERNAL, *PRTSEMFASTMUTEXINTERNAL;
    5562
     
    7077    pFastInt->u32Magic = RTSEMFASTMUTEX_MAGIC;
    7178    sema_init(&pFastInt->Semaphore, 1);
     79#ifdef IPRT_DEBUG_SEMS
     80    pFastInt->Owner = NIL_RTNATIVETHREAD;
     81#endif
    7282    *pMutexSem = pFastInt;
    7383    return VINF_SUCCESS;
     
    108118    }
    109119
     120#ifdef IPRT_DEBUG_SEMS
     121    snprintf(current->comm, TASK_COMM_LEN, "d%lx", IPRT_DEBUG_SEMS_ADDRESS(pFastInt));
     122#endif
    110123    down(&pFastInt->Semaphore);
     124#ifdef IPRT_DEBUG_SEMS
     125    snprintf(current->comm, TASK_COMM_LEN, "o%lx", IPRT_DEBUG_SEMS_ADDRESS(pFastInt));
     126    AssertRelease(pFastInt->Owner == NIL_RTNATIVETHREAD);
     127    ASMAtomicUoWriteSize(&pFastInt->Owner, RTThreadNativeSelf());
     128#endif
    111129    return VINF_SUCCESS;
    112130}
     
    126144    }
    127145
     146#ifdef IPRT_DEBUG_SEMS
     147    AssertRelease(pFastInt->Owner == RTThreadNativeSelf());
     148    ASMAtomicUoWriteSize(&pFastInt->Owner, NIL_RTNATIVETHREAD);
     149#endif
    128150    up(&pFastInt->Semaphore);
     151#ifdef IPRT_DEBUG_SEMS
     152    snprintf(current->comm, TASK_COMM_LEN, "u%lx", IPRT_DEBUG_SEMS_ADDRESS(pFastInt));
     153#endif
    129154    return VINF_SUCCESS;
    130155}
  • trunk/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h

    r6846 r7032  
    242242#endif
    243243
    244 #endif
    245 
     244/**
     245 * Hack for shortening pointers on linux so we can stuff more stuff into the
     246 * task_struct::comm field. This is used by the semaphore code but put here
     247 * because we don't have any better place atm. Don't use outside IPRT, please.
     248 */
     249#ifdef RT_ARCH_AMD64
     250# define IPRT_DEBUG_SEMS_ADDRESS(addr)  ( ((long)(addr) & (long)~UINT64_C(0xfffffff000000000)) )
     251#else
     252# define IPRT_DEBUG_SEMS_ADDRESS(addr)  ( (long)(addr) )
     253#endif
     254
     255#endif
     256
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette