This is the mail archive of the gdb-patches@sourceware.cygnus.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]

[PATCH] MI - when MI interface output additional status info


Hello,

The attatched patch tweeks breakpoint.c and infrun.c so that additional
status information is included when MI reports that the target has
halted.

Any known problems with this one? Yes.  At present the code uses the
test:

	if (interpreter_p && strcmp (interpreter_p, "mi") == 0)

which is pretty MI specific.  It should be using some other more generic
mechanism - the info it provides in this case is probably useful for any
GUI.  I figure resolving that can be held of until the next UI enters
the scene.

	enjoy,
		Andrew
Mon Feb 21 13:57:27 2000  Andrew Cagney  <cagney@b1.cygnus.com>

	* breakpoint.c (print_it_typical, watchpoint_check,
 	print_one_breakpoint, mention): When MI include additional
	target status information.
	* infrun.c (print_stop_reason, normal_stop): Ditto.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.1.1.24
diff -p -r1.1.1.24 breakpoint.c
*** breakpoint.c	2000/02/03 04:14:25	1.1.1.24
--- breakpoint.c	2000/02/21 07:08:46
*************** print_it_typical (bs)
*** 1909,1914 ****
--- 1909,1916 ----
  #ifdef UI_OUT
        annotate_breakpoint (bs->breakpoint_at->number);
        ui_out_text (uiout, "\nBreakpoint ");
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	ui_out_field_string (uiout, "reason", "breakpoint-hit");
        ui_out_field_int (uiout, "bkptno", bs->breakpoint_at->number);
        ui_out_text (uiout, ", ");
        return PRINT_SRC_AND_LOC;
