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 
24 class DebuggerIO;
25 
27 {
28 }
29 
31 {
32 }
33 
35  const HugeStaticString &input, HugeStaticString &output)
36 {
37 }
38 
40  const HugeStaticString &input, HugeStaticString &output,
41  InterruptState &state, DebuggerIO *pScreen)
42 {
43  intptr_t n = input.intValue();
44  if (n == -1)
45  {
46  uintptr_t addr = KernelElf::instance().lookupSymbol(
47  static_cast<const char *>(input));
48  if (addr)
49  output.append(addr, 16);
50  else
51  output += "No symbol corresponding to given name";
52  output += "\n";
53  }
54  else
55  {
56  uintptr_t symStart;
57  const char *pSym = KernelElf::instance().globalLookupSymbol(
58  static_cast<uintptr_t>(n), &symStart);
59  if (!pSym)
60  {
61  output += "No symbol corresponding to given address.";
62  return false;
63  }
64  output += "`";
65  output += pSym;
66  output += "' - symbol starts at ";
67  output.append(symStart, 16);
68  output += "\n";
69  }
70  return true;
71 }
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
const char * lookupSymbol(uintptr_t addr, uintptr_t *startAddr, T *symbolTable)
Definition: linker/Elf.cc:1164
static KernelElf & instance()
Definition: KernelElf.h:129
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
uintptr_t globalLookupSymbol(const char *pName)
Definition: KernelElf.cc:1031