This is the mail archive of the gdb-patches@sources.redhat.com 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]

RFC: threads PREPARE_TO_PROCEED patch


This patch aims to avoid problems when using a native GNU/Linux debugger
(which supports threads) with a remote protocol stub that supports threads. 
lin_lwp_prepare_to_proceed gets called anyway, but it doesn't function,
because the trap_ptid is (unsurprisingly) not set; since it's internal
accounting for lin-lwp.  This patch makes us use generic_prepare_to_proceed
instead of the old default_prepare_to_proceed or lin_lwp_prepare_to_proceed;
it can get everything it needs from infrun.  If I recall correctly, it also,
as per the FIXME, supports switching threads better than the lin_lwp version
did.  But I haven't tested that in a long time.


This is a patch from last year, just before 5.3 was branched.  At the time
it was decided to be generally right, but too risky for 5.3.  Well, now I've
gone and sat on it for too long, and we're coming up on 5.4.  But I've been
using this patch since August without any problems.  Depending on consensus
I'd like to check it in either before or after we branch for release.

Thoughts, thread maintainers?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-03-13  Daniel Jacobowitz  <drow at mvista dot com>

	* arch-utils.c (default_prepare_to_proceed): Remove.
	* arch-utils.h (default_prepare_to_proceed): Remove prototype.
	* gdbarch.sh (PREPARE_TO_PROCEED): Change default to
	generic_prepare_to_proceed.
	* gdbarch.c: Regenerated.
	* gdbarch.h: Regenerated.
	* lin-lwp.c (lin_lwp_prepare_to_proceed): Remove.
	* config/nm-linux.h (PREPARE_TO_PROCEED): Don't define.
	(lin_lwp_prepare_to_proceed): Remove prototype.

Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.76
diff -u -p -r1.76 arch-utils.c
--- arch-utils.c	2 Mar 2003 10:23:09 -0000	1.76
+++ arch-utils.c	11 Mar 2003 14:34:22 -0000
@@ -313,13 +313,6 @@ no_op_reg_to_regnum (int reg)
   return reg;
 }
 
-/* Default prepare_to_procced().  */
-int
-default_prepare_to_proceed (int select_it)
-{
-  return 0;
-}
-
 /* Generic prepare_to_proceed().  This one should be suitable for most
    targets that support threads. */
 int
Index: arch-utils.h
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.h,v
retrieving revision 1.43
diff -u -p -r1.43 arch-utils.h
--- arch-utils.h	9 Dec 2002 02:04:16 -0000	1.43
+++ arch-utils.h	11 Mar 2003 14:34:22 -0000
@@ -111,8 +111,6 @@ extern int no_op_reg_to_regnum (int reg)
 
 /* Default prepare_to_procced. */
 
-extern int default_prepare_to_proceed (int select_it);
-
 extern int generic_prepare_to_proceed (int select_it);
 
 /* Versions of init_frame_pc().  Do nothing; do the default. */
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.188
diff -u -p -r1.188 gdbarch.c
--- gdbarch.c	10 Mar 2003 15:28:40 -0000	1.188
+++ gdbarch.c	11 Mar 2003 14:34:23 -0000
@@ -555,7 +555,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->prepare_to_proceed = default_prepare_to_proceed;
+  current_gdbarch->prepare_to_proceed = generic_prepare_to_proceed;
   current_gdbarch->function_start_offset = -1;
   current_gdbarch->remote_translate_xfer_address = generic_remote_translate_xfer_address;
   current_gdbarch->frame_args_skip = -1;
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.151
diff -u -p -r1.151 gdbarch.h
--- gdbarch.h	10 Mar 2003 15:28:41 -0000	1.151
+++ gdbarch.h	11 Mar 2003 14:34:23 -0000
@@ -2083,7 +2083,7 @@ extern void set_gdbarch_decr_pc_after_br
 
 /* 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))
+#define PREPARE_TO_PROCEED(select_it) (generic_prepare_to_proceed (select_it))
 #endif
 
 typedef int (gdbarch_prepare_to_proceed_ftype) (int select_it);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.203
diff -u -p -r1.203 gdbarch.sh
--- gdbarch.sh	10 Mar 2003 15:28:41 -0000	1.203
+++ gdbarch.sh	11 Mar 2003 14:34:24 -0000
@@ -582,7 +582,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
-f:2:PREPARE_TO_PROCEED:int:prepare_to_proceed:int select_it:select_it::0:default_prepare_to_proceed::0
+f:2:PREPARE_TO_PROCEED:int:prepare_to_proceed:int select_it:select_it::0:generic_prepare_to_proceed::0
 v:2:FUNCTION_START_OFFSET:CORE_ADDR:function_start_offset::::0:-1
 #
 f:2:REMOTE_TRANSLATE_XFER_ADDRESS:void:remote_translate_xfer_address:CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len:gdb_addr, gdb_len, rem_addr, rem_len:::generic_remote_translate_xfer_address::0
Index: lin-lwp.c
===================================================================
RCS file: /cvs/src/src/gdb/lin-lwp.c,v
retrieving revision 1.42
diff -u -p -r1.42 lin-lwp.c
--- lin-lwp.c	13 Jan 2003 21:47:35 -0000	1.42
+++ lin-lwp.c	11 Mar 2003 14:34:24 -0000
@@ -294,46 +294,6 @@ iterate_over_lwps (int (*callback) (stru
 }
 
 
-/* Implementation of the PREPARE_TO_PROCEED hook for the GNU/Linux LWP
-   layer.
-
-   Note that this implementation is potentially redundant now that
-   default_prepare_to_proceed() has been added.
-
-   FIXME This may not support switching threads after Ctrl-C
-   correctly. The default implementation does support this. */
-
-int
-lin_lwp_prepare_to_proceed (void)
-{
-  if (! ptid_equal (trap_ptid, null_ptid)
-      && ! ptid_equal (inferior_ptid, trap_ptid))
-    {
-      /* Switched over from TRAP_PID.  */
-      CORE_ADDR stop_pc = read_pc ();
-      CORE_ADDR trap_pc;
-
-      /* Avoid switching where it wouldn't do any good, i.e. if both
-         threads are at the same breakpoint.  */
-      trap_pc = read_pc_pid (trap_ptid);
-      if (trap_pc != stop_pc && breakpoint_here_p (trap_pc))
-	{
-	  /* User hasn't deleted the breakpoint.  Return non-zero, and
-             switch back to TRAP_PID.  */
-	  inferior_ptid = trap_ptid;
-
-	  /* FIXME: Is this stuff really necessary?  */
-	  flush_cached_frames ();
-	  registers_changed ();
-
-	  return 1;
-	}
-    }
-
-  return 0;
-}
-
-
 #if 0
 static void
 lin_lwp_open (char *args, int from_tty)
Index: config/nm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/nm-linux.h,v
retrieving revision 1.13
diff -u -p -r1.13 nm-linux.h
--- config/nm-linux.h	26 Nov 2002 01:23:46 -0000	1.13
+++ config/nm-linux.h	11 Mar 2003 14:34:24 -0000
@@ -49,9 +49,6 @@ struct target_waitstatus;
 extern ptid_t child_wait (ptid_t ptid, struct target_waitstatus *ourstatus);
 #define CHILD_WAIT
 
-extern int lin_lwp_prepare_to_proceed (void);
-#define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed ()
-
 extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose);
 #define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose))
 


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