From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 323 invoked by alias); 12 Mar 2013 02:53:48 -0000 Received: (qmail 314 invoked by uid 22791); 12 Mar 2013 02:53:47 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-oa0-f53.google.com (HELO mail-oa0-f53.google.com) (209.85.219.53) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Mar 2013 02:53:37 +0000 Received: by mail-oa0-f53.google.com with SMTP id m1so5310041oag.12 for ; Mon, 11 Mar 2013 19:53:36 -0700 (PDT) X-Received: by 10.60.24.72 with SMTP id s8mr10869581oef.68.1363056816500; Mon, 11 Mar 2013 19:53:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.60.7 with HTTP; Mon, 11 Mar 2013 19:52:56 -0700 (PDT) In-Reply-To: <87k3penfy3.fsf@fleche.redhat.com> References: <513DDE2C.9080109@codesourcery.com> <87r4jmngr5.fsf@fleche.redhat.com> <87k3penfy3.fsf@fleche.redhat.com> From: Hui Zhu Date: Tue, 12 Mar 2013 02:53:00 -0000 Message-ID: Subject: Re: [PATCH] Fix agent code generate bug of ref To: Tom Tromey Cc: Yao Qi , gdb-patches ml , Joel Brobecker Content-Type: text/plain; charset=ISO-8859-1 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: 2013-03/txt/msg00499.txt.bz2 On Mon, Mar 11, 2013 at 10:56 PM, Tom Tromey wrote: > Tom> You are correct, but IMO it is simpler to divide each of the case > Tom> constants by 8. > > ... or perhaps use the existing utility function > dwarf2loc.c:access_memory, which also handles trace_kludge. > > Tom Hi Tom, Sorry for my misunderstand in your mail. Accord to discussion with Yao in IRC. I merge 2 patches together. And I found that gdb_assert of access_memory. It should use nbytes. Please help me review this patch. Thanks, Hui 2013-03-12 Yao Qi Hui Zhu * dwarf2loc.c (access_memory): Change nbits to nbytes in gdb_assert. (dwarf2_compile_expr_to_ax): Call access_memory in DW_OP_deref and DW_OP_deref_size. --- a/dwarf2loc.c +++ b/dwarf2loc.c @@ -2539,7 +2539,7 @@ access_memory (struct gdbarch *arch, str { ULONGEST nbytes = (nbits + 7) / 8; - gdb_assert (nbits > 0 && nbits <= sizeof (LONGEST)); + gdb_assert (nbytes > 0 && nbytes <= sizeof (LONGEST)); if (trace_kludge) ax_trace_quick (expr, nbytes); @@ -2933,26 +2933,7 @@ dwarf2_compile_expr_to_ax (struct agent_ else size = addr_size; - switch (size) - { - case 8: - ax_simple (expr, aop_ref8); - break; - case 16: - ax_simple (expr, aop_ref16); - break; - case 32: - ax_simple (expr, aop_ref32); - break; - case 64: - ax_simple (expr, aop_ref64); - break; - default: - /* Note that get_DW_OP_name will never return - NULL here. */ - error (_("Unsupported size %d in %s"), - size, get_DW_OP_name (op)); - } + access_memory (arch, expr, size * TARGET_CHAR_BIT); } break;