VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp@ 75482

Last change on this file since 75482 was 75482, checked in by vboxsync, 6 years ago

IPRT/dbgmodcontainer.cpp: Fix for symbol replacement for the case that we're replacing the most recently added symbol (ordinal = next-ordinal - 1).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.5 KB
Line 
1/* $Id: dbgmodcontainer.cpp 75482 2018-11-15 12:40:53Z vboxsync $ */
2/** @file
3 * IPRT - Debug Info Container.
4 */
5
6/*
7 * Copyright (C) 2009-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#define LOG_GROUP RTLOGGROUP_DBG
32#include <iprt/dbg.h>
33#include "internal/iprt.h"
34
35#include <iprt/avl.h>
36#include <iprt/err.h>
37#include <iprt/log.h>
38#include <iprt/mem.h>
39#define RTDBGMODCNT_WITH_MEM_CACHE
40#ifdef RTDBGMODCNT_WITH_MEM_CACHE
41# include <iprt/memcache.h>
42#endif
43#include <iprt/string.h>
44#include <iprt/strcache.h>
45#include "internal/dbgmod.h"
46
47
48/*********************************************************************************************************************************
49* Structures and Typedefs *
50*********************************************************************************************************************************/
51/**
52 * Symbol entry.
53 */
54typedef struct RTDBGMODCTNSYMBOL
55{
56 /** The address core. */
57 AVLRUINTPTRNODECORE AddrCore;
58 /** The name space core. */
59 RTSTRSPACECORE NameCore;
60 /** The ordinal number core. */
61 AVLU32NODECORE OrdinalCore;
62 /** The segment index. */
63 RTDBGSEGIDX iSeg;
64 /** The symbol flags. */
65 uint32_t fFlags;
66 /** The symbol size.
67 * This may be zero while the range in AddrCore indicates 0. */
68 RTUINTPTR cb;
69} RTDBGMODCTNSYMBOL;
70/** Pointer to a symbol entry in the debug info container. */
71typedef RTDBGMODCTNSYMBOL *PRTDBGMODCTNSYMBOL;
72/** Pointer to a const symbol entry in the debug info container. */
73typedef RTDBGMODCTNSYMBOL const *PCRTDBGMODCTNSYMBOL;
74
75/**
76 * Line number entry.
77 */
78typedef struct RTDBGMODCTNLINE
79{
80 /** The address core.
81 * The Key is the address of the line number. */
82 AVLUINTPTRNODECORE AddrCore;
83 /** The ordinal number core. */
84 AVLU32NODECORE OrdinalCore;
85 /** Pointer to the file name (in string cache). */
86 const char *pszFile;
87 /** The line number. */
88 uint32_t uLineNo;
89 /** The segment index. */
90 RTDBGSEGIDX iSeg;
91} RTDBGMODCTNLINE;
92/** Pointer to a line number entry. */
93typedef RTDBGMODCTNLINE *PRTDBGMODCTNLINE;
94/** Pointer to const a line number entry. */
95typedef RTDBGMODCTNLINE const *PCRTDBGMODCTNLINE;
96
97/**
98 * Segment entry.
99 */
100typedef struct RTDBGMODCTNSEGMENT
101{
102 /** The symbol address space tree. */
103 AVLRUINTPTRTREE SymAddrTree;
104 /** The line number address space tree. */
105 AVLUINTPTRTREE LineAddrTree;
106 /** The segment offset. */
107 RTUINTPTR off;
108 /** The segment size. */
109 RTUINTPTR cb;
110 /** The segment flags. */
111 uint32_t fFlags;
112 /** The segment name. */
113 const char *pszName;
114} RTDBGMODCTNSEGMENT;
115/** Pointer to a segment entry in the debug info container. */
116typedef RTDBGMODCTNSEGMENT *PRTDBGMODCTNSEGMENT;
117/** Pointer to a const segment entry in the debug info container. */
118typedef RTDBGMODCTNSEGMENT const *PCRTDBGMODCTNSEGMENT;
119
120/**
121 * Instance data.
122 */
123typedef struct RTDBGMODCTN
124{
125 /** The name space. */
126 RTSTRSPACE Names;
127 /** Tree containing any absolute addresses. */
128 AVLRUINTPTRTREE AbsAddrTree;
129 /** Tree organizing the symbols by ordinal number. */
130 AVLU32TREE SymbolOrdinalTree;
131 /** Tree organizing the line numbers by ordinal number. */
132 AVLU32TREE LineOrdinalTree;
133 /** Segment table. */
134 PRTDBGMODCTNSEGMENT paSegs;
135 /** The number of segments in the segment table. */
136 RTDBGSEGIDX cSegs;
137 /** The image size. 0 means unlimited. */
138 RTUINTPTR cb;
139 /** The next symbol ordinal. */
140 uint32_t iNextSymbolOrdinal;
141 /** The next line number ordinal. */
142 uint32_t iNextLineOrdinal;
143#ifdef RTDBGMODCNT_WITH_MEM_CACHE
144 /** Line number allocator.
145 * Using a cache is a bit overkill since we normally won't free them, but
146 * it's a construct that exists and does the job relatively efficiently. */
147 RTMEMCACHE hLineNumAllocator;
148#endif
149} RTDBGMODCTN;
150/** Pointer to instance data for the debug info container. */
151typedef RTDBGMODCTN *PRTDBGMODCTN;
152
153
154
155/** @interface_method_impl{RTDBGMODVTDBG,pfnUnwindFrame} */
156static DECLCALLBACK(int)
157rtDbgModContainer_UnwindFrame(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off, PRTDBGUNWINDSTATE pState)
158{
159 RT_NOREF(pMod, iSeg, off, pState);
160 return VERR_DBG_NO_UNWIND_INFO;
161}
162
163
164/**
165 * Fills in a RTDBGSYMBOL structure.
166 *
167 * @returns VINF_SUCCESS.
168 * @param pMySym Our internal symbol representation.
169 * @param pExtSym The external symbol representation.
170 */
171DECLINLINE(int) rtDbgModContainerReturnSymbol(PCRTDBGMODCTNSYMBOL pMySym, PRTDBGSYMBOL pExtSym)
172{
173 pExtSym->Value = pMySym->AddrCore.Key;
174 pExtSym->offSeg = pMySym->AddrCore.Key;
175 pExtSym->iSeg = pMySym->iSeg;
176 pExtSym->fFlags = pMySym->fFlags;
177 pExtSym->cb = pMySym->cb;
178 pExtSym->iOrdinal = pMySym->OrdinalCore.Key;
179 Assert(pMySym->NameCore.cchString < sizeof(pExtSym->szName));
180 memcpy(pExtSym->szName, pMySym->NameCore.pszString, pMySym->NameCore.cchString + 1);
181 return VINF_SUCCESS;
182}
183
184
185
186/** @copydoc RTDBGMODVTDBG::pfnLineByAddr */
187static DECLCALLBACK(int) rtDbgModContainer_LineByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off,
188 PRTINTPTR poffDisp, PRTDBGLINE pLineInfo)
189{
190 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
191
192 /*
193 * Validate the input address.
194 */
195 AssertMsgReturn(iSeg < pThis->cSegs,
196 ("iSeg=%#x cSegs=%#x\n", iSeg, pThis->cSegs),
197 VERR_DBG_INVALID_SEGMENT_INDEX);
198 AssertMsgReturn(off < pThis->paSegs[iSeg].cb,
199 ("off=%RTptr cbSeg=%RTptr\n", off, pThis->paSegs[iSeg].cb),
200 VERR_DBG_INVALID_SEGMENT_OFFSET);
201
202 /*
203 * Lookup the nearest line number with an address less or equal to the specified address.
204 */
205 PAVLUINTPTRNODECORE pAvlCore = RTAvlUIntPtrGetBestFit(&pThis->paSegs[iSeg].LineAddrTree, off, false /*fAbove*/);
206 if (!pAvlCore)
207 return pThis->iNextLineOrdinal
208 ? VERR_DBG_LINE_NOT_FOUND
209 : VERR_DBG_NO_LINE_NUMBERS;
210 PCRTDBGMODCTNLINE pMyLine = RT_FROM_MEMBER(pAvlCore, RTDBGMODCTNLINE const, AddrCore);
211 pLineInfo->Address = pMyLine->AddrCore.Key;
212 pLineInfo->offSeg = pMyLine->AddrCore.Key;
213 pLineInfo->iSeg = iSeg;
214 pLineInfo->uLineNo = pMyLine->uLineNo;
215 pLineInfo->iOrdinal = pMyLine->OrdinalCore.Key;
216 strcpy(pLineInfo->szFilename, pMyLine->pszFile);
217 if (poffDisp)
218 *poffDisp = off - pMyLine->AddrCore.Key;
219 return VINF_SUCCESS;
220}
221
222
223/** @copydoc RTDBGMODVTDBG::pfnLineByOrdinal */
224static DECLCALLBACK(int) rtDbgModContainer_LineByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGLINE pLineInfo)
225{
226 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
227
228 /*
229 * Look it up.
230 */
231 if (iOrdinal >= pThis->iNextLineOrdinal)
232 return pThis->iNextLineOrdinal
233 ? VERR_DBG_LINE_NOT_FOUND
234 : VERR_DBG_NO_LINE_NUMBERS;
235 PAVLU32NODECORE pAvlCore = RTAvlU32Get(&pThis->LineOrdinalTree, iOrdinal);
236 AssertReturn(pAvlCore, VERR_DBG_LINE_NOT_FOUND);
237 PCRTDBGMODCTNLINE pMyLine = RT_FROM_MEMBER(pAvlCore, RTDBGMODCTNLINE const, OrdinalCore);
238 pLineInfo->Address = pMyLine->AddrCore.Key;
239 pLineInfo->offSeg = pMyLine->AddrCore.Key;
240 pLineInfo->iSeg = pMyLine->iSeg;
241 pLineInfo->uLineNo = pMyLine->uLineNo;
242 pLineInfo->iOrdinal = pMyLine->OrdinalCore.Key;
243 strcpy(pLineInfo->szFilename, pMyLine->pszFile);
244 return VINF_SUCCESS;
245}
246
247
248/** @copydoc RTDBGMODVTDBG::pfnLineCount */
249static DECLCALLBACK(uint32_t) rtDbgModContainer_LineCount(PRTDBGMODINT pMod)
250{
251 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
252
253 /* Note! The ordinal numbers are 0-based. */
254 return pThis->iNextLineOrdinal;
255}
256
257
258/** @copydoc RTDBGMODVTDBG::pfnLineAdd */
259static DECLCALLBACK(int) rtDbgModContainer_LineAdd(PRTDBGMODINT pMod, const char *pszFile, size_t cchFile, uint32_t uLineNo,
260 uint32_t iSeg, RTUINTPTR off, uint32_t *piOrdinal)
261{
262 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
263
264 /*
265 * Validate the input address.
266 */
267 AssertMsgReturn(iSeg < pThis->cSegs, ("iSeg=%#x cSegs=%#x\n", iSeg, pThis->cSegs),
268 VERR_DBG_INVALID_SEGMENT_INDEX);
269 AssertMsgReturn(off <= pThis->paSegs[iSeg].cb, ("off=%RTptr cbSeg=%RTptr\n", off, pThis->paSegs[iSeg].cb),
270 VERR_DBG_INVALID_SEGMENT_OFFSET);
271
272 /*
273 * Create a new entry.
274 */
275#ifdef RTDBGMODCNT_WITH_MEM_CACHE
276 PRTDBGMODCTNLINE pLine = (PRTDBGMODCTNLINE)RTMemCacheAlloc(pThis->hLineNumAllocator);
277#else
278 PRTDBGMODCTNLINE pLine = (PRTDBGMODCTNLINE)RTMemAllocZ(sizeof(*pLine));
279#endif
280 if (!pLine)
281 return VERR_NO_MEMORY;
282 pLine->AddrCore.Key = off;
283 pLine->OrdinalCore.Key = pThis->iNextLineOrdinal;
284 pLine->uLineNo = uLineNo;
285 pLine->iSeg = iSeg;
286 pLine->pszFile = RTStrCacheEnterN(g_hDbgModStrCache, pszFile, cchFile);
287 int rc;
288 if (pLine->pszFile)
289 {
290 if (RTAvlUIntPtrInsert(&pThis->paSegs[iSeg].LineAddrTree, &pLine->AddrCore))
291 {
292 if (RTAvlU32Insert(&pThis->LineOrdinalTree, &pLine->OrdinalCore))
293 {
294 if (piOrdinal)
295 *piOrdinal = pThis->iNextLineOrdinal;
296 pThis->iNextLineOrdinal++;
297 return VINF_SUCCESS;
298 }
299
300 rc = VERR_INTERNAL_ERROR_5;
301 RTAvlUIntPtrRemove(&pThis->paSegs[iSeg].LineAddrTree, pLine->AddrCore.Key);
302 }
303
304 /* bail out */
305 rc = VERR_DBG_ADDRESS_CONFLICT;
306 RTStrCacheRelease(g_hDbgModStrCache, pLine->pszFile);
307 }
308 else
309 rc = VERR_NO_MEMORY;
310#ifdef RTDBGMODCNT_WITH_MEM_CACHE
311 RTMemCacheFree(pThis->hLineNumAllocator, pLine);
312#else
313 RTMemFree(pLine);
314#endif
315 return rc;
316}
317
318
319/** @copydoc RTDBGMODVTDBG::pfnSymbolByAddr */
320static DECLCALLBACK(int) rtDbgModContainer_SymbolByAddr(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, RTUINTPTR off, uint32_t fFlags,
321 PRTINTPTR poffDisp, PRTDBGSYMBOL pSymInfo)
322{
323 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
324
325 /*
326 * Validate the input address.
327 */
328 AssertMsgReturn( iSeg == RTDBGSEGIDX_ABS
329 || iSeg < pThis->cSegs,
330 ("iSeg=%#x cSegs=%#x\n", iSeg, pThis->cSegs),
331 VERR_DBG_INVALID_SEGMENT_INDEX);
332 AssertMsgReturn( iSeg >= RTDBGSEGIDX_SPECIAL_FIRST
333 || off <= pThis->paSegs[iSeg].cb,
334 ("off=%RTptr cbSeg=%RTptr\n", off, pThis->paSegs[iSeg].cb),
335 VERR_DBG_INVALID_SEGMENT_OFFSET);
336
337 /*
338 * Lookup the nearest symbol with an address less or equal to the specified address.
339 */
340 PAVLRUINTPTRNODECORE pAvlCore = RTAvlrUIntPtrGetBestFit( iSeg == RTDBGSEGIDX_ABS
341 ? &pThis->AbsAddrTree
342 : &pThis->paSegs[iSeg].SymAddrTree,
343 off,
344 fFlags == RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL /*fAbove*/);
345 if (!pAvlCore)
346 return VERR_SYMBOL_NOT_FOUND;
347 PCRTDBGMODCTNSYMBOL pMySym = RT_FROM_MEMBER(pAvlCore, RTDBGMODCTNSYMBOL const, AddrCore);
348 if (poffDisp)
349 *poffDisp = off - pMySym->AddrCore.Key;
350 return rtDbgModContainerReturnSymbol(pMySym, pSymInfo);
351}
352
353
354/** @copydoc RTDBGMODVTDBG::pfnSymbolByName */
355static DECLCALLBACK(int) rtDbgModContainer_SymbolByName(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol, PRTDBGSYMBOL pSymInfo)
356{
357 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
358 NOREF(cchSymbol);
359
360 /*
361 * Look it up in the name space.
362 */
363 PRTSTRSPACECORE pStrCore = RTStrSpaceGet(&pThis->Names, pszSymbol);
364 if (!pStrCore)
365 return VERR_SYMBOL_NOT_FOUND;
366 PCRTDBGMODCTNSYMBOL pMySym = RT_FROM_MEMBER(pStrCore, RTDBGMODCTNSYMBOL const, NameCore);
367 return rtDbgModContainerReturnSymbol(pMySym, pSymInfo);
368}
369
370
371/** @copydoc RTDBGMODVTDBG::pfnSymbolByOrdinal */
372static DECLCALLBACK(int) rtDbgModContainer_SymbolByOrdinal(PRTDBGMODINT pMod, uint32_t iOrdinal, PRTDBGSYMBOL pSymInfo)
373{
374 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
375
376 /*
377 * Look it up in the ordinal tree.
378 */
379 if (iOrdinal >= pThis->iNextSymbolOrdinal)
380 return pThis->iNextSymbolOrdinal
381 ? VERR_DBG_NO_SYMBOLS
382 : VERR_SYMBOL_NOT_FOUND;
383 PAVLU32NODECORE pAvlCore = RTAvlU32Get(&pThis->SymbolOrdinalTree, iOrdinal);
384 AssertReturn(pAvlCore, VERR_SYMBOL_NOT_FOUND);
385 PCRTDBGMODCTNSYMBOL pMySym = RT_FROM_MEMBER(pAvlCore, RTDBGMODCTNSYMBOL const, OrdinalCore);
386 return rtDbgModContainerReturnSymbol(pMySym, pSymInfo);
387}
388
389
390/** @copydoc RTDBGMODVTDBG::pfnSymbolCount */
391static DECLCALLBACK(uint32_t) rtDbgModContainer_SymbolCount(PRTDBGMODINT pMod)
392{
393 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
394
395 /* Note! The ordinal numbers are 0-based. */
396 return pThis->iNextSymbolOrdinal;
397}
398
399
400/**
401 * Worker for rtDbgModContainer_SymbolAdd that removes a symbol to resolve
402 * address conflicts.
403 *
404 * We don't shift ordinals up as that could be very expensive, instead we move
405 * the last one up to take the place of the one we're removing. Caller must
406 * take this into account.
407 *
408 * @param pThis The container.
409 * @param pAddrTree The address tree to remove from.
410 * @param pToRemove The conflicting symbol to be removed.
411 */
412static void rtDbgModContainer_SymbolReplace(PRTDBGMODCTN pThis, PAVLRUINTPTRTREE pAddrTree, PRTDBGMODCTNSYMBOL pToRemove)
413{
414 RTLogPrintf("rtDbgModContainer_SymbolReplace: pToRemove=%p ordinal=%u %04x:%08RX64 %s\n",
415 pToRemove, pToRemove->OrdinalCore.Key, pToRemove->iSeg, pToRemove->AddrCore.Key, pToRemove->NameCore.pszString);
416
417 /* Unlink it. */
418 PRTSTRSPACECORE pRemovedName = RTStrSpaceRemove(&pThis->Names, pToRemove->NameCore.pszString);
419 Assert(pRemovedName); RT_NOREF_PV(pRemovedName);
420 pToRemove->NameCore.pszString = NULL;
421
422 PAVLRUINTPTRNODECORE pRemovedAddr = RTAvlrUIntPtrRemove(pAddrTree, pToRemove->AddrCore.Key);
423 Assert(pRemovedAddr); RT_NOREF_PV(pRemovedAddr);
424 pToRemove->AddrCore.Key = 0;
425 pToRemove->AddrCore.KeyLast = 0;
426
427 uint32_t const iOrdinal = pToRemove->OrdinalCore.Key;
428 PAVLU32NODECORE pRemovedOrdinal = RTAvlU32Remove(&pThis->SymbolOrdinalTree, iOrdinal);
429 Assert(pRemovedOrdinal); RT_NOREF_PV(pRemovedOrdinal);
430
431 RTMemFree(pToRemove);
432
433 /* Jump the last symbol ordinal to take its place, unless pToRemove is the last one. */
434 if (iOrdinal >= pThis->iNextSymbolOrdinal - 1)
435 pThis->iNextSymbolOrdinal -= 1;
436 else
437 {
438 PAVLU32NODECORE pLastOrdinal = RTAvlU32Remove(&pThis->SymbolOrdinalTree, pThis->iNextSymbolOrdinal - 1);
439 AssertReturnVoid(pLastOrdinal);
440
441 pThis->iNextSymbolOrdinal -= 1;
442 pLastOrdinal->Key = iOrdinal;
443 bool fInsert = RTAvlU32Insert(&pThis->SymbolOrdinalTree, pLastOrdinal);
444 Assert(fInsert); RT_NOREF_PV(fInsert);
445 }
446}
447
448
449/** @copydoc RTDBGMODVTDBG::pfnSymbolAdd */
450static DECLCALLBACK(int) rtDbgModContainer_SymbolAdd(PRTDBGMODINT pMod, const char *pszSymbol, size_t cchSymbol,
451 RTDBGSEGIDX iSeg, RTUINTPTR off, RTUINTPTR cb, uint32_t fFlags,
452 uint32_t *piOrdinal)
453{
454 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
455
456 /*
457 * Address validation. The other arguments have already been validated.
458 */
459 AssertMsgReturn( iSeg == RTDBGSEGIDX_ABS
460 || iSeg < pThis->cSegs,
461 ("iSeg=%#x cSegs=%#x\n", iSeg, pThis->cSegs),
462 VERR_DBG_INVALID_SEGMENT_INDEX);
463 AssertMsgReturn( iSeg >= RTDBGSEGIDX_SPECIAL_FIRST
464 || off <= pThis->paSegs[iSeg].cb,
465 ("off=%RTptr cb=%RTptr cbSeg=%RTptr\n", off, cb, pThis->paSegs[iSeg].cb),
466 VERR_DBG_INVALID_SEGMENT_OFFSET);
467
468 /* Be a little relaxed wrt to the symbol size. */
469 int rc = VINF_SUCCESS;
470 if (iSeg != RTDBGSEGIDX_ABS && off + cb > pThis->paSegs[iSeg].cb)
471 {
472 cb = pThis->paSegs[iSeg].cb - off;
473 rc = VINF_DBG_ADJUSTED_SYM_SIZE;
474 }
475
476 /*
477 * Create a new entry.
478 */
479 PRTDBGMODCTNSYMBOL pSymbol = (PRTDBGMODCTNSYMBOL)RTMemAllocZ(sizeof(*pSymbol));
480 if (!pSymbol)
481 return VERR_NO_MEMORY;
482
483 pSymbol->AddrCore.Key = off;
484 pSymbol->AddrCore.KeyLast = off + (cb ? cb - 1 : 0);
485 pSymbol->OrdinalCore.Key = pThis->iNextSymbolOrdinal;
486 pSymbol->iSeg = iSeg;
487 pSymbol->cb = cb;
488 pSymbol->fFlags = fFlags;
489 pSymbol->NameCore.pszString = RTStrCacheEnterN(g_hDbgModStrCache, pszSymbol, cchSymbol);
490 if (pSymbol->NameCore.pszString)
491 {
492 if (RTStrSpaceInsert(&pThis->Names, &pSymbol->NameCore))
493 {
494 PAVLRUINTPTRTREE pAddrTree = iSeg == RTDBGSEGIDX_ABS
495 ? &pThis->AbsAddrTree
496 : &pThis->paSegs[iSeg].SymAddrTree;
497 if (RTAvlrUIntPtrInsert(pAddrTree, &pSymbol->AddrCore))
498 {
499 if (RTAvlU32Insert(&pThis->SymbolOrdinalTree, &pSymbol->OrdinalCore))
500 {
501 /*
502 * Success.
503 */
504 if (piOrdinal)
505 *piOrdinal = pThis->iNextSymbolOrdinal;
506 RTLogPrintf("rtDbgModContainer_SymbolAdd: ordinal=%u %04x:%08RX64 LB %#RX64 %s\n",
507 pThis->iNextSymbolOrdinal, iSeg, off, cb, pSymbol->NameCore.pszString);
508 pThis->iNextSymbolOrdinal++;
509 return rc;
510 }
511
512 /* bail out */
513 rc = VERR_INTERNAL_ERROR_5;
514 RTAvlrUIntPtrRemove(pAddrTree, pSymbol->AddrCore.Key);
515 }
516 /*
517 * Did the caller specify a conflict resolution method?
518 */
519 else if (fFlags & ( RTDBGSYMBOLADD_F_REPLACE_SAME_ADDR
520 | RTDBGSYMBOLADD_F_REPLACE_ANY
521 | RTDBGSYMBOLADD_F_ADJUST_SIZES_ON_CONFLICT))
522 {
523 /*
524 * Handle anything at or before the start address first:
525 */
526 AssertCompileMemberOffset(RTDBGMODCTNSYMBOL, AddrCore, 0);
527 PRTDBGMODCTNSYMBOL pConflict = (PRTDBGMODCTNSYMBOL)RTAvlrUIntPtrRangeGet(pAddrTree, pSymbol->AddrCore.Key);
528 if (pConflict)
529 {
530 if (pConflict->AddrCore.Key == pSymbol->AddrCore.Key)
531 {
532 /* Same address, only option is replacing it. */
533 if (fFlags & (RTDBGSYMBOLADD_F_REPLACE_SAME_ADDR | RTDBGSYMBOLADD_F_REPLACE_ANY))
534 rtDbgModContainer_SymbolReplace(pThis, pAddrTree, pConflict);
535 else
536 rc = VERR_DBG_ADDRESS_CONFLICT;
537 }
538 else if (fFlags & RTDBGSYMBOLADD_F_ADJUST_SIZES_ON_CONFLICT)
539 {
540 /* Reduce the size of the symbol before us, adopting the size if we've got none. */
541 Assert(pConflict->AddrCore.Key < pSymbol->AddrCore.Key);
542 if (!pSymbol->cb)
543 {
544 pSymbol->AddrCore.KeyLast = pSymbol->AddrCore.KeyLast;
545 pSymbol->cb = pSymbol->AddrCore.KeyLast - pConflict->AddrCore.Key + 1;
546 rc = VINF_DBG_ADJUSTED_SYM_SIZE;
547 }
548 pConflict->AddrCore.KeyLast = pSymbol->AddrCore.Key - 1;
549 pConflict->cb = pSymbol->AddrCore.Key - pConflict->AddrCore.Key;
550 }
551 else if (fFlags & RTDBGSYMBOLADD_F_REPLACE_ANY)
552 rtDbgModContainer_SymbolReplace(pThis, pAddrTree, pConflict);
553 else
554 rc = VERR_DBG_ADDRESS_CONFLICT;
555 }
556
557 /*
558 * Try insert again and deal with symbols in the range.
559 */
560 while (RT_SUCCESS(rc))
561 {
562 if (RTAvlrUIntPtrInsert(pAddrTree, &pSymbol->AddrCore))
563 {
564 pSymbol->OrdinalCore.Key = pThis->iNextSymbolOrdinal;
565 if (RTAvlU32Insert(&pThis->SymbolOrdinalTree, &pSymbol->OrdinalCore))
566 {
567 /*
568 * Success.
569 */
570 if (piOrdinal)
571 *piOrdinal = pThis->iNextSymbolOrdinal;
572 pThis->iNextSymbolOrdinal++;
573 RTLogPrintf("rtDbgModContainer_SymbolAdd: ordinal=%u %04x:%08RX64 LB %#RX64 %s [replace codepath]\n",
574 pThis->iNextSymbolOrdinal, iSeg, off, cb, pSymbol->NameCore.pszString);
575 return rc;
576 }
577
578 rc = VERR_INTERNAL_ERROR_5;
579 RTAvlrUIntPtrRemove(pAddrTree, pSymbol->AddrCore.Key);
580 break;
581 }
582
583 /* Get the first symbol above us and see if we can do anything about it (or ourselves). */
584 AssertCompileMemberOffset(RTDBGMODCTNSYMBOL, AddrCore, 0);
585 pConflict = (PRTDBGMODCTNSYMBOL)RTAvlrUIntPtrGetBestFit(pAddrTree, pSymbol->AddrCore.Key, true /*fAbove*/);
586 AssertBreakStmt(pConflict, rc = VERR_DBG_ADDRESS_CONFLICT);
587 Assert(pSymbol->AddrCore.Key != pConflict->AddrCore.Key);
588 Assert(pSymbol->AddrCore.KeyLast >= pConflict->AddrCore.Key);
589
590 if (fFlags & RTDBGSYMBOLADD_F_ADJUST_SIZES_ON_CONFLICT)
591 {
592 Assert(pSymbol->cb > 0);
593 pSymbol->AddrCore.Key = pConflict->AddrCore.Key - 1;
594 pSymbol->cb = pConflict->AddrCore.Key - pSymbol->AddrCore.Key;
595 rc = VINF_DBG_ADJUSTED_SYM_SIZE;
596 }
597 else if (fFlags & RTDBGSYMBOLADD_F_REPLACE_ANY)
598 rtDbgModContainer_SymbolReplace(pThis, pAddrTree, pConflict);
599 else
600 rc = VERR_DBG_ADDRESS_CONFLICT;
601 }
602 }
603 else
604 rc = VERR_DBG_ADDRESS_CONFLICT;
605 RTStrSpaceRemove(&pThis->Names, pSymbol->NameCore.pszString);
606 }
607 else
608 rc = VERR_DBG_DUPLICATE_SYMBOL;
609 RTStrCacheRelease(g_hDbgModStrCache, pSymbol->NameCore.pszString);
610 }
611 else
612 rc = VERR_NO_MEMORY;
613 RTMemFree(pSymbol);
614 return rc;
615}
616
617
618/** @copydoc RTDBGMODVTDBG::pfnSegmentByIndex */
619static DECLCALLBACK(int) rtDbgModContainer_SegmentByIndex(PRTDBGMODINT pMod, RTDBGSEGIDX iSeg, PRTDBGSEGMENT pSegInfo)
620{
621 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
622 if (iSeg >= pThis->cSegs)
623 return VERR_DBG_INVALID_SEGMENT_INDEX;
624 pSegInfo->Address = RTUINTPTR_MAX;
625 pSegInfo->uRva = pThis->paSegs[iSeg].off;
626 pSegInfo->cb = pThis->paSegs[iSeg].cb;
627 pSegInfo->fFlags = pThis->paSegs[iSeg].fFlags;
628 pSegInfo->iSeg = iSeg;
629 strcpy(pSegInfo->szName, pThis->paSegs[iSeg].pszName);
630 return VINF_SUCCESS;
631}
632
633
634/** @copydoc RTDBGMODVTDBG::pfnSegmentCount */
635static DECLCALLBACK(RTDBGSEGIDX) rtDbgModContainer_SegmentCount(PRTDBGMODINT pMod)
636{
637 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
638 return pThis->cSegs;
639}
640
641
642/** @copydoc RTDBGMODVTDBG::pfnSegmentAdd */
643static DECLCALLBACK(int) rtDbgModContainer_SegmentAdd(PRTDBGMODINT pMod, RTUINTPTR uRva, RTUINTPTR cb, const char *pszName, size_t cchName,
644 uint32_t fFlags, PRTDBGSEGIDX piSeg)
645{
646 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
647
648 /*
649 * Input validation (the bits the caller cannot do).
650 */
651 /* Overlapping segments are not yet supported. Will use flags to deal with it if it becomes necessary. */
652 RTUINTPTR uRvaLast = uRva + RT_MAX(cb, 1) - 1;
653 RTUINTPTR uRvaLastMax = uRvaLast;
654 RTDBGSEGIDX iSeg = pThis->cSegs;
655 while (iSeg-- > 0)
656 {
657 RTUINTPTR uCurRva = pThis->paSegs[iSeg].off;
658 RTUINTPTR uCurRvaLast = uCurRva + RT_MAX(pThis->paSegs[iSeg].cb, 1) - 1;
659 if ( uRva <= uCurRvaLast
660 && uRvaLast >= uCurRva
661 && ( /* HACK ALERT! Allow empty segments to share space (bios/watcom, elf). */
662 (cb != 0 && pThis->paSegs[iSeg].cb != 0)
663 || ( cb == 0
664 && uRva != uCurRva
665 && uRva != uCurRvaLast)
666 || ( pThis->paSegs[iSeg].cb == 0
667 && uCurRva != uRva
668 && uCurRva != uRvaLast)
669 )
670 )
671 AssertMsgFailedReturn(("uRva=%RTptr uRvaLast=%RTptr (cb=%RTptr) \"%s\";\n"
672 "uRva=%RTptr uRvaLast=%RTptr (cb=%RTptr) \"%s\" iSeg=%#x\n",
673 uRva, uRvaLast, cb, pszName,
674 uCurRva, uCurRvaLast, pThis->paSegs[iSeg].cb, pThis->paSegs[iSeg].pszName, iSeg),
675 VERR_DBG_SEGMENT_INDEX_CONFLICT);
676 if (uRvaLastMax < uCurRvaLast)
677 uRvaLastMax = uCurRvaLast;
678 }
679 /* Strict ordered segment addition at the moment. */
680 iSeg = pThis->cSegs;
681 AssertMsgReturn(!piSeg || *piSeg == NIL_RTDBGSEGIDX || *piSeg == iSeg,
682 ("iSeg=%#x *piSeg=%#x\n", iSeg, *piSeg),
683 VERR_DBG_INVALID_SEGMENT_INDEX);
684
685 /*
686 * Add an entry to the segment table, extending it if necessary.
687 */
688 if (!(iSeg % 8))
689 {
690 void *pvSegs = RTMemRealloc(pThis->paSegs, sizeof(RTDBGMODCTNSEGMENT) * (iSeg + 8));
691 if (!pvSegs)
692 return VERR_NO_MEMORY;
693 pThis->paSegs = (PRTDBGMODCTNSEGMENT)pvSegs;
694 }
695
696 pThis->paSegs[iSeg].SymAddrTree = NULL;
697 pThis->paSegs[iSeg].LineAddrTree = NULL;
698 pThis->paSegs[iSeg].off = uRva;
699 pThis->paSegs[iSeg].cb = cb;
700 pThis->paSegs[iSeg].fFlags = fFlags;
701 pThis->paSegs[iSeg].pszName = RTStrCacheEnterN(g_hDbgModStrCache, pszName, cchName);
702 if (pThis->paSegs[iSeg].pszName)
703 {
704 if (piSeg)
705 *piSeg = iSeg;
706 pThis->cSegs++;
707 pThis->cb = uRvaLastMax + 1;
708 if (!pThis->cb)
709 pThis->cb = RTUINTPTR_MAX;
710 return VINF_SUCCESS;
711 }
712 return VERR_NO_MEMORY;
713}
714
715
716/** @copydoc RTDBGMODVTDBG::pfnImageSize */
717static DECLCALLBACK(RTUINTPTR) rtDbgModContainer_ImageSize(PRTDBGMODINT pMod)
718{
719 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
720 return pThis->cb;
721}
722
723
724/** @copydoc RTDBGMODVTDBG::pfnRvaToSegOff */
725static DECLCALLBACK(RTDBGSEGIDX) rtDbgModContainer_RvaToSegOff(PRTDBGMODINT pMod, RTUINTPTR uRva, PRTUINTPTR poffSeg)
726{
727 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
728 PCRTDBGMODCTNSEGMENT paSeg = pThis->paSegs;
729 uint32_t const cSegs = pThis->cSegs;
730#if 0
731 if (cSegs <= 7)
732#endif
733 {
734 /*
735 * Linear search.
736 */
737 for (uint32_t iSeg = 0; iSeg < cSegs; iSeg++)
738 {
739 RTUINTPTR offSeg = uRva - paSeg[iSeg].off;
740 if (offSeg < paSeg[iSeg].cb)
741 {
742 if (poffSeg)
743 *poffSeg = offSeg;
744 return iSeg;
745 }
746 }
747 }
748#if 0 /** @todo binary search doesn't work if we've got empty segments in the list */
749 else
750 {
751 /*
752 * Binary search.
753 */
754 uint32_t iFirst = 0;
755 uint32_t iLast = cSegs - 1;
756 for (;;)
757 {
758 uint32_t iSeg = iFirst + (iLast - iFirst) / 2;
759 RTUINTPTR offSeg = uRva - paSeg[iSeg].off;
760 if (offSeg < paSeg[iSeg].cb)
761 {
762#if 0 /* Enable if we change the above test. */
763 if (offSeg == 0 && paSeg[iSeg].cb == 0)
764 while ( iSeg > 0
765 && paSeg[iSeg - 1].cb == 0
766 && paSeg[iSeg - 1].off == uRva)
767 iSeg--;
768#endif
769
770 if (poffSeg)
771 *poffSeg = offSeg;
772 return iSeg;
773 }
774
775 /* advance */
776 if (uRva < paSeg[iSeg].off)
777 {
778 /* between iFirst and iSeg. */
779 if (iSeg == iFirst)
780 break;
781 iLast = iSeg - 1;
782 }
783 else
784 {
785 /* between iSeg and iLast. paSeg[iSeg].cb == 0 ends up here too. */
786 if (iSeg == iLast)
787 break;
788 iFirst = iSeg + 1;
789 }
790 }
791 }
792#endif
793
794 /* Invalid. */
795 return NIL_RTDBGSEGIDX;
796}
797
798
799/** Destroy a line number node. */
800static DECLCALLBACK(int) rtDbgModContainer_DestroyTreeLineNode(PAVLU32NODECORE pNode, void *pvUser)
801{
802 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pvUser;
803 PRTDBGMODCTNLINE pLine = RT_FROM_MEMBER(pNode, RTDBGMODCTNLINE, OrdinalCore);
804 RTStrCacheRelease(g_hDbgModStrCache, pLine->pszFile);
805 pLine->pszFile = NULL;
806#ifdef RTDBGMODCNT_WITH_MEM_CACHE
807 RTMemCacheFree(pThis->hLineNumAllocator, pLine);
808#else
809 RTMemFree(pLine); NOREF(pThis);
810#endif
811 return 0;
812}
813
814
815/** Destroy a symbol node. */
816static DECLCALLBACK(int) rtDbgModContainer_DestroyTreeNode(PAVLRUINTPTRNODECORE pNode, void *pvUser)
817{
818 PRTDBGMODCTNSYMBOL pSym = RT_FROM_MEMBER(pNode, RTDBGMODCTNSYMBOL, AddrCore);
819 RTStrCacheRelease(g_hDbgModStrCache, pSym->NameCore.pszString);
820 pSym->NameCore.pszString = NULL;
821
822#if 0
823 //PRTDBGMODCTN pThis = (PRTDBGMODCTN)pvUser;
824 //PAVLU32NODECORE pRemoved = RTAvlU32Remove(&pThis->SymbolOrdinalTree, pSym->OrdinalCore.Key);
825 //Assert(pRemoved == &pSym->OrdinalCore); RT_NOREF_PV(pRemoved);
826#else
827 RT_NOREF_PV(pvUser);
828#endif
829
830 RTMemFree(pSym);
831 return 0;
832}
833
834
835/** @copydoc RTDBGMODVTDBG::pfnClose */
836static DECLCALLBACK(int) rtDbgModContainer_Close(PRTDBGMODINT pMod)
837{
838 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
839
840 /*
841 * Destroy the symbols and instance data.
842 */
843 for (uint32_t iSeg = 0; iSeg < pThis->cSegs; iSeg++)
844 {
845 RTAvlrUIntPtrDestroy(&pThis->paSegs[iSeg].SymAddrTree, rtDbgModContainer_DestroyTreeNode, pThis);
846 RTStrCacheRelease(g_hDbgModStrCache, pThis->paSegs[iSeg].pszName);
847 pThis->paSegs[iSeg].pszName = NULL;
848 }
849
850 RTAvlrUIntPtrDestroy(&pThis->AbsAddrTree, rtDbgModContainer_DestroyTreeNode, pThis);
851
852 pThis->Names = NULL;
853
854#ifdef RTDBGMODCNT_WITH_MEM_CACHE
855 RTMemCacheDestroy(pThis->hLineNumAllocator);
856 pThis->hLineNumAllocator = NIL_RTMEMCACHE;
857#else
858 RTAvlU32Destroy(&pThis->LineOrdinalTree, rtDbgModContainer_DestroyTreeLineNode, pThis);
859#endif
860
861 RTMemFree(pThis->paSegs);
862 pThis->paSegs = NULL;
863
864 RTMemFree(pThis);
865
866 return VINF_SUCCESS;
867}
868
869
870/** @copydoc RTDBGMODVTDBG::pfnTryOpen */
871static DECLCALLBACK(int) rtDbgModContainer_TryOpen(PRTDBGMODINT pMod, RTLDRARCH enmArch)
872{
873 NOREF(pMod); NOREF(enmArch);
874 return VERR_INTERNAL_ERROR_5;
875}
876
877
878
879/** Virtual function table for the debug info container. */
880DECL_HIDDEN_CONST(RTDBGMODVTDBG) const g_rtDbgModVtDbgContainer =
881{
882 /*.u32Magic = */ RTDBGMODVTDBG_MAGIC,
883 /*.fSupports = */ 0, /* (Don't call my TryOpen, please.) */
884 /*.pszName = */ "container",
885 /*.pfnTryOpen = */ rtDbgModContainer_TryOpen,
886 /*.pfnClose = */ rtDbgModContainer_Close,
887
888 /*.pfnRvaToSegOff = */ rtDbgModContainer_RvaToSegOff,
889 /*.pfnImageSize = */ rtDbgModContainer_ImageSize,
890
891 /*.pfnSegmentAdd = */ rtDbgModContainer_SegmentAdd,
892 /*.pfnSegmentCount = */ rtDbgModContainer_SegmentCount,
893 /*.pfnSegmentByIndex = */ rtDbgModContainer_SegmentByIndex,
894
895 /*.pfnSymbolAdd = */ rtDbgModContainer_SymbolAdd,
896 /*.pfnSymbolCount = */ rtDbgModContainer_SymbolCount,
897 /*.pfnSymbolByOrdinal = */ rtDbgModContainer_SymbolByOrdinal,
898 /*.pfnSymbolByName = */ rtDbgModContainer_SymbolByName,
899 /*.pfnSymbolByAddr = */ rtDbgModContainer_SymbolByAddr,
900
901 /*.pfnLineAdd = */ rtDbgModContainer_LineAdd,
902 /*.pfnLineCount = */ rtDbgModContainer_LineCount,
903 /*.pfnLineByOrdinal = */ rtDbgModContainer_LineByOrdinal,
904 /*.pfnLineByAddr = */ rtDbgModContainer_LineByAddr,
905
906 /*.pfnUnwindFrame = */ rtDbgModContainer_UnwindFrame,
907
908 /*.u32EndMagic = */ RTDBGMODVTDBG_MAGIC
909};
910
911
912
913/**
914 * Special container operation for removing all symbols.
915 *
916 * @returns IPRT status code.
917 * @param pMod The module instance.
918 */
919DECLHIDDEN(int) rtDbgModContainer_SymbolRemoveAll(PRTDBGMODINT pMod)
920{
921 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
922
923 for (uint32_t iSeg = 0; iSeg < pThis->cSegs; iSeg++)
924 {
925 RTAvlrUIntPtrDestroy(&pThis->paSegs[iSeg].SymAddrTree, rtDbgModContainer_DestroyTreeNode, NULL);
926 Assert(pThis->paSegs[iSeg].SymAddrTree == NULL);
927 }
928
929 RTAvlrUIntPtrDestroy(&pThis->AbsAddrTree, rtDbgModContainer_DestroyTreeNode, NULL);
930 Assert(pThis->AbsAddrTree == NULL);
931
932 pThis->Names = NULL;
933 pThis->iNextSymbolOrdinal = 0;
934
935 return VINF_SUCCESS;
936}
937
938
939/**
940 * Special container operation for removing all line numbers.
941 *
942 * @returns IPRT status code.
943 * @param pMod The module instance.
944 */
945DECLHIDDEN(int) rtDbgModContainer_LineRemoveAll(PRTDBGMODINT pMod)
946{
947 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
948
949 for (uint32_t iSeg = 0; iSeg < pThis->cSegs; iSeg++)
950 pThis->paSegs[iSeg].LineAddrTree = NULL;
951
952 RTAvlU32Destroy(&pThis->LineOrdinalTree, rtDbgModContainer_DestroyTreeLineNode, pThis);
953 Assert(pThis->LineOrdinalTree == NULL);
954
955 pThis->iNextLineOrdinal = 0;
956
957 return VINF_SUCCESS;
958}
959
960
961/**
962 * Special container operation for removing everything.
963 *
964 * @returns IPRT status code.
965 * @param pMod The module instance.
966 */
967DECLHIDDEN(int) rtDbgModContainer_RemoveAll(PRTDBGMODINT pMod)
968{
969 PRTDBGMODCTN pThis = (PRTDBGMODCTN)pMod->pvDbgPriv;
970
971 rtDbgModContainer_LineRemoveAll(pMod);
972 rtDbgModContainer_SymbolRemoveAll(pMod);
973
974 for (uint32_t iSeg = 0; iSeg < pThis->cSegs; iSeg++)
975 {
976 RTStrCacheRelease(g_hDbgModStrCache, pThis->paSegs[iSeg].pszName);
977 pThis->paSegs[iSeg].pszName = NULL;
978 }
979
980 pThis->cSegs = 0;
981 pThis->cb = 0;
982
983 return VINF_SUCCESS;
984}
985
986
987/**
988 * Creates a generic debug info container and associates it with the module.
989 *
990 * @returns IPRT status code.
991 * @param pMod The module instance.
992 * @param cbSeg The size of the initial segment. 0 if segments are to be
993 * created manually later on.
994 */
995int rtDbgModContainerCreate(PRTDBGMODINT pMod, RTUINTPTR cbSeg)
996{
997 PRTDBGMODCTN pThis = (PRTDBGMODCTN)RTMemAlloc(sizeof(*pThis));
998 if (!pThis)
999 return VERR_NO_MEMORY;
1000
1001 pThis->Names = NULL;
1002 pThis->AbsAddrTree = NULL;
1003 pThis->SymbolOrdinalTree = NULL;
1004 pThis->LineOrdinalTree = NULL;
1005 pThis->paSegs = NULL;
1006 pThis->cSegs = 0;
1007 pThis->cb = 0;
1008 pThis->iNextSymbolOrdinal = 0;
1009 pThis->iNextLineOrdinal = 0;
1010
1011 pMod->pDbgVt = &g_rtDbgModVtDbgContainer;
1012 pMod->pvDbgPriv = pThis;
1013
1014#ifdef RTDBGMODCNT_WITH_MEM_CACHE
1015 int rc = RTMemCacheCreate(&pThis->hLineNumAllocator, sizeof(RTDBGMODCTNLINE), sizeof(void *), UINT32_MAX,
1016 NULL /*pfnCtor*/, NULL /*pfnDtor*/, NULL /*pvUser*/, 0 /*fFlags*/);
1017#else
1018 int rc = VINF_SUCCESS;
1019#endif
1020 if (RT_SUCCESS(rc))
1021 {
1022 /*
1023 * Add the initial segment.
1024 */
1025 if (cbSeg)
1026 rc = rtDbgModContainer_SegmentAdd(pMod, 0, cbSeg, "default", sizeof("default") - 1, 0, NULL);
1027 if (RT_SUCCESS(rc))
1028 return rc;
1029
1030#ifdef RTDBGMODCNT_WITH_MEM_CACHE
1031 RTMemCacheDestroy(pThis->hLineNumAllocator);
1032#endif
1033 }
1034
1035 RTMemFree(pThis);
1036 pMod->pDbgVt = NULL;
1037 pMod->pvDbgPriv = NULL;
1038 return rc;
1039}
1040
Note: See TracBrowser for help on using the repository browser.

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