VirtualBox

Ignore:
Timestamp:
Mar 28, 2012 3:06:05 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77143
Message:

dbg-r0drv-solaris.c: gcc 4.5.2 build fixes and a todo.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/dbg-r0drv-solaris.c

    r40670 r40689  
    3838#include <iprt/mem.h>
    3939#include <iprt/string.h>
     40#include <iprt/thread.h>
    4041
    4142#include <sys/kobj.h>
     
    4849*   Structures and Typedefs                                                    *
    4950*******************************************************************************/
     51/**
     52 * Solaris kernel debug info instance data.
     53 */
    5054typedef struct RTDBGKRNLINFOINT
    5155{
    52     /** Magic value (). */
     56    /** Magic value (RTDBGKRNLINFO_MAGIC). */
    5357    uint32_t volatile   u32Magic;
    5458    /** The number of threads referencing this object. */
     
    5963    modctl_t           *pGenUnixMod;
    6064} RTDBGKRNLINFOINT;
     65/** Pointer to the solaris kernel debug info instance data. */
    6166typedef struct RTDBGKRNLINFOINT *PRTDBGKRNLINFOINT;
     67
    6268/** Magic value for RTDBGKRNLINFOINT::u32Magic. (John Carmack) */
    6369#define RTDBGKRNLINFO_MAGIC       UINT32_C(0x19700820)
     
    7480        return VERR_NO_MEMORY;
    7581
    76     int rc = VINF_SUCCESS;
     82    int rc;
     83    /** @todo r=bird: Where do we release this module? I see other users (crypto) of
     84     * this API mod_release_mod().  Not sure if this is a real issue with a primary
     85     * module like genunix, though.  Another thing, I noticed that mod_hold_by_name
     86     * will (a) allocated a module if not found and (b) replace the filename with
     87     * what you hand in under certain conditions.  These issues doesn't apply with
     88     * genunix, but is worth keeping in mind if other modules needs to be held.  A
     89     * safer alternative would probably be mod_name_to_modid + mod_hold_by_id. */
    7790    pThis->pGenUnixMod = mod_hold_by_name("genunix");
    7891    if (RT_LIKELY(pThis->pGenUnixMod))
     
    94107            return VINF_SUCCESS;
    95108        }
    96         else
    97         {
    98             LogRel(("RTR0DbgKrnlInfoOpen: ctf_modopen failed. err=%d\n", err));
    99             rc = VERR_INTERNAL_ERROR_2;
    100         }
     109
     110        LogRel(("RTR0DbgKrnlInfoOpen: ctf_modopen failed. err=%d\n", err));
     111        rc = VERR_INTERNAL_ERROR_2;
    101112    }
    102113    else
     
    116127    Assert(cRefs && cRefs < 100000);
    117128    NOREF(cRefs);
    118 }
    119 
    120 static void rtR0DbgKrnlInfoDestroy(RTDBGKRNLINFO hKrnlInfo)
    121 {
    122     PRTDBGKRNLINFOINT pThis = hKrnlInfo;
    123     AssertPtrReturnVoid(pThis);
    124     AssertPtrReturnVoid(pThis->u32Magic == RTDBGKRNLINFO_MAGIC);
    125     RT_ASSERT_PREEMPTIBLE();
    126 
     129    return cRefs;
     130}
     131
     132
     133static void rtR0DbgKrnlInfoDestroy(PRTDBGKRNLINFOINT pThis)
     134{
     135    pThis->u32Magic = ~RTDBGKRNLINFO_MAGIC;
    127136    ctf_close(pThis->pGenUnixCTF);
    128137    mod_release_mod(pThis->pGenUnixMod);
     
    138147    RT_ASSERT_PREEMPTIBLE();
    139148
    140     if (ASMAtomicDecU32(&pThis->cRefs) == 0)
     149    uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs);
     150    if (cRefs == 0)
    141151        rtR0DbgKrnlInfoDestroy(pThis);
     152    return cRefs;
    142153}
    143154
    144155
    145156RTR0DECL(int) RTR0DbgKrnlInfoQueryMember(RTDBGKRNLINFO hKrnlInfo, const char *pszStructure,
    146                                                const char *pszMember, size_t *poffMember)
     157                                         const char *pszMember, size_t *poffMember)
    147158{
    148159    PRTDBGKRNLINFOINT pThis = hKrnlInfo;
     
    179190    AssertPtrReturn(pszSymbol, VERR_INVALID_PARAMETER);
    180191    AssertPtrReturn(ppvSymbol, VERR_INVALID_PARAMETER);
    181     RT_ASSERT_PREEMPTIBLE();
    182 
    183     NOREF(pszModule);
    184     *ppvSymbol = kobj_getsymvalue(pszSymbol, 1 /* only kernel */);
     192    AssertReturn(!pszModule, VERR_MODULE_NOT_FOUND);
     193    RT_ASSERT_PREEMPTIBLE();
     194
     195    *ppvSymbol = (void *)kobj_getsymvalue((char *)pszSymbol, 1 /* only kernel */);
    185196    if (*ppvSymbol)
    186197        return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

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