25 if ((mDebuggerPrivate.FeatureFlags & Flag) == Flag) {
26 mDebuggerPrivate.StatusFlags = Flag;
28 EXCEPT_EBC_BREAKPOINT,
47 IN UINT64 SourceEntry,
48 IN EFI_DEBUGGER_BRANCH_TYPE Type
51 if (mDebuggerPrivate.CallStackEntryCount > EFI_DEBUGGER_CALLSTACK_MAX) {
53 mDebuggerPrivate.CallStackEntryCount = EFI_DEBUGGER_CALLSTACK_MAX;
59 mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].SourceAddress = SourceEntry;
60 mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Type = Type;
79 IN UINT64 ParameterAddress,
80 IN EFI_DEBUGGER_BRANCH_TYPE Type
83 if (mDebuggerPrivate.CallStackEntryCount > EFI_DEBUGGER_CALLSTACK_MAX) {
85 mDebuggerPrivate.CallStackEntryCount = EFI_DEBUGGER_CALLSTACK_MAX;
91 mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].ParameterAddr = (
UINTN)ParameterAddress;
93 mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Parameter,
94 (VOID *)(
UINTN)ParameterAddress,
95 sizeof (mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Parameter)
116 IN EFI_DEBUGGER_BRANCH_TYPE Type
121 if (mDebuggerPrivate.CallStackEntryCount < EFI_DEBUGGER_CALLSTACK_MAX) {
125 ASSERT (mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].Type == Type);
126 mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].DestAddress = DestEntry;
127 mDebuggerPrivate.CallStackEntryCount++;
132 ASSERT (mDebuggerPrivate.CallStackEntry[EFI_DEBUGGER_TRACE_MAX].Type == Type);
133 for (Index = 0; Index < EFI_DEBUGGER_CALLSTACK_MAX; Index++) {
135 &mDebuggerPrivate.CallStackEntry[Index],
136 &mDebuggerPrivate.CallStackEntry[Index + 1],
137 sizeof (mDebuggerPrivate.CallStackEntry[Index])
141 mDebuggerPrivate.CallStackEntry[EFI_DEBUGGER_CALLSTACK_MAX - 1].DestAddress = DestEntry;
142 mDebuggerPrivate.CallStackEntryCount = EFI_DEBUGGER_CALLSTACK_MAX;
158 if ((mDebuggerPrivate.CallStackEntryCount > 0) &&
159 (mDebuggerPrivate.CallStackEntryCount <= EFI_DEBUGGER_CALLSTACK_MAX))
164 mDebuggerPrivate.CallStackEntryCount--;
165 mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].SourceAddress = 0;
166 mDebuggerPrivate.CallStackEntry[mDebuggerPrivate.CallStackEntryCount].DestAddress = 0;
167 }
else if (mDebuggerPrivate.CallStackEntryCount == 0) {
189 IN UINT64 SourceEntry,
190 IN EFI_DEBUGGER_BRANCH_TYPE Type
193 if (mDebuggerPrivate.TraceEntryCount > EFI_DEBUGGER_TRACE_MAX) {
195 mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX;
201 mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].SourceAddress = SourceEntry;
202 mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].Type = Type;
222 IN EFI_DEBUGGER_BRANCH_TYPE Type
227 if (mDebuggerPrivate.TraceEntryCount < EFI_DEBUGGER_TRACE_MAX) {
231 ASSERT (mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].Type == Type);
232 mDebuggerPrivate.TraceEntry[mDebuggerPrivate.TraceEntryCount].DestAddress = DestEntry;
233 mDebuggerPrivate.TraceEntryCount++;
238 ASSERT (mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_TRACE_MAX].Type == Type);
239 for (Index = 0; Index < EFI_DEBUGGER_TRACE_MAX; Index++) {
241 &mDebuggerPrivate.TraceEntry[Index],
242 &mDebuggerPrivate.TraceEntry[Index + 1],
243 sizeof (mDebuggerPrivate.TraceEntry[Index])
247 mDebuggerPrivate.TraceEntry[EFI_DEBUGGER_CALLSTACK_MAX - 1].DestAddress = DestEntry;
248 mDebuggerPrivate.TraceEntryCount = EFI_DEBUGGER_TRACE_MAX;
273 if ((Flag == EFI_DEBUG_FLAG_EBC_STEPOVER) &&
274 ((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_STEPOVER) == EFI_DEBUG_FLAG_EBC_STEPOVER))
276 mDebuggerPrivate.StepContext.BreakAddress = Entry;
277 mDebuggerPrivate.StepContext.FramePointer = FramePtr;
278 mDebuggerPrivate.FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOVER;
284 if ((Flag == EFI_DEBUG_FLAG_EBC_STEPOUT) &&
285 ((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_STEPOUT) == EFI_DEBUG_FLAG_EBC_STEPOUT))
287 mDebuggerPrivate.StepContext.BreakAddress = Entry;
288 mDebuggerPrivate.StepContext.FramePointer = FramePtr;
289 mDebuggerPrivate.FeatureFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOUT;
309 if ((mDebuggerPrivate.FeatureFlags & EFI_DEBUG_FLAG_EBC_BOK) != EFI_DEBUG_FLAG_EBC_BOK) {
315 mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_BOK;
343 EbcDebugProtocol->RegisterExceptionCallback (
349 EbcDebugProtocol->RegisterExceptionCallback (
361 ASSERT (Object !=
NULL);
362 mDebuggerPrivate.DebuggerSymbolContext.Object = Object;
363 mDebuggerPrivate.DebuggerSymbolContext.ObjectCount = 0;
364 mDebuggerPrivate.DebuggerSymbolContext.MaxObjectCount = EFI_DEBUGGER_SYMBOL_OBJECT_MAX;
365 for (Index = 0; Index < EFI_DEBUGGER_SYMBOL_OBJECT_MAX; Index++) {
367 ASSERT (Entry !=
NULL);
368 Object[Index].Entry = Entry;
369 Object[Index].MaxEntryCount = EFI_DEBUGGER_SYMBOL_ENTRY_MAX;
370 Object[Index].SourceBuffer =
AllocateZeroPool (
sizeof (VOID *) * (EFI_DEBUGGER_SYMBOL_ENTRY_MAX + 1));
371 ASSERT (Object[Index].SourceBuffer !=
NULL);
377 Status =
gBS->LocateProtocol (
378 &gEfiPciRootBridgeIoProtocolGuid,
380 (VOID **)&mDebuggerPrivate.PciRootBridgeIo
387 &gEfiDebugImageInfoTableGuid,
388 (VOID **)&mDebuggerPrivate.DebugImageInfoTableHeader
394 Status =
gBS->InstallProtocolInterface (
396 &gEfiDebuggerConfigurationProtocolGuid,
398 &mDebuggerPrivate.DebuggerConfiguration
405 Status =
gBS->CreateEvent (
406 EVT_TIMER | EVT_NOTIFY_SIGNAL,
410 &mDebuggerPrivate.BreakEvent
412 if (!EFI_ERROR (Status)) {
413 Status =
gBS->SetTimer (
414 mDebuggerPrivate.BreakEvent,
416 EFI_DEBUG_BREAK_TIMER_INTERVAL
441 if (mDebuggerPrivate.BreakEvent !=
NULL) {
442 gBS->CloseEvent (mDebuggerPrivate.BreakEvent);
448 Object = mDebuggerPrivate.DebuggerSymbolContext.Object;
449 for (Index = 0; Index < EFI_DEBUGGER_SYMBOL_OBJECT_MAX; Index++) {
453 gBS->FreePool (Object[Index].Entry);
454 Object[Index].Entry =
NULL;
455 Object[Index].EntryCount = 0;
459 for (SubIndex = 0; Object[Index].SourceBuffer[SubIndex] !=
NULL; SubIndex++) {
460 gBS->FreePool (Object[Index].SourceBuffer[SubIndex]);
461 Object[Index].SourceBuffer[SubIndex] =
NULL;
464 gBS->FreePool (Object[Index].SourceBuffer);
465 Object[Index].SourceBuffer =
NULL;
471 gBS->FreePool (Object);
472 mDebuggerPrivate.DebuggerSymbolContext.Object =
NULL;
473 mDebuggerPrivate.DebuggerSymbolContext.ObjectCount = 0;
558 if (mDebuggerPrivate.GoTilContext.BreakAddress == (UINT64)(
UINTN)VmPtr->Ip) {
559 mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_GT;
560 mDebuggerPrivate.GoTilContext.BreakAddress = 0;
562 EXCEPT_EBC_BREAKPOINT,
566 mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_GT;
573 if ((mDebuggerPrivate.StepContext.BreakAddress == (UINT64)(
UINTN)VmPtr->Ip) &&
574 (mDebuggerPrivate.StepContext.FramePointer == (UINT64)(
UINTN)VmPtr->FramePtr))
576 mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_STEPOVER;
577 mDebuggerPrivate.StepContext.BreakAddress = 0;
578 mDebuggerPrivate.StepContext.FramePointer = 0;
580 EXCEPT_EBC_BREAKPOINT,
584 mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOVER;
590 if (mDebuggerPrivate.StepContext.BreakAddress == (UINT64)(
UINTN)VmPtr->FramePtr) {
591 mDebuggerPrivate.StatusFlags = EFI_DEBUG_FLAG_EBC_STEPOUT;
592 mDebuggerPrivate.StepContext.BreakAddress = 0;
593 mDebuggerPrivate.StepContext.FramePointer = 0;
595 EXCEPT_EBC_BREAKPOINT,
599 mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_STEPOUT;
605 if (mDebuggerPrivate.StatusFlags == EFI_DEBUG_FLAG_EBC_BOK) {
609 CurrentTpl =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
610 gBS->RestoreTPL (CurrentTpl);
611 if (CurrentTpl <= TPL_APPLICATION) {
613 EXCEPT_EBC_BREAKPOINT,
617 mDebuggerPrivate.StatusFlags &= ~EFI_DEBUG_FLAG_EBC_B_BOK;
642 CopyMem (&Address, (VOID *)((
UINTN)VmPtr->FramePtr), sizeof (Address));
692 CopyMem (&FramePtr, (VOID *)((
UINTN)VmPtr->FramePtr), sizeof (FramePtr));
697 CopyMem (&Address, (VOID *)(
UINTN)VmPtr->Gpr[0], sizeof (Address));
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS EbcDebugSignalException(IN EFI_EXCEPTION_TYPE ExceptionType, IN EXCEPTION_FLAGS ExceptionFlags, IN VM_CONTEXT *VmPtr)
VOID EFIAPI EdbExceptionHandler(IN EFI_EXCEPTION_TYPE ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
VOID EbcDebuggerPushTraceSourceEntry(IN UINT64 SourceEntry, IN EFI_DEBUGGER_BRANCH_TYPE Type)
VOID EbcDebuggerHookJMPStart(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookExecuteStart(IN VM_CONTEXT *VmPtr)
VOID EFIAPI EbcDebuggerBreakEventFunc(IN EFI_EVENT Event, IN VOID *Context)
VOID EbcDebuggerPushTraceDestEntry(IN UINT64 DestEntry, IN EFI_DEBUGGER_BRANCH_TYPE Type)
VOID EbcDebuggerHookCALLEnd(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerPushCallstackSource(IN UINT64 SourceEntry, IN EFI_DEBUGGER_BRANCH_TYPE Type)
VOID EbcDebuggerHookEbcInterpret(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerPushStepEntry(IN UINT64 Entry, IN UINT64 FramePtr, IN UINT32 Flag)
VOID EbcDebuggerHookCALLStart(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerPushCallstackParameter(IN UINT64 ParameterAddress, IN EFI_DEBUGGER_BRANCH_TYPE Type)
VOID EbcDebuggerHookCALLEXStart(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookRETEnd(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookInit(IN EFI_HANDLE Handle, IN EFI_DEBUG_SUPPORT_PROTOCOL *EbcDebugProtocol)
VOID EbcDebuggerPopCallstack(VOID)
VOID EbcDebuggerHookCALLEXEnd(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookJMPEnd(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerCheckHookFlag(IN VM_CONTEXT *VmPtr, IN UINT32 Flag)
VOID EbcDebuggerPushCallstackDest(IN UINT64 DestEntry, IN EFI_DEBUGGER_BRANCH_TYPE Type)
VOID EbcDebuggerHookEbcUnloadImage(IN EFI_HANDLE Handle)
VOID EbcDebuggerHookExecuteEbcImageEntryPoint(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookUnload(VOID)
VOID EbcDebuggerHookJMP8Start(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookExecuteEnd(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookRETStart(IN VM_CONTEXT *VmPtr)
VOID EbcDebuggerHookJMP8End(IN VM_CONTEXT *VmPtr)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
#define EXCEPT_EBC_UNDEFINED
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn