This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] PR mi/2077 "set edit off" breaks MI
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 19 Oct 2006 21:55:56 +1300
- Subject: [PATCH] PR mi/2077 "set edit off" breaks MI
This patch is taken out of the async patch. It's probably a good idea to
commit the different parts separately anyway. The bug arises because GDB gets
confused about the current interpreter when doing "set edit off" (via
-interpreter-exec. To see this more clearly, instead of Vladimir's example
try:
~"This GDB was configured as \"i686-pc-linux-gnu\"...\n"
~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n"
(gdb)
start
&"start\n"
~"Breakpoint 1 at 0x8048513: file myprog.c, line 67.\n"
~"Starting program: /home/nickrob/myprog \n"
~"main () at myprog.c:67\n"
~"67\t int i, n, m[10] = {0, 1, 2, 3, 4 , 5, 6, 7, 8, 9};\n"
^done
(gdb)
-exec-next
^running
(gdb)
*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x08048574",func="main",args=[],file="myprog.c",fullname="/home/nickrob/myprog.c",line="68"}
(gdb)
set edit off
&"set edit off\n"
^done
(gdb)
-exec-next
&"Undefined command: \"-exec-next\". Try \"help\".\n"
and note that the response to the second -exec-next is a CLI one (no ^error).
Apple switch interpreters which fixes this bug. Jim Ingham can probably
explain more eloquently why it works.
I don't know how to give attribution to these changes in the ChangeLog as I
can't match them to entries in Apple's. Perhaps Jim can provide the details.
Otherwise can I just write?:
2006-10-19 Apple Computer, Inc <www.apple.com>
Or do I need a person/e-mail address?
--
Nick http://www.inet.net.nz/~nickrob
*** interps.h 18 Dec 2005 11:34:01 +1300 1.10
--- interps.h 19 Oct 2006 11:21:41 +1300
*************** extern struct interp *interp_new (const
*** 59,65 ****
struct ui_out *uiout,
const struct interp_procs *procs);
extern void interp_add (struct interp *interp);
! extern int interp_set (struct interp *interp);
extern struct interp *interp_lookup (const char *name);
extern struct ui_out *interp_ui_out (struct interp *interp);
--- 59,66 ----
struct ui_out *uiout,
const struct interp_procs *procs);
extern void interp_add (struct interp *interp);
! extern struct interp *interp_set (struct interp *interp);
! extern int interp_set_quiet (struct interp *interp, int quiet);
extern struct interp *interp_lookup (const char *name);
extern struct ui_out *interp_ui_out (struct interp *interp);
*** interps.c 18 Sep 2006 16:44:39 +1200 1.18
--- interps.c 19 Oct 2006 11:23:44 +1300
*************** interp_add (struct interp *interp)
*** 127,133 ****
interpreter back in place and return 0. If we can't restore the
old interpreter, then raise an internal error, since we are in
pretty bad shape at this point. */
! int
interp_set (struct interp *interp)
{
struct interp *old_interp = current_interpreter;
--- 127,133 ----
interpreter back in place and return 0. If we can't restore the
old interpreter, then raise an internal error, since we are in
pretty bad shape at this point. */
! struct interp *
interp_set (struct interp *interp)
{
struct interp *old_interp = current_interpreter;
*************** interp_set (struct interp *interp)
*** 188,194 ****
internal_error (__FILE__, __LINE__,
_("Failed to initialize new interp \"%s\" %s"),
interp->name, "and could not restore old interp!\n");
! return 0;
}
/* Finally, put up the new prompt to show that we are indeed here.
--- 188,194 ----
internal_error (__FILE__, __LINE__,
_("Failed to initialize new interp \"%s\" %s"),
interp->name, "and could not restore old interp!\n");
! return NULL;
}
/* Finally, put up the new prompt to show that we are indeed here.
*************** interp_set (struct interp *interp)
*** 206,212 ****
display_gdb_prompt (NULL);
}
! return 1;
}
/* interp_lookup - Looks up the interpreter for NAME. If no such
--- 206,218 ----
display_gdb_prompt (NULL);
}
! /* If there wasn't any interp before, return the current interp.
! That way if somebody is grabbing the return value and using
! it, it will actually work first time through. */
! if (old_interp == NULL)
! return current_interpreter;
! else
! return old_interp;
}
/* interp_lookup - Looks up the interpreter for NAME. If no such
*************** interp_quiet_p (struct interp *interp)
*** 289,295 ****
return current_interpreter->quiet_p;
}
! static int
interp_set_quiet (struct interp *interp, int quiet)
{
int old_val = interp->quiet_p;
--- 295,301 ----
return current_interpreter->quiet_p;
}
! int
interp_set_quiet (struct interp *interp, int quiet)
{
int old_val = interp->quiet_p;
*** mi/mi-interp.c 23 Dec 2005 18:57:46 -0000 1.17
--- mi/mi-interp.c 19 Oct 2006 06:40:21 -0000
*************** struct mi_interp
*** 48,53 ****
--- 48,56 ----
struct interp *mi_interp;
};
+ /* Points to the current interpreter, used by the mi context callbacks. */
+ static struct interp *mi_interp;
+
/* 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);
*************** enum mi_cmd_result
*** 188,196 ****
mi_cmd_interpreter_exec (char *command, char **argv, int argc)
{
struct interp *interp_to_use;
enum mi_cmd_result result = MI_CMD_DONE;
int i;
! struct interp_procs *procs;
if (argc < 2)
{
--- 191,200 ----
mi_cmd_interpreter_exec (char *command, char **argv, int argc)
{
struct interp *interp_to_use;
+ struct interp *old_interp;
enum mi_cmd_result result = MI_CMD_DONE;
int i;
! int old_quiet;
if (argc < 2)
{
*************** mi_cmd_interpreter_exec (char *command,
*** 211,216 ****
--- 215,235 ----
argv[0]);
return MI_CMD_ERROR;
}
+
+ old_quiet = interp_set_quiet (interp_to_use, 1);
+
+ old_interp = interp_set (interp_to_use);
+ if (old_interp == NULL)
+ {
+ asprintf (&mi_error_message,
+ "Could not switch to interpreter \"%s\".", argv[0]);
+ return MI_CMD_ERROR;
+ }
+
+ /* Set the global mi_interp. We need this so that the hook functions
+ can leave their results in the mi interpreter, rather than dumping
+ them to the console. */
+ mi_interp = old_interp;
/* Insert the MI out hooks, making sure to also call the interpreter's hooks
if it has any. */
*************** mi_cmd_interpreter_exec (char *command,
*** 254,260 ****
--- 273,284 ----
sync_execution = 0;
}
+ /* Now do the switch */
+ interp_set (old_interp);
+ mi_interp = NULL;
+
mi_remove_notify_hooks ();
+ interp_set_quiet (interp_to_use, old_quiet);
/* Okay, now let's see if the command set the inferior going...
Tricky point - have to do this AFTER resetting the interpreter, since