From: Pierre Muller <muller@cerbere.u-strasbg.fr>
To: gdb-patches@sources.redhat.com
Cc: djbarrow@de.ibm.com
Subject: [RFA/RFC 2] Remove hardware break and watchpoints at program exit.
Date: Fri, 11 Jan 2002 04:01:00 -0000 [thread overview]
Message-ID: <4.2.0.58.20020111125745.0135ea48@ics.u-strasbg.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 2491 bytes --]
At 10:20 09/01/2002 , vous avez écrit:
>On Wed, 9 Jan 2002, Pierre Muller wrote:
>
> > The patch simply calls i386_cleanup_dregs
> > in breakpoint_init_inferior if context is inf_exited.
I finally change completely my patch to
another (more correct, in my opinion) strategy.
In breakpoint_init_inferior
I added code that conditionally removes hardware watch and breakpoint
if the context is inf_exited, i.e. at exit of the debugged program.
This leads to a much cleaner removal of the watchpoints.
I still kept the call to a generic hardware removal function
and testing the i386 case, I could see that even though the dr_mirror
array is zeored out, the dr_control_mirror and
dr_status_mirror still aren't set to zero.
For dr_control_register, this is due to an error in the I386_DR_DISABLE
because that macro only resets the active bit, but not the size and type bits
associated to that debug register.
I suspect that before this patch,
the hardware watchpoint code that was in s390-nat.c
didn't reset the area_base to nil when a program was exited.
Could DJ Barrow please test this and see if the patch below does
fix this.
(I can't test this as I ave no acces to s390 machine,
but it appears to me that this might cause certain
watchpoints to still show up after removal, if
the debuggee was run several times).
After the patch, probably no HARDWARE_REGISTER_RESET
function is needed anymore, but I didn't inspect the code entirely.
I have a little doubt about the default value of the
HARDWARE_REGISTER_RESET macro.
What should be used as a no-op default ?
2002-01-09 Pierre Muller <muller@ics.u-strasbg.fr>
* breakpoint.c (REMOVE_HARDWARE_BREAKPOINT_AT_EXIT):
Define to 0 if not defined.
(REMOVE_HARDWARE_WATCHPOINT_AT_EXIT):
Define to 0 if not defined.
(HARDWARE_REGISTER_RESET): Default to no-op.
(breakpoint_init_inferior): Use REMOVE_HARDWARE_BREAKPOINT_AT_EXIT
and REMOVE_HARDWARE_WATCHPOINT_AT_EXIT to conditionally
remove hardware break and watchpoints at exit.
Call HARDWARE_REGISTER_RESET macro if defined at exit.
* config/i386/nm-i386.h: Define HARDWARE_REGISTER_RESET
macro to call i386_cleanup_dregs().
Set REMOVE_HARDWARE_BREAKPOINT_AT_EXIT to 1.
Set REMOVE_HARDWARE_WATCHPOINT_AT_EXIT to 1.
* go32-nat.c (go32_mourn_inferior): Remove call to i386_cleanup_dregs
as this is done in breakpoint_init_inferior().
[-- Attachment #2: dregs.diffs --]
[-- Type: text/plain, Size: 2794 bytes --]
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.57
diff -u -p -r1.57 breakpoint.c
--- breakpoint.c 2001/11/11 16:39:59 1.57
+++ breakpoint.c 2002/01/11 11:34:08
@@ -234,6 +234,19 @@ static int executing_breakpoint_commands
B ? (TMP=B->next, 1): 0; \
B = TMP)
+#ifndef REMOVE_HARDWARE_BREAKPOINT_AT_EXIT
+#define REMOVE_HARDWARE_BREAKPOINT_AT_EXIT 0
+#endif
+
+#ifndef REMOVE_HARDWARE_WATCHPOINT_AT_EXIT
+#define REMOVE_HARDWARE_WATCHPOINT_AT_EXIT 0
+#endif
+
+
+#ifndef HARDWARE_REGISTERS_RESET
+#define HARDWARE_REGISTERS_RESET {}
+#endif
+
/* True if SHIFT_INST_REGS defined, false otherwise. */
int must_shift_inst_regs =
@@ -1440,7 +1453,17 @@ breakpoint_init_inferior (enum inf_conte
ALL_BREAKPOINTS_SAFE (b, temp)
{
- b->inserted = 0;
+ if ((((REMOVE_HARDWARE_BREAKPOINT_AT_EXIT)
+ && b->type == bp_hardware_breakpoint)
+ ||((REMOVE_HARDWARE_WATCHPOINT_AT_EXIT)
+ && (b->type == bp_hardware_watchpoint
+ || b->type == bp_access_watchpoint
+ || b->type == bp_read_watchpoint)))
+ && b->inserted
+ && context == inf_exited)
+ remove_breakpoint (b, mark_uninserted);
+
+ b->inserted = 0;
switch (b->type)
{
@@ -1487,6 +1510,8 @@ breakpoint_init_inferior (enum inf_conte
warning ("You must reinsert them explicitly.");
warning_needed = 0;
}
+ if (context == inf_exited)
+ HARDWARE_REGISTER_RESET;
}
/* breakpoint_here_p (PC) returns non-zero if an enabled breakpoint
Index: go32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/go32-nat.c,v
retrieving revision 1.26
diff -u -p -r1.26 go32-nat.c
--- go32-nat.c 2001/12/06 08:15:37 1.26
+++ go32-nat.c 2002/01/11 11:34:08
@@ -670,7 +670,7 @@ go32_mourn_inferior (void)
be nice if GDB itself would take care to remove all breakpoints
at all times, but it doesn't, probably under an assumption that
the OS cleans up when the debuggee exits. */
- i386_cleanup_dregs ();
+ // i386_cleanup_dregs ();
go32_kill_inferior ();
generic_mourn_inferior ();
}
Index: config/i386/nm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386.h,v
retrieving revision 1.2
diff -u -p -r1.2 nm-i386.h
--- nm-i386.h 2001/03/23 16:17:45 1.2
+++ nm-i386.h 2002/01/11 11:34:08
@@ -115,6 +115,12 @@ extern int i386_remove_hw_breakpoint (C
#define DECR_PC_AFTER_HW_BREAK 0
+#define REMOVE_HARDWARE_WATCHPOINT_AT_EXIT 1
+
+#define REMOVE_HARDWARE_BREAKPOINT_AT_EXIT 1
+
+#define HARDWARE_REGISTERS_RESET i386_cleanup_dregs ()
+
#endif /* I386_USE_GENERIC_WATCHPOINTS */
#endif /* NM_I386_H */
[-- Attachment #3: Type: text/plain, Size: 176 bytes --]
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
next reply other threads:[~2002-01-11 12:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-11 4:01 Pierre Muller [this message]
2002-01-11 4:38 ` Eli Zaretskii
2002-01-11 4:57 ` Pierre Muller
2002-01-11 5:58 ` Eli Zaretskii
2002-01-11 5:39 ` Pierre Muller
2002-01-11 6:06 ` Eli Zaretskii
2002-01-11 8:15 ` Pierre Muller
2002-01-11 9:20 ` [RFA/RFC 3] " Pierre Muller
2002-01-12 5:20 ` Mark Kettenis
2002-01-12 13:16 ` muller
2002-01-13 0:31 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4.2.0.58.20020111125745.0135ea48@ics.u-strasbg.fr \
--to=muller@cerbere.u-strasbg.fr \
--cc=djbarrow@de.ibm.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox