[3528] | 1 | /* $Id: kDbgLine.cpp 3528 2007-08-20 02:43:13Z bird $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * kDbg - The Debug Info Read, Line Numbers.
|
---|
| 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 | /**
|
---|
| 37 | * Duplicates a line number.
|
---|
| 38 | *
|
---|
| 39 | * To save heap space, the returned line number will not own more heap space
|
---|
| 40 | * than it strictly need to. So, it's not possible to append stuff to the symbol
|
---|
| 41 | * or anything of that kind.
|
---|
| 42 | *
|
---|
| 43 | * @returns Pointer to the duplicate.
|
---|
| 44 | * This must be freed using kDbgSymbolFree().
|
---|
| 45 | * @param pLine The line number to be duplicated.
|
---|
| 46 | */
|
---|
| 47 | KDBG_DECL(PKDBGLINE) kDbgLineDup(PCKDBGLINE pLine)
|
---|
| 48 | {
|
---|
| 49 | kDbgAssertMsgReturn(KDBG_VALID_PTR(pLine), ("%p\n", pLine), NULL);
|
---|
| 50 | size_t cb = KDBG_OFFSETOF(KDBGLINE, szFile[pLine->cchFile + 1]);
|
---|
| 51 | return (PKDBGLINE)kDbgHlpAllocDup(pLine, cb);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | /**
|
---|
| 56 | * Frees a line number obtained from the RTDbg API.
|
---|
| 57 | *
|
---|
| 58 | * @returns 0 on success.
|
---|
| 59 | * @returns KDBG_ERR_INVALID_POINTER if a NULL pointer or an !KDBG_VALID_PTR() is passed in.
|
---|
| 60 | *
|
---|
| 61 | * @param pLine The line number to be freed.
|
---|
| 62 | */
|
---|
| 63 | KDBG_DECL(int) kDbgLineFree(PKDBGLINE pLine)
|
---|
| 64 | {
|
---|
| 65 | if (!pLine)
|
---|
| 66 | return KDBG_ERR_INVALID_POINTER;
|
---|
| 67 | kDbgAssertMsgReturn(KDBG_VALID_PTR(pLine), ("%p\n", pLine), KDBG_ERR_INVALID_POINTER);
|
---|
| 68 |
|
---|
| 69 | kDbgHlpFree(pLine);
|
---|
| 70 | return 0;
|
---|
| 71 | }
|
---|
| 72 |
|
---|