dbgkrnlinfo-r0drv-solaris.c revision d1e93fc41faaba31e71f55aa41d458519ae02818
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/* $Id$ */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/** @file
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * IPRT - Kernel debug information, Ring-0 Driver, Solaris Code.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/*
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Copyright (C) 2012 Oracle Corporation
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync *
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 *
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 *
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
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/*******************************************************************************
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync* Header Files *
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync*******************************************************************************/
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include "the-solaris-kernel.h"
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include "internal/iprt.h"
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/dbg.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/asm.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/assert.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/err.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/log.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/mem.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/string.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include <iprt/thread.h>
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync#include "internal/magics.h"
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/*******************************************************************************
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync* Structures and Typedefs *
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync*******************************************************************************/
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/**
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Solaris kernel debug info instance data.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsynctypedef struct RTDBGKRNLINFOINT
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync{
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** Magic value (RTDBGKRNLINFO_MAGIC). */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync uint32_t volatile u32Magic;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** The number of threads referencing this object. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync uint32_t volatile cRefs;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** Pointer to the genunix CTF handle. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ctf_file_t *pGenUnixCTF;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /** Pointer to the genunix module handle. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync modctl_t *pGenUnixMod;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync} RTDBGKRNLINFOINT;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/** Pointer to the solaris kernel debug info instance data. */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsynctypedef struct RTDBGKRNLINFOINT *PRTDBGKRNLINFOINT;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/**
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Retains a kernel module and opens the CTF data associated with it.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync *
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 *
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @return IPRT status code.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncstatic int rtR0DbgKrnlInfoModRetain(char *pszModule, modctl_t **ppMod, ctf_file_t **ppCTF)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync{
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertPtrReturn(pszModule, VERR_INVALID_PARAMETER);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertPtrReturn(ppMod, VERR_INVALID_PARAMETER);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertPtrReturn(ppCTF, VERR_INVALID_PARAMETER);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync int rc = VINF_SUCCESS;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync modid_t ModId = mod_name_to_modid(pszModule);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync if (ModId != -1)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync {
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync *ppMod = mod_hold_by_id(ModId);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync if (*ppMod)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync {
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync /*
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Hold mod_lock as ctf_modopen may update the module with uncompressed CTF data.
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync */
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync int err;
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync mutex_enter(&mod_lock);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync *ppCTF = ctf_modopen(((modctl_t *)*ppMod)->mod_mp, &err);
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync mutex_exit(&mod_lock);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync mod_release_mod(*ppMod);
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync if (*ppCTF)
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync return VINF_SUCCESS;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync else
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync {
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync LogRel(("rtR0DbgKrnlInfoModRetain: ctf_modopen failed for '%s' err=%d\n", pszModule, err));
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync rc = VERR_INTERNAL_ERROR_3;
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync }
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync }
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync else
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync {
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync LogRel(("rtR0DbgKrnlInfoModRetain: mod_hold_by_id failed for '%s'\n", pszModule));
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync rc = VERR_INTERNAL_ERROR_2;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync }
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync }
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync else
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync {
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync LogRel(("rtR0DbgKrnlInfoModRetain: mod_name_to_modid failed for '%s'\n", pszModule));
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync rc = VERR_INTERNAL_ERROR;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync }
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
dc45a8f3e936581748c248e00ce572cfe3ea331evboxsync return rc;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync}
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync/**
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * Releases the kernel module and closes its CTF data.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync *
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @param pMod Pointer to the module handle.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync * @param pCTF Pointer to the module's CTF handle.
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync */
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsyncstatic void rtR0DbgKrnlInfoModRelease(modctl_t *pMod, ctf_file_t *pCTF)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync{
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertPtrReturnVoid(pMod);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertPtrReturnVoid(pCTF);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync ctf_close(pCTF);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync}
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(int) RTR0DbgKrnlInfoOpen(PRTDBGKRNLINFO phKrnlInfo, uint32_t fFlags)
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync{
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync AssertPtrReturn(phKrnlInfo, VERR_INVALID_POINTER);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync RT_ASSERT_PREEMPTIBLE();
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
87c5113417e917cdf64545d4f8e0a27047cea783vboxsync *phKrnlInfo = NIL_RTDBGKRNLINFO;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync PRTDBGKRNLINFOINT pThis = (PRTDBGKRNLINFOINT)RTMemAllocZ(sizeof(*pThis));
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (!pThis)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return VERR_NO_MEMORY;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync char szGenUnixModName[] = "genunix";
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync int rc = rtR0DbgKrnlInfoModRetain(szGenUnixModName, &pThis->pGenUnixMod, &pThis->pGenUnixCTF);
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync if (RT_SUCCESS(rc))
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync {
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync pThis->u32Magic = RTDBGKRNLINFO_MAGIC;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync pThis->cRefs = 1;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync *phKrnlInfo = pThis;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync return VINF_SUCCESS;
9888fffcfbe2d41dce14a1249b12cb88cc9b149fvboxsync }
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync LogRel(("RTR0DbgKrnlInfoOpen: rtR0DbgKrnlInfoModRetain failed rc=%d.\n", rc));
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync RTMemFree(pThis);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return rc;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync}
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(uint32_t) RTR0DbgKrnlInfoRetain(RTDBGKRNLINFO hKrnlInfo)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync{
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync PRTDBGKRNLINFOINT pThis = hKrnlInfo;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(pThis, UINT32_MAX);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertMsgReturn(pThis->u32Magic == RTDBGKRNLINFO_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), UINT32_MAX);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync uint32_t cRefs = ASMAtomicIncU32(&pThis->cRefs);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync Assert(cRefs && cRefs < 100000);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return cRefs;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync}
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(uint32_t) RTR0DbgKrnlInfoRelease(RTDBGKRNLINFO hKrnlInfo)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync{
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync PRTDBGKRNLINFOINT pThis = hKrnlInfo;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (pThis == NIL_RTDBGKRNLINFO)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return 0;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(pThis, UINT32_MAX);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertMsgReturn(pThis->u32Magic == RTDBGKRNLINFO_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), UINT32_MAX);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync RT_ASSERT_PREEMPTIBLE();
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync uint32_t cRefs = ASMAtomicDecU32(&pThis->cRefs);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (cRefs == 0)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync {
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync pThis->u32Magic = ~RTDBGKRNLINFO_MAGIC;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync rtR0DbgKrnlInfoModRelease(pThis->pGenUnixMod, pThis->pGenUnixCTF);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync RTMemFree(pThis);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync }
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return cRefs;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync}
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(int) RTR0DbgKrnlInfoQueryMember(RTDBGKRNLINFO hKrnlInfo, const char *pszStructure,
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync const char *pszMember, size_t *poffMember)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync{
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync PRTDBGKRNLINFOINT pThis = hKrnlInfo;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
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 RT_ASSERT_PREEMPTIBLE();
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync int rc = VERR_NOT_FOUND;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync ctf_id_t TypeIdent = ctf_lookup_by_name(pThis->pGenUnixCTF, pszStructure);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (TypeIdent != CTF_ERR)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync {
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync ctf_membinfo_t MemberInfo;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync RT_ZERO(MemberInfo);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (ctf_member_info(pThis->pGenUnixCTF, TypeIdent, pszMember, &MemberInfo) != CTF_ERR)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync {
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync *poffMember = (MemberInfo.ctm_offset >> 3);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return VINF_SUCCESS;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync }
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync }
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return rc;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync}
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsyncRTR0DECL(int) RTR0DbgKrnlInfoQuerySymbol(RTDBGKRNLINFO hKrnlInfo, const char *pszModule,
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync const char *pszSymbol, void **ppvSymbol)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync{
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync PRTDBGKRNLINFOINT pThis = hKrnlInfo;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
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 AssertReturn(!pszModule, VERR_MODULE_NOT_FOUND);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync RT_ASSERT_PREEMPTIBLE();
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync uintptr_t uValue = kobj_getsymvalue((char *)pszSymbol, 1 /* only kernel */);
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (ppvSymbol)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync *ppvSymbol = (void *)uValue;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync if (uValue)
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return VINF_SUCCESS;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync return VERR_SYMBOL_NOT_FOUND;
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync}
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync
50671c30431539dd7d6ff6a5f2ceb6c9f9f471b2vboxsync