[3524] | 1 | /* $Id: $ */
|
---|
| 2 | /** @file
|
---|
| 3 | *
|
---|
| 4 | * kProfile Mark 2 - Debug Info Line Number.
|
---|
| 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"
|
---|
[3526] | 36 | #include "kDbgBase.h"
|
---|
[3524] | 37 |
|
---|
| 38 |
|
---|
| 39 | /**
|
---|
| 40 | * Duplicates a line number.
|
---|
| 41 | *
|
---|
| 42 | * To save heap space, the returned line number will not own more heap space
|
---|
| 43 | * than it strictly need to. So, it's not possible to append stuff to the symbol
|
---|
| 44 | * or anything of that kind.
|
---|
| 45 | *
|
---|
| 46 | * @returns Pointer to the duplicate.
|
---|
| 47 | * This must be freed using RTDbgSymbolFree().
|
---|
| 48 | * @param pLine The line number to be duplicated.
|
---|
| 49 | */
|
---|
| 50 | RTDECL(PRTDBGLINE) RTDbgLineDup(PCRTDBGLINE pLine)
|
---|
| 51 | {
|
---|
| 52 | AssertMsgReturn(VALID_PTR(pLine), ("%p\n", pLine), NULL);
|
---|
[3526] | 53 | size_t cb = KDBG_OFFSETOF(RTDBGLINE, szFile[pLine->cchFile + 1]);
|
---|
[3524] | 54 | return (PRTDBGLINE)RTMemDup(pLine, cb);
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | /**
|
---|
| 59 | * Frees a line number obtained from the RTDbg API.
|
---|
| 60 | *
|
---|
| 61 | * @returns VINF_SUCCESS on success.
|
---|
| 62 | * @returns VERR_INVALID_POINTER if a NULL pointer or an !VALID_PTR() is passed in.
|
---|
| 63 | *
|
---|
| 64 | * @param pLine The line number to be freed.
|
---|
| 65 | */
|
---|
| 66 | RTDECL(int) RTDbgLineFree(PRTDBGLINE pLine)
|
---|
| 67 | {
|
---|
| 68 | if (!pLine)
|
---|
| 69 | return VERR_INVALID_POINTER;
|
---|
| 70 | AssertMsgReturn(VALID_PTR(pLine), ("%p\n", pLine), VERR_INVALID_POINTER);
|
---|
| 71 |
|
---|
| 72 | RTMemFree(pLine);
|
---|
| 73 | return VINF_SUCCESS;
|
---|
| 74 | }
|
---|
| 75 |
|
---|