source: trunk/kStuff/include/k/kDbgAll.h@ 3567

Last change on this file since 3567 was 3550, checked in by bird, 18 years ago

made kDbg compile again (not linking yet though).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1/* $Id: kDbgAll.h 3550 2007-08-26 01:13:35Z bird $ */
2/** @file
3 * kDbg - The Debug Info Read, All Details and Dependencies Included.
4 */
5
6/*
7 * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with This program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifndef ___k_kDbgAll_h___
26#define ___k_kDbgAll_h___
27
28#include <k/kDefs.h>
29#include <k/kTypes.h>
30#include <k/kRdr.h>
31//#include <k/kLdr.h>
32#include "kLdr.h"
33#include <k/kDbg.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/** @defgroup grp_kDbgAll All
40 * @addtogroup grp_kDbg
41 * @{
42 */
43
44/**
45 * The debug module method table.
46 */
47typedef struct KDBGMODOPS
48{
49 /** The name of the reader. */
50 const char *pszName;
51
52 /** Pointer to the next debug module readers.
53 * This is only used for dynamically registered readers. */
54 struct KDBGMODOPS *pNext;
55
56 /**
57 * Tries to open the module.
58 *
59 * @returns 0 on success, KDBG_ERR on failure.
60 * @param ppMod Where to store the module that's been opened.
61 * @param pRdr The file provider.
62 * @param fCloseRdrs Whether the reader should be closed or not when the module is destroyed.
63 * @param off The file offset of the debug info. This is 0 if there isn't
64 * any specfic debug info section and the reader should start
65 * looking for debug info at the start of the file.
66 * @param cb The size of the debug info in the file. INT64_MAX if we don't
67 * know or there isn't any particular debug info section in the file.
68 * @param pLdrMod The associated loader module. This can be NULL.
69 */
70 int (*pfnOpen)(PKDBGMOD *ppMod, PKRDR pRdr, KBOOL fCloseRdr, KFOFF off, KFOFF cb, struct KLDRMOD *pLdrMod);
71
72 /**
73 * Closes the module.
74 *
75 * This should free all resources associated with the module
76 * except the pMod which is freed by the caller.
77 *
78 * @returns IPRT status code.
79 * @param pMod The module.
80 */
81 int (*pfnClose)(PKDBGMOD pMod);
82
83 /**
84 * Gets a symbol by segment:offset.
85 * This will be approximated to the nearest symbol if there is no exact match.
86 *
87 * @returns 0 on success. KLDR_ERR_* on failure.
88 * @param pMod The module.
89 * @param iSegment The segment this offset is relative to.
90 * The -1 segment is special, it means that the addres is relative to
91 * the image base. The image base is where the first bit of the image
92 * is mapped during load.
93 * @param off The offset into the segment.
94 * @param pSym Where to store the symbol details.
95 */
96 int (*pfnQuerySymbol)(PKDBGMOD pMod, KI32 iSegment, KDBGADDR off, PKDBGSYMBOL pSym);
97
98 /**
99 * Gets a line number entry by segment:offset.
100 * This will be approximated to the nearest line number there is no exact match.
101 *
102 * @returns 0 on success. KLDR_ERR_* on failure.
103 * @param pMod The module.
104 * @param iSegment The segment this offset is relative to.
105 * The -1 segment is special, it means that the addres is relative to
106 * the image base. The image base is where the first bit of the image
107 * is mapped during load.
108 * @param off The offset into the segment.
109 * @param pLine Where to store the line number details.
110 */
111 int (*pfnQueryLine)(PKDBGMOD pMod, KI32 iSegment, KDBGADDR uOffset, PKDBGLINE pLine);
112
113 /** This is just to make sure you've initialized all the fields.
114 * Must be identical to pszName. */
115 const char *pszName2;
116} KDBGMODOPS;
117/** Pointer to a module method table. */
118typedef KDBGMODOPS *PKDBGMODOPS;
119/** Pointer to a const module method table. */
120typedef const KDBGMODOPS *PCKDBGMODOPS;
121
122/**
123 * Register a debug module reader with the kDbgModule component.
124 *
125 * Dynamically registered readers are kept in FIFO order, and external
126 * readers will be tried after the builtin ones.
127 *
128 * @returns 0 on success.
129 * @returns KERR_INVALID_POINTER if pOps is missing bits.
130 * @returns KERR_INVALID_PARAMETER if pOps is already in the list.
131 * @param pOps The reader method table, kDbg takes owner ship of
132 * this. This must be writeable as the pNext pointer
133 * will be update. It must also stick around for as
134 * long as kDbg is in use.
135 */
136KDBG_DECL(int) kDbgModuleRegisterReader(PKDBGMODOPS pOps);
137
138
139
140/**
141 * Internal representation of a debug module.
142 */
143typedef struct KDBGMOD
144{
145 /** Magic value (KDBGMOD_MAGIC). */
146 KI32 u32Magic;
147 /** Pointer to the method table. */
148 PCKDBGMODOPS pOps;
149 /** The file provider for the file containing the debug info. */
150 PKRDR pRdr;
151 /** Whether or not to close pRdr. */
152 KBOOL fCloseRdr;
153 /** The associated kLdr module. This may be NULL. */
154 PKLDRMOD pLdrMod;
155} KDBGMOD;
156
157/** @}*/
158
159#ifdef __cplusplus
160}
161#endif
162
163#endif
Note: See TracBrowser for help on using the repository browser.