From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.49]) by sourceware.org (Postfix) with ESMTPS id 57C96383443E for ; Tue, 23 Feb 2021 14:50:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 57C96383443E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lb+fdXXmd9h7ValKwjQ9x8oFLkXsTL+R7BTqHe7TH9RVsrPQyiLefIkybv/Bp5a6euGndeUeFAZYb0dkOX0H6l3+83U0dE6GNyQ//MdzGaJBygynd53NVueKLeyPg70LMrowJg8k6BaEcJ7IXIJskWV3DxVbPeqM9UBnojVh+sumGI8gDeSj6MaRqhABcKGfOxfiYNWxB/4ZTBprrcamtxVgtAzxyGrfnpqjWHNCNfaOxH0mP0XPw8rgA0Z4ZDBQ4i/6G3nAWC490xmIZFPBf3Ixjxyij+wit5CghaKYKoZcPyMJJZg8W5D0sbPhTJo2VyptHC4DNxNIgEzDXzeGlg== 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-SenderADCheck; bh=rmrwQeASIgWRU4cAs1OkqMtDgLYiS7PynQ9VHj9Pnhc=; b=LCT/EWmMIqR+mJhbp9NuXCWbJZEt8cV+dmN4kRq4k60M5hNk6Epe3YW8Clfif5fT4529cgqUv0dWRXaqKnWkOTJEYLguqZDSSZppdLUHVJfAkYhvFO+mEZMEKaXU9GWoSjytHLrdI3qS9sNY03eC4IgJFqY4JpEteWH0v9Np+KcYpDwFCjQO2Dv+wSx1c1e8j3kknQwr/RNXFQsWxZP1PsH6y2j4/c5beiLvY34XsbE0ciGKz1ttAC5y3DLlVsKf2F+XnLcySu1rzgdqw+dlJmqCSZiFR8dj9/0HNbV3GMNjwpTsC3EZnmDRb+Sudd4s4pV6PJOQ33jS5P7uU1YbHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) by DM5PR12MB2344.namprd12.prod.outlook.com (2603:10b6:4:b2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.33; Tue, 23 Feb 2021 14:49:59 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44%3]) with mapi id 15.20.3868.033; Tue, 23 Feb 2021 14:49:59 +0000 Subject: Re: [PATCH 19/30] Add new location description access interface From: Zoran Zaric To: Tom Tromey , Zoran Zaric via Gdb-patches References: <20201207190031.13341-1-Zoran.Zaric@amd.com> <20201207190031.13341-20-Zoran.Zaric@amd.com> <87im72dyge.fsf@tromey.com> <82aea0d9-ee82-9f59-befe-f02a47f0d871@amd.com> Message-ID: <28ce52db-fc37-c5e1-f845-a5fbcb455739@amd.com> Date: Tue, 23 Feb 2021 14:49:54 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 In-Reply-To: <82aea0d9-ee82-9f59-befe-f02a47f0d871@amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [2a00:23c7:5a85:6801:3c68:1988:3c97:9289] X-ClientProxiedBy: LO2P265CA0416.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::20) To DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2a00:23c7:5a85:6801:3c68:1988:3c97:9289] (2a00:23c7:5a85:6801:3c68:1988:3c97:9289) by LO2P265CA0416.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.31 via Frontend Transport; Tue, 23 Feb 2021 14:49:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1b981ee9-1987-490c-06a7-08d8d80a4af4 X-MS-TrafficTypeDiagnostic: DM5PR12MB2344: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8QJc7Nk7wU1TAX0tY34RHbGdkJ2CkHnNkXwomEEVr/slYbagAobhB1hfFnEZ6QsqRK88jQMfPvRWzNX7aRGS1gzMoz+3bq6QQs0lpfB6dTAdiVBgEaaeWhXRtiIVeEG3Ldm+oTT1QW74ETs7yy5APPK0B/yrUij0HFtYGxWY5TFT1eAG2x0Soh1/+GiRL/YJuXL/lqTxH4AnHnfg10KAhz6x79mSYr220PhAdaKat0lDz6YtQXJRsCwFxwwE4+RkDQgr2YTmiKUGBomwFTVUtX2UvZUrp77LH+tbQUhs8N8VfjpZ3+KYcQCQrrpXcXbIAzVwhwg15pE/1VlvKXL6tjG9eY04FkeBUJqEfhwtpyL6xSTg8PzgmQatGWP9K1LMbDjXlN+UEDNVUXWk0scXPFvAsmHe92MwkKeOaX0JF2A6g84c/YH3YEMiIcKXfNtYYzuxF7WoE69PbMnlMVIog/HmD9ZaicRPhY4ss1ny+x2MMpFvlaU54aSJCfrYf6IVa6gNmQImIGI8UnUV+sg3QQLj3ggAMIYiLIN8/C1DlrNoJdDjKnHCq63Rsd11c/mLJfrIIOqLtaxVDJYuKkibdj3o9vTjtz5Q48tIYMrl6pw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB2762.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(396003)(376002)(136003)(39860400002)(346002)(52116002)(8676002)(8936002)(86362001)(110136005)(2616005)(316002)(6486002)(186003)(36756003)(31696002)(2906002)(31686004)(478600001)(16526019)(83380400001)(6666004)(66946007)(5660300002)(66556008)(66476007)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?Z2ZMRnFxbVdCZmNMZElnU0puZ0RYUVhrMWRNU1BON2lTM2trcUZ4dzYwbmlw?= =?utf-8?B?cGpzaHkrcTdZZkRkQk1TdDJ4S2Y1WlhQVUpWVkNvc09VRmswQmVtbzkrMngx?= =?utf-8?B?Z1FRd3VSSFRDVWZyZXBoTFNZS2dwdXpuY3BMeXRiZ29IaHZhTDNLM0N1WGxG?= =?utf-8?B?QW5yMXc5NHBYb0l0eUxXb1hsOUJmVEJLblpsRE1nQkRNT3U3UVRURWYvNTVP?= =?utf-8?B?Sit6aDV2c0lCbHVxSUpZQ2dFT25lZmEvSmdOU3kyZ2llMW9vaU9TV0lvaC8v?= =?utf-8?B?M2ZBdEJBSmJMVDl5dGhEeGMrQmdPSGRNUkdOdmRDMk0zQzlabmVuT0ozYzFv?= =?utf-8?B?a3hkSG16Syt5bXBleGZCY1hIZkYySUFWRjFZejRzdW91UmdFNktPc2RGK3JI?= =?utf-8?B?eFIzRml5UmFQelJ4TXZNQWlqMHB1V2l4V1V4Z0VTa1hvdG0xZVIzb0NJRDZP?= =?utf-8?B?MldNWEFra1p3Y3cyem0wbmlzMFY2N0F3bjQxT1QrMm9mZWwzREpDMUtDYWdl?= =?utf-8?B?eHpvTm5KSy9odWNEbVcwclo5cnRBd2ZtUEs5am9md21uOExEQTFmU1ppOUVi?= =?utf-8?B?VzhXb00xNTN3Y1hTNzUvUWhEb2IxUmJxWHhyb3Q2UVRNbTF2UndhY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yK1lVNjNhR0RSM2FRYjVaOHVUc3g2cTc2?= =?utf-8?B?aWVnYlMyclM4azRhZHhxYXJxT3p3anBQOUhCYkFXM1FiU01HTjN6R3JzNkhq?= =?utf-8?B?YWpObkxtNGVjdlBWTzNXVWdjRUNCQ2JPOGgxN2gyOEYwMURMTE9jZVJLTStH?= =?utf-8?B?L3dDcGN2c0w3Y1NaSUZVK0MwdDB3bml5VUhtdUxVZzV3UWVEbGpPcnpNWlc3?= =?utf-8?B?cHlLNEJjUFdSRTlXa3ZIR3FNbnNMYUJsUWx0SHNBb2s5RlJrL0s5SXhES2NV?= =?utf-8?B?aVkwZDFWQ0xQTEVXbWZkU0x2R2xIb0xwdTZMTDRrY1gwZmxobW5JSGkxNlJm?= =?utf-8?Q?k1Tzr0KKCIoeo?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b981ee9-1987-490c-06a7-08d8d80a4af4 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2021 14:49:59.3863 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rNI0sBTmX3P/GdaoqeAVlfx0vacrQrchRh8DdsUJCmAa4LKYgAp1WmrHREX1JOPtef367liQ2UQJeT1sQupZBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2344 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Feb 2021 14:50:03 -0000 >> Thank you Tom for the review. >> >> To be honest, I am not sure how to do this with virtual functions, >> considering that the information held by the different location >> descriptions categories are so very different. >> >> The only way how I can see this being implemented if I encapsulate all >> the specifics of dealing with the different location descriptions >> (reading, writing, conversions between them and the composite/implicit >> pointer infrastructure) inside of that class hierarchy and change the >> dwarf_entry class to have a bunch of virtual functions that only make >> sense for one location description category. >> >> The reason why I didn't implement it that way in the first place is >> because I was following the existing model of how the struct value >> handling was implemented, where instead of dynamic casting there is an >> enumeration check to figure out what is described by an object. >> >> Don't get me wrong, I am not really against that change, but it would >> require a bit serious rework of the implementation. >> >> So if you really feel that this is a deal breaker, I could give >> another crack at it in the next version. >> >> Zoran >> > > After rereading my response, I realized that I probably need to explain > my thought process a bit more. > > In the original code there were large switch cases that dealt with the > evaluation result (aka location description) based on a result > enumeration. This was done in two places: > > - at the evaluator caller side and > - composite/implicit pointer callback functions. > > I first moved those pieces to be at the expr.c side and then when I > switched to the new classes, I have replaced the big switch statement, > with the if/else statements that used the dynamic cast to cast to the > appropriate class instead to referring to the enumeration to know which > data members are valid or not. > > So in a sense, the ugly code was already there. Not to mention that the > struct value infrastructure is based on the same model. > > Originally, I had an enumeration that would be checked inside of the > dwarf_entry class and return an object of the correct class but that was > functionally the same as having the dynamic cast so people advised me to > just use the dynamic cast because it was already used in gdb. > > So Tom, when you say that the type-case looks bad, do you mean just the > fact that I am using the dynamic cast or the problem is more general > because the dwarf_entry class is supposed to encapsulate all that logic? > > For the dynamic cast issue, I can always switch back to the enumeration > methodology that I've described and is similar to what was there before. > > In the case of a potentially better design of the dwarf_entry classes, I > couldn't agree more. I was trying to first mimic the previous mechanism > so that people would find it easier to understand and accept. > > The proper encapsulation was planned for a later time, but to be frank > the struct value requires the same type of remake which is not a modest > task in either case. > > Hope this makes more sense, > Zoran Hi Tom, I've invested a lot of time during the last two weeks and managed to change the design to be more C++ based and now most of the dynamic casting has been replaced with virtual functions which made the code a lot more elegant. Unfortunately, there are still a few places left that use the casting but those are limited to the evaluator parts that model the logic behind how some of the DWARF operations are defined in the standard, which don't really make sense to be a DWARF entry class virtual functions. This will all make more sense when I submit the new version of my patch series in a few days. Zoran