ARM Packages: Removed trailing spaces
Trailing spaces create issue/warning when generating/applying patches. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ronald Cron <ronald.cron@arm.com> Reviewed-By: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15833 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
committed by
oliviermartin
parent
62d441fb17
commit
3402aac7d9
@@ -1,12 +1,12 @@
|
||||
/** @file
|
||||
UEFI driver that implements a GDB stub
|
||||
|
||||
|
||||
Note: Any code in the path of the Serial IO output can not call DEBUG as will
|
||||
will blow out the stack. Serial IO calls DEBUG, debug calls Serail IO, ...
|
||||
|
||||
|
||||
|
||||
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||
|
||||
|
||||
This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
@@ -29,7 +29,7 @@ UINTN gMaxProcessorIndex = 0;
|
||||
CHAR8 gInBuffer[MAX_BUF_SIZE];
|
||||
CHAR8 gOutBuffer[MAX_BUF_SIZE];
|
||||
|
||||
// Assume gdb does a "qXfer:libraries:read::offset,length" when it connects so we can default
|
||||
// Assume gdb does a "qXfer:libraries:read::offset,length" when it connects so we can default
|
||||
// this value to FALSE. Since gdb can reconnect its self a global default is not good enough
|
||||
BOOLEAN gSymbolTableUpdate = FALSE;
|
||||
EFI_EVENT gEvent;
|
||||
@@ -59,12 +59,12 @@ GdbSymbolEventHandler (
|
||||
|
||||
/**
|
||||
The user Entry Point for Application. The user code starts with this function
|
||||
as the real entry point for the image goes into a library that calls this
|
||||
as the real entry point for the image goes into a library that calls this
|
||||
function.
|
||||
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||
@param[in] SystemTable A pointer to the EFI System Table.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS The entry point is executed successfully.
|
||||
@retval other Some error occurs when executing this entry point.
|
||||
|
||||
@@ -76,7 +76,7 @@ GdbStubEntry (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
EFI_DEBUG_SUPPORT_PROTOCOL *DebugSupport;
|
||||
UINTN HandleCount;
|
||||
EFI_HANDLE *Handles;
|
||||
@@ -101,7 +101,7 @@ GdbStubEntry (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
DebugSupport = NULL;
|
||||
IsaSupported = FALSE;
|
||||
do {
|
||||
@@ -120,19 +120,19 @@ GdbStubEntry (
|
||||
}
|
||||
} while (HandleCount > 0);
|
||||
FreePool (Handles);
|
||||
|
||||
|
||||
if (!IsaSupported) {
|
||||
DEBUG ((EFI_D_ERROR, "Debug Support Protocol does not support our ISA\n"));
|
||||
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
Status = DebugSupport->GetMaximumProcessorIndex (DebugSupport, &gMaxProcessorIndex);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
DEBUG ((EFI_D_INFO, "Debug Support Protocol ISA %x\n", DebugSupport->Isa));
|
||||
DEBUG ((EFI_D_INFO, "Debug Support Protocol Processor Index %d\n", gMaxProcessorIndex));
|
||||
|
||||
|
||||
// Call processor-specific init routine
|
||||
InitializeProcessor ();
|
||||
|
||||
@@ -147,10 +147,10 @@ GdbStubEntry (
|
||||
Status = DebugSupport->RegisterPeriodicCallback (DebugSupport, Processor, GdbPeriodicCallBack);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This even fires every time an image is added. This allows the stub to know when gdb needs
|
||||
// to update the symbol table.
|
||||
// to update the symbol table.
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
@@ -171,11 +171,11 @@ GdbStubEntry (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
|
||||
if (PcdGetBool (PcdGdbSerial)) {
|
||||
GdbInitializeSerialConsole ();
|
||||
}
|
||||
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -196,14 +196,14 @@ TransferFromInBufToMem (
|
||||
{
|
||||
CHAR8 c1;
|
||||
CHAR8 c2;
|
||||
|
||||
|
||||
while (Length-- > 0) {
|
||||
c1 = (CHAR8)HexCharToInt (*NewData++);
|
||||
c2 = (CHAR8)HexCharToInt (*NewData++);
|
||||
|
||||
if ((c1 < 0) || (c2 < 0)) {
|
||||
Print ((CHAR16 *)L"Bad message from write to memory..\n");
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
SendError (GDB_EBADMEMDATA);
|
||||
return;
|
||||
}
|
||||
*Address++ = (UINT8)((c1 << 4) + c2);
|
||||
@@ -239,7 +239,7 @@ TransferFromMemToOutBufAndSend (
|
||||
|
||||
OutBufPtr = OutBuffer;
|
||||
while (Length > 0) {
|
||||
|
||||
|
||||
Char = mHexToStr[*Address >> 4];
|
||||
if ((Char >= 'A') && (Char <= 'F')) {
|
||||
Char = Char - 'A' + 'a';
|
||||
@@ -264,16 +264,16 @@ TransferFromMemToOutBufAndSend (
|
||||
|
||||
/**
|
||||
Send a GDB Remote Serial Protocol Packet
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
the packet teminating character '#' and the two digit checksum.
|
||||
|
||||
If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up
|
||||
|
||||
If an ack '+' is not sent resend the packet, but timeout eventually so we don't end up
|
||||
in an infinit loop. This is so if you unplug the debugger code just keeps running
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
|
||||
|
||||
@retval Number of bytes of packet data sent.
|
||||
|
||||
**/
|
||||
@@ -287,7 +287,7 @@ SendPacket (
|
||||
CHAR8 *Ptr;
|
||||
CHAR8 TestChar;
|
||||
UINTN Count;
|
||||
|
||||
|
||||
Timeout = PcdGet32 (PcdGdbMaxPacketRetryCount);
|
||||
|
||||
Count = 0;
|
||||
@@ -299,38 +299,38 @@ SendPacket (
|
||||
// Only try a finite number of times so we don't get stuck in the loop
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
// Packet prefix
|
||||
GdbPutChar ('$');
|
||||
|
||||
|
||||
for (CheckSum = 0, Count =0 ; *Ptr != '\0'; Ptr++, Count++) {
|
||||
GdbPutChar (*Ptr);
|
||||
CheckSum = CheckSum + *Ptr;
|
||||
}
|
||||
|
||||
// Packet terminating character and checksum
|
||||
|
||||
// Packet terminating character and checksum
|
||||
GdbPutChar ('#');
|
||||
GdbPutChar (mHexToStr[CheckSum >> 4]);
|
||||
GdbPutChar (mHexToStr[CheckSum & 0x0F]);
|
||||
|
||||
|
||||
TestChar = GdbGetChar ();
|
||||
} while (TestChar != '+');
|
||||
|
||||
|
||||
return Count;
|
||||
}
|
||||
|
||||
/**
|
||||
Receive a GDB Remote Serial Protocol Packet
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
|
||||
$PacketData#checksum PacketData is passed in and this function adds the packet prefix '$',
|
||||
the packet teminating character '#' and the two digit checksum.
|
||||
|
||||
|
||||
If host re-starts sending a packet without ending the previous packet, only the last valid packet is proccessed.
|
||||
(In other words, if received packet is '$12345$12345$123456#checksum', only '$123456#checksum' will be processed.)
|
||||
|
||||
|
||||
If an ack '+' is not sent resend the packet
|
||||
|
||||
@param PacketData Payload data for the packet
|
||||
@param PacketData Payload data for the packet
|
||||
|
||||
@retval Number of bytes of packet data received.
|
||||
|
||||
@@ -346,16 +346,16 @@ ReceivePacket (
|
||||
CHAR8 Char;
|
||||
CHAR8 SumString[3];
|
||||
CHAR8 TestChar;
|
||||
|
||||
|
||||
ZeroMem (PacketData, PacketDataSize);
|
||||
|
||||
|
||||
for (;;) {
|
||||
// wait for the start of a packet
|
||||
TestChar = GdbGetChar ();
|
||||
while (TestChar != '$') {
|
||||
TestChar = GdbGetChar ();
|
||||
};
|
||||
|
||||
|
||||
retry:
|
||||
for (Index = 0, CheckSum = 0; Index < (PacketDataSize - 1); Index++) {
|
||||
Char = GdbGetChar ();
|
||||
@@ -375,14 +375,14 @@ ReceivePacket (
|
||||
continue;
|
||||
}
|
||||
|
||||
SumString[0] = GdbGetChar ();
|
||||
SumString[0] = GdbGetChar ();
|
||||
SumString[1] = GdbGetChar ();
|
||||
SumString[2] = '\0';
|
||||
|
||||
|
||||
if (AsciiStrHexToUintn (SumString) == CheckSum) {
|
||||
// Ack: Success
|
||||
GdbPutChar ('+');
|
||||
|
||||
|
||||
// Null terminate the callers string
|
||||
PacketData[Index] = '\0';
|
||||
return Index;
|
||||
@@ -391,27 +391,27 @@ ReceivePacket (
|
||||
GdbPutChar ('-');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Empties the given buffer
|
||||
Empties the given buffer
|
||||
@param Buf pointer to the first element in buffer to be emptied
|
||||
**/
|
||||
VOID
|
||||
EmptyBuffer (
|
||||
EmptyBuffer (
|
||||
IN CHAR8 *Buf
|
||||
)
|
||||
{
|
||||
{
|
||||
*Buf = '\0';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Converts an 8-bit Hex Char into a INTN.
|
||||
|
||||
|
||||
@param Char the hex character to be converted into UINTN
|
||||
@retval a INTN, from 0 to 15, that corressponds to Char
|
||||
-1 if Char is not a hex character
|
||||
@@ -428,7 +428,7 @@ HexCharToInt (
|
||||
} else if ((Char >= '0') && (Char <= '9')) {
|
||||
return Char - '0';
|
||||
} else { // if not a hex value, return a negative value
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ CHAR8 *gError = "E__";
|
||||
Send an error with the given error number after converting to hex.
|
||||
The error number is put into the buffer in hex. '255' is the biggest errno we can send.
|
||||
ex: 162 will be sent as A2.
|
||||
|
||||
|
||||
@param errno the error number that will be sent
|
||||
**/
|
||||
VOID
|
||||
@@ -453,7 +453,7 @@ SendError (
|
||||
//
|
||||
gError[1] = mHexToStr [ErrorNum >> 4];
|
||||
gError[2] = mHexToStr [ErrorNum & 0x0f];
|
||||
|
||||
|
||||
SendPacket (gError); // send buffer
|
||||
}
|
||||
|
||||
@@ -466,7 +466,7 @@ VOID
|
||||
EFIAPI
|
||||
SendSuccess (
|
||||
VOID
|
||||
)
|
||||
)
|
||||
{
|
||||
SendPacket ("OK"); // send buffer
|
||||
}
|
||||
@@ -475,11 +475,11 @@ SendSuccess (
|
||||
/**
|
||||
Send empty packet to specify that particular command/functionality is not supported.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
VOID
|
||||
EFIAPI
|
||||
SendNotSupported (
|
||||
VOID
|
||||
)
|
||||
VOID
|
||||
)
|
||||
{
|
||||
SendPacket ("");
|
||||
}
|
||||
@@ -487,7 +487,7 @@ SendNotSupported (
|
||||
|
||||
/**
|
||||
Send the T signal with the given exception type (in gdb order) and possibly with n:r pairs related to the watchpoints
|
||||
|
||||
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param GdbExceptionType GDB exception type
|
||||
**/
|
||||
@@ -513,9 +513,9 @@ GdbSendTSignal (
|
||||
//
|
||||
// replace _, or previous value, with Exception type
|
||||
//
|
||||
*TSignalPtr++ = mHexToStr [GdbExceptionType >> 4];
|
||||
*TSignalPtr++ = mHexToStr [GdbExceptionType >> 4];
|
||||
*TSignalPtr++ = mHexToStr [GdbExceptionType & 0x0f];
|
||||
|
||||
|
||||
if (GdbExceptionType == GDB_SIGTRAP) {
|
||||
if (gSymbolTableUpdate) {
|
||||
//
|
||||
@@ -531,17 +531,17 @@ GdbSendTSignal (
|
||||
|
||||
//
|
||||
// possible n:r pairs
|
||||
//
|
||||
//
|
||||
|
||||
//Retrieve the breakpoint number
|
||||
BreakpointDetected = GetBreakpointDetected (SystemContext);
|
||||
|
||||
//Figure out if the exception is happend due to watch, rwatch or awatch.
|
||||
BreakType = GetBreakpointType (SystemContext, BreakpointDetected);
|
||||
BreakType = GetBreakpointType (SystemContext, BreakpointDetected);
|
||||
|
||||
//INFO: rwatch is not supported due to the way IA32 debug registers work
|
||||
if ((BreakType == DataWrite) || (BreakType == DataRead) || (BreakType == DataReadWrite)) {
|
||||
|
||||
|
||||
//Construct n:r pair
|
||||
DataAddress = GetBreakpointDataAddress (SystemContext, BreakpointDetected);
|
||||
|
||||
@@ -559,7 +559,7 @@ GdbSendTSignal (
|
||||
}
|
||||
|
||||
*TSignalPtr++ = ':';
|
||||
|
||||
|
||||
//Set up series of bytes in big-endian byte order. "awatch" won't work with little-endian byte order.
|
||||
RegSize = REG_SIZE;
|
||||
while (RegSize > 0) {
|
||||
@@ -575,23 +575,23 @@ GdbSendTSignal (
|
||||
|
||||
*TSignalPtr = '\0';
|
||||
|
||||
SendPacket (TSignalBuffer);
|
||||
SendPacket (TSignalBuffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Translates the EFI mapping to GDB mapping
|
||||
|
||||
|
||||
@param EFIExceptionType EFI Exception that is being processed
|
||||
@retval UINTN that corresponds to EFIExceptionType's GDB exception type number
|
||||
**/
|
||||
UINT8
|
||||
ConvertEFItoGDBtype (
|
||||
ConvertEFItoGDBtype (
|
||||
IN EFI_EXCEPTION_TYPE EFIExceptionType
|
||||
)
|
||||
{
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
|
||||
for (Index = 0; Index < MaxEfiException () ; Index++) {
|
||||
if (gExceptionType[Index].Exception == EFIExceptionType) {
|
||||
return gExceptionType[Index].SignalNo;
|
||||
@@ -602,8 +602,8 @@ ConvertEFItoGDBtype (
|
||||
|
||||
|
||||
/** "m addr,length"
|
||||
Find the Length of the area to read and the start addres. Finally, pass them to
|
||||
another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
|
||||
Find the Length of the area to read and the start addres. Finally, pass them to
|
||||
another function, TransferFromMemToOutBufAndSend, that will read from that memory space and
|
||||
send it as a packet.
|
||||
**/
|
||||
|
||||
@@ -618,39 +618,39 @@ ReadFromMemory (
|
||||
CHAR8 AddressBuffer[MAX_ADDR_SIZE]; // the buffer that will hold the address in hex chars
|
||||
CHAR8 *AddrBufPtr; // pointer to the address buffer
|
||||
CHAR8 *InBufPtr; /// pointer to the input buffer
|
||||
|
||||
|
||||
AddrBufPtr = AddressBuffer;
|
||||
InBufPtr = &PacketData[1];
|
||||
while (*InBufPtr != ',') {
|
||||
*AddrBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
*AddrBufPtr = '\0';
|
||||
|
||||
|
||||
InBufPtr++; // this skips ',' in the buffer
|
||||
|
||||
|
||||
/* Error checking */
|
||||
if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
|
||||
Print((CHAR16 *)L"Address is too long\n");
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 2 = 'm' + ','
|
||||
if (AsciiStrLen (PacketData) - AsciiStrLen (AddressBuffer) - 2 >= MAX_LENGTH_SIZE) {
|
||||
Print((CHAR16 *)L"Length is too long\n");
|
||||
SendError (GDB_EBADMEMLENGTH);
|
||||
SendError (GDB_EBADMEMLENGTH);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Address = AsciiStrHexToUintn (AddressBuffer);
|
||||
Length = AsciiStrHexToUintn (InBufPtr);
|
||||
|
||||
|
||||
TransferFromMemToOutBufAndSend (Length, (unsigned char *)Address);
|
||||
}
|
||||
|
||||
|
||||
/** "M addr,length :XX..."
|
||||
Find the Length of the area in bytes to write and the start addres. Finally, pass them to
|
||||
Find the Length of the area in bytes to write and the start addres. Finally, pass them to
|
||||
another function, TransferFromInBufToMem, that will write to that memory space the info in
|
||||
the input buffer.
|
||||
**/
|
||||
@@ -668,50 +668,50 @@ WriteToMemory (
|
||||
CHAR8 *AddrBufPtr; // pointer to the Address buffer
|
||||
CHAR8 *LengthBufPtr; // pointer to the Length buffer
|
||||
CHAR8 *InBufPtr; /// pointer to the input buffer
|
||||
|
||||
|
||||
AddrBufPtr = AddressBuffer;
|
||||
LengthBufPtr = LengthBuffer;
|
||||
InBufPtr = &PacketData[1];
|
||||
|
||||
|
||||
while (*InBufPtr != ',') {
|
||||
*AddrBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
*AddrBufPtr = '\0';
|
||||
|
||||
|
||||
InBufPtr++; // this skips ',' in the buffer
|
||||
|
||||
|
||||
while (*InBufPtr != ':') {
|
||||
*LengthBufPtr++ = *InBufPtr++;
|
||||
}
|
||||
*LengthBufPtr = '\0';
|
||||
|
||||
|
||||
InBufPtr++; // this skips ':' in the buffer
|
||||
|
||||
|
||||
Address = AsciiStrHexToUintn (AddressBuffer);
|
||||
Length = AsciiStrHexToUintn (LengthBuffer);
|
||||
|
||||
|
||||
/* Error checking */
|
||||
|
||||
|
||||
//Check if Address is not too long.
|
||||
if (AsciiStrLen (AddressBuffer) >= MAX_ADDR_SIZE) {
|
||||
Print ((CHAR16 *)L"Address too long..\n");
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
SendError (GDB_EBADMEMADDRBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Check if message length is not too long
|
||||
if (AsciiStrLen (LengthBuffer) >= MAX_LENGTH_SIZE) {
|
||||
Print ((CHAR16 *)L"Length too long..\n");
|
||||
SendError (GDB_EBADMEMLENGBUFSIZE);
|
||||
SendError (GDB_EBADMEMLENGBUFSIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check if Message is not too long/short.
|
||||
// 3 = 'M' + ',' + ':'
|
||||
MessageLength = (AsciiStrLen (PacketData) - AsciiStrLen (AddressBuffer) - AsciiStrLen (LengthBuffer) - 3);
|
||||
if (MessageLength != (2*Length)) {
|
||||
//Message too long/short. New data is not the right size.
|
||||
SendError (GDB_EBADMEMDATASIZE);
|
||||
SendError (GDB_EBADMEMDATASIZE);
|
||||
return;
|
||||
}
|
||||
TransferFromInBufToMem (Length, (unsigned char *)Address, InBufPtr);
|
||||
@@ -800,7 +800,7 @@ gXferObjectReadResponse (
|
||||
*OutBufPtr++ = Type;
|
||||
Count = 1;
|
||||
|
||||
// Binary data encoding
|
||||
// Binary data encoding
|
||||
OutBufPtr = gOutBuffer;
|
||||
while (*Str != '\0') {
|
||||
Char = *Str++;
|
||||
@@ -816,17 +816,17 @@ gXferObjectReadResponse (
|
||||
|
||||
*OutBufPtr = '\0' ; // the end of the buffer
|
||||
SendPacket (gOutBuffer);
|
||||
|
||||
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Note: This should be a library function. In the Apple case you have to add
|
||||
the size of the PE/COFF header into the starting address to make things work
|
||||
Note: This should be a library function. In the Apple case you have to add
|
||||
the size of the PE/COFF header into the starting address to make things work
|
||||
right as there is no way to pad the Mach-O for the size of the PE/COFF header.
|
||||
|
||||
|
||||
|
||||
|
||||
Returns a pointer to the PDB file name for a PE/COFF image that has been
|
||||
loaded into system memory with the PE/COFF Loader Library functions.
|
||||
|
||||
@@ -844,7 +844,7 @@ gXferObjectReadResponse (
|
||||
|
||||
@return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
|
||||
if it cannot be retrieved. DebugBase is only valid if PDB file name is
|
||||
valid.
|
||||
valid.
|
||||
|
||||
**/
|
||||
VOID *
|
||||
@@ -895,14 +895,14 @@ PeCoffLoaderGetDebuggerInfo (
|
||||
TEImageAdjust);
|
||||
}
|
||||
SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
|
||||
|
||||
|
||||
// __APPLE__ check this math...
|
||||
*DebugBase = ((CHAR8 *)Pe32Data) - TEImageAdjust;
|
||||
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
|
||||
|
||||
|
||||
*DebugBase = Pe32Data;
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
|
||||
// It is due to backward-compatibility, for some system might
|
||||
@@ -983,38 +983,38 @@ PeCoffLoaderGetDebuggerInfo (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
Process "qXfer:object:read:annex:offset,length" request.
|
||||
|
||||
Returns an XML document that contains loaded libraries. In our case it is
|
||||
|
||||
Returns an XML document that contains loaded libraries. In our case it is
|
||||
information in the EFI Debug Image Table converted into an XML document.
|
||||
|
||||
GDB will call with an arbitrary length (it can't know the real length and
|
||||
will reply with chunks of XML that are easy for us to deal with. Gdb will
|
||||
|
||||
GDB will call with an arbitrary length (it can't know the real length and
|
||||
will reply with chunks of XML that are easy for us to deal with. Gdb will
|
||||
keep calling until we say we are done. XML doc looks like:
|
||||
|
||||
|
||||
<library-list>
|
||||
<library name="/a/a/c/d.dSYM"><segment address="0x10000000"/></library>
|
||||
<library name="/a/m/e/e.pdb"><segment address="0x20000000"/></library>
|
||||
<library name="/a/l/f/f.dll"><segment address="0x30000000"/></library>
|
||||
</library-list>
|
||||
|
||||
|
||||
Since we can not allocate memory in interrupt context this module has
|
||||
assumptions about how it will get called:
|
||||
1) Length will generally be max remote packet size (big enough)
|
||||
2) First Offset of an XML document read needs to be 0
|
||||
3) This code will return back small chunks of the XML document on every read.
|
||||
Each subsequent call will ask for the next available part of the document.
|
||||
|
||||
|
||||
Note: The only variable size element in the XML is:
|
||||
" <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
|
||||
" <library name=\"%s\"><segment address=\"%p\"/></library>\n" and it is
|
||||
based on the file path and name of the symbol file. If the symbol file name
|
||||
is bigger than the max gdb remote packet size we could update this code
|
||||
to respond back in chunks.
|
||||
|
||||
@param Offset offset into special data area
|
||||
@param Length number of bytes to read starting at Offset
|
||||
|
||||
@param Length number of bytes to read starting at Offset
|
||||
|
||||
**/
|
||||
VOID
|
||||
QxferLibrary (
|
||||
@@ -1029,8 +1029,8 @@ QxferLibrary (
|
||||
if (Offset != gPacketqXferLibraryOffset) {
|
||||
SendError (GDB_EINVALIDARG);
|
||||
Print (L"\nqXferLibrary (%d, %d) != %d\n", Offset, Length, gPacketqXferLibraryOffset);
|
||||
|
||||
// Force a retry from the beginning
|
||||
|
||||
// Force a retry from the beginning
|
||||
gPacketqXferLibraryOffset = 0;
|
||||
|
||||
return;
|
||||
@@ -1038,41 +1038,41 @@ QxferLibrary (
|
||||
|
||||
if (Offset == 0) {
|
||||
gPacketqXferLibraryOffset += gXferObjectReadResponse ('m', "<library-list>\n");
|
||||
|
||||
|
||||
// The owner of the table may have had to ralloc it so grab a fresh copy every time
|
||||
// we assume qXferLibrary will get called over and over again until the entire XML table is
|
||||
// we assume qXferLibrary will get called over and over again until the entire XML table is
|
||||
// returned in a tight loop. Since we are in the debugger the table should not get updated
|
||||
gDebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;
|
||||
gEfiDebugImageTableEntry = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (gDebugTable != NULL) {
|
||||
for (; gEfiDebugImageTableEntry < gDebugImageTableHeader->TableSize; gEfiDebugImageTableEntry++, gDebugTable++) {
|
||||
if (gDebugTable->NormalImage != NULL) {
|
||||
if ((gDebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
|
||||
if ((gDebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
|
||||
(gDebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
|
||||
Pdb = PeCoffLoaderGetDebuggerInfo (
|
||||
gDebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase,
|
||||
gDebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase,
|
||||
&LoadAddress
|
||||
);
|
||||
if (Pdb != NULL) {
|
||||
Size = AsciiSPrint (
|
||||
gXferLibraryBuffer,
|
||||
sizeof (gXferLibraryBuffer),
|
||||
" <library name=\"%a\"><segment address=\"0x%p\"/></library>\n",
|
||||
gXferLibraryBuffer,
|
||||
sizeof (gXferLibraryBuffer),
|
||||
" <library name=\"%a\"><segment address=\"0x%p\"/></library>\n",
|
||||
Pdb,
|
||||
LoadAddress
|
||||
);
|
||||
if ((Size != 0) && (Size != (sizeof (gXferLibraryBuffer) - 1))) {
|
||||
gPacketqXferLibraryOffset += gXferObjectReadResponse ('m', gXferLibraryBuffer);
|
||||
|
||||
|
||||
// Update loop variables so we are in the right place when we get back
|
||||
gEfiDebugImageTableEntry++;
|
||||
gDebugTable++;
|
||||
return;
|
||||
} else {
|
||||
// We could handle <library> entires larger than sizeof (gXferLibraryBuffer) here if
|
||||
// We could handle <library> entires larger than sizeof (gXferLibraryBuffer) here if
|
||||
// needed by breaking up into N packets
|
||||
// "<library name=\"%s
|
||||
// the rest of the string (as many packets as required
|
||||
@@ -1080,13 +1080,13 @@ QxferLibrary (
|
||||
//
|
||||
// But right now we just skip any entry that is too big
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
gXferObjectReadResponse ('l', "</library-list>\n");
|
||||
gPacketqXferLibraryOffset = 0;
|
||||
return;
|
||||
@@ -1096,55 +1096,55 @@ QxferLibrary (
|
||||
/**
|
||||
Exception Hanldler for GDB. It will be called for all exceptions
|
||||
registered via the gExceptionType[] array.
|
||||
|
||||
|
||||
@param ExceptionType Exception that is being processed
|
||||
@param SystemContext Register content at time of the exception
|
||||
@param SystemContext Register content at time of the exception
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
GdbExceptionHandler (
|
||||
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
UINT8 GdbExceptionType;
|
||||
CHAR8 *Ptr;
|
||||
|
||||
|
||||
|
||||
|
||||
if (ValidateException (ExceptionType, SystemContext) == FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveSingleStep (SystemContext);
|
||||
|
||||
|
||||
GdbExceptionType = ConvertEFItoGDBtype (ExceptionType);
|
||||
GdbSendTSignal (SystemContext, GdbExceptionType);
|
||||
|
||||
|
||||
for( ; ; ) {
|
||||
ReceivePacket (gInBuffer, MAX_BUF_SIZE);
|
||||
|
||||
|
||||
switch (gInBuffer[0]) {
|
||||
case '?':
|
||||
GdbSendTSignal (SystemContext, GdbExceptionType);
|
||||
break;
|
||||
|
||||
|
||||
case 'c':
|
||||
ContinueAtAddress (SystemContext, gInBuffer);
|
||||
ContinueAtAddress (SystemContext, gInBuffer);
|
||||
return;
|
||||
|
||||
case 'g':
|
||||
ReadGeneralRegisters (SystemContext);
|
||||
break;
|
||||
|
||||
|
||||
case 'G':
|
||||
WriteGeneralRegisters (SystemContext, gInBuffer);
|
||||
break;
|
||||
|
||||
|
||||
case 'H':
|
||||
//Return "OK" packet since we don't have more than one thread.
|
||||
//Return "OK" packet since we don't have more than one thread.
|
||||
SendSuccess ();
|
||||
break;
|
||||
|
||||
|
||||
case 'm':
|
||||
ReadFromMemory (gInBuffer);
|
||||
break;
|
||||
@@ -1160,7 +1160,7 @@ GdbExceptionHandler (
|
||||
//
|
||||
// Still debugging this code. Not used in Darwin
|
||||
//
|
||||
case 'q':
|
||||
case 'q':
|
||||
// General Query Packets
|
||||
if (AsciiStrnCmp (gInBuffer, "qSupported", 10) == 0) {
|
||||
// return what we currently support, we don't parse what gdb suports
|
||||
@@ -1170,7 +1170,7 @@ GdbExceptionHandler (
|
||||
// ‘qXfer:libraries:read::offset,length
|
||||
// gInBuffer[22] is offset string, ++Ptr is length string’
|
||||
for (Ptr = &gInBuffer[22]; *Ptr != ','; Ptr++);
|
||||
|
||||
|
||||
// Not sure if multi-radix support is required. Currently only support decimal
|
||||
QxferLibrary (AsciiStrHexToUintn (&gInBuffer[22]), AsciiStrHexToUintn (++Ptr));
|
||||
} if (AsciiStrnCmp (gInBuffer, "qOffsets", 10) == 0) {
|
||||
@@ -1183,18 +1183,18 @@ GdbExceptionHandler (
|
||||
break;
|
||||
|
||||
case 's':
|
||||
SingleStep (SystemContext, gInBuffer);
|
||||
SingleStep (SystemContext, gInBuffer);
|
||||
return;
|
||||
|
||||
|
||||
case 'z':
|
||||
RemoveBreakPoint (SystemContext, gInBuffer);
|
||||
break;
|
||||
|
||||
|
||||
case 'Z':
|
||||
InsertBreakPoint (SystemContext, gInBuffer);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
default:
|
||||
//Send empty packet
|
||||
SendNotSupported ();
|
||||
break;
|
||||
@@ -1204,28 +1204,28 @@ GdbExceptionHandler (
|
||||
|
||||
|
||||
/**
|
||||
Periodic callback for GDB. This function is used to catch a ctrl-c or other
|
||||
Periodic callback for GDB. This function is used to catch a ctrl-c or other
|
||||
break in type command from GDB.
|
||||
|
||||
@param SystemContext Register content at time of the call
|
||||
|
||||
@param SystemContext Register content at time of the call
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
GdbPeriodicCallBack (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
GdbPeriodicCallBack (
|
||||
IN OUT EFI_SYSTEM_CONTEXT SystemContext
|
||||
)
|
||||
{
|
||||
//
|
||||
// gCtrlCBreakFlag may have been set from a previous F response package
|
||||
// and we set the global as we need to process it at a point where we
|
||||
// gCtrlCBreakFlag may have been set from a previous F response package
|
||||
// and we set the global as we need to process it at a point where we
|
||||
// can update the system context. If we are in the middle of processing
|
||||
// a F Packet it is not safe to read the GDB serial stream so we need
|
||||
// to skip it on this check
|
||||
//
|
||||
if (!gCtrlCBreakFlag && !gProcessingFPacket) {
|
||||
//
|
||||
// Ctrl-C was not pending so grab any pending characters and see if they
|
||||
// are a Ctrl-c (0x03). If so set the Ctrl-C global.
|
||||
// Ctrl-C was not pending so grab any pending characters and see if they
|
||||
// are a Ctrl-c (0x03). If so set the Ctrl-C global.
|
||||
//
|
||||
while (TRUE) {
|
||||
if (!GdbIsCharAvailable ()) {
|
||||
@@ -1234,7 +1234,7 @@ GdbPeriodicCallBack (
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (GdbGetChar () == 0x03) {
|
||||
gCtrlCBreakFlag = TRUE;
|
||||
//
|
||||
@@ -1244,7 +1244,7 @@ GdbPeriodicCallBack (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (gCtrlCBreakFlag) {
|
||||
//
|
||||
// Update the context to force a single step trap when we exit the GDB
|
||||
|
Reference in New Issue
Block a user