From patchwork Fri Jul 27 21:03:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Franco de Carvalho X-Patchwork-Id: 28663 Received: (qmail 117587 invoked by alias); 27 Jul 2018 21:03:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 117483 invoked by uid 89); 27 Jul 2018 21:03:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Better, ownership X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Jul 2018 21:03:46 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6RKsOXf131512 for ; Fri, 27 Jul 2018 17:03:45 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kg89hdppv-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 27 Jul 2018 17:03:44 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Jul 2018 15:03:44 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 27 Jul 2018 15:03:41 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6RL3d5b8847836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 27 Jul 2018 14:03:39 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCDBEC6055; Fri, 27 Jul 2018 15:03:38 -0600 (MDT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71DB2C6059; Fri, 27 Jul 2018 15:03:38 -0600 (MDT) Received: from pedro.localdomain (unknown [9.85.199.57]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 27 Jul 2018 15:03:38 -0600 (MDT) Received: by pedro.localdomain (Postfix, from userid 1000) id B8B273C0478; Fri, 27 Jul 2018 18:03:35 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Cc: uweigand@de.ibm.com Subject: [PATCH v2 4/6] Use remote register numbers in tracepoint mask Date: Fri, 27 Jul 2018 18:03:16 -0300 In-Reply-To: <20180727210318.2960-1-pedromfc@linux.ibm.com> References: <20180727210318.2960-1-pedromfc@linux.ibm.com> x-cbid: 18072721-0036-0000-0000-00000A15DC94 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009440; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01067028; UDB=6.00548259; IPR=6.00844894; MB=3.00022359; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-27 21:03:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072721-0037-0000-0000-0000484106DA Message-Id: <20180727210318.2960-5-pedromfc@linux.ibm.com> Currently, tracepoint register masks in the QTDP packets include both internal and remote register numbers, as well as pseudo-register numbers. This patch changes this so that the mask only includes remote register numbers. Register numbers from agent expressions are already set in the mask using remote numbers. Other tracepoint actions used internal numbers, e.g. "collect $regs" or "collect $". To handle pseudoreg numbers, an empty agent expression is created and ax_reg_mask is called for this expression and the pseudoreg. This will cause the ax to set its mask with the corresponding remote raw register numbers (using gdbarch_ax_pseudo_register_collect). This assumes that all gdbarch_ax_pseudo_register_collect implementations only use ax_reg_mask themselves to set the mask, and don't generate more complicated agent expressions to collect pseudoregs. This seems to be the case, and seems to be the intended use of gdbarch_ax_pseudo_register_collect, despite the gdbarch.h comment for this function. gdb/ChangeLog: YYYY-MM-DD Pedro Franco de Carvalho * tracepoint.h (class collection_list) : Remove. : Declare. : Add scope parameter. * tracepoint.c (collection_list::add_register): Rename to ... (collection_list::add_remote_register): ... this. Update comment. (collection_list::add_ax_registers, add_local_register): New methods. (collection_list::add_memrange): Add scope parameter. Call add_local_register instead of add_register. (collection_list::collect_symbol): Update calls to add_memrange. Call add_local_register instead of add_register. (collection_list::collect_symbol): Call add_ax_registers. (encode_actions_1): Get remote regnos for $reg action. Call add_remote_register, add_ax_registers, and add_local_register. Update call to add_memrange. --- gdb/tracepoint.c | 142 +++++++++++++++++++++++++++++++------------------------ gdb/tracepoint.h | 8 +++- 2 files changed, 85 insertions(+), 65 deletions(-) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 74d1183386..f06386158a 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -811,10 +811,10 @@ memrange_sortmerge (std::vector &memranges) } } -/* Add a register to a collection list. */ +/* Add remote register number REGNO to the collection list mask. */ void -collection_list::add_register (unsigned int regno) +collection_list::add_remote_register (unsigned int regno) { if (info_verbose) printf_filtered ("collect register %d\n", regno); @@ -824,12 +824,62 @@ collection_list::add_register (unsigned int regno) m_regs_mask[regno / 8] |= 1 << (regno % 8); } +/* Add all the registers from the mask in AEXPR to the mask in the + collection list. Registers in the AEXPR mask are already remote + register numbers. */ + +void +collection_list::add_ax_registers (struct agent_expr *aexpr) +{ + if (aexpr->reg_mask_len > 0) + { + for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) + { + QUIT; /* Allow user to bail out with ^C. */ + if (aexpr->reg_mask[ndx1] != 0) + { + /* Assume chars have 8 bits. */ + for (int ndx2 = 0; ndx2 < 8; ndx2++) + if (aexpr->reg_mask[ndx1] & (1 << ndx2)) + /* It's used -- record it. */ + add_remote_register (ndx1 * 8 + ndx2); + } + } + } +} + +/* If REGNO is raw, add its corresponding remote register number to + the mask. If REGNO is a pseudo-register, figure out the necessary + registers using a temporary agent expression. */ + +void +collection_list::add_local_register (struct gdbarch *gdbarch, + unsigned int regno, + CORE_ADDR scope) +{ + if (regno < gdbarch_num_regs (gdbarch)) + { + int remote_regno = gdbarch_remote_register_number (gdbarch, regno); + + if (remote_regno < 0) + error (_("Can't collect register %d"), regno); + + add_remote_register (remote_regno); + } + else + { + struct agent_expr aexpr (gdbarch, scope); + ax_reg_mask (&aexpr, regno); + add_ax_registers (&aexpr); + } +} + /* Add a memrange to a collection list. */ void collection_list::add_memrange (struct gdbarch *gdbarch, int type, bfd_signed_vma base, - unsigned long len) + unsigned long len, CORE_ADDR scope) { if (info_verbose) printf_filtered ("(%d,%s,%ld)\n", type, paddress (gdbarch, base), len); @@ -840,7 +890,7 @@ collection_list::add_memrange (struct gdbarch *gdbarch, m_memranges.emplace_back (type, base, base + len); if (type != memrange_absolute) /* Better collect the base register! */ - add_register (type); + add_local_register (gdbarch, type, scope); } /* Add a symbol to a collection list. */ @@ -882,19 +932,19 @@ collection_list::collect_symbol (struct symbol *sym, if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT) treat_as_expr = 1; else - add_memrange (gdbarch, memrange_absolute, offset, len); + add_memrange (gdbarch, memrange_absolute, offset, len, scope); break; case LOC_REGISTER: reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch); if (info_verbose) printf_filtered ("LOC_REG[parm] %s: ", SYMBOL_PRINT_NAME (sym)); - add_register (reg); + add_local_register (gdbarch, reg, scope); /* Check for doubles stored in two registers. */ /* FIXME: how about larger types stored in 3 or more regs? */ if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FLT && len > register_size (gdbarch, reg)) - add_register (reg + 1); + add_local_register (gdbarch, reg + 1, scope); break; case LOC_REF_ARG: printf_filtered ("Sorry, don't know how to do LOC_REF_ARG yet.\n"); @@ -911,7 +961,7 @@ collection_list::collect_symbol (struct symbol *sym, SYMBOL_PRINT_NAME (sym), len, paddress (gdbarch, offset), reg); } - add_memrange (gdbarch, reg, offset, len); + add_memrange (gdbarch, reg, offset, len, scope); break; case LOC_REGPARM_ADDR: reg = SYMBOL_VALUE (sym); @@ -923,7 +973,7 @@ collection_list::collect_symbol (struct symbol *sym, SYMBOL_PRINT_NAME (sym), len, paddress (gdbarch, offset), reg); } - add_memrange (gdbarch, reg, offset, len); + add_memrange (gdbarch, reg, offset, len, scope); break; case LOC_LOCAL: reg = frame_regno; @@ -935,7 +985,7 @@ collection_list::collect_symbol (struct symbol *sym, SYMBOL_PRINT_NAME (sym), len, paddress (gdbarch, offset), reg); } - add_memrange (gdbarch, reg, offset, len); + add_memrange (gdbarch, reg, offset, len, scope); break; case LOC_UNRESOLVED: @@ -973,21 +1023,7 @@ collection_list::collect_symbol (struct symbol *sym, report_agent_reqs_errors (aexpr.get ()); /* Take care of the registers. */ - if (aexpr->reg_mask_len > 0) - { - for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) - { - QUIT; /* Allow user to bail out with ^C. */ - if (aexpr->reg_mask[ndx1] != 0) - { - /* Assume chars have 8 bits. */ - for (int ndx2 = 0; ndx2 < 8; ndx2++) - if (aexpr->reg_mask[ndx1] & (1 << ndx2)) - /* It's used -- record it. */ - add_register (ndx1 * 8 + ndx2); - } - } - } + add_ax_registers (aexpr.get ()); add_aexpr (std::move (aexpr)); } @@ -1257,8 +1293,18 @@ encode_actions_1 (struct command_line *action, if (0 == strncasecmp ("$reg", action_exp, 4)) { - for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); i++) - collect->add_register (i); + for (i = 0; i < gdbarch_num_regs (target_gdbarch ()); + i++) + { + int remote_regno = (gdbarch_remote_register_number + (target_gdbarch (), i)); + + /* Ignore arch regnos without a corresponding + remote regno. This can happen for regnos not + in the tdesc. */ + if (remote_regno >= 0) + collect->add_remote_register (remote_regno); + } action_exp = strchr (action_exp, ','); /* more? */ } else if (0 == strncasecmp ("$arg", action_exp, 4)) @@ -1292,23 +1338,7 @@ encode_actions_1 (struct command_line *action, report_agent_reqs_errors (aexpr.get ()); /* take care of the registers */ - if (aexpr->reg_mask_len > 0) - { - for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) - { - QUIT; /* allow user to bail out with ^C */ - if (aexpr->reg_mask[ndx1] != 0) - { - /* assume chars have 8 bits */ - for (int ndx2 = 0; ndx2 < 8; ndx2++) - if (aexpr->reg_mask[ndx1] & (1 << ndx2)) - { - /* It's used -- record it. */ - collect->add_register (ndx1 * 8 + ndx2); - } - } - } - } + collect->add_ax_registers (aexpr.get ()); collect->add_aexpr (std::move (aexpr)); action_exp = strchr (action_exp, ','); /* more? */ @@ -1340,7 +1370,8 @@ encode_actions_1 (struct command_line *action, name); if (info_verbose) printf_filtered ("OP_REGISTER: "); - collect->add_register (i); + collect->add_local_register (target_gdbarch (), + i, tloc->address); break; } @@ -1352,7 +1383,8 @@ encode_actions_1 (struct command_line *action, check_typedef (exp->elts[1].type); collect->add_memrange (target_gdbarch (), memrange_absolute, addr, - TYPE_LENGTH (exp->elts[1].type)); + TYPE_LENGTH (exp->elts[1].type), + tloc->address); collect->append_exp (exp.get ()); break; @@ -1381,23 +1413,7 @@ encode_actions_1 (struct command_line *action, report_agent_reqs_errors (aexpr.get ()); /* Take care of the registers. */ - if (aexpr->reg_mask_len > 0) - { - for (int ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++) - { - QUIT; /* Allow user to bail out with ^C. */ - if (aexpr->reg_mask[ndx1] != 0) - { - /* Assume chars have 8 bits. */ - for (int ndx2 = 0; ndx2 < 8; ndx2++) - if (aexpr->reg_mask[ndx1] & (1 << ndx2)) - { - /* It's used -- record it. */ - collect->add_register (ndx1 * 8 + ndx2); - } - } - } - } + collect->add_ax_registers (aexpr.get ()); collect->add_aexpr (std::move (aexpr)); collect->append_exp (exp.get ()); diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h index 42e413018a..8bdad3567e 100644 --- a/gdb/tracepoint.h +++ b/gdb/tracepoint.h @@ -262,10 +262,14 @@ public: /* Add AEXPR to the list, taking ownership. */ void add_aexpr (agent_expr_up aexpr); - void add_register (unsigned int regno); + void add_remote_register (unsigned int regno); + void add_ax_registers (struct agent_expr *aexpr); + void add_local_register (struct gdbarch *gdbarch, + unsigned int regno, + CORE_ADDR scope); void add_memrange (struct gdbarch *gdbarch, int type, bfd_signed_vma base, - unsigned long len); + unsigned long len, CORE_ADDR scope); void collect_symbol (struct symbol *sym, struct gdbarch *gdbarch, long frame_regno, long frame_offset,