This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] Avoid recursivly defined user functions.
- From: Don Howard <dhoward at redhat dot com>
- To: <gdb-patches at sources dot redhat dot com>
- Date: Wed, 3 Apr 2002 14:10:21 -0800 (PST)
- Subject: [RFA] Avoid recursivly defined user functions.
Executing a recursively defined user function results in a core-dump from
gdb:
(gdb) define foo
Type commands for definition of "foo".
End with a line saying just "end".
>foo
>end
(gdb) foo
Segmentation fault (core dumped)
The following patch catches recursive user function definitions and
disallowes them:
2002-04-03 Don Howard <dhoward@redhat.com>
* cli/cli-script.c (define_command): Avoid recursivly defined user
commands.
Index: cli-script.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-script.c,v
retrieving revision 1.11
diff -p -u -w -r1.11 cli-script.c
--- cli-script.c 2002/03/17 19:53:39 1.11
+++ cli-script.c 2002/04/03 22:07:36
@@ -1099,6 +1099,13 @@ define_command (char *comname, int from_
sprintf (tmpbuf, "Type commands for definition of \"%s\".", comname);
cmds = read_command_lines (tmpbuf, from_tty);
+ {
+ struct command_line *c;
+ for (c=cmds; c; c=c->next)
+ if (strcmp (c->line, comname) == 0)
+ error ("Recursive user command definitions are not supported.");
+ }
+
if (c && c->class == class_user)
free_command_lines (&c->user_commands);
--
dhoward@redhat.com
gdb engineering