121 if (Machine::instance().getNumSerial()) {
125 entry.append(state.getInstructionPointer(), 16);
129 entry += description;
131 serial->write_str(entry);
136 if (!processorsQuiesced) {
137 ERROR_NOLOCK(
"Debugger: not all other processors quiesced");
142 entry << Log::Notice <<
" << Flushing log content >>";
144#if defined(VALGRIND) || defined(HAS_SANITIZERS)
147 static String graphicsService(
"graphics");
151 ByteSet(¶ms, 0,
sizeof(params));
152 params.wantTextMode =
false;
156 bool bSuccess =
false;
157 if (ServiceManager::instance().tryGetService(graphicsService, pService, pFeatures) &&
163 if (bSuccess && params.providerFound) {
165 if (params.providerResult.pDisplay) {
177 bool debugState = Machine::instance().
getKeyboard()->getDebugState();
182#if !DONT_LOG_TO_SERIAL
183 static SerialIO serialIO(Machine::instance().getSerial(0));
184 serialIO.initialise();
191 if (Machine::instance().getNumVga())
193 static LocalIO localIO(Machine::instance().getVga(0), Machine::instance().getKeyboard());
194#if DONT_LOG_TO_SERIAL
195 pInterfaces[0] = &localIO;
198 pInterfaces[0] = &localIO;
199 pInterfaces[1] = &serialIO;
203#if !DONT_LOG_TO_SERIAL
205 pInterfaces[0] = &serialIO;
213 "This machine/CPU combination doesn't support any output "
214 "methods for the debugger!");
219 int nChosenInterface = -1;
267 &g_AllocationCommand,
275 const size_t nCommands =
sizeof(pCommands) /
sizeof(pCommands[0]);
279 int n = trace.execTrace();
284 for (
int i = 0; i < nInterfaces; i++) {
285 pInterfaces[i]->disableCli();
286 pInterfaces[i]->
drawString(
"Press any key to enter the debugger...", 0, 0,
287 DebuggerIO::LightBlue, DebuggerIO::Black);
290 pInterfaces[i]->
drawString(str, 2, 0, DebuggerIO::LightBlue, DebuggerIO::Black);
294 for (
int i = 0; i < nInterfaces; i++) {
295 char c = pInterfaces[i]->getCharNonBlock();
296 if ((c >= 32 &&
static_cast<unsigned char>(c) <= 127) || c ==
'\n' || c == 0x08 ||
297 c ==
'\r' || c == 0x09) {
298 pIo = pInterfaces[i];
299 nChosenInterface = i;
307 pIo = pInterfaces[n];
308 nChosenInterface = n;
310 pIo->readDimensions();
313 for (
int i = 0; i < nInterfaces; i++)
314 if (pIo != pInterfaces[i])
315 pInterfaces[i]->
drawString(
"Locked by another device.", 1, 0, DebuggerIO::LightRed,
319 pIo->setCliLowerLimit(1);
323 pIo->
writeCli(description, DebuggerIO::Yellow, DebuggerIO::Black);
326 description +=
"Kernel heap ends at ";
330 pIo->
writeCli(description, DebuggerIO::Yellow, DebuggerIO::Black);
333 bool bKeepGoing =
false;
338 if (trace.execTrace() != -1) {
339 bKeepGoing = trace.execute(command, output, state, pIo);
342 trace.setInterface(nChosenInterface);
348 pIo->
drawString(
"Pedigree debugger", 0, 0, DebuggerIO::White, DebuggerIO::Green);
350 bool matchedCommand =
false;
356 if (pIo->
readCli(command, pAutoComplete))
363 matchedCommand =
false;
364 for (
size_t i = 0; i < nCommands; i++) {
371 if (matchesCommand(
const_cast<char*
>(
static_cast<const char*
>(command)), pCommands[i])) {
372 str2 =
static_cast<const char*
>(pCommands[i]->
getString());
375 matchedCommand =
true;
381 if (!matchedCommand) {
383 while ((i = getCommandMatchingPrefix(
const_cast<char*
>(
static_cast<const char*
>(command)),
384 pCommands, nCommands, i + 1)) != -1) {
386 pAutoComplete = pCommands[i];
387 str +=
static_cast<const char*
>(pCommands[i]->
getString());
394 pIo->
drawString(str2, pIo->getHeight() - 1, 0, DebuggerIO::Yellow, DebuggerIO::Green);
395 pIo->
drawString(str, pIo->getHeight() - 1, str2.length(), DebuggerIO::White,
400 bool bValidCommand =
false;
401 for (
size_t i = 0; i < nCommands; i++) {
402 if (matchesCommand(
const_cast<char*
>(
static_cast<const char*
>(command)), pCommands[i])) {
403 bKeepGoing = pCommands[i]->
execute(command, output, state, pIo);
404 pIo->
writeCli(output, DebuggerIO::LightGrey, DebuggerIO::Black);
405 bValidCommand =
true;
409 if (!bValidCommand) {
410 pIo->
writeCli(
"Unrecognised command.\n", DebuggerIO::LightGrey, DebuggerIO::Black);
414 }
while (bKeepGoing);
416 pInterfaces[0]->destroy();
417#if !DONT_LOG_TO_SERIAL
423 if (processorsQuiesced && !Machine::instance().resumeAllOtherProcessors()) {
424 ERROR_NOLOCK(
"Debugger: not all quiesced processors resumed");