diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 88fe9755336..aebd3dfb4b5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2001-07-04 Andrew Cagney + + * ui-out.h (struct ui_out_impl): Add field is_mi_like_p. + (ui_out_is_mi_like_p): Declare. + * ui-out.c (ui_out_is_mi_like_p): Define. + (default_ui_out_impl): Initialize is_mi_like_p to zero. + * cli-out.c (cli_ui_out_impl): Ditto. + * breakpoint.c (print_it_typical): Use ui_out_is_mi_like_p. + (watchpoint_check, print_one_breakpoint, mention): Ditto. + * infrun.c (print_stop_reason, normal_stop): Ditto. + 2001-07-05 Daniel Jacobowitz * mips-tdep.c (mips_software_single_step): New function. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index cee302e8faf..ed152bede86 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1889,7 +1889,7 @@ print_it_typical (bpstat bs) #ifdef UI_OUT annotate_breakpoint (bs->breakpoint_at->number); ui_out_text (uiout, "\nBreakpoint "); - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "breakpoint-hit"); ui_out_field_int (uiout, "bkptno", bs->breakpoint_at->number); ui_out_text (uiout, ", "); @@ -2034,7 +2034,7 @@ print_it_typical (bpstat bs) { annotate_watchpoint (bs->breakpoint_at->number); #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "watchpoint-trigger"); mention (bs->breakpoint_at); ui_out_tuple_begin (uiout, "value"); @@ -2064,7 +2064,7 @@ print_it_typical (bpstat bs) case bp_read_watchpoint: #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "read-watchpoint-trigger"); mention (bs->breakpoint_at); ui_out_tuple_begin (uiout, "value"); @@ -2088,7 +2088,7 @@ print_it_typical (bpstat bs) if (bs->old_val != NULL) { annotate_watchpoint (bs->breakpoint_at->number); - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "access-watchpoint-trigger"); mention (bs->breakpoint_at); ui_out_tuple_begin (uiout, "value"); @@ -2102,7 +2102,7 @@ print_it_typical (bpstat bs) else { mention (bs->breakpoint_at); - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "access-watchpoint-trigger"); ui_out_tuple_begin (uiout, "value"); ui_out_text (uiout, "\nValue = "); @@ -2139,7 +2139,7 @@ print_it_typical (bpstat bs) case bp_finish: #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "function-finished"); #endif return PRINT_UNKNOWN; @@ -2147,7 +2147,7 @@ print_it_typical (bpstat bs) case bp_until: #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "location-reached"); #endif return PRINT_UNKNOWN; @@ -2354,7 +2354,7 @@ watchpoint_check (PTR p) will be deleted already. So we have no choice but print the information here. */ #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "watchpoint-scope"); ui_out_text (uiout, "\nWatchpoint "); ui_out_field_int (uiout, "wpnum", bs->breakpoint_at->number); @@ -3481,7 +3481,7 @@ print_one_breakpoint (struct breakpoint *b, #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 && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) if (show_breakpoint_hit_counts && b->hit_count == 0) ui_out_field_int (uiout, "times", b->hit_count); #endif @@ -4509,7 +4509,7 @@ mention (struct breakpoint *b) #endif case bp_breakpoint: #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) { say_where = 0; break; @@ -4520,7 +4520,7 @@ mention (struct breakpoint *b) break; case bp_hardware_breakpoint: #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) { say_where = 0; break; @@ -4583,7 +4583,7 @@ mention (struct breakpoint *b) do_cleanups (old_chain); #endif #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) return; #endif printf_filtered ("\n"); diff --git a/gdb/cli-out.c b/gdb/cli-out.c index 42adc798b3d..9bcfa4684a1 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -89,7 +89,8 @@ static struct ui_out_impl cli_ui_out_impl = cli_text, cli_message, cli_wrap_hint, - cli_flush + cli_flush, + 0, /* Does not need MI hacks (i.e. needs CLI hacks). */ }; /* Prototypes for local functions */ diff --git a/gdb/infrun.c b/gdb/infrun.c index e3556229473..8b126db6523 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3308,7 +3308,7 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) /* 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 && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "end-stepping-range"); #endif break; @@ -3320,7 +3320,7 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) /* The inferior was terminated by a signal. */ #ifdef UI_OUT annotate_signalled (); - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "exited-signalled"); ui_out_text (uiout, "\nProgram terminated with signal "); annotate_signal_name (); @@ -3354,7 +3354,7 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) annotate_exited (stop_info); if (stop_info) { - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) 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); @@ -3362,7 +3362,7 @@ print_stop_reason (enum inferior_stop_reason stop_reason, int stop_info) } else { - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_string (uiout, "reason", "exited-normally"); ui_out_text (uiout, "\nProgram exited normally.\n"); } @@ -3548,12 +3548,12 @@ and/or watchpoints.\n"); #ifdef UI_OUT /* For mi, have the same behavior every time we stop: print everything but the source line. */ - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) source_flag = LOC_AND_ADDRESS; #endif #ifdef UI_OUT - if (interpreter_p && strncmp (interpreter_p, "mi", 2) == 0) + if (ui_out_is_mi_like_p (uiout)) ui_out_field_int (uiout, "thread-id", pid_to_thread_id (inferior_ptid)); #endif diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog index 2611b4559d5..ab493195301 100644 --- a/gdb/mi/ChangeLog +++ b/gdb/mi/ChangeLog @@ -1,3 +1,7 @@ +2001-07-04 Andrew Cagney + + * mi-out.c (mi_ui_out_impl): Initialize is_mi_like_p to one. + 2001-06-27 Andrew Cagney * mi-out.c (mi_table_begin): Include nr_cols and nr_rows in mi1 diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 040e2e40910..7e09f2d1494 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -88,7 +88,8 @@ struct ui_out_impl mi_ui_out_impl = mi_text, mi_message, mi_wrap_hint, - mi_flush + mi_flush, + 1, /* Needs MI hacks. */ }; /* Prototypes for local functions */ diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 5fe212bcd06..910cb169c4e 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -190,7 +190,8 @@ struct ui_out_impl default_ui_out_impl = default_text, default_message, default_wrap_hint, - default_flush + default_flush, + 0, /* Does not need MI hacks. */ }; /* The default ui_out */ @@ -712,6 +713,12 @@ gdb_query (struct ui_out *uiout, int qflags, char *qprompt) } #endif +int +ui_out_is_mi_like_p (struct ui_out *uiout) +{ + return uiout->impl->is_mi_like_p; +} + /* default gdb-out hook functions */ static void diff --git a/gdb/ui-out.h b/gdb/ui-out.h index e71c291fcad..797c2fe960d 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -184,6 +184,13 @@ extern void gdb_error (struct ui_out *uiout, int severity, char *format, ...); extern void gdb_query (struct ui_out *uiout, int qflags, char *qprompt); #endif +/* HACK: Code in GDB is currently checking to see the type of ui_out + builder when determining which output to produce. This function is + a hack to encapsulate that test. Once GDB manages to separate the + CLI/MI from the core of GDB the problem should just go away .... */ + +extern int ui_out_is_mi_like_p (struct ui_out *uiout); + /* From here on we have things that are only needed by implementation routines and main.c. We should pehaps have a separate file for that, like a ui-out-impl.h file */ @@ -253,6 +260,7 @@ struct ui_out_impl message_ftype *message; wrap_hint_ftype *wrap_hint; flush_ftype *flush; + int is_mi_like_p; }; extern struct ui_out_data *ui_out_data (struct ui_out *uiout);