1 | /* $Id: $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * kProfile Mark 2 - Debug Info Symbol.
|
---|
5 | *
|
---|
6 | * Copyright (c) 2006 knut st. osmundsen <bird-src-spam@anduin.net.de>
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * This file is part of kLIBC.
|
---|
10 | *
|
---|
11 | * kLIBC is free software; you can redistribute it and/or modify
|
---|
12 | * it under the terms of the GNU General Public License as published by
|
---|
13 | * the Free Software Foundation; either version 2 of the License, or
|
---|
14 | * (at your option) any later version.
|
---|
15 | *
|
---|
16 | * kLIBC is distributed in the hope that it will be useful,
|
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | * GNU General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with kLIBC; if not, write to the Free Software
|
---|
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
24 | *
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*******************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *******************************************************************************/
|
---|
31 | #include <iprt/err.h>
|
---|
32 | #include <iprt/assert.h>
|
---|
33 | #include <iprt/alloc.h>
|
---|
34 |
|
---|
35 | #include "dbg.h"
|
---|
36 |
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Duplicates a symbol.
|
---|
40 | *
|
---|
41 | * To save heap space, the returned symbol will not own more heap space than
|
---|
42 | * it strictly need to. So, it's not possible to append stuff to the symbol
|
---|
43 | * or anything of that kind.
|
---|
44 | *
|
---|
45 | * @returns Pointer to the duplicate.
|
---|
46 | * This must be freed using RTDbgSymbolFree().
|
---|
47 | * @param pSymbol The symbol to be duplicated.
|
---|
48 | */
|
---|
49 | RTDECL(PRTDBGSYMBOL) RTDbgSymbolDup(PCRTDBGSYMBOL pSymbol)
|
---|
50 | {
|
---|
51 | AssertMsgReturn(VALID_PTR(pSymbol), ("%p\n", pSymbol), NULL);
|
---|
52 | size_t cb = OFFSETOF(RTDBGSYMBOL, szName[pSymbol->cchName + 1]);
|
---|
53 | return (PRTDBGSYMBOL)RTMemDup(pSymbol, cb);
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Frees a symbol obtained from the RTDbg API.
|
---|
59 | *
|
---|
60 | * @returns VINF_SUCCESS on success.
|
---|
61 | * @returns VERR_INVALID_POINTER if a NULL pointer or an !VALID_PTR() is passed in.
|
---|
62 | *
|
---|
63 | * @param pSymbol The symbol to be freed.
|
---|
64 | */
|
---|
65 | RTDECL(int) RTDbgSymbolFree(PRTDBGSYMBOL pSymbol)
|
---|
66 | {
|
---|
67 | if (!pSymbol)
|
---|
68 | return VERR_INVALID_POINTER;
|
---|
69 | AssertMsgReturn(VALID_PTR(pSymbol), ("%p\n", pSymbol), VERR_INVALID_POINTER);
|
---|
70 |
|
---|
71 | RTMemFree(pSymbol);
|
---|
72 | return VINF_SUCCESS;
|
---|
73 | }
|
---|
74 |
|
---|