constant character pointers. Update everything.
As a consequence fix infrun's follow-fork plugging a small memory leak.
+Wed Jun 7 15:13:04 2000 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * command.h (add_set_enum_cmd): Make ``enumlist'' and ``var''
+ constant char pointers.
+ (complete_on_enum): Change ``enumlist'' to a constant char
+ pointer.
+ (struct cmd_list_element): Ditto for member ``enums''.
+ * command.c (complete_on_enum, add_set_enum_cmd,
+ do_setshow_command): Update.
+
+ * infrun.c (follow_fork_mode_ask, follow_fork_mode_parent,
+ follow_fork_mode_both, follow_fork_mode_child): New. Use to
+ construct the follow_fork_mode_kind_names.
+ (set_follow_fork_mode_command): Delete function.
+ (_initialize_infrun): Update.
+ (follow_inferior_fork): Do not strdup follow_fork_mode_string.
+ Use follow_fork_mode_* variables directly instead. Call
+ internal_error instead of error when unimplemented "ask" mode.
+
+ * infrun.c (scheduler_enums, scheduler_mode, schedlock_off,
+ schedlock_on, schedlock_step): Update.
+ * serial.c (serial_logbase, logbase_hex, logbase_octal,
+ logbase_ascii, logbase_enums): Update.
+ * remote.c (packet_support_enums, packet_support_auto,
+ packet_enable, packet_disable, struct packet_config): Update.
+ * arch-utils.c (initialize_current_architecture,
+ set_architecture_string): Update.
+ (endian_big, endian_little, endian_auto, endian_enum,
+ set_endian_string): Update.
+ * i386-tdep.c (valid_flavors, att_flavor, intel_flavor,
+ disassembly_flavor): Update.
+ * mips-tdep.c (size_enums, size_64, size_32, size_auto,
+ mips_stack_argsize_string, mips_saved_regsize_string): Update.
+ * arm-tdep.c (disassembly_flavor, valid_flavors): Update.
+ (_initialize_arm_tdep): Ditto.
+
+ * TODO: Update.
+
Mon Jun 5 18:44:14 2000 Andrew Cagney <cagney@b1.cygnus.com>
* thread.c (make_cleanup_restore_current_thread,
--
-Change the parameter ``char *list[]'' (etc) to ``const char (*)[]'' so
-that dynamic lists from things like gdbarch_printable_names() can be
-passed.
-
---
-
The ``maintenance deprecate set endian big'' command doesn't notice
that it is deprecating ``set endian'' and not ``set endian big'' (big
is implemented using an enum). Is anyone going to notice this?
--
+Eliminate ``arm_register_names[j] = (char *) regnames[j]'' and the
+like from arm-tdep.c.
+
+--
+
+Fix uses of ->function.cfunc = set_function().
+
+The command.c code calls sfunc() when a set command. Rather than
+change it suggest fixing the callback function so that it is more
+useful. See:
+
+http://sourceware.cygnus.com/ml/gdb-patches/2000-06/msg00062.html
+
+See also ``Fix implementation of ``target xxx''.'' below.
+
+--
New Features and Fixes
======================
for that command. Other changes such as making ``struct command''
opaque may also help.
+See also:
+http://sourceware.cygnus.com/ml/gdb-patches/2000-06/msg00062.html
+
--
Make "target xxx" command interruptible.
int target_byte_order = TARGET_BYTE_ORDER_DEFAULT;
int target_byte_order_auto = 1;
-static char endian_big[] = "big";
-static char endian_little[] = "little";
-static char endian_auto[] = "auto";
-static char *endian_enum[] =
+static const char endian_big[] = "big";
+static const char endian_little[] = "little";
+static const char endian_auto[] = "auto";
+static const char *endian_enum[] =
{
endian_big,
endian_little,
endian_auto,
NULL,
};
-static char *set_endian_string;
+static const char *set_endian_string;
/* Called by ``show endian''. */
int target_architecture_auto = 1;
-char *set_architecture_string;
+const char *set_architecture_string;
/* Old way of changing the current architecture. */
of ``const char *''. We just happen to know that the casts are
safe. */
c = add_set_enum_cmd ("architecture", class_support,
- (char **) arches, (char **) &set_architecture_string,
+ arches, &set_architecture_string,
"Set architecture of target.",
&setlist);
c->function.sfunc = set_architecture;
char **arm_register_names = arm_register_name_strings;
/* Valid register name flavors. */
-static char **valid_flavors;
+static const char **valid_flavors;
/* Disassembly flavor to use. Default to "std" register names. */
-static char *disassembly_flavor;
+static const char *disassembly_flavor;
static int current_option; /* Index to that option in the opcodes table. */
/* This is used to keep the bfd arch_info in sync with the disassembly
struct ui_file *stb;
long length;
struct cmd_list_element *new_cmd;
- const char *setname, *setdesc, **regnames;
+ const char *setname;
+ const char *setdesc;
+ const char **regnames;
int numregs, i, j;
static char *helptext;
for (i = 0; i < num_flavor_options; i++)
{
numregs = get_arm_regnames (i, &setname, &setdesc, ®names);
- valid_flavors[i] = (char *) setname;
+ valid_flavors[i] = setname;
fprintf_unfiltered (stb, "%s - %s\n", setname,
setdesc);
/* Copy the default names (if found) and synchronize disassembler. */
if (!strcmp (setname, "std"))
{
- disassembly_flavor = (char *) setname;
+ disassembly_flavor = setname;
current_option = i;
for (j = 0; j < numregs; j++)
arm_register_names[j] = (char *) regnames[j];
struct cmd_list_element *
add_set_enum_cmd (char *name,
enum command_class class,
- char *enumlist[],
- char **var,
+ const char *enumlist[],
+ const char **var,
char *doc,
struct cmd_list_element **list)
{
"oobar"; if WORD is "baz/foo", return "baz/foobar". */
char **
-complete_on_enum (enumlist, text, word)
- char **enumlist;
- char *text;
- char *word;
+complete_on_enum (const char *enumlist[],
+ char *text,
+ char *word)
{
char **matchlist;
int sizeof_matchlist;
int matches;
int textlen = strlen (text);
int i;
- char *name;
+ const char *name;
sizeof_matchlist = 10;
matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
int i;
int len;
int nmatches;
- char *match = NULL;
+ const char *match = NULL;
char *p;
/* if no argument was supplied, print an informative error message */
if (nmatches > 1)
error ("Ambiguous item \"%s\".", arg);
- *(char **) c->var = match;
+ *(const char **) c->var = match;
}
break;
default:
var_types var_type;
/* Pointer to NULL terminated list of enumerated values (like argv). */
- char **enums;
+ const char **enums;
/* Pointer to command strings of user-defined commands */
struct command_line *user_commands;
extern char **complete_on_cmdlist (struct cmd_list_element *, char *, char *);
-extern char **complete_on_enum (char **enumlist, char *, char *);
+extern char **complete_on_enum (const char *enumlist[], char *, char *);
extern void delete_cmd (char *, struct cmd_list_element **);
extern struct cmd_list_element *add_set_enum_cmd (char *name,
enum command_class class,
- char *enumlist[],
- char **var,
+ const char *enumlist[],
+ const char **var,
char *doc,
struct cmd_list_element **list);
/* This is the variable the is set with "set disassembly-flavor",
and its legitimate values. */
-static char att_flavor[] = "att";
-static char intel_flavor[] = "intel";
-static char *valid_flavors[] =
+static const char att_flavor[] = "att";
+static const char intel_flavor[] = "intel";
+static const char *valid_flavors[] =
{
att_flavor,
intel_flavor,
NULL
};
-static char *disassembly_flavor = att_flavor;
+static const char *disassembly_flavor = att_flavor;
static void i386_print_register (char *, int, int);
follow-fork-mode.) */
static int follow_vfork_when_exec;
-static char *follow_fork_mode_kind_names[] =
+static const char follow_fork_mode_ask[] = "ask";
+static const char follow_fork_mode_both[] = "both";
+static const char follow_fork_mode_child[] = "child";
+static const char follow_fork_mode_parent[] = "parent";
+
+static const char *follow_fork_mode_kind_names[] =
{
+ follow_fork_mode_ask,
/* ??rehrauer: The "both" option is broken, by what may be a 10.20
kernel problem. It's also not terribly useful without a GUI to
help the user drive two debuggers. So for now, I'm disabling the
"both" option. */
- /* "parent", "child", "both", "ask" */
- "parent", "child", "ask", NULL
+ /* follow_fork_mode_both, */
+ follow_fork_mode_child,
+ follow_fork_mode_parent,
+ NULL
};
-static char *follow_fork_mode_string = NULL;
+static const char *follow_fork_mode_string = follow_fork_mode_parent;
\f
static void
int followed_child = 0;
/* Which process did the user want us to follow? */
- char *follow_mode =
- savestring (follow_fork_mode_string, strlen (follow_fork_mode_string));
+ const char *follow_mode = follow_fork_mode_string;
/* Or, did the user not know, and want us to ask? */
- if (STREQ (follow_fork_mode_string, "ask"))
+ if (follow_fork_mode_string == "ask")
{
- char requested_mode[100];
-
- free (follow_mode);
- error ("\"ask\" mode NYI");
- follow_mode = savestring (requested_mode, strlen (requested_mode));
+ internal_error ("follow_inferior_fork: \"ask\" mode not implemented");
+ /* follow_mode = follow_fork_mode_...; */
}
/* If we're to be following the parent, then detach from child_pid.
We're already following the parent, so need do nothing explicit
for it. */
- if (STREQ (follow_mode, "parent"))
+ if (follow_mode == follow_fork_mode_parent)
{
followed_parent = 1;
/* If we're to be following the child, then attach to it, detach
from inferior_pid, and set inferior_pid to child_pid. */
- else if (STREQ (follow_mode, "child"))
+ else if (follow_mode == follow_fork_mode_child)
{
char child_pid_spelling[100]; /* Arbitrary length. */
/* If we're to be following both parent and child, then fork ourselves,
and attach the debugger clone to the child. */
- else if (STREQ (follow_mode, "both"))
+ else if (follow_mode == follow_fork_mode_both)
{
char pid_suffix[100]; /* Arbitrary length. */
pending_follow.fork_event.saw_parent_fork = 0;
pending_follow.fork_event.saw_child_fork = 0;
-
- free (follow_mode);
}
static void
normal_stop ();
}
-static char schedlock_off[] = "off";
-static char schedlock_on[] = "on";
-static char schedlock_step[] = "step";
-static char *scheduler_mode = schedlock_off;
-static char *scheduler_enums[] =
+static const char schedlock_off[] = "off";
+static const char schedlock_on[] = "on";
+static const char schedlock_step[] = "step";
+static const char *scheduler_mode = schedlock_off;
+static const char *scheduler_enums[] =
{
schedlock_off,
schedlock_on,
free_inferior_status (inf_status);
}
-static void
-set_follow_fork_mode_command (char *arg, int from_tty,
- struct cmd_list_element *c)
-{
- if (!STREQ (arg, "parent") &&
- !STREQ (arg, "child") &&
- !STREQ (arg, "both") &&
- !STREQ (arg, "ask"))
- error ("follow-fork-mode must be one of \"parent\", \"child\", \"both\" or \"ask\".");
-
- if (follow_fork_mode_string != NULL)
- free (follow_fork_mode_string);
- follow_fork_mode_string = savestring (arg, strlen (arg));
-}
\f
static void
build_infrun (void)
/* c->function.sfunc = ; */
add_show_from_set (c, &showlist);
- set_follow_fork_mode_command ("parent", 0, NULL);
-
c = add_set_enum_cmd ("scheduler-locking", class_run,
scheduler_enums, /* array of string names */
&scheduler_mode, /* current mode */
overridden dynamically. Establish an enum/array for managing
them. */
-static char size_auto[] = "auto";
-static char size_32[] = "32";
-static char size_64[] = "64";
+static const char size_auto[] = "auto";
+static const char size_32[] = "32";
+static const char size_64[] = "64";
-static char *size_enums[] = {
+static const char *size_enums[] = {
size_auto,
size_32,
size_64,
#define MIPS_DEFAULT_SAVED_REGSIZE MIPS_REGSIZE
#endif
-static char *mips_saved_regsize_string = size_auto;
+static const char *mips_saved_regsize_string = size_auto;
#define MIPS_SAVED_REGSIZE (mips_saved_regsize())
#define MIPS_STACK_ARGSIZE (mips_stack_argsize ())
-static char *mips_stack_argsize_string = size_auto;
+static const char *mips_stack_argsize_string = size_auto;
static unsigned int
mips_stack_argsize (void)
struct packet_config
{
- char *state;
+ const char *state;
char *name;
char *title;
enum packet_detect detect;
enum packet_support support;
};
-static char packet_support_auto[] = "auto";
-static char packet_enable[] = "enable";
-static char packet_disable[] = "disable";
-static char *packet_support_enums[] =
+static const char packet_support_auto[] = "auto";
+static const char packet_enable[] = "enable";
+static const char packet_disable[] = "disable";
+static const char *packet_support_enums[] =
{
packet_support_auto,
packet_enable,
static struct serial_ops *serial_interface_lookup (char *);
static void serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout);
-static char logbase_hex[] = "hex";
-static char logbase_octal[] = "octal";
-static char logbase_ascii[] = "ascii";
-static char *logbase_enums[] =
+static const char logbase_hex[] = "hex";
+static const char logbase_octal[] = "octal";
+static const char logbase_ascii[] = "ascii";
+static const char *logbase_enums[] =
{logbase_hex, logbase_octal, logbase_ascii, NULL};
-static char *serial_logbase = logbase_ascii;
+static const char *serial_logbase = logbase_ascii;
\f