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]

[RFA/RFC] Add i386_cleanup_dregs at program exit.



   A rather long thread started by my
description of a failure to catch hardware watchpoints
on the second run of a linux i386 executable when debugging with 5.1 version.

See
http://sources.redhat.com/ml/gdb-patches/2001-11/msg00613.html
that contains a description of how to reproduce this bug.

The following patch does fix the problem and 
has the further advantage of being multi-target,
so it might well fix the same bug on FreeBSD for example 
(I didn't test if this bug is also present in FreeBSD).
But it isn't multi-arch yet.

The patch simply calls i386_cleanup_dregs
in breakpoint_init_inferior if context is inf_exited.

I have no idea if other processor might need a similar 
cleanup of debug registers, but if there are,
simply setting the HARDWARE_REGISTER_CLEANUP
macro should be enough.

Andrew, how can this be multi-arched ??
Should I add something like 
#ifndef HARDWARE_REGISTER_CLEANUP_P
#define HARDWARE_REGISTER_CLEANUP_P 0
#endif 
#ifndef HARDWARE_REGISTER_CLEANUP
#define HARDWARE_REGISTER_CLEANUP {}
#endif 
and replace the patch in breakpoint.c by
  if (HARDWARE_REGISTER_CLEANUP_P
      && (context == inf_exited))
       HARDWARE_REGISTER_CLEANUP; 

This removes the #ifdef
but full multi-arch probably will require 
to add two new fields to the gdbarch vector ?


  
2002-01-09  Pierre Muller <muller@ics.u-strasbg.fr>

	* breakpoint.c (breakpoint_init_inferior): Call
	HARDWARE_REGISTER_CLEANUP macro if defined
	if context is inf_exited.
	* config/i386/nm-i386.h: Define HARDWARE_REGISTER_CLEANUP
	macro to call i386_cleanup_dregs().

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.57
diff -u -r1.57 breakpoint.c
--- breakpoint.c        2001/11/11 16:39:59     1.57
+++ breakpoint.c        2002/01/08 23:44:00
@@ -1487,6 +1487,10 @@
        warning ("You must reinsert them explicitly.");
        warning_needed = 0;
      }
+#ifdef HARDWARE_REGISTER_CLEANUP
+  if (context == inf_exited)
+     HARDWARE_REGISTER_CLEANUP;
+#endif
  }

  /* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
Index: config/i386/nm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386.h,v
retrieving revision 1.2
diff -u -r1.2 nm-i386.h
--- nm-i386.h   2001/03/23 16:17:45     1.2
+++ nm-i386.h   2002/01/08 23:44:01
@@ -115,6 +115,8 @@

  #define DECR_PC_AFTER_HW_BREAK 0

+#define HARDWARE_REGISTER_CLEANUP i386_cleanup_dregs ()
+
  #endif /* I386_USE_GENERIC_WATCHPOINTS */

  #endif /* NM_I386_H */




Pierre Muller
Institut Charles Sadron
6,rue Boussingault
F 67083 STRASBOURG CEDEX (France)
mailto:muller@ics.u-strasbg.fr
Phone : (33)-3-88-41-40-07  Fax : (33)-3-88-41-40-99


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