The Pedigree Project  0.1
DumpCommand.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/DumpCommand.h"
21 #include "pedigree/kernel/processor/state.h"
22 #include "pedigree/kernel/processor/types.h"
23 #include "pedigree/kernel/utilities/utility.h"
24 
25 class DebuggerIO;
26 
28 {
29 }
30 
32 {
33 }
34 
36  const HugeStaticString &input, HugeStaticString &output)
37 {
38 }
39 
41  const HugeStaticString &input, HugeStaticString &output,
42  InterruptState &state, DebuggerIO *pScreen)
43 {
44  if (state.kernelMode() == true)
45  output += "kernel-mode\n";
46  else
47  output += "user-mode\n";
48 
49  // Output all the other registers
50  size_t curLength = output.length();
51  for (size_t i = 0; i < state.getRegisterCount(); i++)
52  {
53  output += state.getRegisterName(i);
54  output += ": 0x";
55  output.append(
56  state.getRegister(i), 16, state.getRegisterSize(i) * 2, '0');
57 
58  if (i == (state.getRegisterCount() - 1))
59  output += '\n';
60  else
61  {
62  size_t addLength = StringLength(state.getRegisterName(i + 1)) + 4 +
63  state.getRegisterSize(i + 1) * 2;
64  if ((addLength + (output.length() - curLength)) > 80)
65  {
66  output += '\n';
67  curLength = output.length();
68  }
69  else
70  output += ' ';
71  }
72  }
73 
74  return true;
75 }
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
Definition: DumpCommand.cc:40
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
Definition: DumpCommand.cc:35