This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 11/14] export dwarf2_reg_to_regnum_or_error
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Fri, 16 May 2014 09:26:32 -0600
- Subject: [PATCH 11/14] export dwarf2_reg_to_regnum_or_error
- Authentication-results: sourceware.org; auth=none
- References: <1400253995-12333-1-git-send-email-tromey at redhat dot com>
From: Jan Kratochvil <jan.kratochvil@redhat.com>
This exports a utility function, dwarf2_reg_to_regnum_or_error, that
was previously private to dwarf2loc.c.
2014-05-16 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2loc.h (dwarf2_reg_to_regnum_or_error): Declare.
* dwarf2loc.c (dwarf2_reg_to_regnum_or_error): Rename from
translate_register. Now public.
(dwarf2_compile_expr_to_ax): Update.
---
gdb/ChangeLog | 7 +++++++
gdb/dwarf2loc.c | 18 +++++++-----------
gdb/dwarf2loc.h | 8 ++++++++
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index e6652c5..7bb4c48 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2733,14 +2733,10 @@ unimplemented (unsigned int op)
op);
}
-/* A helper function to convert a DWARF register to an arch register.
- ARCH is the architecture.
- DWARF_REG is the register.
- This will throw an exception if the DWARF register cannot be
- translated to an architecture register. */
+/* See dwarf2loc.h. */
-static int
-translate_register (struct gdbarch *arch, int dwarf_reg)
+int
+dwarf2_reg_to_regnum_or_error (struct gdbarch *arch, int dwarf_reg)
{
int reg = gdbarch_dwarf2_reg_to_regnum (arch, dwarf_reg);
if (reg == -1)
@@ -2991,14 +2987,14 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
case DW_OP_reg30:
case DW_OP_reg31:
dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx");
- loc->u.reg = translate_register (arch, op - DW_OP_reg0);
+ loc->u.reg = dwarf2_reg_to_regnum_or_error (arch, op - DW_OP_reg0);
loc->kind = axs_lvalue_register;
break;
case DW_OP_regx:
op_ptr = safe_read_uleb128 (op_ptr, op_end, ®);
dwarf_expr_require_composition (op_ptr, op_end, "DW_OP_regx");
- loc->u.reg = translate_register (arch, reg);
+ loc->u.reg = dwarf2_reg_to_regnum_or_error (arch, reg);
loc->kind = axs_lvalue_register;
break;
@@ -3061,7 +3057,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
case DW_OP_breg30:
case DW_OP_breg31:
op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
- i = translate_register (arch, op - DW_OP_breg0);
+ i = dwarf2_reg_to_regnum_or_error (arch, op - DW_OP_breg0);
ax_reg (expr, i);
if (offset != 0)
{
@@ -3073,7 +3069,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
{
op_ptr = safe_read_uleb128 (op_ptr, op_end, ®);
op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
- i = translate_register (arch, reg);
+ i = dwarf2_reg_to_regnum_or_error (arch, reg);
ax_reg (expr, i);
if (offset != 0)
{
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
index 341f64d..bc7dfb7 100644
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
@@ -219,4 +219,12 @@ extern struct call_site_chain *call_site_find_chain (struct gdbarch *gdbarch,
CORE_ADDR caller_pc,
CORE_ADDR callee_pc);
+/* A helper function to convert a DWARF register to an arch register.
+ ARCH is the architecture.
+ DWARF_REG is the register.
+ This will throw an exception if the DWARF register cannot be
+ translated to an architecture register. */
+
+extern int dwarf2_reg_to_regnum_or_error (struct gdbarch *arch, int dwarf_reg);
+
#endif /* dwarf2loc.h */
--
1.9.0