[RFA] Avoid recursivly defined user functions.

Don Howard
2002-04-03T22:09:41Z

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