This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix agent code generate bug of ref
On Mon, Mar 11, 2013 at 10:56 PM, Tom Tromey <tromey@redhat.com> 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 <yao@codesourcery.com>
Hui Zhu <hui_zhu@mentor.com>
* 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;