From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32415 invoked by alias); 17 Jul 2012 21:29:49 -0000 Received: (qmail 32406 invoked by uid 22791); 17 Jul 2012 21:29:48 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jul 2012 21:29:36 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6HLTZTc030471 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Jul 2012 17:29:35 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6HLTXel027713 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Tue, 17 Jul 2012 17:29:35 -0400 Message-ID: <5005D93D.7020808@redhat.com> Date: Tue, 17 Jul 2012 21:29:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: "gp >> \"gdb-patches@sourceware.org ml\"" Subject: [RFA] Cleanup: Use add_sal_to_sals for expressions Content-Type: multipart/mixed; boundary="------------050209040502000201060105" X-IsSubscribed: yes 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 X-SW-Source: 2012-07/txt/msg00243.txt.bz2 This is a multi-part message in MIME format. --------------050209040502000201060105 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1002 Hi, Currently convert_linespec_to_sals treats expressions a little differently than other linespec conversions. It allocates a SaL, fills it in, and then relies on decode_line_full to fill in the "missing" canonical name. This patch causes expressions to use add_sal_to_sals, which will then set a canonical name for the linespec, thereby negating the need to double-check for missing linespecs later (in decode_line_full). [This would not be committed until after the 7.5 branch is cut. While I haven't run into the new assert, I would feel better with more people/platforms using this before pushing this to the public.] Keith ChangeLog 2012-07-17 Keith Seitz * linespec.c (add_sal_to_sals): Use SYMNAME as canonical if it is non-NULL and no symtab is set in the SaL. (convert_linespec_to_sals): Use add_sal_to_sals for expressions, too. (decode_line_full): No need to "fill in missing canonical names" anymore. Simply make cleanups for the allocated names. --------------050209040502000201060105 Content-Type: text/x-patch; name="use-add_sal_to_sals-for-expressions.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="use-add_sal_to_sals-for-expressions.patch" Content-length: 1951 diff --git a/gdb/linespec.c b/gdb/linespec.c index 4156694..91cacb5 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -842,6 +842,8 @@ add_sal_to_sals (struct linespec_state *self, else canonical_name = xstrprintf ("%s:%d", filename, sal->line); } + else if (symname != NULL) + canonical_name = xstrdup (symname); self->canonical_names[sals->nelts - 1] = canonical_name; } @@ -1837,13 +1839,14 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls) if (ls->expression != NULL) { + struct symtab_and_line sal; + /* We have an expression. No other attribute is allowed. */ - sals.sals = XMALLOC (struct symtab_and_line); - sals.nelts = 1; - sals.sals[0] = find_pc_line (ls->expr_pc, 0); - sals.sals[0].pc = ls->expr_pc; - sals.sals[0].section = find_pc_overlay (ls->expr_pc); - sals.sals[0].explicit_pc = 1; + sal = find_pc_line (ls->expr_pc, 0); + sal.pc = ls->expr_pc; + sal.section = find_pc_overlay (ls->expr_pc); + sal.explicit_pc = 1; + add_sal_to_sals (state, &sals, &sal, ls->expression); } else if (ls->labels.label_symbols != NULL) { @@ -2284,19 +2287,15 @@ decode_line_full (char **argptr, int flags, gdb_assert (canonical->addr_string != NULL); canonical->pre_expanded = 1; - /* Fill in the missing canonical names. */ + /* Arrange for allocated canonical names to be freed. */ if (result.nelts > 0) { int i; - if (state->canonical_names == NULL) - state->canonical_names = xcalloc (result.nelts, sizeof (char *)); make_cleanup (xfree, state->canonical_names); for (i = 0; i < result.nelts; ++i) { - if (state->canonical_names[i] == NULL) - state->canonical_names[i] = savestring (arg_start, - *argptr - arg_start); + gdb_assert (state->canonical_names[i] != NULL); make_cleanup (xfree, state->canonical_names[i]); } } --------------050209040502000201060105--