dbgkrnlinfo-r0drv-solaris.c revision d1e93fc41faaba31e71f55aa41d458519ae02818
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * IPRT - Kernel debug information, Ring-0 Driver, Solaris Code.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Copyright (C) 2012 Oracle Corporation
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * available from http://www.virtualbox.org. This file is free software;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * General Public License (GPL) as published by the Free Software
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * The contents of this file may alternatively be used under the terms
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * of the Common Development and Distribution License Version 1.0
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * VirtualBox OSE distribution, in which case the provisions of the
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * CDDL are applicable instead of those of the GPL.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * You may elect to license modified versions of this file under the
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * terms and conditions of either the GPL or the CDDL or both.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/*******************************************************************************
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync* Header Files *
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync*******************************************************************************/
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/*******************************************************************************
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync* Structures and Typedefs *
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync*******************************************************************************/
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Solaris kernel debug info instance data.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** Magic value (RTDBGKRNLINFO_MAGIC). */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** The number of threads referencing this object. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** Pointer to the genunix CTF handle. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** Pointer to the genunix module handle. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/** Pointer to the solaris kernel debug info instance data. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Retains a kernel module and opens the CTF data associated with it.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @param pszModule The name of the module to open.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @param ppMod Where to store the module handle.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @param ppCTF Where to store the module's CTF handle.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @return IPRT status code.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncstatic int rtR0DbgKrnlInfoModRetain(char *pszModule, modctl_t **ppMod, ctf_file_t **ppCTF)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertPtrReturn(pszModule, VERR_INVALID_PARAMETER);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Hold mod_lock as ctf_modopen may update the module with uncompressed CTF data.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync *ppCTF = ctf_modopen(((modctl_t *)*ppMod)->mod_mp, &err);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync LogRel(("rtR0DbgKrnlInfoModRetain: ctf_modopen failed for '%s' err=%d\n", pszModule, err));
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync LogRel(("rtR0DbgKrnlInfoModRetain: mod_hold_by_id failed for '%s'\n", pszModule));
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync LogRel(("rtR0DbgKrnlInfoModRetain: mod_name_to_modid failed for '%s'\n", pszModule));
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Releases the kernel module and closes its CTF data.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @param pMod Pointer to the module handle.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @param pCTF Pointer to the module's CTF handle.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncstatic void rtR0DbgKrnlInfoModRelease(modctl_t *pMod, ctf_file_t *pCTF)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(int) RTR0DbgKrnlInfoOpen(PRTDBGKRNLINFO phKrnlInfo, uint32_t fFlags)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync PRTDBGKRNLINFOINT pThis = (PRTDBGKRNLINFOINT)RTMemAllocZ(sizeof(*pThis));
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync int rc = rtR0DbgKrnlInfoModRetain(szGenUnixModName, &pThis->pGenUnixMod, &pThis->pGenUnixCTF);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync LogRel(("RTR0DbgKrnlInfoOpen: rtR0DbgKrnlInfoModRetain failed rc=%d.\n", rc));
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(uint32_t) RTR0DbgKrnlInfoRetain(RTDBGKRNLINFO hKrnlInfo)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertMsgReturn(pThis->u32Magic == RTDBGKRNLINFO_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), UINT32_MAX);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(uint32_t) RTR0DbgKrnlInfoRelease(RTDBGKRNLINFO hKrnlInfo)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertMsgReturn(pThis->u32Magic == RTDBGKRNLINFO_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), UINT32_MAX);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync rtR0DbgKrnlInfoModRelease(pThis->pGenUnixMod, pThis->pGenUnixCTF);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(int) RTR0DbgKrnlInfoQueryMember(RTDBGKRNLINFO hKrnlInfo, const char *pszStructure,
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertMsgReturn(pThis->u32Magic == RTDBGKRNLINFO_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(pszMember, VERR_INVALID_PARAMETER);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(pszStructure, VERR_INVALID_PARAMETER);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(poffMember, VERR_INVALID_PARAMETER);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync ctf_id_t TypeIdent = ctf_lookup_by_name(pThis->pGenUnixCTF, pszStructure);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (ctf_member_info(pThis->pGenUnixCTF, TypeIdent, pszMember, &MemberInfo) != CTF_ERR)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(int) RTR0DbgKrnlInfoQuerySymbol(RTDBGKRNLINFO hKrnlInfo, const char *pszModule,
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertMsgReturn(pThis->u32Magic == RTDBGKRNLINFO_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(pszSymbol, VERR_INVALID_PARAMETER);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrNullReturn(ppvSymbol, VERR_INVALID_PARAMETER);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync uintptr_t uValue = kobj_getsymvalue((char *)pszSymbol, 1 /* only kernel */);