This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] arc: Add evaluation of long jump targets


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aaf43c4882f827d9f778b40dcdb93566f765f5f9

commit aaf43c4882f827d9f778b40dcdb93566f765f5f9
Author: Anton Kolesov <Anton.Kolesov@synopsys.com>
Date:   Wed Oct 12 14:36:44 2016 +0300

    arc: Add evaluation of long jump targets
    
    Standard get_longjmp_target implementation, similar to what is in arm-tdep.c.
    Actual value of jb_pc should be set in init_osabi methods of particular OS/ABI
    implementations.
    
    gdb/ChangeLog:
    
    	* arc-tdep.h (struct gdbarch_tdep) <jb_pc>: New field.
    	* arc-tdep.c (arc_get_longjmp_target): New function.
    	(arc_gdbarch_init): Set get_longjmp_target if jb_pc is non-negative.
    	(arc_dump_tdep): Print jb_pc.

Diff:
---
 gdb/ChangeLog  |  7 +++++++
 gdb/arc-tdep.c | 30 +++++++++++++++++++++++++++++-
 gdb/arc-tdep.h |  3 +++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 29544c9..b346137 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2016-10-12  Anton Kolesov  <anton.kolesov@synopsys.com>
 
+	* arc-tdep.h (struct gdbarch_tdep) <jb_pc>: New field.
+	* arc-tdep.c (arc_get_longjmp_target): New function.
+	(arc_gdbarch_init): Set get_longjmp_target if jb_pc is non-negative.
+	(arc_dump_tdep): Print jb_pc.
+
+2016-10-12  Anton Kolesov  <anton.kolesov@synopsys.com>
+
 	* arc-tdep.h (struct gdbarch_tdep): New.
 	* arc-tdep.c (arc_gdbarch_init): Allocate gdbarch_tdep.
 
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 58de8e9..c848dc2 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -557,6 +557,28 @@ arc_store_return_value (struct gdbarch *gdbarch, struct type *type,
     error (_("arc_store_return_value: type length too large."));
 }
 
+/* Implement the "get_longjmp_target" gdbarch method.  */
+
+static int
+arc_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
+{
+  if (arc_debug)
+    debug_printf ("arc: get_longjmp_target\n");
+
+  struct gdbarch *gdbarch = get_frame_arch (frame);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  int pc_offset = tdep->jb_pc * ARC_REGISTER_SIZE;
+  gdb_byte buf[ARC_REGISTER_SIZE];
+  CORE_ADDR jb_addr = get_frame_register_unsigned (frame, ARC_FIRST_ARG_REGNUM);
+
+  if (target_read_memory (jb_addr + pc_offset, buf, ARC_REGISTER_SIZE))
+    return 0; /* Failed to read from memory.  */
+
+  *pc = extract_unsigned_integer (buf, ARC_REGISTER_SIZE,
+				  gdbarch_byte_order (gdbarch));
+  return 1;
+}
+
 /* Implement the "return_value" gdbarch method.  */
 
 static enum return_value_convention
@@ -1162,6 +1184,7 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Allocate the ARC-private target-dependent information structure, and the
      GDB target-independent information structure.  */
   struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep);
+  tdep->jb_pc = -1; /* No longjmp support by default.  */
   struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
 
   /* Data types.  */
@@ -1246,6 +1269,9 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      It can override functions set earlier.  */
   gdbarch_init_osabi (info, gdbarch);
 
+  if (tdep->jb_pc >= 0)
+    set_gdbarch_get_longjmp_target (gdbarch, arc_get_longjmp_target);
+
   tdesc_use_registers (gdbarch, tdesc, tdesc_data);
 
   return gdbarch;
@@ -1256,7 +1282,9 @@ arc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 static void
 arc_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
 {
-  /* Empty for now.  */
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+  fprintf_unfiltered (file, "arc_dump_tdep: jb_pc = %i\n", tdep->jb_pc);
 }
 
 /* Suppress warning from -Wmissing-prototypes.  */
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index ea34b9e..1e792b9 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -81,6 +81,9 @@ extern int arc_debug;
 
 struct gdbarch_tdep
 {
+  /* Offset to PC value in jump buffer.  If this is negative, longjmp
+     support will be disabled.  */
+  int jb_pc;
 };
 
 /* Utility functions used by other ARC-specific modules.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]