Re: [RFA] Multi-arch DECR_PC_AFTER_HW_BREAKPOINT

David S. Miller
2002-04-22T09:45:32Z

From: "David S. Miller" <davem@redhat.com>
Date: Mon, 22 Apr 2002 02:31:27 -0700 (PDT)

2002-04-22 David S. Miller <davem@redhat.com>

* target.h (DECR_PC_AFTER_HW_BREAK): Delete definition.
* gdbarch.sh: Add DECR_PC_AFTER_HW_BREAK.
* gdbarch.c, gdbarch.h: Regenerate.

There was a typo that patch, this copy is OK.

2002-04-22 David S. Miller <davem@redhat.com>

* target.h (DECR_PC_AFTER_HW_BREAK): Delete definition.
* gdbarch.sh: Add DECR_PC_AFTER_HW_BREAK.
* gdbarch.c, gdbarch.h: Regenerate.

--- ./gdbarch.c.~1~ Mon Apr 22 02:12:35 2002
+++ ./gdbarch.c Mon Apr 22 02:40:41 2002
@@ -225,6 +225,7 @@ struct gdbarch
gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint;
gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint;
CORE_ADDR decr_pc_after_break;
+ CORE_ADDR decr_pc_after_hw_break;
gdbarch_prepare_to_proceed_ftype *prepare_to_proceed;
CORE_ADDR function_start_offset;
gdbarch_remote_translate_xfer_address_ftype *remote_translate_xfer_address;
@@ -399,6 +400,7 @@ struct gdbarch startup_gdbarch =
0,
0,
0,
+ 0,
generic_in_function_epilogue_p,
construct_inferior_arguments,
0,
@@ -506,6 +508,7 @@ gdbarch_alloc (const struct gdbarch_info
current_gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
current_gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
current_gdbarch->decr_pc_after_break = -1;
+ current_gdbarch->decr_pc_after_hw_break = -1;
current_gdbarch->prepare_to_proceed = default_prepare_to_proceed;
current_gdbarch->function_start_offset = -1;
current_gdbarch->remote_translate_xfer_address = generic_remote_translate_xfer_address;
@@ -722,6 +725,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
&& (gdbarch->decr_pc_after_break == -1))
fprintf_unfiltered (log, "\n\tdecr_pc_after_break");
+ if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
+ && (gdbarch->decr_pc_after_hw_break == -1))
+ fprintf_unfiltered (log, "\n\tdecr_pc_after_hw_break");
/* Skip verify of prepare_to_proceed, invalid_p == 0 */
if ((GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL)
&& (gdbarch->function_start_offset == -1))
@@ -1024,6 +1030,14 @@ gdbarch_dump (struct gdbarch *gdbarch, s
"gdbarch_dump: DECR_PC_AFTER_BREAK = %ld\n",
(long) DECR_PC_AFTER_BREAK);
#endif
+#ifdef DECR_PC_AFTER_HW_BREAK
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DECR_PC_AFTER_HW_BREAK # %s\n",
+ XSTRING (DECR_PC_AFTER_HW_BREAK));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: DECR_PC_AFTER_HW_BREAK = %ld\n",
+ (long) DECR_PC_AFTER_HW_BREAK);
+#endif
#ifdef DO_REGISTERS_INFO
#if GDB_MULTI_ARCH
/* Macro might contain `[{}]' when not multi-arch */
@@ -3936,6 +3950,24 @@ set_gdbarch_decr_pc_after_break (struct
CORE_ADDR decr_pc_after_break)
{
gdbarch->decr_pc_after_break = decr_pc_after_break;
+}
+
+CORE_ADDR
+gdbarch_decr_pc_after_hw_break (struct gdbarch *gdbarch)
+{
+ if (gdbarch->decr_pc_after_hw_break == -1)
+ internal_error (__FILE__, __LINE__,
+ "gdbarch: gdbarch_decr_pc_after_hw_break invalid");
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_decr_pc_after_hw_break called\n");
+ return gdbarch->decr_pc_after_hw_break;
+}
+
+void
+set_gdbarch_decr_pc_after_hw_break (struct gdbarch *gdbarch,
+ CORE_ADDR decr_pc_after_hw_break)
+{
+ gdbarch->decr_pc_after_hw_break = decr_pc_after_hw_break;
}

int
--- ./target.h.~1~ Thu Apr 18 11:09:06 2002
+++ ./target.h Mon Apr 22 02:32:14 2002
@@ -1091,13 +1091,6 @@ extern void (*target_new_objfile_hook) (
#define target_stopped_data_address() 0
#endif

-/* If defined, then we need to decr pc by this much after a hardware break-
- point. Presumably this overrides DECR_PC_AFTER_BREAK... */
-
-#ifndef DECR_PC_AFTER_HW_BREAK
-#define DECR_PC_AFTER_HW_BREAK 0
-#endif
-
/* Sometimes gdb may pick up what appears to be a valid target address
from a minimal symbol, but the value really means, essentially,
"This is an index into a table which is populated when the inferior
--- ./gdbarch.h.~1~ Mon Apr 22 02:11:55 2002
+++ ./gdbarch.h Mon Apr 22 02:40:00 2002
@@ -1762,6 +1762,17 @@ extern void set_gdbarch_decr_pc_after_br
#endif
#endif

+extern CORE_ADDR gdbarch_decr_pc_after_hw_break (struct gdbarch *gdbarch);
+extern void set_gdbarch_decr_pc_after_hw_break (struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_hw_break);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DECR_PC_AFTER_HW_BREAK)
+#error "Non multi-arch definition of DECR_PC_AFTER_HW_BREAK"
+#endif
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (DECR_PC_AFTER_HW_BREAK)
+#define DECR_PC_AFTER_HW_BREAK (gdbarch_decr_pc_after_hw_break (current_gdbarch))
+#endif
+#endif
+
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (PREPARE_TO_PROCEED)
#define PREPARE_TO_PROCEED(select_it) (default_prepare_to_proceed (select_it))
--- ./gdbarch.sh.~1~ Mon Apr 22 02:11:27 2002
+++ ./gdbarch.sh Mon Apr 22 02:39:35 2002
@@ -552,6 +552,7 @@ f:2:BREAKPOINT_FROM_PC:const unsigned ch
f:2:MEMORY_INSERT_BREAKPOINT:int:memory_insert_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_insert_breakpoint::0
f:2:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_remove_breakpoint::0
v:2:DECR_PC_AFTER_BREAK:CORE_ADDR:decr_pc_after_break::::0:-1
+v:2:DECR_PC_AFTER_HW_BREAK:CORE_ADDR:decr_pc_after_hw_break::::0:-1
f::PREPARE_TO_PROCEED:int:prepare_to_proceed:int select_it:select_it::0:default_prepare_to_proceed::0
v:2:FUNCTION_START_OFFSET:CORE_ADDR:function_start_offset::::0:-1
#