aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2000-06-08 00:52:56 +0000
committerAndrew Cagney <cagney@redhat.com>2000-06-08 00:52:56 +0000
commit53904c9e670da0974aebfb6cdaa30e9c55876508 (patch)
tree05ca51eb0b7848a88993468318da40d301819565
parent150f24a284293f28cc74a5469fb5d4b242336154 (diff)
downloadgdb-53904c9e670da0974aebfb6cdaa30e9c55876508.zip
gdb-53904c9e670da0974aebfb6cdaa30e9c55876508.tar.gz
gdb-53904c9e670da0974aebfb6cdaa30e9c55876508.tar.bz2
Change signature of function add_set_enum_cmd() so that it uses
constant character pointers. Update everything. As a consequence fix infrun's follow-fork plugging a small memory leak.
-rw-r--r--gdb/ChangeLog38
-rw-r--r--gdb/TODO25
-rw-r--r--gdb/arch-utils.c14
-rw-r--r--gdb/arm-tdep.c12
-rw-r--r--gdb/command.c17
-rw-r--r--gdb/command.h8
-rw-r--r--gdb/i386-tdep.c8
-rw-r--r--gdb/infrun.c62
-rw-r--r--gdb/mips-tdep.c12
-rw-r--r--gdb/remote.c10
-rw-r--r--gdb/serial.c10
11 files changed, 127 insertions, 89 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5c2d7c3..747312d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,41 @@
+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,
diff --git a/gdb/TODO b/gdb/TODO
index 7fa33c8..671e811 100644
--- a/gdb/TODO
+++ b/gdb/TODO
@@ -292,12 +292,6 @@ http://sourceware.cygnus.com/ml/gdb/2000-q1/msg00845.html
--
-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?
@@ -309,6 +303,22 @@ deprecated ``set archdebug'' and expand to ``set architecture''.
--
+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
======================
@@ -1149,6 +1159,9 @@ command) useful information such as the actual command and a context
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.
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index d604bd4..ab0c2de 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -249,17 +249,17 @@ generic_register_convertible_not (num)
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''. */
@@ -352,7 +352,7 @@ enum set_arch { set_arch_auto, set_arch_manual };
int target_architecture_auto = 1;
-char *set_architecture_string;
+const char *set_architecture_string;
/* Old way of changing the current architecture. */
@@ -585,7 +585,7 @@ initialize_current_architecture (void)
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;
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 84a350a..7cc53e0 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -52,10 +52,10 @@ static char * arm_register_name_strings[] =
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
@@ -2037,7 +2037,9 @@ _initialize_arm_tdep (void)
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;
@@ -2059,13 +2061,13 @@ The valid values are:\n");
for (i = 0; i < num_flavor_options; i++)
{
numregs = get_arm_regnames (i, &setname, &setdesc, &regnames);
- 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];
diff --git a/gdb/command.c b/gdb/command.c
index ec67d96..d9284cd 100644
--- a/gdb/command.c
+++ b/gdb/command.c
@@ -315,8 +315,8 @@ add_set_cmd (char *name,
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)
{
@@ -1470,17 +1470,16 @@ complete_on_cmdlist (list, text, word)
"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 *));
@@ -1667,7 +1666,7 @@ do_setshow_command (arg, from_tty, c)
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 */
@@ -1715,7 +1714,7 @@ do_setshow_command (arg, from_tty, c)
if (nmatches > 1)
error ("Ambiguous item \"%s\".", arg);
- *(char **) c->var = match;
+ *(const char **) c->var = match;
}
break;
default:
diff --git a/gdb/command.h b/gdb/command.h
index f6c46e9..7f5a6b2 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -199,7 +199,7 @@ struct cmd_list_element
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;
@@ -274,7 +274,7 @@ extern struct cmd_list_element *add_info_alias (char *, char *, int);
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 **);
@@ -294,8 +294,8 @@ extern struct cmd_list_element *add_set_cmd (char *name, enum
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);
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 63f2ba4..4eddde5 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -75,15 +75,15 @@ int i386_register_virtual_size[MAX_NUM_REGS];
/* 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);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index d607577..23877a4 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -434,17 +434,25 @@ pending_follow;
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;
static void
@@ -455,23 +463,19 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
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;
@@ -496,7 +500,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
/* 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. */
@@ -558,7 +562,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
/* 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. */
@@ -614,8 +618,6 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked,
pending_follow.fork_event.saw_parent_fork = 0;
pending_follow.fork_event.saw_child_fork = 0;
-
- free (follow_mode);
}
static void
@@ -757,11 +759,11 @@ resume_cleanups (void *ignore)
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,
@@ -4133,20 +4135,6 @@ discard_inferior_status (struct inferior_status *inf_status)
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));
-}
static void
build_infrun (void)
@@ -4309,8 +4297,6 @@ By default, the debugger will follow the parent process.",
/* 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 */
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 95dc72d..cf9ac59 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -62,11 +62,11 @@ struct frame_extra_info
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,
@@ -143,7 +143,7 @@ struct gdbarch_tdep
#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())
@@ -191,7 +191,7 @@ 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)
diff --git a/gdb/remote.c b/gdb/remote.c
index fbe959a..62a7a1c 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -526,17 +526,17 @@ enum packet_detect
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,
diff --git a/gdb/serial.c b/gdb/serial.c
index 0914e39..d78fb40 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -50,12 +50,12 @@ static struct ui_file *serial_logfp = NULL;
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;