tools/*: remove bcc and as86 as they are no longer required to compile the system...
[virtualbox.git] / src / VBox / Debugger / DBGCFunctions.cpp
blobb3cc27310c50c00d870cf173d4472b40dac91b47
1 /* $Id$ */
2 /** @file
3 * DBGC - Debugger Console, Native Functions.
4 */
6 /*
7 * Copyright (C) 2006-2012 Oracle Corporation
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.
18 /*******************************************************************************
19 * Header Files *
20 *******************************************************************************/
21 #define LOG_GROUP LOG_GROUP_DBGC
22 #include <VBox/dbg.h>
23 #include <VBox/vmm/dbgf.h>
24 #include <VBox/err.h>
25 #include <VBox/log.h>
27 #include <iprt/assert.h>
28 #include <iprt/rand.h>
29 #include <iprt/string.h>
31 #include "DBGCInternal.h"
35 /*******************************************************************************
36 * Global Variables *
37 *******************************************************************************/
38 /** Pointer to head of the list of exteranl functions. */
39 static PDBGCEXTFUNCS g_pExtFuncsHead;
44 /**
45 * @callback_method_impl{The randu32() function implementation.}
47 static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, uint32_t cArgs,
48 PDBGCVAR pResult)
50 AssertReturn(cArgs == 0, VERR_DBGC_PARSE_BUG);
51 uint32_t u32 = RTRandU32();
52 DBGCVAR_INIT_NUMBER(pResult, u32);
53 NOREF(pFunc); NOREF(pCmdHlp); NOREF(pVM); NOREF(paArgs);
54 return VINF_SUCCESS;
58 /** Functions descriptors for the basic functions. */
59 const DBGCFUNC g_aDbgcFuncs[] =
61 /* pszCmd, cArgsMin, cArgsMax, paArgDescs, cArgDescs, fFlags, pfnHandler pszSyntax, ....pszDescription */
62 { "randu32", 0, 0, NULL, 0, 0, dbgcFuncRandU32, "", "Returns an unsigned 32-bit random number." },
65 /** The number of function descriptions in g_aDbgcFuncs. */
66 const uint32_t g_cDbgcFuncs = RT_ELEMENTS(g_aDbgcFuncs);
69 /**
70 * Looks up a function.
72 * @returns Pointer to the function descriptor on success, NULL if not found.
73 * @param pDbgc The DBGC instance.
74 * @param pachName The first charater in the name.
75 * @param cchName The length of the function name.
76 * @param fExternal Whether it's an external function.
78 PCDBGCFUNC dbgcFunctionLookup(PDBGC pDbgc, const char *pachName, size_t cchName, bool fExternal)
80 if (!fExternal)
82 /* emulation first, so commands can be overloaded (info ++). */
83 PCDBGCFUNC pFunc = pDbgc->paEmulationFuncs;
84 uint32_t cLeft = pDbgc->cEmulationFuncs;
85 while (cLeft-- > 0)
87 if ( !strncmp(pachName, pFunc->pszFuncNm, cchName)
88 && !pFunc->pszFuncNm[cchName])
89 return pFunc;
90 pFunc++;
93 for (uint32_t iFunc = 0; iFunc < RT_ELEMENTS(g_aDbgcFuncs); iFunc++)
95 if ( !strncmp(pachName, g_aDbgcFuncs[iFunc].pszFuncNm, cchName)
96 && !g_aDbgcFuncs[iFunc].pszFuncNm[cchName])
97 return &g_aDbgcFuncs[iFunc];
100 else
102 DBGCEXTLISTS_LOCK_RD();
103 for (PDBGCEXTFUNCS pExtFuncs = g_pExtFuncsHead; pExtFuncs; pExtFuncs = pExtFuncs->pNext)
105 for (uint32_t iFunc = 0; iFunc < pExtFuncs->cFuncs; iFunc++)
107 if ( !strncmp(pachName, pExtFuncs->paFuncs[iFunc].pszFuncNm, cchName)
108 && !pExtFuncs->paFuncs[iFunc].pszFuncNm[cchName])
109 return &pExtFuncs->paFuncs[iFunc];
112 DBGCEXTLISTS_UNLOCK_RD();
115 return NULL;