The Pedigree Project  0.1
TraceCommand.h
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 #ifndef TRACECOMMAND_H
21 #define TRACECOMMAND_H
22 
23 #include "pedigree/kernel/debugger/Backtrace.h"
24 #include "pedigree/kernel/debugger/DebuggerCommand.h"
25 #include "pedigree/kernel/debugger/DebuggerIO.h"
26 #include "pedigree/kernel/debugger/Scrollable.h"
27 #include "pedigree/kernel/processor/state_forward.h"
28 #include "pedigree/kernel/processor/types.h"
29 #include "pedigree/kernel/utilities/StaticString.h"
30 
40 {
41  public:
45  TraceCommand();
46 
50  ~TraceCommand();
51 
55  void autocomplete(const HugeStaticString &input, HugeStaticString &output);
56 
57  void setInterface(int nInterface);
58 
62  bool execute(
63  const HugeStaticString &input, HugeStaticString &output,
64  InterruptState &state, DebuggerIO *screen);
65 
70  {
71  return NormalStaticString("trace");
72  }
73 
78  int execTrace()
79  {
80  return m_nExec;
81  }
82 
83  private:
84  class Disassembly : public Scrollable
85  {
86  public:
87  Disassembly(InterruptState &state);
88  ~Disassembly()
89  {
90  }
91  const char *getLine1(
92  size_t index, DebuggerIO::Colour &colour,
93  DebuggerIO::Colour &bgColour);
94  const char *getLine2(
95  size_t index, size_t &colOffset, DebuggerIO::Colour &colour,
96  DebuggerIO::Colour &bgColour);
97  size_t getLineCount();
98 
99  private:
100  size_t m_nInstructions;
101  uintptr_t m_nFirstInstruction;
102  uintptr_t m_nIp;
110  size_t m_LastLine;
111  uintptr_t m_LastInstructionLocation;
112  };
113 
114  class Registers : public Scrollable
115  {
116  public:
117  Registers(InterruptState &state);
118  ~Registers()
119  {
120  }
121  const char *getLine1(
122  size_t index, DebuggerIO::Colour &colour,
123  DebuggerIO::Colour &bgColour);
124  const char *getLine2(
125  size_t index, size_t &colOffset, DebuggerIO::Colour &colour,
126  DebuggerIO::Colour &bgColour);
127  size_t getLineCount();
128 
129  private:
130  InterruptState &m_State;
131  };
132 
133  class Stacktrace : public Scrollable
134  {
135  public:
136  Stacktrace(InterruptState &state);
137  ~Stacktrace()
138  {
139  }
140  const char *getLine1(
141  size_t index, DebuggerIO::Colour &colour,
142  DebuggerIO::Colour &bgColour);
143  const char *getLine2(
144  size_t index, size_t &colOffset, DebuggerIO::Colour &colour,
145  DebuggerIO::Colour &bgColour);
146  size_t getLineCount();
147 
148  private:
149  Backtrace m_Bt;
150  };
151 
152  void drawBackground(size_t nCols, size_t nLines, DebuggerIO *pScreen);
153 
158  int m_nExec;
159  int m_nInterface;
160 };
161 
164 #endif
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
Definition: TraceCommand.cc:36
const NormalStaticString getString()
Definition: TraceCommand.h:69
int execTrace()
Definition: TraceCommand.h:78
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
Definition: TraceCommand.cc:46