From nobody Thu May 16 16:43:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109927+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1698070704341452.63300807385383; Mon, 23 Oct 2023 07:18:24 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=bboPrAsgrD/suVj311AaQTQJfqzzqT4qolaq20+3mWU=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1698070703; v=1; b=go/dUoibCYl2yBR12OgubqP1pz4Z1tYhlu4N5XOq+kGwvxWjC1vcU6H8nYmU9xQ5fNpKerUp EeBRpcR/i+4l+GIH23hQT1wZ24Ug0xSI9aCHew7xE6jUmUaiHyV+4gT9B0xct18Go4sPBQxc2jV 7lPPrd3egj5776PKVMyuV1sQ= X-Received: by 127.0.0.2 with SMTP id CPmPYY1788612xQv8RAyutL6; Mon, 23 Oct 2023 07:18:23 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.87]) by mx.groups.io with SMTP id smtpd.web10.121692.1698070701304578339 for ; Mon, 23 Oct 2023 07:18:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hNrZ7OMaQc7B0OEDSufhQYriy/H0UThVexpQLuBdYp8jQSi9FVQfcxCsjaTMKThQhGFAKUjoVfrhpYtOeu8oyk+YvspdQtvygu9U7+Yfsteeuc3iJSavuZDNklahDuzC8VK8nl4IuD2XP9BE4Nvyr9YkXQ7F4JIguWbr/VyAmAZzg0MKCtEnD4PKuEDO63VLmV8WTtATYZBPF8fkb/hfZi+bNOorsSoeQFeLneezZKnkRdQSFp9+J1RBbsJ+EnnbWPaoZXrT7tRJN+x4pviM1j2EXh5abx6uimsSpkLR1UudaqCM/IpGBfjz5B9QrKL9cvMmNpR+W2n/vEOfwIerqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=syHbxz4ololVGYXNsVdxFH7+SYOsdO0m9lnY3KkWdmw=; b=ocDBhBVHaYyt7ytWZrUaE82XX+EuEmHI2LBKBctG4q0+X+eHG7ZFije5uuZmqjAcm6hfYRtNGN5IrK+WstFEmdQeQ9kE/ALF7OJ5DL31ywQYBd55B/0N61piYK1yxV5JJUfLt5FMtfOH+PvzPyh8/cloVQQl/bMtG47QCdB+hb3s2aLrsAdMOvhj1oILvHg9+RAVE4UfRWPZctx8xBOiCdQ+dA4MLWGnKiGj72/WamxHroMxQV2qGzJzLrgZchhi39asQYs8WtEkceXkD5bQM1BHv6HaK1MGrYULYJ3EWHRJVG4kw8ZNUAEyFAzzMYdP+TQdcIQJYUlxuXL/QacX2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from CH2PR07CA0055.namprd07.prod.outlook.com (2603:10b6:610:5b::29) by MW3PR12MB4441.namprd12.prod.outlook.com (2603:10b6:303:59::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Mon, 23 Oct 2023 14:18:18 +0000 X-Received: from DS3PEPF000099DE.namprd04.prod.outlook.com (2603:10b6:610:5b:cafe::71) by CH2PR07CA0055.outlook.office365.com (2603:10b6:610:5b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.34 via Frontend Transport; Mon, 23 Oct 2023 14:18:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109927+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.118.232) by DS3PEPF000099DE.mail.protection.outlook.com (10.167.17.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Mon, 23 Oct 2023 14:18:18 +0000 X-Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 23 Oct 2023 07:18:02 -0700 X-Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 23 Oct 2023 07:17:57 -0700 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Mon, 23 Oct 2023 07:17:56 -0700 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [PATCH] RedfishPkg/RedfishPlatformConfigDxe: add debug message. Date: Mon, 23 Oct 2023 22:17:55 +0800 Message-ID: <20231023141755.365-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DE:EE_|MW3PR12MB4441:EE_ X-MS-Office365-Filtering-Correlation-Id: 61862168-edee-45d3-5b98-08dbd3d2e79f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: ngx2ZJWH9dGwu74n9fHBNX2mX0zf0Pf4s7Uh9ut/0m2bO0GLjscQsb+35TCOeQNPs3EscOBjvCzP5yIbmfAXmjZ2okvey8SiqWkdGMNK4ZuNJK/u3RCZPC5EO5jw1aNRIwIjoaUKXaor6snJs1bW7f6g0ztZwh+srXZDC2pcfNRhB48lR4eG9qD4h8dgHD3s76/z2+jFQEANuoFUbirUqgnt35L4xjz8E8j3fc8QdXZBVn/Z2+C7HjwxVH9EP3SqfI5s/UhGqLJhbEgxc9nr3fJqoB+GKpYURIR5O9HAAzueIbB+OKvIwh4zdrxEJOXxdvBY7di2tT4mWqXKrIdHHS4817M0Y++HAqTJ3BzlH9VaFVjhzUhsWqXGKLB/0candmtGDfhu2V25h/JOS8cnP+JZLo/zavj1Gg7rWGUmtQj9mPZp4EGu3MxPirOz6vL/Ms4e8Z5jGk6glD81tam20nX8TfY80xX7WSYtjN9ERYcrt7ej9+iAPbIJrzXmUVIvTkV9ATSDW5bEPHHOkpIfpsb9Trou2TkbI5lqzWQvt8U+EKYV86MIMMqK2v3TRC+gNN8uTguAi5MXoXLnhnIz2YlYzp6nDWcCuh3HaV/2vTAZeQ4pb038TRt6WKw0oOxEAVjIjDcBNwGgO9bHUCy6I0jsvBW4dhpDfuAD43tgU1S9cYSsX6py9khxlvaggnRPRZJzMmE/LeNy7QzqXOpGydYuU0Uu3x0LxoJ7bwy+H7E= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2023 14:18:18.4068 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61862168-edee-45d3-5b98-08dbd3d2e79f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DE.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4441 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: A3G1kzGJ3E3PLaQzMAYH2lCux1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1698070706409100007 Content-Type: text/plain; charset="utf-8" Add debug prints to show HII option name when assert happens. This helps developer to debug assert issue easily while Redfish failed to convert HII value to Redfish value. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez Reviewed-by: Abner Chang --- .../RedfishPlatformConfigDxe.c | 123 +++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c= b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c index 30d2ef351eca..cbc65ba59408 100644 --- a/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c +++ b/RedfishPkg/RedfishPlatformConfigDxe/RedfishPlatformConfigDxe.c @@ -203,6 +203,106 @@ FindFormLinkToThis ( return NULL; } =20 +/** + Debug dump HII statement value. + + @param[in] ErrorLevel DEBUG macro error level + @param[in] Value HII statement value to dump + @param[in] Message Debug message + + @retval EFI_SUCCESS Dump HII statement value successfully + @retval Others Errors occur + +**/ +EFI_STATUS +DumpHiiStatementValue ( + IN UINTN ErrorLevel, + IN HII_STATEMENT_VALUE *Value, + IN CHAR8 *Message OPTIONAL + ) +{ + UINT64 Data; + + if (Value =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + switch (Value->Type) { + case EFI_IFR_TYPE_NUM_SIZE_8: + Data =3D Value->Value.u8; + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + Data =3D Value->Value.u16; + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + Data =3D Value->Value.u32; + break; + case EFI_IFR_TYPE_NUM_SIZE_64: + Data =3D Value->Value.u64; + break; + case EFI_IFR_TYPE_BOOLEAN: + Data =3D (Value->Value.b ? 1 : 0); + break; + default: + DEBUG ((ErrorLevel, "%a: unsupported type: 0x%x\n", __func__, Value-= >Type)); + return EFI_UNSUPPORTED; + } + + if (IS_EMPTY_STRING (Message)) { + DEBUG ((ErrorLevel, "0x%lx\n", Data)); + } else { + DEBUG ((ErrorLevel, "%a: 0x%lx\n", Message, Data)); + } + + return EFI_SUCCESS; +} + +/** + Debug dump HII statement prompt string. + + @param[in] ErrorLevel DEBUG macro error level + @param[in] HiiHandle HII handle instance + @param[in] HiiStatement HII statement + @param[in] Message Debug message + + @retval EFI_SUCCESS Dump HII statement string successfully + @retval Others Errors occur + +**/ +EFI_STATUS +DumpHiiStatementPrompt ( + IN UINTN ErrorLevel, + IN EFI_HII_HANDLE HiiHandle, + IN HII_STATEMENT *HiiStatement, + IN CHAR8 *Message OPTIONAL + ) +{ + EFI_STRING String; + + if ((HiiHandle =3D=3D NULL) || (HiiStatement =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + if (HiiStatement->Prompt =3D=3D 0) { + return EFI_NOT_FOUND; + } + + String =3D HiiGetString (HiiHandle, HiiStatement->Prompt, NULL); + if (String =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + if (IS_EMPTY_STRING (Message)) { + DEBUG ((ErrorLevel, "%s\n", String)); + } else { + DEBUG ((ErrorLevel, "%a: %s\n", Message, String)); + } + + FreePool (String); + + return EFI_SUCCESS; +} + /** Build the menu path to given statement instance. It is caller's responsibility to free returned string buffer. @@ -890,6 +990,7 @@ HiiValueToRedfishNumeric ( break; default: RedfishValue->Type =3D RedfishValueTypeUnknown; + DEBUG ((DEBUG_ERROR, "%a: Unsupported value type: 0x%x\n", __func__,= Value->Type)); break; } =20 @@ -1187,6 +1288,11 @@ HiiValueToRedfishValue ( case EFI_IFR_ONE_OF_OP: StringId =3D HiiValueToOneOfOptionStringId (HiiStatement, Value); if (StringId =3D=3D 0) { + // + // Print prompt string of HII statement for ease of debugging + // + DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "Can= not find string ID"); + DumpHiiStatementValue (DEBUG_ERROR, Value, "Current value"); ASSERT (FALSE); Status =3D EFI_DEVICE_ERROR; break; @@ -1254,6 +1360,10 @@ HiiValueToRedfishValue ( case EFI_IFR_ORDERED_LIST_OP: StringIdArray =3D HiiValueToOrderedListOptionStringId (HiiStatement,= &Count); if (StringIdArray =3D=3D NULL) { + // + // Print prompt string of HII statement for ease of debugging + // + DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "Can= not get string ID array"); ASSERT (FALSE); Status =3D EFI_DEVICE_ERROR; break; @@ -1261,13 +1371,24 @@ HiiValueToRedfishValue ( =20 RedfishValue->Value.StringArray =3D AllocatePool (sizeof (CHAR8 *) *= Count); if (RedfishValue->Value.StringArray =3D=3D NULL) { + // + // Print prompt string of HII statement for ease of debugging + // + DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "Can= not allocate memory"); ASSERT (FALSE); Status =3D EFI_OUT_OF_RESOURCES; break; } =20 for (Index =3D 0; Index < Count; Index++) { - ASSERT (StringIdArray[Index] !=3D 0); + if (StringIdArray[Index] =3D=3D 0) { + // + // Print prompt string of HII statement for ease of debugging + // + DumpHiiStatementPrompt (DEBUG_ERROR, HiiHandle, HiiStatement, "S= tring ID in array is 0"); + ASSERT (FALSE); + } + RedfishValue->Value.StringArray[Index] =3D HiiGetRedfishAsciiStrin= g (HiiHandle, FullSchema, StringIdArray[Index]); ASSERT (RedfishValue->Value.StringArray[Index] !=3D NULL); } --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109927): https://edk2.groups.io/g/devel/message/109927 Mute This Topic: https://groups.io/mt/102136156/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-