From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UE1HL2T+PGAGJAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 09:47:00 -0500 Received: by simark.ca (Postfix, from userid 112) id BA0C01EF82; Mon, 1 Mar 2021 09:47:00 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3114C1EF78 for ; Mon, 1 Mar 2021 09:46:59 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF386393A41A; Mon, 1 Mar 2021 14:46:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF386393A41A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614610017; bh=P32NTsn2EZXqJLXU1UwmD6zsaakqfR8MVLL0c2j1KRk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=oH6p4k2CGF6Dx/Pm/NeYeIJf1yq9IOJFs/DLoZNJmNHGZxMxz/BTPXMGPPNlyCU63 aH76sYQ0iOcdM7FncN8QiaxnHVkL+WRYsk13ydRYb3NntKKlhBBTrskyio+2/KJgdU e73RfTaznTJm8QB66cRbPSWLii6T8ueCI2sSdI+k= Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062.outbound.protection.outlook.com [40.107.244.62]) by sourceware.org (Postfix) with ESMTPS id 409B73939C32 for ; Mon, 1 Mar 2021 14:46:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 409B73939C32 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cjG51z64WrmYKjQWshvZR+FlBBB4wluA0YDpRxuq9WEyK9cucncXSNzng/UBPzZ/hwEdP0sbNjQw3Wbc2nJzsrubPK4djpCb8ts6owyFuOMs51ft8mWHFjUC3wMph7CbL5w1PGp7ic/UmAYmT+8I7OQO9c+WzvUs702bTIhi4OHRi22kEI5Z8rbotlsQrZGZmhw7ylQ4oQZiFL8jDWoREEmekVA80t969yLvj7uTf4gwtrIkYU0pHsX93LPldKnHHDIhIb3V1K4lgWgKDOUqfHZdfgQ2+Q9ll3QEoIXnhLrailKhDqMjeGoEgbgij9F/cwZ0qnG2MI4e+4DkTBvE/w== 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=P32NTsn2EZXqJLXU1UwmD6zsaakqfR8MVLL0c2j1KRk=; b=WmGYmMmnL3uSRUR6ZJ5zSH65UQY7OY78c2W6+YGIPOflNz+UxVpZy6K1LezHR8QGkvqixuSuk8HtUlSMYWncgaIjNDcRNGCI0UZE0YKdcgxsUUrcz5aq/28xo+W2uT12lBy/UCY/vKCWJXsH3VHIpy1TCaNZ3KXS4/twOr6RcCVZXuKQRLzXerXc4J+njB484f6wa7KA5vjOpa9k7n1P7BpGgXEjtwsgfCADAXbXjSSemdouKu2PQ9cJ9gfSEWNTtwy6NPN1yW7lsoyjLsJBkdw39Jxk4OeD8Zzz77Z4I9Q/QzTxOmmmIefEulFkqnet2UiQBR1nwgNtW5y3BjhVWw== 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 DM6PR12MB3676.namprd12.prod.outlook.com (2603:10b6:5:1c7::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Mon, 1 Mar 2021 14:46:52 +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; Mon, 1 Mar 2021 14:46:52 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 12/43] Merge evaluate_for_locexpr_baton evaluator Date: Mon, 1 Mar 2021 14:45:49 +0000 Message-Id: <20210301144620.103016-13-Zoran.Zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210301144620.103016-1-Zoran.Zaric@amd.com> References: <20210301144620.103016-1-Zoran.Zaric@amd.com> Content-Type: text/plain X-Originating-IP: [2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d] X-ClientProxiedBy: AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) To DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d) by AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Mon, 1 Mar 2021 14:46:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 36656867-e4c7-43ea-8bf1-08d8dcc0da07 X-MS-TrafficTypeDiagnostic: DM6PR12MB3676: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vo/zs1Rt5B0sRzwEGBV9pwHnvqxVHBYfNMJ0oDbo15B/CpkITm0SpoTEXx3jXPf2QcGfe54gSrSPg0XWbOyHzaP+8vVjJluW3PUiHw1JiDUmKWeZgmGRphJLfZzhD77qEswhmaceZdewdgWVtICEk54eA/T6ZdFwMCGb8vn2v6YrIzEQsEuQQBEvEOZ52H60FP0ongZO7smELakOeh6e/1qmSjmGRn8hGrgIYRbWTjN0qpL/ZcgOf8DRvMHLQDEb45ZqRaiLPa3YbgW87r59/we84Wslgm/ywY9vK3IfuqesleYFChf+e3EaAVkj4DbY2VxwFofomSPfdC09H4ExKVR+1pY7KMjqAnI8Tb8uC4M/iYzNTL7z2Pt/dBLEO5eH5gNbrFRZg/rKtStc6ctG7XtmA44QXiolzWIpJROieJJF0FZZCxodAvv1RuWBP/9h1HiyiY5zEEWWVXnRbwqlfj6YNLSu36hrZ9Ms6LISgNtwJoZAqOuJwbqzVLfo0nhU9dTJdKcB/V2nJ6lZpqpHHpArtOC5c3MwMjs3DwyGwigtiOFtFt2akIns7PfmswkGB2yxeTzuxhGg0vUOyAOVOg== 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)(376002)(366004)(396003)(346002)(136003)(39860400002)(16526019)(1076003)(83380400001)(2616005)(69590400012)(2906002)(186003)(36756003)(66946007)(316002)(66476007)(8936002)(52116002)(86362001)(6506007)(478600001)(5660300002)(4326008)(6486002)(8676002)(6916009)(6512007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?Pn5ZOB3ErTZEDYHctTl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C44Y71H9?= =?us-ascii?Q?70cwrSwBsilwcf8l+qPG11AEJWkoZSuDa/GwvXGIIlFjmXrGY7XJRFcDRv4t?= =?us-ascii?Q?G7GAhaBAEBOfIwJev7vJ1DquKjleO+CS6Xoom+Cn/c/VVFW4t1zIDWbhmA4M?= =?us-ascii?Q?5bBTenZzoxD0zp9N4eAVHpDHCmPof+0b5uCtGQz7qDKg1jLPpb2zpz9y5h8E?= =?us-ascii?Q?TvzpYk/oJYnQaPbARe+7IEoob+t404R5D7cZHvcQaPTyvhfwdMkgQBWeQCb0?= =?us-ascii?Q?0SnqceVoOFcCxj1y+CJm+tpHtH1vTZmPLOJewfOboL7mMy33G2B4EZF2Qx6S?= =?us-ascii?Q?TgGKI20UYcXuYdlTbxPPdWI3DMmlISj09SYG4blMH2JOBwrVdG6h0MDCbfn8?= =?us-ascii?Q?fl3ydTjReayenRuf2s1pHZRnwXRNL8KxLNIxcODK0hnKfc1zLfO2ZKbK3O7+?= =?us-ascii?Q?SEPlM0NWRfzM4Gbx6Spse62yYY9dPBhPcAEt8DaE1z6wMUq/1XF8QVS0sjRY?= =?us-ascii?Q?YoxgEngsdMaoR+Gka/azO2iQlDsc?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36656867-e4c7-43ea-8bf1-08d8dcc0da07 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2021 14:46:52.5212 (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: guMSu1PZa1YryS9x+URiTRfyAbmEGsk2ZRMYweCMFb8BfXtefJHlHVhXvYsF61cJONz2csLHws5npCCC1sH3Dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3676 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: , From: Zoran Zaric via Gdb-patches Reply-To: Zoran Zaric Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Zoran Zaric The evaluate_for_locexpr_baton is the last derived class from the dwarf_expr_context class. It's purpose is to support the passed in buffer functionality. Although, it is not really necessary to merge this class with it's base class, doing that simplifies new expression evaluator design. Considering that this functionality is going around the DWARF standard, it is also reasonable to expect that with a new evaluator design and extending the push object address functionality to accept any location description, there will be no need to support passed in buffers. Alternatively, it would also makes sense to abstract the interaction between the evaluator and a given resource in the near future. The passed in buffer would then be a specialization of that abstraction. gdb/ChangeLog: * dwarf2/expr.c (dwarf_expr_context::read_mem): Merge with evaluate_for_locexpr_baton implementation. * dwarf2/loc.c (class evaluate_for_locexpr_baton): Remove class. (evaluate_for_locexpr_baton::read_mem): Move to dwarf_expr_context. (dwarf2_locexpr_baton_eval): Instantiate dwarf_expr_context instead of evaluate_for_locexpr_baton class. --- gdb/dwarf2/expr.c | 19 +++++++++++++++++-- gdb/dwarf2/expr.h | 13 +++---------- gdb/dwarf2/loc.c | 45 ++------------------------------------------- 3 files changed, 22 insertions(+), 55 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 1212be9c984..fe6d072ac8f 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -252,6 +252,18 @@ void dwarf_expr_context::read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length) { + if (length == 0) + return; + + /* Prefer the passed-in memory, if it exists. */ + CORE_ADDR offset = addr - obj_address; + + if (offset < data_view.size () && offset + length <= data_view.size ()) + { + memcpy (buf, data_view.data (), length); + return; + } + read_memory (addr, buf, length); } @@ -1576,8 +1588,11 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_push_object_address: /* Return the address of the object we are currently observing. */ - result = this->get_object_address (); - result_val = value_from_ulongest (address_type, result); + if (this->data_view.data () == nullptr + && this->obj_address == 0) + error (_("Location address is not set.")); + + result_val = value_from_ulongest (address_type, this->obj_address); break; default: diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h index 3faedebfb83..af14f6ee0c2 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -195,16 +195,8 @@ struct dwarf_expr_context /* Object address used for the evaluation. */ CORE_ADDR obj_address = 0; - /* Read LENGTH bytes at ADDR into BUF. */ - virtual void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length); - - /* Return the `object address' for DW_OP_push_object_address. */ - virtual CORE_ADDR get_object_address () - { - if (obj_address == 0) - error (_("Location address is not set.")); - return obj_address; - } + /* The data that was passed in. */ + gdb::array_view data_view; private: @@ -239,6 +231,7 @@ struct dwarf_expr_context void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind, union call_site_parameter_u kind_u, int deref_size); + void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length); }; /* Return the value of register number REG (a DWARF register number), diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index bd3f7d4d46a..d02fb1cd792 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -2221,45 +2221,6 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame, per_objfile, NULL, 0); } -/* A specialization of dwarf_expr_context that is used by - dwarf2_locexpr_baton_eval. This subclass exists to handle the case - where a caller of dwarf2_locexpr_baton_eval passes in some data, - but with the address being 0. In this situation, we arrange for - memory reads to come from the passed-in buffer. */ - -struct evaluate_for_locexpr_baton : public dwarf_expr_context -{ - evaluate_for_locexpr_baton (dwarf2_per_objfile *per_objfile) - : dwarf_expr_context (per_objfile) - {} - - /* The data that was passed in. */ - gdb::array_view data_view; - - CORE_ADDR get_object_address () override - { - if (data_view.data () == nullptr && obj_address == 0) - error (_("Location address is not set.")); - return obj_address; - } - - void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t len) override - { - if (len == 0) - return; - - /* Prefer the passed-in memory, if it exists. */ - CORE_ADDR offset = addr - obj_address; - if (offset < data_view.size () && offset + len <= data_view.size ()) - { - memcpy (buf, data_view.data (), len); - return; - } - - read_memory (addr, buf, len); - } -}; - /* Evaluates a dwarf expression and stores the result in VAL, expecting that the dwarf expression only produces a single CORE_ADDR. FRAME is the frame in which the expression is @@ -2283,13 +2244,11 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, return 0; dwarf2_per_objfile *per_objfile = dlbaton->per_objfile; - evaluate_for_locexpr_baton ctx (per_objfile); + dwarf_expr_context ctx (per_objfile); ctx.frame = frame; ctx.per_cu = dlbaton->per_cu; - if (addr_stack == nullptr) - ctx.obj_address = 0; - else + if (addr_stack != nullptr) { ctx.obj_address = addr_stack->addr; ctx.data_view = addr_stack->valaddr; -- 2.17.1