[3528] | 1 | /* $Id: kDbgSymbol.cpp 3528 2007-08-20 02:43:13Z bird $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * kDbg - The Debug Info Reader, Symbols.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
| 7 | * Copyright (c) 2006-2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
---|
| 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 "kDbg.h"
|
---|
| 32 | #include "kDbgInternal.h"
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | /**
|
---|
| 36 | * Duplicates a symbol.
|
---|
| 37 | *
|
---|
| 38 | * To save heap space, the returned symbol will not own more heap space than
|
---|
| 39 | * it strictly need to. So, it's not possible to append stuff to the symbol
|
---|
| 40 | * or anything of that kind.
|
---|
| 41 | *
|
---|
| 42 | * @returns Pointer to the duplicate.
|
---|
| 43 | * This must be freed using kDbgSymbolFree().
|
---|
| 44 | * @param pSymbol The symbol to be duplicated.
|
---|
| 45 | */
|
---|
| 46 | KDBG_DECL(PKDBGSYMBOL) kDbgSymbolDup(PCKDBGSYMBOL pSymbol)
|
---|
| 47 | {
|
---|
| 48 | kDbgAssertPtrReturn(pSymbol, NULL);
|
---|
| 49 | size_t cb = KDBG_OFFSETOF(KDBGSYMBOL, szName[pSymbol->cchName + 1]);
|
---|
| 50 | return (PKDBGSYMBOL)kDbgHlpAllocDup(pSymbol, cb);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | /**
|
---|
| 55 | * Frees a symbol obtained from the RTDbg API.
|
---|
| 56 | *
|
---|
| 57 | * @returns 0 on success.
|
---|
| 58 | * @returns KDBG_ERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in.
|
---|
| 59 | *
|
---|
| 60 | * @param pSymbol The symbol to be freed.
|
---|
| 61 | */
|
---|
| 62 | KDBG_DECL(int) kDbgSymbolFree(PKDBGSYMBOL pSymbol)
|
---|
| 63 | {
|
---|
| 64 | if (!pSymbol)
|
---|
| 65 | return KDBG_ERR_INVALID_POINTER;
|
---|
| 66 | kDbgAssertPtrReturn(pSymbol, KDBG_ERR_INVALID_POINTER);
|
---|
| 67 |
|
---|
| 68 | kDbgHlpFree(pSymbol);
|
---|
| 69 | return 0;
|
---|
| 70 | }
|
---|
| 71 |
|
---|