This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 08/18] Add options to control Vxworks related settings.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: Joel Brobecker <brobecker at adacore dot com>
- Date: Thu, 24 Feb 2011 12:49:13 -0500
- Subject: [PATCH 08/18] Add options to control Vxworks related settings.
- References: <1298569763-18784-1-git-send-email-brobecker@adacore.com>
This is module provides the commands that allow a user to configure
certain settings related to the WTX/VxWorks environment. For instance,
it allows the user to configure the stack size used when "running"
their program (in reality, spawning a new task), or the maximum amount
of time allowed to load a module before a timeout kicks in; etc.
It also provides some set commands that allow the user to turn some
traces on, for bug-hunting purposes...
gdb/ChangeLog:
* remote-wtx-opt.h, remote-wtx-opt.c: New files.
---
gdb/remote-wtx-opt.c | 357 ++++++++++++++++++++++++++++++++++++++++++++++++++
gdb/remote-wtx-opt.h | 49 +++++++
2 files changed, 406 insertions(+), 0 deletions(-)
create mode 100644 gdb/remote-wtx-opt.c
create mode 100644 gdb/remote-wtx-opt.h
diff --git a/gdb/remote-wtx-opt.c b/gdb/remote-wtx-opt.c
new file mode 100644
index 0000000..2c9d712
--- /dev/null
+++ b/gdb/remote-wtx-opt.c
@@ -0,0 +1,357 @@
+/* Support for the WTX protocol.
+
+ This unit provides a user interface to various settings which are
+ related to the WTX protocol. We also provide several debug switches
+ that the user can use to turn on some debugging traces.
+
+ Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "defs.h"
+#include "command.h"
+#include "gdbcmd.h"
+#include "remote-wtx-opt.h"
+#include "remote-wtxapi.h"
+
+/* The various settings that affect the the WTX protocol will be
+ accessible through the "set/show wtx" command prefix. The following
+ cmd_list_element variables contain the list of commands accessible
+ under that prefix. */
+
+static struct cmd_list_element *set_wtx_list = NULL;
+static struct cmd_list_element *show_wtx_list = NULL;
+
+/* The various debug switches are accessible through the "set/show wtx
+ debug" command prefix. The following cmd_list_element variables
+ contain the list of commands accessible under that prefix. */
+
+static struct cmd_list_element *set_wtx_debug_list = NULL;
+static struct cmd_list_element *show_wtx_debug_list = NULL;
+
+/* The name we use to identify ourselves when we connect to
+ the target server. The default value is allocated during
+ this file initialization phase. */
+static char *tool_name = NULL;
+
+/* The module load timeout in seconds. */
+static int load_timeout = 30;
+
+/* The stack size in bytes used when spawning a new process. */
+static int stack_size = 0x10000;
+
+/* The options used when spawning a new process. */
+static int task_options = 0;
+
+/* The priority used when spawning a new process. */
+static int task_priority = 100;
+
+/* Set to non-zero to print debug traces of the events received by GDB. */
+static int debug_events_level = 0;
+
+/* Set to non-zero to print debug traces related to break support. */
+static int debug_breakpoints = 0;
+
+/* Set to non-zero to print debug traces related to watchpoint support. */
+static int debug_watchpoints = 0;
+
+/* Set to non-zero to print debug traces of the operations involving
+ objfile manipuations. */
+static int debug_objfiles = 0;
+
+/* If set to non-zero, then the user wants to see more verbose error
+ messages when the TCL interpreter failed to evaluate a command. */
+static int debug_tcl = 0;
+
+/* Accessor for TOOL_NAME. */
+
+char *
+wtx_opt_tool_name (void)
+{
+ return tool_name;
+}
+
+/* Accessor for LOAD_TIMEOUT. */
+
+int
+wtx_opt_load_timeout (void)
+{
+ return load_timeout;
+}
+
+int
+wtx_opt_stack_size (void)
+{
+ return stack_size;
+}
+
+int
+wtx_opt_task_options (void)
+{
+ return task_options;
+}
+
+/* Init task options using the target information. */
+
+void
+wtx_opt_init_task_options (void)
+{
+ const int VX_FP_TASK = wtxapi_vx_fp_task ();
+ const int VX_SPE_TASK = 0x04000000;
+
+ /* If the target has a floating-point processor, then set the
+ floating-point option flag. */
+ if (wtxapi_target_has_fpp_get ())
+ task_options |= VX_FP_TASK;
+
+ /* If the target is e500v2, the SPE APU should be enabled to run
+ floating point programs.
+
+ FIXME: guitton/2009-07-20: In VxWorks 6.6, there is no way to
+ discriminate between e500 and e500v2: both have the same cpu
+ variant "ppc85XX". As we only support e500v2, it is fine to
+ assume that PPC85XX actually means e500v2... For now. But
+ it is not in the general case. The problem is fixed in Vxworks
+ 6.7, so we may get rid of this kludge at some point. */
+ if (wtxapi_has_target_variant ("_e500v2")
+ || wtxapi_has_target_variant ("_ppc85XX"))
+ task_options |= VX_SPE_TASK;
+}
+
+int
+wtx_opt_task_priority (void)
+{
+ return task_priority;
+}
+
+/* Accessor for DEBUG_TCL */
+
+int
+wtx_opt_tcl_verbose_p (void)
+{
+ return debug_tcl;
+}
+
+/* Print a debug message if DEBUG_OBJFILES is non-zero.
+ The message uses the string FORMAT and all the associated parameters,
+ following the printf syntax. */
+
+void
+wtx_opt_objfiles_debug (const char *format, ...)
+{
+ if (debug_objfiles)
+ {
+ va_list args;
+
+ va_start (args, format);
+ printf_filtered ("DEBUG (objfiles): ");
+ vprintf_filtered (format, args);
+ printf_filtered ("\n");
+ va_end (args);
+ }
+}
+
+/* Print a debug message if DEBUG_EVENTS is non-zero.
+ The message uses the string FORMAT and all the associated parameters,
+ following the printf syntax. */
+
+void
+wtx_opt_events_debug (int level, const char *format, ...)
+{
+ if (debug_events_level >= level)
+ {
+ va_list args;
+
+ va_start (args, format);
+ printf_filtered ("DEBUG (events): ");
+ vprintf_filtered (format, args);
+ printf_filtered ("\n");
+ va_end (args);
+ }
+}
+
+/* Print a debug message if DEBUG_BREAKPOINTS is non-zero.
+ The message uses the string FORMAT and all the associated parameters,
+ following the printf syntax. */
+
+void
+wtx_opt_breakpoints_debug (const char *format, ...)
+{
+ if (debug_breakpoints)
+ {
+ va_list args;
+
+ va_start (args, format);
+ printf_filtered ("DEBUG (breakpoints): ");
+ vprintf_filtered (format, args);
+ printf_filtered ("\n");
+ va_end (args);
+ }
+}
+
+/* Print a debug message if DEBUG_WATCHPOINTS is non-zero.
+ The message uses the string FORMAT and all the associated parameters,
+ following the printf syntax. */
+
+void
+wtx_opt_watchpoints_debug (const char *format, ...)
+{
+ if (debug_watchpoints)
+ {
+ va_list args;
+
+ va_start (args, format);
+ printf_filtered ("DEBUG (watchpoints): ");
+ vprintf_filtered (format, args);
+ printf_filtered ("\n");
+ va_end (args);
+ }
+}
+
+/* Implement the "set wtx" command.
+ This is not actually a valid command, so inform the user of that fact,
+ and print the list of valid subcommands to help him. */
+
+static void
+set_wtx_command (char *args, int from_tty)
+{
+ printf_filtered (_("\"set wtx\" must be followed by a subcommand.\n"));
+ help_list (set_wtx_list, "set wtx ", -1, gdb_stdout);
+}
+
+/* Implement the "show wtx" command: Print the value of all settings
+ available through that command prefix. */
+
+static void
+show_wtx_command (char *args, int from_tty)
+{
+ cmd_show_list (show_wtx_list, from_tty, "");
+}
+
+/* Implement the "set wtx debug" command.
+ This is not actually a valid command, so inform the user of that fact,
+ and print the list of valid subcommands to help him. */
+
+static void
+set_wtx_debug_command (char *args, int from_tty)
+{
+ printf_filtered (_("\"set wtx debug\" must be followed by a subcommand.\n"));
+ help_list (set_wtx_debug_list, "set wtx debug", -1, gdb_stdout);
+}
+
+/* Implement the "show wtx" command: Print the value of all settings
+ available through that command prefix. */
+
+static void
+show_wtx_debug_command (char *args, int from_tty)
+{
+ cmd_show_list (show_wtx_debug_list, from_tty, "");
+}
+
+void
+_initialize_remote_wtx_opt (void)
+{
+ tool_name = xstrdup ("gdb");
+
+ /* Various "set/show" switches. */
+ add_prefix_cmd ("wtx", no_class, set_wtx_command, _("\
+Adjust various settings specific to the WTX protocol."), &set_wtx_list,
+ "set wtx ", 0 /* allow_unknown */, &setlist);
+ add_prefix_cmd ("wtx", no_class, show_wtx_command, _("\
+Print various settings specific to the WTX protocol."), &show_wtx_list,
+ "show wtx ", 0 /* allow_unknown */, &showlist);
+
+ add_setshow_string_noescape_cmd ("tool-name", class_support,
+ &tool_name, _("\
+Set the tool name used when connecting to the target server."), _("\
+Show the tool name used when connecting to the target server."), NULL,
+ NULL, NULL,
+ &set_wtx_list, &show_wtx_list);
+
+ add_setshow_integer_cmd ("load-timeout", class_support,
+ &load_timeout, _("\
+Set the timeout in seconds when loading new modules on the target."), _("\
+Show the timeout in seconds when loading new modules on the target."), _("\
+Use this setting to adjust the maximum duration that loading a module\n\
+on the target can take before a timeout aborts the operation."),
+ NULL, NULL, &set_wtx_list, &show_wtx_list);
+
+ add_setshow_zinteger_cmd ("stack-size", class_support,
+ &stack_size, _("\
+Set the stack size in bytes for tasks spawned by the debugger."), _("\
+Show the stack size in bytes for tasks spawned by the debugger.."), _("\
+Use this setting to adjust the stack size of new tasks."),
+ NULL, NULL, &set_wtx_list, &show_wtx_list);
+
+ add_setshow_zinteger_cmd ("task-options", class_support,
+ &task_options, _("\
+Set the options of new tasks spawned by the debugger."), _("\
+Show the options of new tasks spawned by the debugger.."), _("\
+Use this setting to change the options used when spawning new tasks."),
+ NULL, NULL, &set_wtx_list, &show_wtx_list);
+
+ add_setshow_zinteger_cmd ("task-priority", class_support,
+ &task_priority, _("\
+Set the priority of new tasks spawned by the debugger."), _("\
+Show the priority of new tasks spawned by the debugger.."), _("\
+Use this setting to change the priority used when spawning new tasks."),
+ NULL, NULL, &set_wtx_list, &show_wtx_list);
+
+ /* Various debug switches for WTX. */
+ add_prefix_cmd ("debug", no_class, set_wtx_debug_command, _("\
+Adjust various settings specific to the WTX protocol."), &set_wtx_debug_list,
+ "set wtx debug ", 0 /* allow_unknown */, &set_wtx_list);
+ add_prefix_cmd ("debug", no_class, show_wtx_debug_command, _("\
+Print various settings specific to the WTX protocol."), &show_wtx_debug_list,
+ "show wtx debug ", 0 /* allow_unknown */, &show_wtx_list);
+
+ add_setshow_zinteger_cmd ("events", class_maintenance,
+ &debug_events_level, _("\
+Print debug traces related to WTX event handling."), _("\
+Debug traces related to WTX event handling."),
+ NULL, NULL, NULL, &set_wtx_debug_list,
+ &show_wtx_debug_list);
+
+ add_setshow_boolean_cmd ("objfiles", class_maintenance,
+ &debug_objfiles, _("\
+Print debug traces related to objfile handling for WTX."), _("\
+Debug traces related to objfile handling for WTX."),
+ NULL, NULL, NULL, &set_wtx_debug_list,
+ &show_wtx_debug_list);
+
+ add_setshow_boolean_cmd ("breakpoints", class_maintenance,
+ &debug_breakpoints, _("\
+Print debug traces related to WTX breakpoint handling."), _("\
+Debug traces related to WTX breakpoint handling."),
+ NULL, NULL, NULL, &set_wtx_debug_list,
+ &show_wtx_debug_list);
+
+ add_setshow_boolean_cmd ("watchpoints", class_maintenance,
+ &debug_watchpoints, _("\
+Print debug traces related to WTX watchpoint handling."), _("\
+Debug traces related to WTX watchpoint handling."),
+ NULL, NULL, NULL, &set_wtx_debug_list,
+ &show_wtx_debug_list);
+
+ add_setshow_boolean_cmd ("tcl", class_maintenance,
+ &debug_tcl, _("\
+Set the verbosity of the error messages from the TCL interpreter."), _("\
+Show the verbosity of the error messages from the TCL interpreter."), _("\
+When set, the TCL interpreter prints more verbose error messages"),
+ NULL, NULL,
+ &set_wtx_debug_list, &show_wtx_debug_list);
+
+}
diff --git a/gdb/remote-wtx-opt.h b/gdb/remote-wtx-opt.h
new file mode 100644
index 0000000..a786764
--- /dev/null
+++ b/gdb/remote-wtx-opt.h
@@ -0,0 +1,49 @@
+/* Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef REMOTE_WTX_OPT_H
+#define REMOTE_WTX_OPT_H
+
+char *wtx_opt_tool_name (void);
+
+int wtx_opt_load_timeout (void);
+
+int wtx_opt_stack_size (void);
+
+int wtx_opt_task_options (void);
+
+void wtx_opt_init_task_options (void);
+
+int wtx_opt_task_priority (void);
+
+int wtx_opt_tcl_verbose_p (void);
+
+/* Support for debugging traces. */
+
+void wtx_opt_objfiles_debug (const char *format, ...)
+ ATTRIBUTE_PRINTF (1, 2);
+
+void wtx_opt_events_debug (int level, const char *format, ...)
+ ATTRIBUTE_PRINTF (2, 3);
+
+void wtx_opt_breakpoints_debug (const char *format, ...)
+ ATTRIBUTE_PRINTF (1, 2);
+
+void wtx_opt_watchpoints_debug (const char *format, ...)
+ ATTRIBUTE_PRINTF (1, 2);
+
+#endif
--
1.7.0.4