The Pedigree Project 0.1
LookupCommand.cc
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include "pedigree/kernel/debugger/commands/LookupCommand.h"
21#include "pedigree/kernel/linker/KernelElf.h"
22#include "pedigree/kernel/processor/types.h"
23
24class DebuggerIO;
25
27
29
31
33 InterruptState& state, DebuggerIO* pScreen) {
34 intptr_t n = input.intValue();
35 if (n == -1) {
36 uintptr_t addr = KernelElf::instance().lookupSymbol(static_cast<const char*>(input));
37 if (addr)
38 output.append(addr, 16);
39 else
40 output += "No symbol corresponding to given name";
41 output += "\n";
42 } else {
43 uintptr_t symStart;
44 const char* pSym =
45 KernelElf::instance().globalLookupSymbol(static_cast<uintptr_t>(n), &symStart);
46 if (!pSym) {
47 output += "No symbol corresponding to given address.";
48 return false;
49 }
50 output += "`";
51 output += pSym;
52 output += "' - symbol starts at ";
53 output.append(symStart, 16);
54 output += "\n";
55 }
56 return true;
57}
const char * lookupSymbol(uintptr_t addr, uintptr_t *startAddr, T *symbolTable)
static KernelElf & instance()
Definition KernelElf.h:135
uintptr_t globalLookupSymbol(const char *pName)
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
void autocomplete(const HugeStaticString &input, HugeStaticString &output)