22 #include "pedigree/kernel/debugger/commands/ThreadsCommand.h" 23 #include "pedigree/kernel/debugger/DebuggerIO.h" 24 #include "pedigree/kernel/linker/KernelElf.h" 25 #include "pedigree/kernel/process/Process.h" 26 #include "pedigree/kernel/process/Scheduler.h" 27 #include "pedigree/kernel/process/Thread.h" 28 #include "pedigree/kernel/processor/Processor.h" 29 #include "pedigree/kernel/processor/ProcessorInformation.h" 30 #include "pedigree/kernel/utilities/demangle.h" 59 pScreen->disableCli();
63 resize(pScreen->
getWidth(), pScreen->getHeight() - 2);
64 setScrollKeys(
'j',
'k');
68 ' ', 0, 0, pScreen->
getWidth() - 1, DebuggerIO::White,
73 "Pedigree debugger - Thread selector", 0, 0, DebuggerIO::White,
81 ' ', pScreen->getHeight() - 1, 0, pScreen->
getWidth() - 1,
82 DebuggerIO::White, DebuggerIO::Green);
87 "backspace: Page up. space: Page down. q: Quit. enter: Switch to " 89 pScreen->getHeight() - 1, 0, DebuggerIO::White, DebuggerIO::Green);
91 "backspace", pScreen->getHeight() - 1, 0, DebuggerIO::Yellow,
94 "space", pScreen->getHeight() - 1, 20, DebuggerIO::Yellow,
97 "q", pScreen->getHeight() - 1, 38, DebuggerIO::Yellow,
100 "enter", pScreen->getHeight() - 1, 47, DebuggerIO::Yellow,
112 while (!(c = pScreen->
getChar()))
119 if (static_cast<ssize_t>(m_SelectedLine) - 1 >= 0)
125 if (m_SelectedLine + 1 < getLineCount())
130 scroll(static_cast<ssize_t>(height()));
131 if (m_SelectedLine + height() < getLineCount())
132 m_SelectedLine += height();
134 m_SelectedLine = getLineCount() - 1;
138 scroll(-static_cast<ssize_t>(height()));
139 if (static_cast<ssize_t>(m_SelectedLine) -
140 static_cast<ssize_t>(height()) >=
142 m_SelectedLine -= height();
146 else if (c ==
'\n' || c ==
'\r')
162 pScreen->
drawString(
" ", 1, 0, DebuggerIO::White, DebuggerIO::Black);
167 const char *ThreadsCommand::getLine1(
209 colour = DebuggerIO::Yellow;
210 if (index == m_SelectedLine)
211 bgColour = DebuggerIO::Blue;
213 bgColour = DebuggerIO::Black;
217 Line += tehProcess->
getId();
228 const char *ThreadsCommand::getLine2(
263 if (tehThread != 0 &&
269 case Thread::Running:
275 case Thread::Sleeping:
281 case Thread::AwaitingJoin:
284 case Thread::Suspended:
293 Line += tehThread->
getId();
298 if (state != Thread::None)
300 if (state == Thread::SemWait)
301 Line +=
"Sem-Wait @ ";
302 else if (state == Thread::Joining)
304 else if (state == Thread::CondWait)
305 Line +=
"Cond-Wait @";
307 Line +=
"<unknown DebugState> @";
321 colour = DebuggerIO::LightGrey;
323 else if (tehThread != 0)
328 case Thread::Running:
334 case Thread::Sleeping:
340 case Thread::AwaitingJoin:
343 case Thread::Suspended:
351 Line += tehThread->
getId();
352 Line +=
"] - CURRENT";
356 if (state != Thread::None)
358 if (state == Thread::SemWait)
359 Line +=
"Sem-Wait @ ";
360 else if (state == Thread::Joining)
362 else if (state == Thread::CondWait)
363 Line +=
"Cond-Wait @";
365 Line +=
"<unknown DebugState> @";
380 colour = DebuggerIO::Yellow;
383 if (index == m_SelectedLine)
384 bgColour = DebuggerIO::Blue;
386 bgColour = DebuggerIO::Black;
391 size_t ThreadsCommand::getLineCount()
396 bool ThreadsCommand::swapThread(InterruptState &state,
DebuggerIO *pScreen)
406 if (m_SelectedLine == idx)
414 if (m_SelectedLine == idx)
virtual size_t getWidth()=0
virtual void enableCli()=0
static ProcessorInformation & information()
static KernelElf & instance()
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
uintptr_t globalLookupSymbol(const char *pName)
static Scheduler & instance()
Process * getProcess(size_t n)
virtual void drawString(const char *str, size_t row, size_t col, Colour foreColour, Colour backColour)=0
Thread * getThread(size_t n)
LargeStaticString & description()
virtual void drawHorizontalLine(char c, size_t row, size_t colStart, size_t colEnd, Colour foreColour, Colour backColour)=0
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
DebugState getDebugState(uintptr_t &address)