From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wPQrBgB8zl+QTQAAWB0awg (envelope-from ) for ; Mon, 07 Dec 2020 14:01:20 -0500 Received: by simark.ca (Postfix, from userid 112) id A87EB1EF4B; Mon, 7 Dec 2020 14:01:16 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [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 7D4291EF4B for ; Mon, 7 Dec 2020 14:01:11 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A633395180D; Mon, 7 Dec 2020 19:01:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A633395180D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607367671; bh=AMo0FCadqCjUG7kpRrwSbxvZj0hq8W8y4gkT3xdVo6E=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=x15mvfb80a1e9T+kdjfGemuW5DaDWwnmK6UOEcxIv/2lmS9/6unLzXEtpBIpdxFKc AUH3kJEGV9trfqcsGdJInIMdDztZRwK+fv/eMj1RXVQWYtw96jpAtra0Ik2YcV6c7d rbjlQ/1+hZ2m4+Y5McNGx3XiHB7RQugGu/bWL10I= Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by sourceware.org (Postfix) with ESMTPS id DB7A03951809 for ; Mon, 7 Dec 2020 19:01:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DB7A03951809 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MffJeHzWy15SdWoZbX12V2zjfbAd4oTTjo5wpTYLrIMCB3Vyob2PxrdU8wbUqKRO/J6J3dP3XE5AIKXumvPqko1fZm1cgvfry0Cfs+Os2x5UYaUqg5tkRYuKmEH2Bua/m9XhfFWWeagfpfaOCmm8DuapfSKUTfgmQXZAuImjuFkSy4GF5ZLlR0r/lRN3UmER9l9QWHp9J6f/hfN8K81a1wzey/CXk/sb6EDQrrrrNPPwG4Y7qrkWs47AvNOP82vEZ3t0QyIHo4ETxIuLYWMGHCTC0UsYFPRTkFOsoB8XIVI+xCjeQxzmVNo0zGDEo2lxzfaEZTjOJacaShP/1hNFHw== 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=AMo0FCadqCjUG7kpRrwSbxvZj0hq8W8y4gkT3xdVo6E=; b=MyCY3qEYOTaZ72qaSyqDJ7QaamnJy6aYN0228JlKiHPFKHDy5rlZ489z7bm9A2Cx36uofjAM7SQqHySorEQjrRLKCf8UvQgFGwlOyM0ATK/edmu54rQUqJVXsfLqPnmC52670F2YeavFsKCfCKUhBvareoobkzsZgg6hdecw8jHHTOE5IlBJrSihq7NXWBBQvSExYZIskmiXTohEi1MiyGMYStoHH4O6TyV0xBHliif5a6DLNYgac9Y0w2a/lgtuj4RDjVz9SHklyJJQBbbiXP3XR+NVmsBYOR4FgsquJ+zCtdNgkkxbZyoAgsIs+VAhtfwu4pfDfJ1o+SCN2kSnpA== 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 DM6PR12MB4561.namprd12.prod.outlook.com (2603:10b6:5:2ac::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Mon, 7 Dec 2020 19:01:01 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::6841:61df:984b:b3c]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::6841:61df:984b:b3c%3]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 19:01:01 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 08/30] Move push_dwarf_reg_entry_value to expr.c Date: Mon, 7 Dec 2020 19:00:09 +0000 Message-Id: <20201207190031.13341-9-Zoran.Zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201207190031.13341-1-Zoran.Zaric@amd.com> References: <20201207190031.13341-1-Zoran.Zaric@amd.com> Content-Type: text/plain X-Originating-IP: [2a00:23c7:5a85:6801:5c7:2db6:d2c2:ae4e] X-ClientProxiedBy: AM4PR0101CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::21) 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:5c7:2db6:d2c2:ae4e) by AM4PR0101CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Mon, 7 Dec 2020 19:01:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 86c5af7f-6924-43b1-0c15-08d89ae270b7 X-MS-TrafficTypeDiagnostic: DM6PR12MB4561: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bhf+G9T/hCpZNmLEAGZQY9o8ZCuZJzXCw21zu9d0iLMP8laZk+JaFBBDO2lzJ6RjnEPFOquwWCd2SEO1lJNxSoVWb5r2J/tMzJA1dS5EMIp4RHqq6A6hjJ8ORI1iEtX6+WOROEZqJ/buBfUy6I0vTe2TEEHM2spaa8/8yug7GNDdPcGxX/kuO7WVdiEloZ1BvL9NstjoOYTvK/5n6ZBCRnEMtOCeae5RUfyzehiIXpJfWQLw7g6Z3epazUyWs9sicz5ag33kPRNCQIFi0+S0auCYODRQqFf4P+l4kMDut7lhXNm3XO+xlJGa+XkIK383bm//eKbSrQjt8YCuWxh+Pj33i6eQVmiYddbtQUoWwnSGhY+F31im93XCPM34sg51 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)(346002)(39860400002)(366004)(136003)(396003)(1076003)(83380400001)(86362001)(6506007)(4326008)(69590400008)(52116002)(36756003)(2906002)(6512007)(8676002)(6486002)(16526019)(2616005)(66946007)(66476007)(66556008)(6916009)(5660300002)(186003)(8936002)(478600001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?vJ86xV0smxckQ2Nx8hObS8rY6yu0Tq0KoSBIP0+8jUTGbau6NJxRMOWDBGSM?= =?us-ascii?Q?hktTAljUZacwCFcU/f5GkgNl/he2VcDYVunbts6XDvSQi5+ACC+zlM/75hF3?= =?us-ascii?Q?d2WiZdHbeDbPfipv4h77LyDElYKqPrbtpmNkHAWVdOaLnNNqgru1fEMmd8KX?= =?us-ascii?Q?L8kjjENMOJZt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ap1NeLfBz/g7?= =?us-ascii?Q?0ogN7ZDO?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 19:01:01.6396 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 86c5af7f-6924-43b1-0c15-08d89ae270b7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UQikfD7WpVlcJeve+ums/o5EWzXowmoPk6Ist/diaX4nFUa0rdRTvFSXLel2N40tyxqbgUm40Gz32I+UW2WeLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4561 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 Cc: Zoran Zaric Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Zoran Zaric Following the idea of merging the evaluators, the push_dwarf_reg_entry_value method can be moved from dwarf_expr_executor and dwarf_evaluate_loc_desc classes to their base class dwarf_expr_context. gdb/ChangeLog: * dwarf2/expr.c (dwarf_expr_context::push_dwarf_reg_entry_value): Move from dwarf_evaluate_loc_desc. * dwarf2/frame.c (dwarf_expr_executor::push_dwarf_reg_entry_value): Remove method. * dwarf2/loc.c (dwarf_expr_reg_to_entry_parameter): Expose function. (dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value): Move to dwarf_expr_context. * dwarf2/loc.h (dwarf_expr_reg_to_entry_parameter): Expose function. --- gdb/dwarf2/expr.c | 51 +++++++++++++++++++++++++++++++++ gdb/dwarf2/expr.h | 16 +++++------ gdb/dwarf2/frame.c | 7 ----- gdb/dwarf2/loc.c | 70 ++-------------------------------------------- gdb/dwarf2/loc.h | 14 ++++++++++ 5 files changed, 75 insertions(+), 83 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index a2aa9435a2..33237e1f27 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -272,6 +272,57 @@ dwarf_expr_context::read_mem (gdb_byte *buf, CORE_ADDR addr, read_memory (addr, buf, length); } +/* See expr.h. */ + +void +dwarf_expr_context::push_dwarf_reg_entry_value + (enum call_site_parameter_kind kind, + union call_site_parameter_u kind_u, + int deref_size) +{ + ensure_have_per_cu (per_cu, "DW_OP_entry_value"); + ensure_have_frame (frame, "DW_OP_entry_value"); + + dwarf2_per_cu_data *caller_per_cu; + dwarf2_per_objfile *caller_per_objfile; + struct frame_info *caller_frame = get_prev_frame (frame); + struct call_site_parameter *parameter + = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, + &caller_per_cu, + &caller_per_objfile); + const gdb_byte *data_src + = deref_size == -1 ? parameter->value : parameter->data_value; + size_t size + = deref_size == -1 ? parameter->value_size : parameter->data_value_size; + + /* DEREF_SIZE size is not verified here. */ + if (data_src == NULL) + throw_error (NO_ENTRY_VALUE_ERROR, + _("Cannot resolve DW_AT_call_data_value")); + + /* We are about to evaluate an expression in the context of the caller + of the current frame. This evaluation context may be different from + the current (callee's) context), so temporarily set the caller's context. + + It is possible for the caller to be from a different objfile from the + callee if the call is made through a function pointer. */ + scoped_restore save_frame = make_scoped_restore (&this->frame, + caller_frame); + scoped_restore save_per_cu = make_scoped_restore (&this->per_cu, + caller_per_cu); + scoped_restore save_obj_addr = make_scoped_restore (&this->obj_address, + (CORE_ADDR) 0); + scoped_restore save_per_objfile = make_scoped_restore (&this->per_objfile, + caller_per_objfile); + + scoped_restore save_arch = make_scoped_restore (&this->gdbarch); + this->gdbarch = this->per_objfile->objfile->arch (); + scoped_restore save_addr_size = make_scoped_restore (&this->addr_size); + this->addr_size = this->per_cu->addr_size (); + + this->eval (data_src, size); +} + /* Require that TYPE be an integral type; throw an exception if not. */ static void diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h index 3c40dde13d..71c10ebe3b 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -198,14 +198,6 @@ struct dwarf_expr_context /* Read LENGTH bytes at ADDR into BUF. */ virtual void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length); - /* 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 - DW_AT_call_value. */ - virtual void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind, - union call_site_parameter_u kind_u, - int deref_size) = 0; - /* Return the `object address' for DW_OP_push_object_address. */ virtual CORE_ADDR get_object_address () { @@ -245,6 +237,14 @@ struct dwarf_expr_context STACK while it being passed to and returned from the called DWARF subroutine. */ void dwarf_call (cu_offset die_cu_off); + + /* 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 + DW_AT_call_value. */ + void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind, + union call_site_parameter_u kind_u, + int deref_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 46f3f5145d..3eb2aa9991 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -231,13 +231,6 @@ class dwarf_expr_executor : public dwarf_expr_context : dwarf_expr_context (per_objfile) {} - void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind, - union call_site_parameter_u kind_u, - int deref_size) override - { - invalid ("DW_OP_entry_value"); - } - private: void invalid (const char *op) ATTRIBUTE_NORETURN diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 679852c81b..2750907c9e 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -52,13 +52,6 @@ static struct value *dwarf2_evaluate_loc_desc_full size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile, struct type *subobj_type, LONGEST subobj_byte_offset); -static struct call_site_parameter *dwarf_expr_reg_to_entry_parameter - (struct frame_info *frame, - enum call_site_parameter_kind kind, - union call_site_parameter_u kind_u, - dwarf2_per_cu_data **per_cu_return, - dwarf2_per_objfile **per_objfile_return); - static struct value *indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, dwarf2_per_cu_data *per_cu, @@ -631,61 +624,6 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context dwarf_evaluate_loc_desc (dwarf2_per_objfile *per_objfile) : dwarf_expr_context (per_objfile) {} - - /* Execute DWARF block of call_site_parameter which matches KIND and - KIND_U. Choose DEREF_SIZE value of that parameter. Search - caller of this objects's frame. - - The caller can be from a different CU - per_cu_dwarf_call - implementation can be more simple as it does not support cross-CU - DWARF executions. */ - - void push_dwarf_reg_entry_value (enum call_site_parameter_kind kind, - union call_site_parameter_u kind_u, - int deref_size) override - { - struct frame_info *caller_frame; - dwarf2_per_cu_data *caller_per_cu; - dwarf2_per_objfile *caller_per_objfile; - struct call_site_parameter *parameter; - const gdb_byte *data_src; - size_t size; - - caller_frame = get_prev_frame (frame); - - parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u, - &caller_per_cu, - &caller_per_objfile); - data_src = deref_size == -1 ? parameter->value : parameter->data_value; - size = deref_size == -1 ? parameter->value_size : parameter->data_value_size; - - /* DEREF_SIZE size is not verified here. */ - if (data_src == NULL) - throw_error (NO_ENTRY_VALUE_ERROR, - _("Cannot resolve DW_AT_call_data_value")); - - /* We are about to evaluate an expression in the context of the caller - of the current frame. This evaluation context may be different from - the current (callee's) context), so temporarily set the caller's context. - - It is possible for the caller to be from a different objfile from the - callee if the call is made through a function pointer. */ - scoped_restore save_frame = make_scoped_restore (&this->frame, - caller_frame); - scoped_restore save_per_cu = make_scoped_restore (&this->per_cu, - caller_per_cu); - scoped_restore save_obj_addr = make_scoped_restore (&this->obj_address, - (CORE_ADDR) 0); - scoped_restore save_per_objfile = make_scoped_restore (&this->per_objfile, - caller_per_objfile); - - scoped_restore save_arch = make_scoped_restore (&this->gdbarch); - this->gdbarch = this->per_objfile->objfile->arch (); - scoped_restore save_addr_size = make_scoped_restore (&this->addr_size); - this->addr_size = this->per_cu->addr_size (); - - this->eval (data_src, size); - } }; /* See dwarf2loc.h. */ @@ -1166,13 +1104,9 @@ call_site_parameter_matches (struct call_site_parameter *parameter, return 0; } -/* Fetch call_site_parameter from caller matching KIND and KIND_U. - FRAME is for callee. - - Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR - otherwise. */ +/* See loc.h. */ -static struct call_site_parameter * +struct call_site_parameter * dwarf_expr_reg_to_entry_parameter (struct frame_info *frame, enum call_site_parameter_kind kind, union call_site_parameter_u kind_u, diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 85700ea99d..068c75af93 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -61,6 +61,20 @@ struct value *sect_variable_value (sect_offset sect_off, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile); +/* Fetch call_site_parameter from caller matching KIND and KIND_U. + FRAME is for callee. + + Function always returns non-NULL, it throws NO_ENTRY_VALUE_ERROR + otherwise. */ + +struct call_site_parameter *dwarf_expr_reg_to_entry_parameter + (struct frame_info *frame, + enum call_site_parameter_kind kind, + union call_site_parameter_u kind_u, + dwarf2_per_cu_data **per_cu_return, + dwarf2_per_objfile **per_objfile_return); + + /* 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