From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4532 invoked by alias); 16 Jan 2008 22:37:24 -0000 Received: (qmail 4516 invoked by uid 22791); 16 Jan 2008 22:37:22 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 16 Jan 2008 22:36:56 +0000 Received: from kahikatea.snap.net.nz (180.31.255.123.static.snap.net.nz [123.255.31.180]) by viper.snap.net.nz (Postfix) with ESMTP id E34CF3DA3FD; Thu, 17 Jan 2008 11:36:52 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id EBCEA8FC6D; Thu, 17 Jan 2008 11:36:50 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18318.34560.237450.362651@kahikatea.snap.net.nz> Date: Wed, 16 Jan 2008 22:37:00 -0000 To: dodji@seketeli.org, gdb-patches@sourceware.org Subject: [PATCH] Re: bug in mi when setting breakpoint In-Reply-To: <18316.10856.89097.335103@kahikatea.snap.net.nz> References: <20071216125625.GE4783@coin> <18277.36237.521792.245470@kahikatea.snap.net.nz> <18316.10856.89097.335103@kahikatea.snap.net.nz> X-Mailer: VM 7.19 under Emacs 23.0.50.31 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00421.txt.bz2 [continued from gdb mailing list] > How about doing something similar in FSF GDB? Like below? Apple also have a MI command called -break-commands which I want to add to FSF GDB to avoid similar prompting problems in MI with "commands". -- Nick http://www.inet.net.nz/~nickrob 2008-01-17 Nick Roberts Based on work by Apple Computer, Inc. * linespec.c: Include mi/mi-cmds.h. (decode_objc, find_method): When using MI, set accept_all to 1. (decode_line_2): Add argument accept_all. Accept all breakpoints when non-zero. * mi/mi-interp.c (mi_underlying): New variable (mi_insert_notify_hooks, mi_remove_notify_hooks): Use it. * mi/mi-cmds.h (mi_underlying): New extern. *** mi-cmds.h.~1.27.~ 2008-01-04 10:24:35.000000000 +1300 --- mi-cmds.h 2008-01-15 17:25:11.000000000 +1300 *************** extern struct ui_file *raw_stdout; *** 158,161 **** --- 158,164 ---- extern char *mi_error_message; extern void mi_execute_command (char *cmd, int from_tty); + /* From mi-interp.c */ + extern int mi_underlying; + #endif *** mi-interp.c.~1.23.~ 2008-01-04 10:24:35.000000000 +1300 --- mi-interp.c 2008-01-17 11:12:57.000000000 +1300 *************** struct mi_interp *** 47,52 **** --- 47,55 ---- struct interp *mi_interp; }; + /* Set to 1 to make CLI commands behave as MI would like. */ + int mi_underlying = 0; + /* These are the interpreter setup, etc. functions for the MI interpreter */ static void mi_execute_command_wrapper (char *cmd); static void mi_command_loop (int mi_version); *************** static void *** 264,275 **** --- 267,280 ---- mi_insert_notify_hooks (void) { deprecated_query_hook = mi_interp_query_hook; + mi_underlying = 1; } static void mi_remove_notify_hooks (void) { deprecated_query_hook = NULL; + mi_underlying = 0; } static int *** linespec.c.~1.74.~ 2008-01-04 10:24:14.000000000 +1300 --- linespec.c 2008-01-15 17:42:11.000000000 +1300 *************** *** 36,41 **** --- 36,42 ---- #include "linespec.h" #include "exceptions.h" #include "language.h" + #include "mi/mi-cmds.h" /* We share this one with symtab.c, but it is not exported widely. */ *************** static char *find_toplevel_char (char *s *** 102,108 **** static int is_objc_method_format (const char *s); static struct symtabs_and_lines decode_line_2 (struct symbol *[], ! int, int, char ***); static struct symtab *symtab_from_filename (char **argptr, char *p, int is_quote_enclosed, --- 103,109 ---- static int is_objc_method_format (const char *s); static struct symtabs_and_lines decode_line_2 (struct symbol *[], ! int, int, int, char ***); static struct symtab *symtab_from_filename (char **argptr, char *p, int is_quote_enclosed, *************** is_objc_method_format (const char *s) *** 482,487 **** --- 483,489 ---- static struct symtabs_and_lines decode_line_2 (struct symbol *sym_arr[], int nelts, int funfirstline, + int accept_all, char ***canonical) { struct symtabs_and_lines values, return_values; *************** decode_line_2 (struct symbol *sym_arr[], *** 507,512 **** --- 509,515 ---- } i = 0; + if (!accept_all) printf_unfiltered (_("[0] cancel\n[1] all\n")); while (i < nelts) { *************** decode_line_2 (struct symbol *sym_arr[], *** 515,547 **** if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) { values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); ! if (values.sals[i].symtab) ! printf_unfiltered ("[%d] %s at %s:%d\n", ! (i + 2), ! SYMBOL_PRINT_NAME (sym_arr[i]), ! values.sals[i].symtab->filename, ! values.sals[i].line); ! else ! printf_unfiltered (_("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n"), ! (i + 2), ! SYMBOL_PRINT_NAME (sym_arr[i]), ! values.sals[i].line); ! } else printf_unfiltered (_("?HERE\n")); i++; } ! prompt = getenv ("PS2"); ! if (prompt == NULL) { ! prompt = "> "; } ! args = command_line_input (prompt, 0, "overload-choice"); ! ! if (args == 0 || *args == 0) ! error_no_arg (_("one or more choice numbers")); i = 0; while (*args) --- 518,565 ---- if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) { values.sals[i] = find_function_start_sal (sym_arr[i], funfirstline); ! if (!accept_all) ! { ! if (values.sals[i].symtab) ! printf_unfiltered ("[%d] %s at %s:%d\n", ! (i + 2), ! SYMBOL_PRINT_NAME (sym_arr[i]), ! values.sals[i].symtab->filename, ! values.sals[i].line); ! else ! printf_unfiltered ("[%d] %s at ?FILE:%d [No symtab? Probably broken debug info...]\n", ! (i + 2), ! SYMBOL_PRINT_NAME (sym_arr[i]), ! values.sals[i].line); ! } ! } ! else if (!accept_all) ! { ! /* APPLE LOCAL: We can do a little better than just printing ?HERE?... */ ! printf_filtered ("[%d] %s\n", ! (i + 2), ! (sym_arr[i] && SYMBOL_PRINT_NAME (sym_arr[i])) ? ! SYMBOL_PRINT_NAME (sym_arr[i]) : "?HERE?"); } else printf_unfiltered (_("?HERE\n")); i++; } ! if (!accept_all) { ! prompt = getenv ("PS2"); ! if (prompt == NULL) ! { ! prompt = "> "; ! } ! args = command_line_input (prompt, 0, "overload-choice"); ! ! if (args == 0 || *args == 0) ! error_no_arg ("one or more choice numbers"); } ! else ! args = "1"; i = 0; while (*args) *************** decode_objc (char **argptr, int funfirst *** 1154,1161 **** if (i1 > 1) { /* More than one match. The user must choose one or more. */ ! return decode_line_2 (sym_arr, i2, funfirstline, canonical); } return values; --- 1172,1184 ---- if (i1 > 1) { + int accept_all; + if (mi_underlying == 1 || ui_out_is_mi_like_p (uiout)) + accept_all = 1; + else + accept_all = 0; /* More than one match. The user must choose one or more. */ ! return decode_line_2 (sym_arr, i2, funfirstline, accept_all, canonical); } return values; *************** find_method (int funfirstline, char ***c *** 1442,1450 **** } if (i1 > 0) { /* There is more than one field with that name (overloaded). Ask the user which one to use. */ ! return decode_line_2 (sym_arr, i1, funfirstline, canonical); } else { --- 1465,1479 ---- } if (i1 > 0) { + int accept_all; + if (mi_underlying == 1 || ui_out_is_mi_like_p (uiout)) + accept_all = 1; + else + accept_all = 0; + /* There is more than one field with that name (overloaded). Ask the user which one to use. */ ! return decode_line_2 (sym_arr, i1, funfirstline, accept_all, canonical); } else {