From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6OUbEWL+PGA3JAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 09:46:58 -0500 Received: by simark.ca (Postfix, from userid 112) id 3D8461F0B9; Mon, 1 Mar 2021 09:46:58 -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 E1EE61EF7E for ; Mon, 1 Mar 2021 09:46:53 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F2063939C33; Mon, 1 Mar 2021 14:46:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F2063939C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614610013; bh=nio7ospL8IatDUPdOsdjpLxg7BvLZzapWZPEGppyTO4=; 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=FD9DGRxwtj5d0gOMjXdPs4sgieztBpeO1nOWTVoV931hn0JlQMDRSsiMDc0y9/TEi k8oIFVUF5jwXCVcU44phn3ivhJR8wgB7VEfWZKJ/xQpWDz4iDhJ7pDEi3HZWbcyw5+ 4qzQNJPaQV2ZDJmIFRYjTUWiBZyayBjhz3TL1FjM= Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by sourceware.org (Postfix) with ESMTPS id A40843939C11 for ; Mon, 1 Mar 2021 14:46:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A40843939C11 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lULOBrn8q7ngvYQZBAbKIguut50B/Esy+3bEu70fnyyimdDf25WfO9KReLtmdMM11cc21wFvgMz9nVlDt9GwQRZWdfWQDwBM7yyygqXWI7oR40G0jzA+4mebbXgEsfgtXfPdM6jMYh/y1FreA8USUdX+zkoGvjps0vticfEmaxfTrYUy0ulSAVWnphskuwEEj34oLGIBSJhQXm59PzMn/Pd5KL+MS4/jkNgelkBlaA5CGfV9UNNdvkz+G3s+wSV6XVgoc4mvkcPsqZURYE0h5h8tmgdnUMkDFDnKe16T7UC2bc8yYnYysg+c0EDkHSdJbwR3B1e4miDTHeR9fSkrkw== 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=nio7ospL8IatDUPdOsdjpLxg7BvLZzapWZPEGppyTO4=; b=MgRh1q3OShpuy4fYd+swsQ+L2UHDDT8PMqkm8w5Jg+0aaSG10FqaB51+HrKO0IHFMOg8xi+ZXeFByOoXeYklSn9/f7oyvfpGOyWf1GXiSWj4mflRiPp/M9Q682/CkgsJTg3mr1Qy4nWnFie2hVBjVUgHKqlX+3LfMkjzbtTGylR2aelx/QsPyMRWn6k99Bg8Ww/aD7cKK5wJYxx3Jv08h5FzpTywL6yHjlzrEuQxXmQyktNuTARBwP4iilEdbvTeK2EfOITo5g6cRX5zPif2IlYJfrS1FoaJCmLEhNw2a2Zm0bbFBdccCg3esMXIYZ4gJps9pvQR+zggikTyrqq52Q== 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 DM5PR1201MB0236.namprd12.prod.outlook.com (2603:10b6:4:57::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.28; Mon, 1 Mar 2021 14:46:44 +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:44 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 05/43] Move compilation unit info to dwarf_expr_context Date: Mon, 1 Mar 2021 14:45:42 +0000 Message-Id: <20210301144620.103016-6-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:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 72f13b13-7477-4186-006a-08d8dcc0d53b X-MS-TrafficTypeDiagnostic: DM5PR1201MB0236: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:133; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5X4JCs72L7LqcSw8ww4pHguLui3XyF/RxBxvZao5MrgGkBJ+Lj231rzqg4Xhr46D66U0tVffzshTFiPPLA/R5qp/DD3nPMqVIYhZeX1CSLXQq/zHQAlFCMDQ1G0eRxSC0KdB55ce/UUqrTvFnSvooMyItfjxmF49rfYe6R/afZUPft6A8B+qEI8L5T8SfFIIj5UZ2Z0EyALCwDyGDl8+bsaEhgr10iLJlfimS/t2NHWw4xS6wTXTMpnI1ARGse1fMJTS1IfTqeHaPOKTJrs/rnoxtDcNGDDuxD+HTrWIK6UT6BqJgYprEekPnpti01CWYfqUakAklcHXP15T2t73aTvhRZNsF3Gu1c3MKz10VVjf6MFcc+EhZoooICLzEet57+8lf+Id5MncTPz6/e1V1G7Bt9AKM7lbY9rDTjm89fjPnoPHXa7BzGveTQOWuN3vQWKvgAC+eF9zBVbEPHG7+FhUQs9n0vzSsty15nAiO3Acxpz7WK+YpGUSjNKj+pfEWH/UrkJNd4dLpiuViYrXCpnjF5NNLTfe11lUi+QjbP5TxwJJ6IoFYh6rrqZic+XqqYAb/1hbBpxy684ruu+kUA== 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)(136003)(39860400002)(396003)(346002)(5660300002)(16526019)(1076003)(8936002)(52116002)(478600001)(83380400001)(2906002)(30864003)(6486002)(66476007)(6916009)(86362001)(4326008)(2616005)(316002)(66946007)(8676002)(6506007)(36756003)(66556008)(6512007)(69590400012)(186003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?AD8cSiiz/6R6iwt3LL1SjA0QxgV/3uoIq5N63waJmjJlY91MadwkRlhDgHqZ?= =?us-ascii?Q?p0UEsPvyfIITYxm2MngCtoIlmYU1EjISRZMxY4C7QWyeGCQZaJC4lCAPba7W?= =?us-ascii?Q?6CBce/eLV+QDWiCiyzXBfqP3jDuWDpuFdiGG1/aUvgMK6xNdDOEUvN2hcHE6?= =?us-ascii?Q?ScBlYDfBoWVLAz2isTcZ/SDpQ69Ip4hpj+NqY/Dnmocin6q4EQnujdtbEINv?= =?us-ascii?Q?+dEagZg6Im3BtVOvDod5l1C3Wolkkx4zjTJPl5Ut8fLeQlMHBX9fApIG9RqQ?= =?us-ascii?Q?xwUcSxjSlK/6vbyNu0VzsnbZVYt+NrGAee1ta0Ax+HyD30IJ7cU9Okg61m4y?= =?us-ascii?Q?R91+es57CSa3HVLnpx86qdwSsLMsAOcXxZDiDw3DaOqoQGpqFGxx1FRZ6T7q?= =?us-ascii?Q?TPcQDOTHYZLRsGQTzht96SzJ2LqKiQCajjybt1myoNQlEeUFyigSysokClhe?= =?us-ascii?Q?SbZpqfVNRNpfBl8Dgj2OY6FDWZqF/gchErNyQgHtJ7lQcf28IwhkL1+AhItC?= =?us-ascii?Q?+CJ+OUK0wtlyBvbj+l9gylKXPhs/5hZSR3TV/cRyxuIed9TYC//XWmH3KmxP?= =?us-ascii?Q?rWpIzs6x4bXcriFldQykCrAm6XS0wOU2II6fbRYxCE46epHLEk5xL/KSKl3N?= =?us-ascii?Q?tGGo8wcEJNJzfM9MdDPwOG/uZ6+RluxQw9Jz1L+nGYyfxNZYju1KduiTKOAE?= =?us-ascii?Q?Txtjgh7RxmQrFSshi/YljtmEFB3PW3V8hcb6uKQyAhYQpMGnZOV81rhrsM/z?= =?us-ascii?Q?SpteXqZEnYXYDIxj0MU+3GUCL8AIfmO93TZifqBITRYTFp0AS7jIiytH2X2K?= =?us-ascii?Q?mk8/U8ukRlts+WjCqJVpvNZEkK8kkMm9ESh7zWuSyGI6C0dlJRy2oYiuM3Si?= =?us-ascii?Q?ha5uQLzzL0hgqcM0HRkyuXXawkVZmMk9GlR+PzyOlod+8B8nzBfi27d0enL7?= =?us-ascii?Q?sSooMSWjkFfPGrlhACAOV6qcoTe5bVx9B5Yutm3impCAqyUtUkSoK96nB8+f?= =?us-ascii?Q?bLi7qPT/pl4cfsm5KPrNxGCGYNNmvEDTYUKVA3tc4PucRb4F0cHFvWgYpNVx?= =?us-ascii?Q?6iHYk/x/EPzKTgGxjwcOQEQ1w+Dk/llfDmYAnLm1Si6ON1552xjXBcMchCf3?= =?us-ascii?Q?eJQuRC9x0skHnaaTgkGnVguBGH2OS7oKb7z9gDun1t9ljCD5NvaTMAGGp4d6?= =?us-ascii?Q?N5Sri3h/8/iumjzLh7Qcnx6NWAJndZOuC6JBYWC8lI5figGu6gF8qY+SCLys?= =?us-ascii?Q?ZDLadQsg7WCG3LWBSADM3goWVAQRcwWKQtk78116zkbfvbaIxnUhUoXusIYT?= =?us-ascii?Q?SDqA8YXFLC/0rGo0sewS2SPZuLX0R7mqP9fQzP1W6HqyIff+wE0JlLt4Fjfr?= =?us-ascii?Q?edbMYs7Q0NDAruZan7uX7IylMAqM?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72f13b13-7477-4186-006a-08d8dcc0d53b 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:44.8017 (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: TmMhYswiwBOBwZv/pxwsRnxSmbIm4keajt5HEQgnY6fNY/HOxS7txioOtXy0wBDmoGH151PUJcnUEkVQdBwZnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0236 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 This patch moves the compilation unit context information and support from dwarf_expr_executor and dwarf_evaluate_loc_desc to dwarf_expr_context evaluator. The idea is to report an error when a given operation requires a compilation unit information to be resolved, which is not available. gdb/ChangeLog: * dwarf2/expr.c (ensure_have_per_cu): New function. (dwarf_expr_context::dwarf_expr_context): Add compilation unit context information. (dwarf_expr_context::get_base_type): Move from dwarf_evaluate_loc_desc. (dwarf_expr_context::get_addr_index): Remove method. (dwarf_expr_context::dwarf_variable_value): Remove method. (dwarf_expr_context::execute_stack_op): Call compilation unit context info check. Inline get_addr_index and dwarf_variable_value methods. * dwarf2/expr.h (struct dwarf_expr_context): Add compilation context info. Remove get_addr_index and dwarf_variable_value. * dwarf2/frame.c (dwarf_expr_executor::get_addr_index): Remove method. (dwarf_expr_executor::dwarf_variable_value): Remove method. * dwarf2/loc.c (sect_variable_value): Expose function. (dwarf_evaluate_loc_desc::get_addr_index): Remove method. (dwarf_evaluate_loc_desc::dwarf_variable_value): Remove method. (class dwarf_evaluate_loc_desc): Move compilation unit context information to dwarf_expr_context class. * dwarf2/loc.h (sect_variable_value): Expose function. --- gdb/dwarf2/expr.c | 55 +++++++++++++++++++++++++++++++++++++++------- gdb/dwarf2/expr.h | 26 ++++++++-------------- gdb/dwarf2/frame.c | 10 --------- gdb/dwarf2/loc.c | 35 +++-------------------------- gdb/dwarf2/loc.h | 8 +++++++ 5 files changed, 67 insertions(+), 67 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 6b5cba6b7b4..5a0a4a4299c 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -72,6 +72,20 @@ ensure_have_frame (struct frame_info *frame, const char *op_name) _("%s evaluation requires a frame."), op_name); } +/* Ensure that a PER_CU is defined and throw an exception otherwise. + + Throwing NOT_AVAILABLE_ERROR error so that a client can chose + to react differently if the evaluation ended because there + was a missing context information. */ + +static void +ensure_have_per_cu (struct dwarf2_per_cu_data *per_cu, const char* op_name) +{ + if (per_cu == nullptr) + throw_error (NOT_AVAILABLE_ERROR, + _("%s evaluation requires a compilation unit."), op_name); +} + /* See expr.h. */ CORE_ADDR @@ -201,6 +215,25 @@ dwarf_expr_context::get_frame_base (const gdb_byte **start, start, length); } +/* See expr.h. */ + +struct type * +dwarf_expr_context::get_base_type (cu_offset die_cu_off, int size) +{ + if (per_cu == nullptr) + return builtin_type (this->gdbarch)->builtin_int; + + struct type *result = dwarf2_get_die_type (die_cu_off, per_cu, per_objfile); + + if (result == NULL) + error (_("Could not find type for DW_OP_const_type")); + + if (size != 0 && TYPE_LENGTH (result) != size) + error (_("DW_OP_const_type has different sizes for type and data")); + + return result; +} + /* Require that TYPE be an integral type; throw an exception if not. */ static void @@ -697,14 +730,20 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_addrx: case DW_OP_GNU_addr_index: + ensure_have_per_cu (this->per_cu, "DW_OP_addrx"); + op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset); - result = this->get_addr_index (uoffset); + result = dwarf2_read_addr_index (this->per_cu, this->per_objfile, + uoffset); result += this->per_objfile->objfile->text_section_offset (); result_val = value_from_ulongest (address_type, result); break; case DW_OP_GNU_const_index: + ensure_have_per_cu (per_cu, "DW_OP_GNU_const_index"); + op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset); - result = this->get_addr_index (uoffset); + result = dwarf2_read_addr_index (this->per_cu, this->per_objfile, + uoffset); result_val = value_from_ulongest (address_type, result); break; @@ -834,10 +873,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_GNU_implicit_pointer: { int64_t len; - - if (this->ref_addr_size == -1) - error (_("DWARF-2 expression error: DW_OP_implicit_pointer " - "is not allowed in frame context")); + ensure_have_per_cu (per_cu, "DW_OP_implicit_pointer"); /* The referred-to DIE of sect_offset kind. */ this->len = extract_unsigned_integer (op_ptr, this->ref_addr_size, @@ -1330,13 +1366,16 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, case DW_OP_GNU_variable_value: { + ensure_have_per_cu (per_cu, "DW_OP_GNU_variable_value"); + sect_offset sect_off = (sect_offset) extract_unsigned_integer (op_ptr, this->ref_addr_size, byte_order); op_ptr += this->ref_addr_size; - result_val = value_cast (address_type, - this->dwarf_variable_value (sect_off)); + result_val = sect_variable_value (sect_off, this->per_cu, + this->per_objfile); + result_val = value_cast (address_type, result_val); } break; diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h index 6ba8efb3cc6..48dd37150db 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -189,6 +189,9 @@ struct dwarf_expr_context /* Frame information used for the evaluation. */ struct frame_info *frame = nullptr; + /* Compilation unit used for the evaluation. */ + struct dwarf2_per_cu_data *per_cu = nullptr; + /* Read LENGTH bytes at ADDR into BUF. */ virtual void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length) = 0; @@ -208,19 +211,6 @@ struct dwarf_expr_context subroutine. */ virtual void dwarf_call (cu_offset die_cu_off) = 0; - /* Execute "variable value" operation on the DIE at SECT_OFF. */ - virtual struct value *dwarf_variable_value (sect_offset sect_off) = 0; - - /* Return the base type given by the indicated DIE at DIE_CU_OFF. - This can throw an exception if the DIE is invalid or does not - represent a base type. SIZE is non-zero if this function should - verify that the resulting type has the correct size. */ - virtual struct type *get_base_type (cu_offset die_cu_off, int size) - { - /* Anything will do. */ - return builtin_type (this->gdbarch)->builtin_int; - } - /* Push on DWARF stack an entry evaluated for DW_TAG_call_site's parameter matching KIND and KIND_U at the caller of specified BATON. If DEREF_SIZE is not -1 then use DW_AT_call_data_value instead of @@ -229,10 +219,6 @@ struct dwarf_expr_context union call_site_parameter_u kind_u, int deref_size) = 0; - /* Return the address indexed by DW_OP_addrx or DW_OP_GNU_addr_index. - This can throw an exception if the index is out of range. */ - virtual CORE_ADDR get_addr_index (unsigned int index) = 0; - /* Return the `object address' for DW_OP_push_object_address. */ virtual CORE_ADDR get_object_address () = 0; @@ -255,6 +241,12 @@ struct dwarf_expr_context START and LENGTH. The result must be live until the current expression evaluation is complete. */ void get_frame_base (const gdb_byte **start, size_t *length); + + /* Return the base type given by the indicated DIE at DIE_CU_OFF. + This can throw an exception if the DIE is invalid or does not + represent a base type. SIZE is non-zero if this function should + verify that the resulting type has the correct size. */ + struct type *get_base_type (cu_offset die_cu_off, int size); }; /* Return the value of register number REG (a DWARF register number), diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 682f2881556..69a3e424c6e 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -258,16 +258,6 @@ class dwarf_expr_executor : public dwarf_expr_context invalid ("DW_OP_call*"); } - struct value *dwarf_variable_value (sect_offset sect_off) override - { - invalid ("DW_OP_GNU_variable_value"); - } - - CORE_ADDR get_addr_index (unsigned int index) override - { - invalid ("DW_OP_addrx or DW_OP_GNU_addr_index"); - } - private: void invalid (const char *op) ATTRIBUTE_NORETURN diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 2ad262dc802..1281a8a3d34 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -620,12 +620,10 @@ per_cu_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset, ctx->eval (block.data, block.size); } -/* Given context CTX, section offset SECT_OFF, and compilation unit - data PER_CU, execute the "variable value" operation on the DIE - found at SECT_OFF. */ +/* See loc.h. */ -static struct value * -sect_variable_value (struct dwarf_expr_context *ctx, sect_offset sect_off, +struct value * +sect_variable_value (sect_offset sect_off, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) { @@ -654,7 +652,6 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context : dwarf_expr_context (per_objfile) {} - struct dwarf2_per_cu_data *per_cu; CORE_ADDR obj_address; /* Helper function for dwarf2_evaluate_loc_desc. Computes the PC for @@ -680,32 +677,6 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context per_cu_dwarf_call (this, die_offset, per_cu, per_objfile); } - /* Helper interface of sect_variable_value for - dwarf2_evaluate_loc_desc. */ - - struct value *dwarf_variable_value (sect_offset sect_off) override - { - return sect_variable_value (this, sect_off, per_cu, per_objfile); - } - - struct type *get_base_type (cu_offset die_offset, int size) override - { - struct type *result = dwarf2_get_die_type (die_offset, per_cu, per_objfile); - if (result == NULL) - error (_("Could not find type for DW_OP_const_type")); - if (size != 0 && TYPE_LENGTH (result) != size) - error (_("DW_OP_const_type has different sizes for type and data")); - return result; - } - - /* Callback function for dwarf2_evaluate_loc_desc. - Fetch the address indexed by DW_OP_addrx or DW_OP_GNU_addr_index. */ - - CORE_ADDR get_addr_index (unsigned int index) override - { - return dwarf2_read_addr_index (per_cu, per_objfile, index); - } - /* Callback function for get_object_address. Return the address of the VLA object. */ diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 2943baf91d2..a729b370e2e 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -53,6 +53,14 @@ extern void func_get_frame_base_dwarf_block (struct symbol *framefunc, const gdb_byte **start, size_t *length); +/* Given section offset SECT_OFF, and compilation unit data + PER_CU, execute the "variable value" operation on the DIE + found at SECT_OFF. */ + +struct value *sect_variable_value (sect_offset sect_off, + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile); + /* Evaluate a location description, starting at DATA and with length SIZE, to find the current location of variable of TYPE in the context of FRAME. */ -- 2.17.1