dbgmod.h revision a1df400bbe9d64aad400442e56eb637019300a5e
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* $Id$ */
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding/** @file
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * IPRT - Internal Header for RTDbgMod and the associated interpreters.
b99dbaab171d91e1b664397cc40e039d0c087c65fielding */
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/*
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Copyright (C) 2008-2009 Sun Microsystems, Inc.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * This file is part of VirtualBox Open Source Edition (OSE), as
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * available from http://www.virtualbox.org. This file is free software;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * you can redistribute it and/or modify it under the terms of the GNU
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * General Public License (GPL) as published by the Free Software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Foundation, in version 2 as it comes in the "COPYING" file of the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The contents of this file may alternatively be used under the terms
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * of the Common Development and Distribution License Version 1.0
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * VirtualBox OSE distribution, in which case the provisions of the
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * CDDL are applicable instead of those of the GPL.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding *
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * You may elect to license modified versions of this file under the
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * terms and conditions of either the GPL or the CDDL or both.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * Clara, CA 95054 USA or visit http://www.sun.com if you need
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * additional information or have any questions.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding#ifndef ___internal_dbgmod_h
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding#define ___internal_dbgmod_h
64185f9824e42f21ca7b9ae6c004484215c031a7rbb
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include <iprt/types.h>
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding#include <iprt/critsect.h>
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding#include "internal/magics.h"
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffieldingRT_C_DECLS_BEGIN
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding/** @defgroup grp_rt_dbgmod RTDbgMod - Debug Module Interperter
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * @ingroup grp_rt
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * @internal
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * @{
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding */
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/** Pointer to the internal module structure. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct RTDBGMODINT *PRTDBGMODINT;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding/**
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding * Virtual method table for executable image interpreters.
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct RTDBGMODVTIMG
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding{
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding /** Magic number (RTDBGMODVTIMG_MAGIC). */
7e79e8fd53348f9fc6e8009a4a2522425ab6f08ffielding uint32_t u32Magic;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /** Mask of supported executable image types, see grp_rt_exe_img_type.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Used to speed up the search for a suitable interpreter. */
b6055b7832a0e4d0818416252fff5925aaebae4brbb uint32_t fSupports;
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein /** The name of the interpreter. */
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein const char *pszName;
e001a2b3aa785811274ee7af89165945926bc8eetrawick
e001a2b3aa785811274ee7af89165945926bc8eetrawick /**
e001a2b3aa785811274ee7af89165945926bc8eetrawick * Try open the image.
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * This combines probing and opening.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @returns IPRT status code. No informational returns defined.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pMod Pointer to the module that is being opened.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * The RTDBGMOD::pszDbgFile member will point to
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * the filename of any debug info we're aware of
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * on input. Also, or alternatively, it is expected
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * that the interpreter will look for debug info in
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the executable image file when present and that it
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * may ask the image interpreter for this when it's
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * around.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * Upon successful return the method is expected to
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * initialize pDbgOps and pvDbgPriv.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Close the interpreter, freeing all associated resources.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The caller sets the pDbgOps and pvDbgPriv RTDBGMOD members
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * to NULL upon return.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pMod Pointer to the module structure.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding DECLCALLBACKMEMBER(int, pfnClose)(PRTDBGMODINT pMod);
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} RTDBGMODVTIMG;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/** Pointer to a const RTDBGMODVTIMG. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef RTDBGMODVTIMG const *PCRTDBGMODVTIMG;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Virtual method table for debug info interpreters.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb */
141b1a93f508248cbc0e9a124cc38041eb3e2562rbbtypedef struct RTDBGMODVTDBG
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb{
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb /** Magic number (RTDBGMODVTDBG_MAGIC). */
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb uint32_t u32Magic;
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb /** Mask of supported debug info types, see grp_rt_dbg_type.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Used to speed up the search for a suitable interpreter. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding uint32_t fSupports;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /** The name of the interpreter. */
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb const char *pszName;
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb
cd5c0afc86ca2eb23d6d12e14590e03cf2f80450gstein /**
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * Try open the image.
cd5c0afc86ca2eb23d6d12e14590e03cf2f80450gstein *
cd5c0afc86ca2eb23d6d12e14590e03cf2f80450gstein * This combines probing and opening.
cd5c0afc86ca2eb23d6d12e14590e03cf2f80450gstein *
cd5c0afc86ca2eb23d6d12e14590e03cf2f80450gstein * @returns IPRT status code. No informational returns defined.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
b1476ba063e6d9577cd86db3db5dd98ff6bc78b9rbb * @param pMod Pointer to the module that is being opened.
b1476ba063e6d9577cd86db3db5dd98ff6bc78b9rbb *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The RTDBGMOD::pszDbgFile member will point to
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * the filename of any debug info we're aware of
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * on input. Also, or alternatively, it is expected
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * that the interpreter will look for debug info in
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * the executable image file when present and that it
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * may ask the image interpreter for this when it's
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * around.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * Upon successful return the method is expected to
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * initialize pDbgOps and pvDbgPriv.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
321f97740766bd0accb8ad67a6423ab0e10b8574fanf DECLCALLBACKMEMBER(int, pfnTryOpen)(PRTDBGMODINT pMod);
321f97740766bd0accb8ad67a6423ab0e10b8574fanf
55ed31c59448336c78c93671291a23484d82e2cerbb /**
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * Close the interpreter, freeing all associated resources.
55ed31c59448336c78c93671291a23484d82e2cerbb *
6dba59bb4ccbfbc2592d124a8d649f6a22c8e2d9trawick * The caller sets the pDbgOps and pvDbgPriv RTDBGMOD members
6dba59bb4ccbfbc2592d124a8d649f6a22c8e2d9trawick * to NULL upon return.
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe *
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * @param pMod Pointer to the module structure.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf */
321f97740766bd0accb8ad67a6423ab0e10b8574fanf DECLCALLBACKMEMBER(int, pfnClose)(PRTDBGMODINT pMod);
321f97740766bd0accb8ad67a6423ab0e10b8574fanf
321f97740766bd0accb8ad67a6423ab0e10b8574fanf
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe
54f7f1c85247dad29d8fa275866cea31d465b392stoddard /**
8454451006e6e3e836662a73ce3a4a7fcd853c42trawick * Converts an image relative virtual address address to a segmented address.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein *
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * @returns Segment index on success, NIL_RTDBGSEGIDX on failure.
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * @param pMod Pointer to the module structure.
5ee34d166b04ca0043866b4c8180e82d167c7cc5fanf * @param uRva The image relative address to convert.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @param poffSeg Where to return the segment offset. Optional.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf */
321f97740766bd0accb8ad67a6423ab0e10b8574fanf DECLCALLBACKMEMBER(RTDBGSEGIDX, pfnRvaToSegOff)(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg);
54f7f1c85247dad29d8fa275866cea31d465b392stoddard
54f7f1c85247dad29d8fa275866cea31d465b392stoddard /**
54f7f1c85247dad29d8fa275866cea31d465b392stoddard * Image size when mapped if segments are mapped adjecently.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein *
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * For ELF, PE, and Mach-O images this is (usually) a natural query, for LX and
321f97740766bd0accb8ad67a6423ab0e10b8574fanf * NE and such it's a bit odder and the answer may not make much sense for them.
f92e51e1951be0ef34da086bdff019d8ddc71c63rbb *
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @returns Image mapped size.
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * @param pMod Pointer to the module structure.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf */
321f97740766bd0accb8ad67a6423ab0e10b8574fanf DECLCALLBACKMEMBER(RTUINTPTR, pfnImageSize)(PRTDBGMODINT pMod);
321f97740766bd0accb8ad67a6423ab0e10b8574fanf
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf /**
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * Adds a segment to the module (optional).
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf *
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @returns IPRT status code.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @retval VERR_NOT_SUPPORTED if the interpreter doesn't support this feature.
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * @retval VERR_DBG_SEGMENT_INDEX_CONFLICT if the segment index exists already.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf *
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @param pMod Pointer to the module structure.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @param uRva The segment image relative address.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @param cb The segment size.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @param pszName The segment name.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @param cchName The length of the segment name.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @param fFlags Segment flags.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @param piSeg The segment index or NIL_RTDBGSEGIDX on input.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * The assigned segment index on successful return.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf * Optional.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf */
321f97740766bd0accb8ad67a6423ab0e10b8574fanf DECLCALLBACKMEMBER(int, pfnSegmentAdd)(PRTDBGMODINT pMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName, size_t cchName,
321f97740766bd0accb8ad67a6423ab0e10b8574fanf uint32_t fFlags, PRTDBGSEGIDX piSeg);
321f97740766bd0accb8ad67a6423ab0e10b8574fanf
1bf57b6327406b428289869c4ddeb5f186b5e55egstein /**
321f97740766bd0accb8ad67a6423ab0e10b8574fanf * Gets the segment count.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf *
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @returns Number of segments.
0a4b617fb980de599fe68b99d5b53f9e1806592dfanf * @retval NIL_RTDBGSEGIDX if unknown.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf *
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @param pMod Pointer to the module structure.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein */
1bf57b6327406b428289869c4ddeb5f186b5e55egstein DECLCALLBACKMEMBER(RTDBGSEGIDX, pfnSegmentCount)(PRTDBGMODINT pMod);
1bf57b6327406b428289869c4ddeb5f186b5e55egstein
1bf57b6327406b428289869c4ddeb5f186b5e55egstein /**
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * Gets information about a segment.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein *
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @returns IPRT status code.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @retval VERR_DBG_INVALID_SEGMENT_INDEX if iSeg is too high.
5ee34d166b04ca0043866b4c8180e82d167c7cc5fanf *
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @param pMod Pointer to the module structure.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @param iSeg The segment.
67f6dca9f3c35eb904c7b29a220db6c4482374dctrawick * @param pSegInfo Where to store the segment information.
066877f1a045103acfdd376d48cdd473c33f409bdougm */
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe DECLCALLBACKMEMBER(int, pfnSegmentByIndex)(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo);
1bf57b6327406b428289869c4ddeb5f186b5e55egstein
1bf57b6327406b428289869c4ddeb5f186b5e55egstein
54f7f1c85247dad29d8fa275866cea31d465b392stoddard
54f7f1c85247dad29d8fa275866cea31d465b392stoddard /**
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * Adds a symbol to the module (optional).
066877f1a045103acfdd376d48cdd473c33f409bdougm *
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @returns IPRT code.
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * @retval VERR_NOT_SUPPORTED if the interpreter doesn't support this feature.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein *
54f7f1c85247dad29d8fa275866cea31d465b392stoddard * @param pMod Pointer to the module structure.
54f7f1c85247dad29d8fa275866cea31d465b392stoddard * @param pszSymbol The symbol name.
54f7f1c85247dad29d8fa275866cea31d465b392stoddard * @param cchSymbol The length for the symbol name.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @param iSeg The segment number (0-based). RTDBGMOD_SEG_RVA can be used.
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe * @param off The offset into the segment.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @param cb The area covered by the symbol. 0 is fine.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @param piOrdinal Where to return the symbol ordinal on success. If the
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * interpreter doesn't do ordinals, this will be set to
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * UINT32_MAX. Optional
1bf57b6327406b428289869c4ddeb5f186b5e55egstein */
1bf57b6327406b428289869c4ddeb5f186b5e55egstein DECLCALLBACKMEMBER(int, pfnSymbolAdd)(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
1bf57b6327406b428289869c4ddeb5f186b5e55egstein uint32_t iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags,
1bf57b6327406b428289869c4ddeb5f186b5e55egstein uint32_t *piOrdinal);
1bf57b6327406b428289869c4ddeb5f186b5e55egstein
1bf57b6327406b428289869c4ddeb5f186b5e55egstein /**
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * Gets the number of symbols in the module.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein *
5ee34d166b04ca0043866b4c8180e82d167c7cc5fanf * This is used for figuring out the max value to pass to pfnSymbolByIndex among
5ee34d166b04ca0043866b4c8180e82d167c7cc5fanf * other things.
5ee34d166b04ca0043866b4c8180e82d167c7cc5fanf *
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @returns The number of symbols, UINT32_MAX if not known/supported.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein *
5ee34d166b04ca0043866b4c8180e82d167c7cc5fanf * @param pMod Pointer to the module structure.
066877f1a045103acfdd376d48cdd473c33f409bdougm */
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe DECLCALLBACKMEMBER(uint32_t, pfnSymbolCount)(PRTDBGMODINT pMod);
1bf57b6327406b428289869c4ddeb5f186b5e55egstein
1bf57b6327406b428289869c4ddeb5f186b5e55egstein /**
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * Queries symbol information by ordinal number.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein *
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @returns IPRT status code.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf * @retval VINF_SUCCESS on success, no informational status code.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
55ed31c59448336c78c93671291a23484d82e2cerbb * @retval VERR_NOT_SUPPORTED if lookup by ordinal is not supported.
1bf57b6327406b428289869c4ddeb5f186b5e55egstein * @retval VERR_SYMBOL_NOT_FOUND if there is no symbol at that index.
321f97740766bd0accb8ad67a6423ab0e10b8574fanf *
55ed31c59448336c78c93671291a23484d82e2cerbb * @param pMod Pointer to the module structure.
55ed31c59448336c78c93671291a23484d82e2cerbb * @param iOrdinal The symbol ordinal number.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pSymInfo Where to store the symbol information.
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding */
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding DECLCALLBACKMEMBER(int, pfnSymbolByOrdinal)(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo);
776398cb0573181cea7d6d2c49c3640c33019a34coar
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding /**
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding * Queries symbol information by symbol name.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * @returns IPRT status code.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @retval VINF_SUCCESS on success, no informational status code.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pMod Pointer to the module structure.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pszSymbol The symbol name.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param cchSymbol The length of the symbol name.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pSymInfo Where to store the symbol information.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb */
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb DECLCALLBACKMEMBER(int, pfnSymbolByName)(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol, PRTDBGSYMBOL pSymInfo);
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb /**
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * Queries symbol information by address.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * The returned symbol is what the debug info interpreter consideres the symbol
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * most applicable to the specified address. This usually means a symbol with an
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * address equal or lower than the requested.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @returns IPRT status code.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @retval VINF_SUCCESS on success, no informational status code.
c981632de03d61667b7a6dda3e1f0a80fd5973b1gregames * @retval VERR_DBG_NO_SYMBOLS if there aren't any symbols.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @retval VERR_SYMBOL_NOT_FOUND if no suitable symbol was found.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pMod Pointer to the module structure.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param iSeg The segment number (0-based) or RTDBGSEGIDX_ABS.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param off The offset into the segment.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param poffDisp Where to store the distance between the specified address
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * and the returned symbol. Optional.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pSymInfo Where to store the symbol information.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb */
c981632de03d61667b7a6dda3e1f0a80fd5973b1gregames DECLCALLBACKMEMBER(int, pfnSymbolByAddr)(PRTDBGMODINT pMod, uint32_t iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo);
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb /**
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * Adds a line number to the module (optional).
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @returns IPRT status code.
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb * @retval VERR_NOT_SUPPORTED if the interpreter doesn't support this feature.
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb *
801b4a342341706c86ec580dee8352a912bda9bdminfrin * @param pMod Pointer to the module structure.
801b4a342341706c86ec580dee8352a912bda9bdminfrin * @param pszFile The filename.
e3d0e5e9b5764c1f41a6bdd9a26b8bbbf11d9e95trawick * @param cchFile The length of the filename.
e3d0e5e9b5764c1f41a6bdd9a26b8bbbf11d9e95trawick * @param iSeg The segment number (0-based).
e3d0e5e9b5764c1f41a6bdd9a26b8bbbf11d9e95trawick * @param off The offset into the segment.
e3d0e5e9b5764c1f41a6bdd9a26b8bbbf11d9e95trawick * @param piOrdinal Where to return the line number ordinal on success. If
e3d0e5e9b5764c1f41a6bdd9a26b8bbbf11d9e95trawick * the interpreter doesn't do ordinals, this will be set to
801b4a342341706c86ec580dee8352a912bda9bdminfrin * UINT32_MAX. Optional
801b4a342341706c86ec580dee8352a912bda9bdminfrin */
73e8b26287de5c06fa470d36162e103dbac9c7e5wrowe DECLCALLBACKMEMBER(int, pfnLineAdd)(PRTDBGMODINT pMod, const char *pszFile, size_t cchFile, uint32_t uLineNo,
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding uint32_t iSeg, RTUINTPTR off, uint32_t *piOrdinal);
34883dbfd7eb43a4bd63504495b84eb6514634c2rbb
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe /**
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding * Gets the number of line numbers in the module.
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @returns The number or UINT32_MAX if not known/supported.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb *
c9b85d26144df8738f9635ad72381232bb5f1e9brbb * @param pMod Pointer to the module structure.
801b4a342341706c86ec580dee8352a912bda9bdminfrin */
304ace8323a52b386b4d5236b27ed0cfe9d36257trawick DECLCALLBACKMEMBER(uint32_t, pfnLineCount)(PRTDBGMODINT pMod);
6200a47d781fa5913c60429edaacf1cd556f2454trawick
c9b85d26144df8738f9635ad72381232bb5f1e9brbb /**
c9b85d26144df8738f9635ad72381232bb5f1e9brbb * Queries line number information by ordinal number.
6200a47d781fa5913c60429edaacf1cd556f2454trawick *
66f62d70d05d9011c6ac59d5cd10a24e452fa1b3rbb * @returns IPRT status code.
66f62d70d05d9011c6ac59d5cd10a24e452fa1b3rbb * @retval VINF_SUCCESS on success, no informational status code.
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding * @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding * @retval VERR_DBG_LINE_NOT_FOUND if there is no line number with that
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * ordinal.
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding *
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pMod Pointer to the module structure.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param iOrdinal The line number ordinal number.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb * @param pLine Where to store the information about the line number.
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb */
141b1a93f508248cbc0e9a124cc38041eb3e2562rbb DECLCALLBACKMEMBER(int, pfnLineByOrdinal)(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGLINE pLine);
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /**
* Queries line number information by address.
*
* @returns IPRT status code.
* @retval VINF_SUCCESS on success, no informational status code.
* @retval VERR_DBG_NO_LINE_NUMBERS if there aren't any line numbers.
* @retval VERR_DBG_LINE_NOT_FOUND if no suitable line number was found.
*
* @param pMod Pointer to the module structure.
* @param iSeg The segment number (0-based) or RTDBGSEGIDX_ABS.
* @param off The offset into the segment.
* @param poffDisp Where to store the distance between the specified address
* and the returned line number. Optional.
* @param pLine Where to store the information about the closest line number.
*/
DECLCALLBACKMEMBER(int, pfnLineByAddr)(PRTDBGMODINT pMod, uint32_t iSeg, RTUINTPTR off, PRTINTPTR poffDisp, PRTDBGLINE pLine);
/** For catching initialization errors (RTDBGMODVTDBG_MAGIC). */
uint32_t u32EndMagic;
} RTDBGMODVTDBG;
/** Pointer to a const RTDBGMODVTDBG. */
typedef RTDBGMODVTDBG const *PCRTDBGMODVTDBG;
/**
* Debug module structure.
*/
typedef struct RTDBGMODINT
{
/** Magic value (RTDBGMOD_MAGIC). */
uint32_t u32Magic;
/** The number of reference there are to this module.
* This is used to perform automatic cleanup and sharing. */
uint32_t volatile cRefs;
/** The module name (short). */
char const *pszName;
/** The module filename. Can be NULL. */
char const *pszImgFile;
/** The debug info file (if external). Can be NULL. */
char const *pszDbgFile;
/** Critical section serializing access to the module. */
RTCRITSECT CritSect;
/** The method table for the executable image interpreter. */
PCRTDBGMODVTIMG pImgVt;
/** Pointer to the private data of the executable image interpreter. */
void *pvImgPriv;
/** The method table for the debug info interpreter. */
PCRTDBGMODVTDBG pDbgVt;
/** Pointer to the private data of the debug info interpreter. */
void *pvDbgPriv;
} RTDBGMODINT;
/** Pointer to an debug module structure. */
typedef RTDBGMODINT *PRTDBGMODINT;
extern DECLHIDDEN(RTSTRCACHE) g_hDbgModStrCache;
int rtDbgModContainerCreate(PRTDBGMODINT pMod, RTUINTPTR cbSeg);
/** @} */
RT_C_DECLS_END
#endif