From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31504 invoked by alias); 14 Sep 2017 08:17:08 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 24666 invoked by uid 89); 14 Sep 2017 08:16:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN autolearn=ham version=3.3.2 spammy=PIECES X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Sep 2017 08:16:13 +0000 Received: from ESESSHC003.ericsson.se (Unknown_Domain [153.88.183.27]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id E3.4F.28997.ACA3AB95; Thu, 14 Sep 2017 10:16:10 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.27) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 14 Sep 2017 10:15:58 +0200 Received: from elxacz23q12.localdomain (95.192.89.253) by AMSPR07MB309.eurprd07.prod.outlook.com (2a01:111:e400:802f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.4; Thu, 14 Sep 2017 08:15:56 +0000 From: Simon Marchi To: CC: , Simon Marchi Subject: [PATCH] Make dwarf_expr_piece::pieces an std::vector Date: Thu, 14 Sep 2017 08:17:00 -0000 Message-ID: <1505376948-22860-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: HE1PR05CA0176.eurprd05.prod.outlook.com (2603:10a6:3:f8::24) To AMSPR07MB309.eurprd07.prod.outlook.com (2a01:111:e400:802f::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f69b24c4-6d01-4134-375e-08d4fb48d374 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:AMSPR07MB309; X-Microsoft-Exchange-Diagnostics: 1;AMSPR07MB309;3:CXLOsHbNnYtMyJCGRjLZnSW9WMurtNxeAuMzPg38lkEA5OCFe+5KjNWJ0/ZxjK/SQmh/HExC1DHe6sz9vP1pJzxbfr2g/KrD3pBo9JzGDabZ6mU4APKRNXtTzYNJriSev7XquexJ3G5L0qxxV2+IrCD9TkXAqkv4fZPv5igT9SZqmD0jKF4hTjRUxsq3OgTJc4957u5X9e4VNJ8lp4hVtIjzEJqw+EqcLsopb2NrF/zg0LjyBSO7jw4yXRqw96MI;25:9vFsF1wVMQh5RuAuV5tZda9OMloEk288TUyYu2qfq+zppnEttBxWR4nZgflUK0N9cj5YlIeq36Z8OHUNsEBaoSP2jMBtDKWj8EXVScGGVP650+ZreAKwtn58Q1gQlZyFS97Kwv5yDSa87Y/MdBeDDrysvUF2I3/gxMJFrrw1eY7lnqG6dLFnC8l3h8WDIqJqPDFtCSbrzQ0eTRNBwDusi4+03YQT5WAPVPp9cTHlyXKQ7Yx5EwMyVPj/w9iGaEENPh/R5N+O6NbWb8euisqW8FdmU4pIERvNpPfZpQ/GqZ1W/o0J+NYOFNCHmE0StT6ukGYWBzwwhwQT1AtBNAgpfw==;31:D5NnBG0bwflsQgGxeBS1jzFWHEwhskR76mA4gB2HlKlj2fAsDRu2hho6sfsD5KASF8Nci4BDpP9oHn+/+WyPDgT9UuNAgIx3fvMiupwOarKTCDs62CUqIy8bBDkGXDhP/z4EdQzS5AVJwiVhBJXCGkvYEVXcCFuk1GZKCkLyb7+euo0DZ08ILm12MSGJ3OAV36H67NiMRug+He2tTGRPRjK0a1NJ7c3reAspDNz6w6Q= X-MS-TrafficTypeDiagnostic: AMSPR07MB309: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1;AMSPR07MB309;20:W7kY9khKWDEd1o/7D9Vc1X35/m4Q6eSCSuepsZ9klUfCFT20ZfDDneeIhnCEW88pqOO41Dp8q43Lbxaa0+SKbn0AH+p4pPX+Q4fqVRNolw2dnHejoriuJcvTmqIjujxRXB6UAUpUa7exoC4k55dkmGfMeP6kXC9/s7wkmGsA/Ozm6m63g0qrpkQrC12LT2k3x4TAor9fA25UNuCZoapXiTfAFwG5M3tTwgg02vW4rGIoJbwGaoT+59CP0Z+pmP/eCaYfX/sl67PSjXWoN1McPDH6vrt1E1SJOzgwPlJnO9XaZ7hR/YRNW4xQpGYHgXs0FwQMFtIPvlKgDmhBaM7Zsd7oQp1ayUAQCbR7C4buWjkNI4ovW2aqH7JBMRbvvIpJxp6/pyEWb39YDhp7hGSHijLhQ+GjVFbhWlw2HVx4/jq9HPDDGj0uWdifNzw0RK3d+YXvE82+CiAP+2+RcLZ1WqzUCjfstnMjl3+SGUk5upNnGCbkkxSyUUGwENKWdqgl;4:6d13N+Ii09FM67OfYeNZDgRDaoOt0R1UYAGWNCB7dLe3f4FTTBmIQ/403ekk7a82KhMcGkmjlvqL03wqDR0Y8wbYzwRj5uOj8Rde3cZCYbAf9oXYGYkQbluQg+UtS1LvvYGKwgntojUQZU0mK/vN06PE07h0BSZGqxFEz4o2lwVxiJ21cCH6PtHkkN0YmXNIJyM7nRf7j3h9rghTYW+YMPMMO0InesP5ZUm8DgFMLGaABDsnfjbTrQOj/4cRu/HF X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123555025)(20161123564025)(20161123558100)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AMSPR07MB309;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AMSPR07MB309; X-Forefront-PRVS: 0430FA5CB7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(7370300001)(4630300001)(6009001)(346002)(376002)(189002)(54534003)(199003)(6486002)(6506006)(4326008)(6916009)(6666003)(33646002)(47776003)(66066001)(2906002)(7350300001)(2351001)(101416001)(2361001)(106356001)(189998001)(7736002)(5003940100001)(305945005)(105586002)(81166006)(8676002)(81156014)(50226002)(36756003)(6116002)(107886003)(110136004)(6512007)(53936002)(3846002)(48376002)(50466002)(5660300001)(68736007)(50986999)(25786009)(16526017)(86362001)(316002)(97736004)(16586007)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:AMSPR07MB309;H:elxacz23q12.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;AMSPR07MB309;23:as3aXNIINaKmheGzDMtOiYozKunf7k0jO0g0YpUOf5?= =?us-ascii?Q?XckOp3fH5AuoCf+RJbvtkyq+H2iRXjmaiRbQCk14dB52UU/BjF2U+FvGSjeK?= =?us-ascii?Q?Q0j+8iSqeUT+EG9/D1roAp17EiNKXOpPpOLCzcVCXh6wXZMlqc8BHeC9uvIq?= =?us-ascii?Q?kyPRMJHeCGqNOjT2Pd2I86/1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agnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2017 08:15:56.6471 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR07MB309 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00370.txt.bz2 Change the manually managed array dwarf_expr_piece::piece with an std::vector. After passing the pieces array to allocate_piece_closure, dwarf2_evaluate_loc_desc_full doesn't need that data anymore. We can therefore move the content of the vector to avoid copying it. Reg-tested on the buildbot. gdb/ChangeLog: * dwarf2expr.h (struct dwarf_expr_piece): Move up. (struct dwarf_expr_context) : Remove. : Change type to std::vector. * dwarf2expr.c (dwarf_expr_context::dwarf_expr_context): Adjust. (dwarf_expr_context::~dwarf_expr_context): Don't manually free pieces. (dwarf_expr_context::add_piece): Adjust. * dwarf2loc.c (struct piece_closure): Initialize fields. : Remove. : Change type to std::vector. (allocate_piece_closure): Adjust, change parameter to std::vector rvalue and std::move it to piece_closure. (rw_pieced_value): Adjust. (check_pieced_synthetic_pointer): Adjust. (indirect_synthetic_pointer): Adjust. (coerce_pieced_ref): Adjust. (free_pieced_value_closure): Adjust. Use delete to free piece_closure. (dwarf2_evaluate_loc_desc_full): Adjust. std::move ctx.pieces to allocate_piece_closure. (dwarf2_loc_desc_get_symbol_read_needs): Adjust. --- gdb/dwarf2expr.c | 14 ++------ gdb/dwarf2expr.h | 101 +++++++++++++++++++++++++++---------------------------- gdb/dwarf2loc.c | 77 ++++++++++++++++++------------------------ 3 files changed, 84 insertions(+), 108 deletions(-) diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c index e2724da..e91dab0 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c @@ -100,9 +100,7 @@ dwarf_expr_context::dwarf_expr_context () location (DWARF_VALUE_MEMORY), len (0), data (NULL), - initialized (0), - num_pieces (0), - pieces (NULL) + initialized (0) { this->stack = XNEWVEC (struct dwarf_stack_value, this->stack_allocated); } @@ -112,7 +110,6 @@ dwarf_expr_context::dwarf_expr_context () dwarf_expr_context::~dwarf_expr_context () { xfree (this->stack); - xfree (this->pieces); } /* Expand the memory allocated stack to contain at least @@ -285,14 +282,9 @@ dwarf_expr_context::stack_empty_p () const void dwarf_expr_context::add_piece (ULONGEST size, ULONGEST offset) { - struct dwarf_expr_piece *p; + this->pieces.emplace_back (); + dwarf_expr_piece *p = &(this->pieces.back ()); - this->num_pieces++; - - this->pieces - = XRESIZEVEC (struct dwarf_expr_piece, this->pieces, this->num_pieces); - - p = &this->pieces[this->num_pieces - 1]; p->location = this->location; p->size = size; p->offset = offset; diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h index 7df697d..39bcea3 100644 --- a/gdb/dwarf2expr.h +++ b/gdb/dwarf2expr.h @@ -49,6 +49,53 @@ enum dwarf_value_location DWARF_VALUE_IMPLICIT_POINTER }; +/* A piece of an object, as recorded by DW_OP_piece or DW_OP_bit_piece. */ +struct dwarf_expr_piece +{ + enum dwarf_value_location location; + + union + { + struct + { + /* This piece's address, for DWARF_VALUE_MEMORY pieces. */ + CORE_ADDR addr; + /* Non-zero if the piece is known to be in memory and on + the program's stack. */ + int in_stack_memory; + } mem; + + /* The piece's register number, for DWARF_VALUE_REGISTER pieces. */ + int regno; + + /* The piece's literal value, for DWARF_VALUE_STACK pieces. */ + struct value *value; + + struct + { + /* A pointer to the data making up this piece, + for DWARF_VALUE_LITERAL pieces. */ + const gdb_byte *data; + /* The length of the available data. */ + ULONGEST length; + } literal; + + /* Used for DWARF_VALUE_IMPLICIT_POINTER. */ + struct + { + /* The referent DIE from DW_OP_implicit_pointer. */ + sect_offset die_sect_off; + /* The byte offset into the resulting data. */ + LONGEST offset; + } ptr; + } v; + + /* The length of the piece, in bits. */ + ULONGEST size; + /* The piece offset, in bits. */ + ULONGEST offset; +}; + /* The dwarf expression stack. */ struct dwarf_stack_value @@ -114,8 +161,7 @@ struct dwarf_expr_context initialized; zero otherwise. */ int initialized; - /* An array of pieces. PIECES points to its first element; - NUM_PIECES is its length. + /* A vector of pieces. Each time DW_OP_piece is executed, we add a new element to the end of this array, recording the current top of the stack, the @@ -137,8 +183,7 @@ struct dwarf_expr_context no DW_OP_piece operations have no value to place in a piece's 'size' field; the size comes from the surrounding data. So the two cases need to be handled separately.) */ - int num_pieces; - struct dwarf_expr_piece *pieces; + std::vector pieces; /* Return the value of register number REGNUM (a DWARF register number), read as an address. */ @@ -213,54 +258,6 @@ private: void pop (); }; - -/* A piece of an object, as recorded by DW_OP_piece or DW_OP_bit_piece. */ -struct dwarf_expr_piece -{ - enum dwarf_value_location location; - - union - { - struct - { - /* This piece's address, for DWARF_VALUE_MEMORY pieces. */ - CORE_ADDR addr; - /* Non-zero if the piece is known to be in memory and on - the program's stack. */ - int in_stack_memory; - } mem; - - /* The piece's register number, for DWARF_VALUE_REGISTER pieces. */ - int regno; - - /* The piece's literal value, for DWARF_VALUE_STACK pieces. */ - struct value *value; - - struct - { - /* A pointer to the data making up this piece, - for DWARF_VALUE_LITERAL pieces. */ - const gdb_byte *data; - /* The length of the available data. */ - ULONGEST length; - } literal; - - /* Used for DWARF_VALUE_IMPLICIT_POINTER. */ - struct - { - /* The referent DIE from DW_OP_implicit_pointer. */ - sect_offset die_sect_off; - /* The byte offset into the resulting data. */ - LONGEST offset; - } ptr; - } v; - - /* The length of the piece, in bits. */ - ULONGEST size; - /* The piece offset, in bits. */ - ULONGEST offset; -}; - void dwarf_expr_require_composition (const gdb_byte *, const gdb_byte *, const char *); diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index ded9e00..42a140a 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -1479,16 +1479,13 @@ value_of_dwarf_block_entry (struct type *type, struct frame_info *frame, struct piece_closure { /* Reference count. */ - int refc; + int refc = 0; /* The CU from which this closure's expression came. */ - struct dwarf2_per_cu_data *per_cu; - - /* The number of pieces used to describe this variable. */ - int n_pieces; + struct dwarf2_per_cu_data *per_cu = NULL; - /* The pieces themselves. */ - struct dwarf_expr_piece *pieces; + /* The pieces describing this variable. */ + std::vector pieces; /* Frame ID of frame to which a register value is relative, used only by DWARF_VALUE_REGISTER. */ @@ -1500,25 +1497,23 @@ struct piece_closure static struct piece_closure * allocate_piece_closure (struct dwarf2_per_cu_data *per_cu, - int n_pieces, struct dwarf_expr_piece *pieces, + const std::vector &&pieces, struct frame_info *frame) { - struct piece_closure *c = XCNEW (struct piece_closure); + struct piece_closure *c = new piece_closure; int i; c->refc = 1; c->per_cu = per_cu; - c->n_pieces = n_pieces; - c->pieces = XCNEWVEC (struct dwarf_expr_piece, n_pieces); + c->pieces = std::move (pieces); if (frame == NULL) c->frame_id = null_frame_id; else c->frame_id = get_frame_id (frame); - memcpy (c->pieces, pieces, n_pieces * sizeof (struct dwarf_expr_piece)); - for (i = 0; i < n_pieces; ++i) - if (c->pieces[i].location == DWARF_VALUE_STACK) - value_incref (c->pieces[i].v.value); + for (dwarf_expr_piece &piece : c->pieces) + if (piece.location == DWARF_VALUE_STACK) + value_incref (piece.v.value); return c; } @@ -1816,10 +1811,10 @@ rw_pieced_value (struct value *v, struct value *from) max_offset = 8 * TYPE_LENGTH (value_type (v)); /* Advance to the first non-skipped piece. */ - for (i = 0; i < c->n_pieces && bits_to_skip >= c->pieces[i].size; i++) + for (i = 0; i < c->pieces.size () && bits_to_skip >= c->pieces[i].size; i++) bits_to_skip -= c->pieces[i].size; - for (; i < c->n_pieces && offset < max_offset; i++) + for (; i < c->pieces.size () && offset < max_offset; i++) { struct dwarf_expr_piece *p = &c->pieces[i]; size_t this_size_bits, this_size; @@ -2079,7 +2074,7 @@ check_pieced_synthetic_pointer (const struct value *value, LONGEST bit_offset, if (value_bitsize (value)) bit_offset += value_bitpos (value); - for (i = 0; i < c->n_pieces && bit_length > 0; i++) + for (i = 0; i < c->pieces.size () && bit_length > 0; i++) { struct dwarf_expr_piece *p = &c->pieces[i]; size_t this_size_bits = p->size; @@ -2200,7 +2195,7 @@ indirect_pieced_value (struct value *value) if (value_bitsize (value)) bit_offset += value_bitpos (value); - for (i = 0; i < c->n_pieces && bit_length > 0; i++) + for (i = 0; i < c->pieces.size () && bit_length > 0; i++) { struct dwarf_expr_piece *p = &c->pieces[i]; size_t this_size_bits = p->size; @@ -2271,11 +2266,12 @@ coerce_pieced_ref (const struct value *value) /* gdb represents synthetic pointers as pieced values with a single piece. */ gdb_assert (closure != NULL); - gdb_assert (closure->n_pieces == 1); + gdb_assert (closure->pieces.size () == 1); - return indirect_synthetic_pointer (closure->pieces->v.ptr.die_sect_off, - closure->pieces->v.ptr.offset, - closure->per_cu, frame, type); + return indirect_synthetic_pointer + (closure->pieces[0].v.ptr.die_sect_off, + closure->pieces[0].v.ptr.offset, + closure->per_cu, frame, type); } else { @@ -2303,14 +2299,11 @@ free_pieced_value_closure (struct value *v) --c->refc; if (c->refc == 0) { - int i; - - for (i = 0; i < c->n_pieces; ++i) - if (c->pieces[i].location == DWARF_VALUE_STACK) - value_free (c->pieces[i].v.value); + for (dwarf_expr_piece &p : c->pieces) + if (p.location == DWARF_VALUE_STACK) + value_free (p.v.value); - xfree (c->pieces); - xfree (c); + delete c; } } @@ -2390,21 +2383,20 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame, } END_CATCH - if (ctx.num_pieces > 0) + if (ctx.pieces.size () > 0) { struct piece_closure *c; ULONGEST bit_size = 0; int i; - for (i = 0; i < ctx.num_pieces; ++i) - bit_size += ctx.pieces[i].size; + for (dwarf_expr_piece &piece : ctx.pieces) + bit_size += piece.size; /* Complain if the expression is larger than the size of the outer type. */ if (bit_size > 8 * TYPE_LENGTH (type)) invalid_synthetic_pointer (); - c = allocate_piece_closure (per_cu, ctx.num_pieces, ctx.pieces, - frame); + c = allocate_piece_closure (per_cu, std::move (ctx.pieces), frame); /* We must clean up the value chain after creating the piece closure but before allocating the result. */ free_values.free_to_mark (); @@ -2866,16 +2858,11 @@ dwarf2_loc_desc_get_symbol_read_needs (const gdb_byte *data, size_t size, in_reg = ctx.location == DWARF_VALUE_REGISTER; - if (ctx.num_pieces > 0) - { - int i; - - /* If the location has several pieces, and any of them are in - registers, then we will need a frame to fetch them from. */ - for (i = 0; i < ctx.num_pieces; i++) - if (ctx.pieces[i].location == DWARF_VALUE_REGISTER) - in_reg = 1; - } + /* If the location has several pieces, and any of them are in + registers, then we will need a frame to fetch them from. */ + for (dwarf_expr_piece &p : ctx.pieces) + if (p.location == DWARF_VALUE_REGISTER) + in_reg = 1; if (in_reg) ctx.needs = SYMBOL_NEEDS_FRAME; -- 2.7.4