20 #include "pedigree/kernel/debugger/commands/AllocationCommand.h" 21 #include "pedigree/kernel/Log.h" 22 #include "pedigree/kernel/debugger/Backtrace.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/Thread.h" 27 #include "pedigree/kernel/processor/Processor.h" 28 #include "pedigree/kernel/processor/ProcessorInformation.h" 29 #include "pedigree/kernel/utilities/Iterator.h" 30 #include "pedigree/kernel/utilities/demangle.h" 31 #include "pedigree/kernel/utilities/utility.h" 37 m_Tree(), m_It(), m_nIdx(0), m_bAllocating(false)
57 m_nLines = NUM_BT_FRAMES + 1;
63 it != m_Allocations.end(); it++)
68 for (
int i = 0; i < NUM_BT_FRAMES; i++)
72 accum += pA->pid << 16;
79 m_Tree.insert(accum, pA);
87 m_It = m_Tree.begin();
91 pScreen->disableCli();
95 resize(pScreen->
getWidth(), pScreen->getHeight() - 2);
96 setScrollKeys(
'j',
'k');
100 ' ', 0, 0, pScreen->
getWidth() - 1, DebuggerIO::White,
105 "Pedigree debugger - Page allocation resolver", 0, 0, DebuggerIO::White,
113 ' ', pScreen->getHeight() - 1, 0, pScreen->
getWidth() - 1,
114 DebuggerIO::White, DebuggerIO::Green);
119 "backspace: Page up. space: Page down. q: Quit. enter: Next allocation",
120 pScreen->getHeight() - 1, 0, DebuggerIO::White, DebuggerIO::Green);
122 "backspace", pScreen->getHeight() - 1, 0, DebuggerIO::Yellow,
125 "space", pScreen->getHeight() - 1, 20, DebuggerIO::Yellow,
128 "q", pScreen->getHeight() - 1, 38, DebuggerIO::Yellow,
131 "enter", pScreen->getHeight() - 1, 47, DebuggerIO::Yellow,
143 while (!(c = pScreen->
getChar()))
157 scroll(static_cast<ssize_t>(height()));
161 scroll(-static_cast<ssize_t>(height()));
163 else if (c ==
'\n' || c ==
'\r')
167 if (m_It == m_Tree.end())
169 m_It = m_Tree.begin();
181 pScreen->
drawString(
" ", 1, 0, DebuggerIO::White, DebuggerIO::Black);
186 const char *AllocationCommand::getLine1(
194 bgColour = DebuggerIO::Black;
197 colour = DebuggerIO::Yellow;
199 Line +=
" allocations from this source (";
202 Line += m_Tree.count();
209 colour = DebuggerIO::White;
210 uintptr_t symStart = 0;
216 Line.append(pA->ra[index], 16);
223 Line.append(symStart, 16);
227 Line +=
static_cast<const char *
>(symbol.name);
232 const char *AllocationCommand::getLine2(
242 size_t AllocationCommand::getLineCount()
247 void AllocationCommand::allocatePage(physical_uintptr_t page)
261 pA->pid = pP->
getId();
266 m_Allocations.pushBack(pA);
269 void AllocationCommand::freePage(physical_uintptr_t page)
271 m_Frees.
pushBack(reinterpret_cast<void *>(page));
274 void AllocationCommand::postProcess()
276 NOTICE(
"Beginning free-list post processing...");
280 physical_uintptr_t page =
reinterpret_cast<physical_uintptr_t
>(*it);
284 it2 != m_Allocations.end(); it2++)
286 if ((*it2)->page == page)
289 m_Allocations.erase(it2);
295 it = m_Frees.
begin();
297 NOTICE(
"End free-list post processing.");
300 void AllocationCommand::checkpoint()
302 NOTICE(
"Allocation checkpoint.");
304 m_Allocations.clear();
void pushBack(const T &value)
virtual size_t getWidth()=0
virtual void enableCli()=0
A vector / dynamic array.
bool execute(const HugeStaticString &input, HugeStaticString &output, InterruptState &state, DebuggerIO *screen)
static ProcessorInformation & information()
static KernelElf & instance()
uintptr_t m_pReturnAddresses[MAX_STACK_FRAMES]
uintptr_t globalLookupSymbol(const char *pName)
virtual void drawString(const char *str, size_t row, size_t col, Colour foreColour, Colour backColour)=0
void autocomplete(const HugeStaticString &input, HugeStaticString &output)
void performBpBacktrace(uintptr_t base, uintptr_t instruction)
virtual void drawHorizontalLine(char c, size_t row, size_t colStart, size_t colEnd, Colour foreColour, Colour backColour)=0
void clear(bool freeMem=false)