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]

[RFA/C] Inferior stop events


Hi,

It appears that no one thought my proposed approach to inferior stop event
notification was completely absurd, so let's now get into some
implementation details...

The following patch moves "enum inferior_stop_reason" from inrun.c to
gdb-events.sh, which will put it into gdb-events.h. This reflects the real
usage of the enumeration, which is for event notifications.

I've scattered a few event notifications into infrun.c, most around all
calls to "print_stop_reason". I have been running this under Insight now
for about a week, and for simple step, next, si, ni, continue, finish,
breakpoints (permanent and temporary), it works well.

It seems that we want to put inferior event notifications everywhere
stop_stepping is called (is this correct?). With this patch, there are
five places where stop_stepping is called and inferior_stop_event is not. I
don't know what many of these places do. I know that one is for shared
library event notifications, another is used by call dummies (and maybe
more?). I have not included these five places just yet. I'll get to them
as I sort out some of the mess I've made. This is just the first step.

So, are there any comments now? :-)
Keith

ChangeLog
2001-06-14  Keith Seitz  <keiths@redhat.com>

        * Makefile.in (infrun.o): Add dependency for gdb-events.h.
        * gdb-events.sh: Add inferior_stop event.
        (enum inferior_stop_reason): Moved from infrun.c here.
        * gdb-events.c: Regenerated.
        * gdb-events.h: Regenerated.
        * infrun.c (enum inferior_stop_reason): Moved to gdb-event.h.
        (handle_inferior_event): Add inferior_stop event notifications.
        (step_into_function): Ditto.

Patch
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.90
diff -u -p -r1.90 Makefile.in
--- Makefile.in	2001/06/10 00:47:02	1.90
+++ Makefile.in	2001/06/14 18:21:24
@@ -1580,7 +1580,7 @@ infptrace.o: infptrace.c $(defs_h) $(gdb

 infrun.o: infrun.c gdb_wait.h $(defs_h) $(gdbcmd_h) $(gdbcore_h) \
 	$(inferior_h) target.h gdbthread.h $(gdb_string_h) $(event_loop_h) \
-	$(event_top_h) $(regcache_h)
+	$(event_top_h) $(regcache_h) gdb-events.h

 inftarg.o: inftarg.c gdb_wait.h $(defs_h) $(gdbcore_h) $(inferior_h) \
 	target.h terminal.h $(command_h)
Index: gdb-events.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdb-events.sh,v
retrieving revision 1.9
diff -u -p -r1.9 gdb-events.sh
--- gdb-events.sh	2001/06/07 20:18:45	1.9
+++ gdb-events.sh	2001/06/14 18:21:24
@@ -64,6 +64,7 @@ f:void:breakpoint_modify:int b:b
 f:void:tracepoint_create:int number:number
 f:void:tracepoint_delete:int number:number
 f:void:tracepoint_modify:int number:number
+f:void:inferior_stop:enum inferior_stop_reason stop_reason, int stop_info:stop_reason, stop_info
 #*:void:annotate_starting_hook:void
 #*:void:annotate_stopped_hook:void
 #*:void:annotate_signalled_hook:void
@@ -163,6 +164,34 @@ cat <<EOF
 #ifndef WITH_GDB_EVENTS
 #define WITH_GDB_EVENTS 1
 #endif
+
+/* Why did the inferior stop?
+   All inferior_stop event notifications have two bits of data:
+   a reason (given by this enumeration), and integer information. */
+
+enum inferior_stop_reason
+{
+  /* We don't know why. Info is undefined. */
+  STOP_UNKNOWN,
+
+  /* Step, next, nexti, stepi finished. Info is undefined. */
+  END_STEPPING_RANGE,
+
+  /* Hit a breakpoint. Info is the breakpoint that was hit, or -1 if
+     an internal BP was hit (probably from doing a "finish"). */
+  BREAKPOINT_HIT,
+
+  /* Inferior terminated by signal. Info is the signal number. */
+  SIGNAL_EXITED,
+
+  /* Inferior exited. Info is the exit status. */
+  EXITED,
+
+  /* Inferior received signal, and user asked to be notified.
+     Info is the signal number. */
+  SIGNAL_RECEIVED
+};
+
 EOF

 # pointer declarations
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.36
diff -u -p -r1.36 infrun.c
--- infrun.c	2001/06/13 22:56:16	1.36
+++ infrun.c	2001/06/14 18:21:25
@@ -37,6 +37,7 @@
 #include <signal.h>
 #include "inf-loop.h"
 #include "regcache.h"
+#include "gdb-events.h"

 /* Prototypes for local functions */

@@ -1202,24 +1203,6 @@ enum infwait_states
   infwait_nonstep_watch_state
 };

