From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 967C3223CCEF6 for ; Thu, 1 Feb 2018 17:35:53 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 17:41:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,445,1511856000"; d="scan'208";a="14416155" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.19]) ([10.239.9.19]) by orsmga007.jf.intel.com with ESMTP; 01 Feb 2018 17:41:29 -0800 To: Laszlo Ersek , krishnaLee , edk2-devel@lists.01.org References: <20478935.ac13.16150c3aa05.Coremail.sssky307@163.com> From: "Ni, Ruiyu" Message-ID: <4f6ea449-5241-d528-a867-b794cd6a8b86@Intel.com> Date: Fri, 2 Feb 2018 09:41:29 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Subject: Re: Why the DEBUG can't output the full string? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Feb 2018 01:35:54 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit 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> { >> 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