This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Re: bug in mi when setting breakpoint
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: dodji at seketeli dot org, gdb-patches at sourceware dot org
- Date: Thu, 17 Jan 2008 11:36:48 +1300
- Subject: [PATCH] Re: bug in mi when setting breakpoint
- References: <20071216125625.GE4783@coin> <18277.36237.521792.245470@kahikatea.snap.net.nz> <18316.10856.89097.335103@kahikatea.snap.net.nz>
[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 <nickrob@snap.net.nz>
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
{