-/* Why did the inferior stop? Used to print the appropriate messages
-   to the interface from within handle_inferior_event(). */
-enum inferior_stop_reason
-{
-  /* We don't know why. */
-  STOP_UNKNOWN,
-  /* Step, next, nexti, stepi finished. */
-  END_STEPPING_RANGE,
-  /* Found breakpoint. */
-  BREAKPOINT_HIT,
-  /* Inferior terminated by signal. */
-  SIGNAL_EXITED,
-  /* Inferior exited. */
-  EXITED,
-  /* Inferior received signal, and user asked to be notified. */
-  SIGNAL_RECEIVED
-};
-
 /* This structure contains what used to be local variables in
    wait_for_inferior.  Probably many of them can return to being
    locals in handle_inferior_event.  */
@@ -1589,6 +1572,7 @@ handle_inferior_event (struct execution_
       case TARGET_WAITKIND_EXITED:
 	target_terminal_ours ();	/* Must do this before mourn anyway */
 	print_stop_reason (EXITED, ecs->ws.value.integer);
+	inferior_stop_event (EXITED, ecs->ws.value.integer);

 	/* Record the exit code in the convenience variable $_exitcode, so
 	   that the user can inspect this again later.  */
@@ -1615,6 +1599,7 @@ handle_inferior_event (struct execution_
 	target_mourn_inferior ();

 	print_stop_reason (SIGNAL_EXITED, stop_signal);
+	inferior_stop_event (SIGNAL_EXITED, stop_signal);
 	singlestep_breakpoints_inserted_p = 0;	/*SOFTWARE_SINGLE_STEP_P() */
 	stop_stepping (ecs);
 	return;
@@ -2283,6 +2268,7 @@ handle_inferior_event (struct execution_
 	  }
 	if (signal_stop[stop_signal])
 	  {
+	    inferior_stop_event (SIGNAL_RECEIVED, stop_signal);
 	    stop_stepping (ecs);
 	    return;
 	  }
@@ -2428,6 +2414,11 @@ handle_inferior_event (struct execution_
 	     through_sigtramp_breakpoint via the cleanup chain, so
 	     no need to worry about it here.  */

+	  inferior_stop_event (BREAKPOINT_HIT,
+			       ((stop_bpstat != NULL
+				 && stop_bpstat->breakpoint_at != NULL)
+				? stop_bpstat->breakpoint_at->number : -1));
+
 	  stop_stepping (ecs);
 	  return;

@@ -2792,6 +2783,7 @@ handle_inferior_event (struct execution_
 	       ("stepi").  Just stop.  */
 	    stop_step = 1;
 	    print_stop_reason (END_STEPPING_RANGE, 0);
+	    inferior_stop_event (END_STEPPING_RANGE, 0);
 	    stop_stepping (ecs);
 	    return;
 	  }
@@ -2870,6 +2862,7 @@ handle_inferior_event (struct execution_
 	  {
 	    stop_step = 1;
 	    print_stop_reason (END_STEPPING_RANGE, 0);
+	    inferior_stop_event (END_STEPPING_RANGE, 0);
 	    stop_stepping (ecs);
 	    return;
 	  }
@@ -2890,6 +2883,7 @@ handle_inferior_event (struct execution_
 	   one instruction.  */
 	stop_step = 1;
 	print_stop_reason (END_STEPPING_RANGE, 0);
+	inferior_stop_event (END_STEPPING_RANGE, 0);
 	stop_stepping (ecs);
 	return;
       }
@@ -2936,6 +2930,7 @@ handle_inferior_event (struct execution_
 	   or can this happen as a result of a return or longjmp?).  */
 	stop_step = 1;
 	print_stop_reason (END_STEPPING_RANGE, 0);
+	inferior_stop_event (END_STEPPING_RANGE, 0);
 	stop_stepping (ecs);
 	return;
       }
@@ -2949,6 +2944,7 @@ handle_inferior_event (struct execution_
 	   better.  */
 	stop_step = 1;
 	print_stop_reason (END_STEPPING_RANGE, 0);
+	inferior_stop_event (END_STEPPING_RANGE, 0);
 	stop_stepping (ecs);
 	return;
       }
@@ -2969,6 +2965,7 @@ handle_inferior_event (struct execution_
 	   we will be in mid-line.  */
 	stop_step = 1;
 	print_stop_reason (END_STEPPING_RANGE, 0);
+	inferior_stop_event (END_STEPPING_RANGE, 0);
 	stop_stepping (ecs);
 	return;
       }
@@ -3076,6 +3073,7 @@ step_into_function (struct execution_con
       /* We are already there: stop now.  */
       stop_step = 1;
 	print_stop_reason (END_STEPPING_RANGE, 0);
+	inferior_stop_event (END_STEPPING_RANGE, 0);
       stop_stepping (ecs);
       return;
     }





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