public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Why the DEBUG can't output the full string?
@ 2018-02-01  9:47 krishnaLee
  2018-02-01 16:23 ` Laszlo Ersek
  0 siblings, 1 reply; 6+ messages in thread
From: krishnaLee @ 2018-02-01  9:47 UTC (permalink / raw)
  To: edk2-devel

Hi,
For example,the follow code:
//-code-start
ConfigRequestHdr = HiiConstructConfigHdr (&mBlankDrvFormSetGuid, VariableName, PrivateData1->DriverHandle[0]);
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
//-code-end


I add a debug message at the end of code:
DEBUG((EFI_D_INFO,"construct-ConfigRequest:%s",ConfigRequest));
DEBUG((EFI_D_INFO,"\r\n"));


and the output will be:
construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000


If I add another debug message at the end of code:
DEBUG((EFI_D_INFO,"construct-ConfigRequest:"));
for(UINTN i=0;i<Size;i++)
{
DEBUG((EFI_D_INFO,"%c",ConfigRequest[i]));
}
DEBUG((EFI_D_INFO,"\r\n"));


and the output will be:
construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000000052 pa&#65533;&#65533;?&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;pr&#65533;a <_<_ &#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;


my platform:
win10_x64 + udk2017 + vs2015




by krishna

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why the DEBUG can't output the full string?
  2018-02-01  9:47 Why the DEBUG can't output the full string? krishnaLee
@ 2018-02-01 16:23 ` Laszlo Ersek
  2018-02-01 19:21   ` Andrew Fish
  2018-02-02  1:41   ` Ni, Ruiyu
  0 siblings, 2 replies; 6+ messages in thread
From: Laszlo Ersek @ 2018-02-01 16:23 UTC (permalink / raw)
  To: krishnaLee, edk2-devel

On 02/01/18 10:47, krishnaLee wrote:
> Hi,
> For example,the follow code:
> //-code-start
> ConfigRequestHdr = HiiConstructConfigHdr (&mBlankDrvFormSetGuid, VariableName, PrivateData1->DriverHandle[0]);
> Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
> ConfigRequest = AllocateZeroPool (Size);
> ASSERT (ConfigRequest != NULL);
> AllocatedRequest = TRUE;
> UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
> FreePool (ConfigRequestHdr);
> //-code-end
> 
> 
> I add a debug message at the end of code:
> DEBUG((EFI_D_INFO,"construct-ConfigRequest:%s",ConfigRequest));
> DEBUG((EFI_D_INFO,"\r\n"));
> 
> 
> and the output will be:
> construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000
> 
> 
> If I add another debug message at the end of code:
> DEBUG((EFI_D_INFO,"construct-ConfigRequest:"));
> for(UINTN i=0;i<Size;i++)
> {
> DEBUG((EFI_D_INFO,"%c",ConfigRequest[i]));
> }
> DEBUG((EFI_D_INFO,"\r\n"));
> 
> 
> and the output will be:
> construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000000052 pa?pr╝ <_<_ 
> 
> 
> my platform:
> win10_x64 + udk2017 + vs2015

Umm, I'm a bit confused by your query.

* First, most DebugLib instances have an internal buffer with fixed size
(for the DebugPrint() function). If you try to log longer messages, they
will be truncated.

For example, in "MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c",
there is:

#define MAX_DEBUG_MESSAGE_LENGTH  0x100

(I don't really understand your situation because the first debug
message that you pasted does *not* look truncated.)


* Second, regarding the trailing garbage. You set "Size" to the number
of *bytes* required for a NUL-terminated CHAR16 config request string,
plus 32 CHAR16 objects. This is then correctly passed to both
AllocateZeroPool() and UnicodeSPrint(). However, in the loop where you
print individual CHAR16 objects, you also count up to the number of
*bytes* -- that's incorrect, the limit should be the number of CHAR16
objects (or the NUL-terminator, of course).

Laszlo


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why the DEBUG can't output the full string?
  2018-02-01 16:23 ` Laszlo Ersek
@ 2018-02-01 19:21   ` Andrew Fish
  2018-02-02  2:07     ` krishnaLee
  2018-02-02  1:41   ` Ni, Ruiyu
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Fish @ 2018-02-01 19:21 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: krishnaLee, edk2-devel



> On Feb 1, 2018, at 8:23 AM, Laszlo Ersek <lersek@redhat.com> wrote:
> 
> On 02/01/18 10:47, krishnaLee wrote:
>> Hi,
>> For example,the follow code:
>> //-code-start
>> ConfigRequestHdr = HiiConstructConfigHdr (&mBlankDrvFormSetGuid, VariableName, PrivateData1->DriverHandle[0]);
>> Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
>> ConfigRequest = AllocateZeroPool (Size);
>> ASSERT (ConfigRequest != NULL);
>> AllocatedRequest = TRUE;
>> UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
>> FreePool (ConfigRequestHdr);
>> //-code-end
>> 
>> 
>> I add a debug message at the end of code:
>> DEBUG((EFI_D_INFO,"construct-ConfigRequest:%s",ConfigRequest));
>> DEBUG((EFI_D_INFO,"\r\n"));
>> 
>> 
>> and the output will be:
>> construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000
>> 
>> 
>> If I add another debug message at the end of code:
>> DEBUG((EFI_D_INFO,"construct-ConfigRequest:"));
>> for(UINTN i=0;i<Size;i++)
>> {
>> DEBUG((EFI_D_INFO,"%c",ConfigRequest[i]));
>> }
>> DEBUG((EFI_D_INFO,"\r\n"));
>> 
>> 
>> and the output will be:
>> construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000000052 pa?pr╝ <_<_ 
>> 
>> 
>> my platform:
>> win10_x64 + udk2017 + vs2015
> 
> Umm, I'm a bit confused by your query.
> 
> * First, most DebugLib instances have an internal buffer with fixed size
> (for the DebugPrint() function). If you try to log longer messages, they
> will be truncated.
> 
> For example, in "MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c",
> there is:
> 
> #define MAX_DEBUG_MESSAGE_LENGTH  0x100
> 
> (I don't really understand your situation because the first debug
> message that you pasted does *not* look truncated.)
> 

WIDTH=0000000000 != WIDTH=0000000000000052 

Maybe "%016LX" is a little overkill for a width?

Thanks,

Andrew Fish

> 
> * Second, regarding the trailing garbage. You set "Size" to the number
> of *bytes* required for a NUL-terminated CHAR16 config request string,
> plus 32 CHAR16 objects. This is then correctly passed to both
> AllocateZeroPool() and UnicodeSPrint(). However, in the loop where you
> print individual CHAR16 objects, you also count up to the number of
> *bytes* -- that's incorrect, the limit should be the number of CHAR16
> objects (or the NUL-terminator, of course).
> 
> Laszlo
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org <mailto:edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel <https://lists.01.org/mailman/listinfo/edk2-devel>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why the DEBUG can't output the full string?
  2018-02-01 16:23 ` Laszlo Ersek
  2018-02-01 19:21   ` Andrew Fish
@ 2018-02-02  1:41   ` Ni, Ruiyu
  1 sibling, 0 replies; 6+ messages in thread
From: Ni, Ruiyu @ 2018-02-02  1:41 UTC (permalink / raw)
  To: Laszlo Ersek, krishnaLee, edk2-devel

On 2/2/2018 12:23 AM, Laszlo Ersek wrote:
> On 02/01/18 10:47, krishnaLee wrote:
>> Hi,
>> For example,the follow code:
>> //-code-start
>> ConfigRequestHdr = HiiConstructConfigHdr (&mBlankDrvFormSetGuid, VariableName, PrivateData1->DriverHandle[0]);
>> Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
>> ConfigRequest = AllocateZeroPool (Size);
>> ASSERT (ConfigRequest != NULL);
>> AllocatedRequest = TRUE;
>> UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
>> FreePool (ConfigRequestHdr);
>> //-code-end
>>
>>
>> I add a debug message at the end of code:
>> DEBUG((EFI_D_INFO,"construct-ConfigRequest:%s",ConfigRequest));
>> DEBUG((EFI_D_INFO,"\r\n"));
>>
>>
>> and the output will be:
>> construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000
>>
>>
>> If I add another debug message at the end of code:
>> DEBUG((EFI_D_INFO,"construct-ConfigRequest:"));
>> for(UINTN i=0;i<Size;i++)
>> {
>> DEBUG((EFI_D_INFO,"%c",ConfigRequest[i]));
>> }
>> DEBUG((EFI_D_INFO,"\r\n"));
>>
>>
>> and the output will be:
>> construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000000052 pa?pr╝ <_<_ 
>>
>>
>> my platform:
>> win10_x64 + udk2017 + vs2015
> 
> Umm, I'm a bit confused by your query.
> 
> * First, most DebugLib instances have an internal buffer with fixed size
> (for the DebugPrint() function). If you try to log longer messages, they
> will be truncated.
> 
> For example, in "MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c",
> there is:
> 
> #define MAX_DEBUG_MESSAGE_LENGTH  0x100

Yes that's the root cause I guess.
The DebugLib depends on ReportStatusCode also has similar
max message length limitation.

> 
> (I don't really understand your situation because the first debug
> message that you pasted does *not* look truncated.)
> 
> 
> * Second, regarding the trailing garbage. You set "Size" to the number
> of *bytes* required for a NUL-terminated CHAR16 config request string,
> plus 32 CHAR16 objects. This is then correctly passed to both
> AllocateZeroPool() and UnicodeSPrint(). However, in the loop where you
> print individual CHAR16 objects, you also count up to the number of
> *bytes* -- that's incorrect, the limit should be the number of CHAR16
> objects (or the NUL-terminator, of course).
> 
> Laszlo
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 


-- 
Thanks,
Ray


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why the DEBUG can't output the full string?
  2018-02-01 19:21   ` Andrew Fish
