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;
164 if (bSuccess && params.providerFound) {
166 if (params.providerResult.pDisplay) {
178 bool debugState = Machine::instance().
getKeyboard()->getDebugState();
183#if !DONT_LOG_TO_SERIAL
184 static SerialIO serialIO(Machine::instance().getSerial(0));
185 serialIO.initialise();
192 if (Machine::instance().getNumVga())
194 static LocalIO localIO(Machine::instance().getVga(0), Machine::instance().getKeyboard());
195#if DONT_LOG_TO_SERIAL
196 pInterfaces[0] = &localIO;
199 pInterfaces[0] = &localIO;
200 pInterfaces[1] = &serialIO;
204#if !DONT_LOG_TO_SERIAL
206 pInterfaces[0] = &serialIO;
214 "This machine/CPU combination doesn't support any output "
215 "methods for the debugger!");
220 int nChosenInterface = -1;
268 &g_AllocationCommand,
276 const size_t nCommands =
sizeof(pCommands) /
sizeof(pCommands[0]);
280 int n = trace.execTrace();
285 for (
int i = 0; i < nInterfaces; i++) {
286 pInterfaces[i]->disableCli();
287 pInterfaces[i]->
drawString(
"Press any key to enter the debugger...", 0, 0,
288 DebuggerIO::LightBlue, DebuggerIO::Black);
291 pInterfaces[i]->
drawString(str, 2, 0, DebuggerIO::LightBlue, DebuggerIO::Black);
295 for (
int i = 0; i < nInterfaces; i++) {
296 char c = pInterfaces[i]->getCharNonBlock();
297 if ((c >= 32 &&
static_cast<unsigned char>(c) <= 127) || c ==
'\n' || c == 0x08 ||
298 c ==
'\r' || c == 0x09) {
299 pIo = pInterfaces[i];
300 nChosenInterface = i;
308 pIo = pInterfaces[n];
309 nChosenInterface = n;
311 pIo->readDimensions();
314 for (
int i = 0; i < nInterfaces; i++)
315 if (pIo != pInterfaces[i])
316 pInterfaces[i]->
drawString(
"Locked by another device.", 1, 0, DebuggerIO::LightRed,
320 pIo->setCliLowerLimit(1);
324 pIo->
writeCli(description, DebuggerIO::Yellow, DebuggerIO::Black);
327 description +=
"Kernel heap ends at ";
331 pIo->
writeCli(description, DebuggerIO::Yellow, DebuggerIO::Black);
334 bool bKeepGoing =
false;
339 if (trace.execTrace() != -1) {
340 bKeepGoing = trace.execute(command, output, state, pIo);
343 trace.setInterface(nChosenInterface);
349 pIo->
drawString(
"Pedigree debugger", 0, 0, DebuggerIO::White, DebuggerIO::Green);
351 bool matchedCommand =
false;
357 if (pIo->
readCli(command, pAutoComplete))
364 matchedCommand =
false;
365 for (
size_t i = 0; i < nCommands; i++) {
372 if (matchesCommand(
const_cast<char*
>(
static_cast<const char*
>(command)), pCommands[i])) {
373 str2 =
static_cast<const char*
>(pCommands[i]->
getString());
376 matchedCommand =
true;
382 if (!matchedCommand) {
384 while ((i = getCommandMatchingPrefix(
const_cast<char*
>(
static_cast<const char*
>(command)),
385 pCommands, nCommands, i + 1)) != -1) {
387 pAutoComplete = pCommands[i];
388 str +=
static_cast<const char*
>(pCommands[i]->
getString());
395 pIo->
drawString(str2, pIo->getHeight() - 1, 0, DebuggerIO::Yellow, DebuggerIO::Green);
396 pIo->
drawString(str, pIo->getHeight() - 1, str2.length(), DebuggerIO::White,
401 bool bValidCommand =
false;
402 for (
size_t i = 0; i < nCommands; i++) {
403 if (matchesCommand(
const_cast<char*
>(
static_cast<const char*
>(command)), pCommands[i])) {
404 bKeepGoing = pCommands[i]->
execute(command, output, state, pIo);
405 pIo->
writeCli(output, DebuggerIO::LightGrey, DebuggerIO::Black);
406 bValidCommand =
true;
410 if (!bValidCommand) {
411 pIo->
writeCli(
"Unrecognised command.\n", DebuggerIO::LightGrey, DebuggerIO::Black);
415 }
while (bKeepGoing);
417 pInterfaces[0]->destroy();
418#if !DONT_LOG_TO_SERIAL
424 if (processorsQuiesced && !Machine::instance().resumeAllOtherProcessors()) {
425 ERROR_NOLOCK(
"Debugger: not all quiesced processors resumed");