*************** print_it_typical (bs)
*** 2052,2057 ****
--- 2054,2061 ----
  	{
  	  annotate_watchpoint (bs->breakpoint_at->number);
  #ifdef UI_OUT
+ 	  if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	    ui_out_field_string (uiout, "reason", "watchpoint-trigger");
  	  mention (bs->breakpoint_at);
  	  ui_out_list_begin (uiout, "value");
  	  ui_out_text (uiout, "\nOld value = ");
*************** print_it_typical (bs)
*** 2080,2085 ****
--- 2084,2091 ----
  
      case bp_read_watchpoint:
  #ifdef UI_OUT
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	ui_out_field_string (uiout, "reason", "read-watchpoint-trigger");
        mention (bs->breakpoint_at);
        ui_out_list_begin (uiout, "value");
        ui_out_text (uiout, "\nValue = ");
*************** print_it_typical (bs)
*** 2102,2107 ****
--- 2108,2115 ----
        if (bs->old_val != NULL)     
  	{
  	  annotate_watchpoint (bs->breakpoint_at->number);
+ 	  if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	    ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
  	  mention (bs->breakpoint_at);
  	  ui_out_list_begin (uiout, "value");
  	  ui_out_text (uiout, "\nOld value = ");
*************** print_it_typical (bs)
*** 2114,2119 ****
--- 2122,2129 ----
        else 
  	{
  	  mention (bs->breakpoint_at);
+ 	  if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	    ui_out_list_begin (uiout, "value");
  	  ui_out_field_string (uiout, "reason", "access-watchpoint-trigger");
  	  ui_out_text (uiout, "\nValue = ");
  	}
*************** print_it_typical (bs)
*** 2148,2157 ****
--- 2158,2175 ----
         here. */
  
      case bp_finish:
+ #ifdef UI_OUT
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	ui_out_field_string (uiout, "reason", "function-finished");
+ #endif
        return PRINT_UNKNOWN;
        break;
  
      case bp_until:
+ #ifdef UI_OUT
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	ui_out_field_string (uiout, "reason", "location-reached");
+ #endif
        return PRINT_UNKNOWN;
        break;
  
*************** watchpoint_check (p)
*** 2360,2365 ****
--- 2378,2385 ----
  	 will be deleted already. So we have no choice but print the
  	 information here. */
  #ifdef UI_OUT
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	ui_out_field_string (uiout, "reason", "watchpoint-scope");
        ui_out_text (uiout, "\nWatchpoint ");
        ui_out_field_int (uiout, "wpnum", bs->breakpoint_at->number);
        ui_out_text (uiout, " deleted because the program has left the block in\n\
*************** print_one_breakpoint (struct breakpoint 
*** 3446,3451 ****
--- 3466,3478 ----
  #endif
      }
    
+ #ifdef UI_OUT
+   /* Output the count also if it is zero, but only if this is
+      mi. FIXME: Should have a better test for this. */
+   if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+     if (show_breakpoint_hit_counts && b->hit_count == 0)
+       ui_out_field_int (uiout, "times", b->hit_count);
+ #endif
  
    if (b->ignore_count)
      {
*************** mention (b)
*** 4446,4455 ****
--- 4473,4496 ----
        break;
  #endif
      case bp_breakpoint:
+ #ifdef UI_OUT
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	{
+ 	  say_where = 0;
+ 	  break;
+ 	}
+ #endif
        printf_filtered ("Breakpoint %d", b->number);
        say_where = 1;
        break;
      case bp_hardware_breakpoint:
+ #ifdef UI_OUT
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	{
+ 	  say_where = 0;
+ 	  break;
+ 	}
+ #endif
        printf_filtered ("Hardware assisted breakpoint %d", b->number);
        say_where = 1;
        break;
*************** mention (b)
*** 4505,4510 ****
--- 4546,4555 ----
      }
  #ifdef UI_OUT
    do_cleanups (old_chain);
+ #endif
+ #ifdef UI_OUT
+   if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+     return;
  #endif
    printf_filtered ("\n");
  }
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.2
diff -p -r1.2 infrun.c
*** infrun.c	2000/02/09 08:52:45	1.2
--- infrun.c	2000/02/21 07:09:17
*************** print_stop_reason (enum inferior_stop_re
*** 3223,3228 ****
--- 3223,3235 ----
      case END_STEPPING_RANGE:
        /* We are done with a step/next/si/ni command. */
        /* For now print nothing. */
+ #ifdef UI_OUT
+       /* Print a message only if not in the middle of doing a "step n"
+ 	 operation for n > 1 */
+       if (!step_multi || !stop_step)
+ 	if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	  ui_out_field_string (uiout, "reason", "end-stepping-range");
+ #endif
        break;
      case BREAKPOINT_HIT:
        /* We found a breakpoint. */
*************** print_stop_reason (enum inferior_stop_re
*** 3232,3237 ****
--- 3239,3246 ----
        /* The inferior was terminated by a signal. */
  #ifdef UI_OUT
        annotate_signalled ();
+       if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	ui_out_field_string (uiout, "reason", "exited-signalled");
        ui_out_text (uiout, "\nProgram terminated with signal ");
        annotate_signal_name ();
        ui_out_field_string (uiout, "signal-name", target_signal_to_name (stop_info));
*************** print_stop_reason (enum inferior_stop_re
*** 3264,3275 ****
--- 3273,3288 ----
        annotate_exited (stop_info);
        if (stop_info)
  	{
+ 	  if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	    ui_out_field_string (uiout, "reason", "exited");
  	  ui_out_text (uiout, "\nProgram exited with code ");
  	  ui_out_field_fmt (uiout, "exit-code", "0%o", (unsigned int) stop_info);
  	  ui_out_text (uiout, ".\n");
  	}
        else
  	{
+ 	  if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	    ui_out_field_string (uiout, "reason", "exited-normally");
  	  ui_out_text (uiout, "\nProgram exited normally.\n");
  	}
  #else
*************** The same program may be running in anoth
*** 3445,3451 ****
--- 3458,3474 ----
  	    default:
  	      internal_error ("Unknown value.");
  	    }
+ #ifdef UI_OUT
+ 	  /* For mi, have the same behavior every time we stop:
+              print everything but the source line. */
+ 	  if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	    source_flag = LOC_AND_ADDRESS;
+ #endif
  
+ #ifdef UI_OUT
+ 	  if (interpreter_p && strcmp (interpreter_p, "mi") == 0)
+ 	    ui_out_field_int (uiout, "thread-id", pid_to_thread_id (inferior_pid));
+ #endif
  	  /* The behavior of this routine with respect to the source
  	     flag is:
  	     SRC_LINE: Print only source line

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