@ 2018-02-02  2:07     ` krishnaLee
  2018-02-06  1:52       ` krishnaLee
  0 siblings, 1 reply; 6+ messages in thread
From: krishnaLee @ 2018-02-02  2:07 UTC (permalink / raw)
  To: Andrew Fish; +Cc: Laszlo Ersek, edk2-devel

Hi Andrew Fish,
I didn't know the internal buffer is limited, I just think the Hii <ConfigRequest>  will be a formatted string,I want to understarnd how it worked so I print it,I find the result is not  as I expected...
I had calculate the first DEBUG string length,it is 199 chars limited.then I  search the MdePkg+MdeModulePkg for the define "MAX_DEBUG_MESSAGE_LENGTH",and modify them all to"#define MAX_DEBUG_MESSAGE_LENGTH 0x200",
rebuild Nt32Pkg,run my test,but the result is same,it is still 199 chars limited.


thanks.














At 2018-02-02 03:21:06, "Andrew Fish" <afish@apple.com> wrote:




On Feb 1, 2018, at 8:23 AM, Laszlo Ersek <lersek@redhat.com> wrote:


On 02/01/18 10:47, krishnaLee wrote:
Hi,
For example,the follow code:
//-code-start
ConfigRequestHdr = HiiConstructConfigHdr (&mBlankDrvFormSetGuid, VariableName, PrivateData1->DriverHandle[0]);
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
//-code-end


I add a debug message at the end of code:
DEBUG((EFI_D_INFO,"construct-ConfigRequest:%s",ConfigRequest));
DEBUG((EFI_D_INFO,"\r\n"));


and the output will be:
construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000


If I add another debug message at the end of code:
DEBUG((EFI_D_INFO,"construct-ConfigRequest:"));
for(UINTN i=0;i<Size;i++)
{
DEBUG((EFI_D_INFO,"%c",ConfigRequest[i]));
}
DEBUG((EFI_D_INFO,"\r\n"));


and the output will be:
construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000000052 pa&#65533;&#65533;?&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;pr&#65533;a <_<_ &#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;


my platform:
win10_x64 + udk2017 + vs2015

Umm, I'm a bit confused by your query.

* First, most DebugLib instances have an internal buffer with fixed size
(for the DebugPrint() function). If you try to log longer messages, they
will be truncated.

For example, in "MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c",
there is:

#define MAX_DEBUG_MESSAGE_LENGTH  0x100

(I don't really understand your situation because the first debug
message that you pasted does *not* look truncated.)




WIDTH=0000000000 != WIDTH=0000000000000052 


Maybe "%016LX" is a little overkill for a width?


Thanks,


Andrew Fish



* Second, regarding the trailing garbage. You set "Size" to the number
of *bytes* required for a NUL-terminated CHAR16 config request string,
plus 32 CHAR16 objects. This is then correctly passed to both
AllocateZeroPool() and UnicodeSPrint(). However, in the loop where you
print individual CHAR16 objects, you also count up to the number of
*bytes* -- that's incorrect, the limit should be the number of CHAR16
objects (or the NUL-terminator, of course).

Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why the DEBUG can't output the full string?
  2018-02-02  2:07     ` krishnaLee
@ 2018-02-06  1:52       ` krishnaLee
  0 siblings, 0 replies; 6+ messages in thread
From: krishnaLee @ 2018-02-06  1:52 UTC (permalink / raw)
  To: krishnaLee; +Cc: Andrew Fish, Laszlo Ersek, edk2-devel



Hi Laszlo Ersek and Andrew Fish,
I had change all the MACRO in MdePkg + MdeModulePkg  like this  "#define MAX_DEBUG_MESSAGE_LENGTH 0x1000",and it has no function;
I had also change follow MACRO value from 200 to 1000:
//
D:\edk2-vUDK2017\MdeModulePkg\Include\Guid\StatusCodeDataTypeDebug.h
///
/// The maximum size of an EFI_DEBUG_INFO structure.
///
#define EFI_STATUS_CODE_DATA_MAX_SIZE 1000
//


I had clean and rebuild the project Nt32Pkg and follow test.
then the debug char's length is extended ok,This behave looks strange...


//test code:
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
CHAR16 buffer[]=L"-A000000000-1111111111-aaaaaaaaaa-bbbbbbbbbb-cccccccccc-dddddddddd-eeeeeeeeee-ffffffffff-gggggggggg\
--B000000000-1111111111-aaaaaaaaaa-bbbbbbbbbb-cccccccccc-dddddddddd-eeeeeeeeee-ffffffffff-gggggggggg";
CHAR16 buffer2[]=L"-C000000000-1111111111-aaaaaaaaaa-bbbbbbbbbb-cccccccccc-dddddddddd-eeeeeeeeee-ffffffffff-gggggggggg\
--D000000000-1111111111-aaaaaaaaaa-bbbbbbbbbb-cccccccccc-dddddddddd-eeeeeeeeee-ffffffffff-gggggggggg-----";


DEBUG ((EFI_D_INFO,"size-of-buffer:%d\n",sizeof(buffer)));
DEBUG ((EFI_D_INFO,"%s",buffer));
DEBUG ((EFI_D_INFO,"\r\n"));


DEBUG ((EFI_D_INFO,"%s",buffer2));
DEBUG ((EFI_D_INFO,"\r\n"));


return EFI_SUCCESS;
}
//test code end;




I don't know if it is a bug,nevertheless,it worked as I expect.
thank you.
by krishna.





















At 2018-02-02 10:07:14, "krishnaLee" <sssky307@163.com> wrote:

Hi Andrew Fish,
I didn't know the internal buffer is limited, I just think the Hii <ConfigRequest>  will be a formatted string,I want to understarnd how it worked so I print it,I find the result is not  as I expected...
I had calculate the first DEBUG string length,it is 199 chars limited.then I  search the MdePkg+MdeModulePkg for the define "MAX_DEBUG_MESSAGE_LENGTH",and modify them all to"#define MAX_DEBUG_MESSAGE_LENGTH 0x200",
rebuild Nt32Pkg,run my test,but the result is same,it is still 199 chars limited.


thanks.














At 2018-02-02 03:21:06, "Andrew Fish" <afish@apple.com> wrote:




On Feb 1, 2018, at 8:23 AM, Laszlo Ersek <lersek@redhat.com> wrote:


On 02/01/18 10:47, krishnaLee wrote:
Hi,
For example,the follow code:
//-code-start
ConfigRequestHdr = HiiConstructConfigHdr (&mBlankDrvFormSetGuid, VariableName, PrivateData1->DriverHandle[0]);
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
FreePool (ConfigRequestHdr);
//-code-end


I add a debug message at the end of code:
DEBUG((EFI_D_INFO,"construct-ConfigRequest:%s",ConfigRequest));
DEBUG((EFI_D_INFO,"\r\n"));


and the output will be:
construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000


If I add another debug message at the end of code:
DEBUG((EFI_D_INFO,"construct-ConfigRequest:"));
for(UINTN i=0;i<Size;i++)
{
DEBUG((EFI_D_INFO,"%c",ConfigRequest[i]));
}
DEBUG((EFI_D_INFO,"\r\n"));


and the output will be:
construct-ConfigRequest:GUID=db3b005aa15068459170ebd49e16c47c&NAME=00420044004d0079004900660072004e00560044006100740061&PATH=01041400db3b005aa15068459170ebd49e16c47c7fff0400&OFFSET=0&WIDTH=0000000000000052 pa&#65533;&#65533;?&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;pr&#65533;a <_<_ &#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;&#65533;


my platform:
win10_x64 + udk2017 + vs2015

Umm, I'm a bit confused by your query.

* First, most DebugLib instances have an internal buffer with fixed size
(for the DebugPrint() function). If you try to log longer messages, they
will be truncated.

For example, in "MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c",
there is:

#define MAX_DEBUG_MESSAGE_LENGTH  0x100

(I don't really understand your situation because the first debug
message that you pasted does *not* look truncated.)




WIDTH=0000000000 != WIDTH=0000000000000052 


Maybe "%016LX" is a little overkill for a width?


Thanks,


Andrew Fish



* Second, regarding the trailing garbage. You set "Size" to the number
of *bytes* required for a NUL-terminated CHAR16 config request string,
plus 32 CHAR16 objects. This is then correctly passed to both
AllocateZeroPool() and UnicodeSPrint(). However, in the loop where you
print individual CHAR16 objects, you also count up to the number of
*bytes* -- that's incorrect, the limit should be the number of CHAR16
objects (or the NUL-terminator, of course).

Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-06  1:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-01  9:47 Why the DEBUG can't output the full string? krishnaLee
2018-02-01 16:23 ` Laszlo Ersek
2018-02-01 19:21   ` Andrew Fish
2018-02-02  2:07     ` krishnaLee
2018-02-06  1:52       ` krishnaLee
2018-02-02  1:41   ` Ni, Ruiyu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox