+2013-06-20 Pedro Alves <pedro@codesourcery.com>
+ Yao Qi <yao@codesourcery.com>
+
+ * NEWS: Mention the new option '--skip-unavailable' of command
+ -data-list-register-values.
+ * mi/mi-main.c (mi_cmd_data_list_register_values): Accept the
+ --skip-unavailable option. Adjust to use output_register.
+ (output_register): Add new 'skip_unavailable' parameter.
+ Handle it.
+
2013-06-19 Mike Frysinger <vapier@gentoo.org>
* Makefile.in (HFILES_NO_SRCDIR): Add common/i386-cpuid.h and
** The new command -dprintf-insert sets a dynamic printf breakpoint.
+ ** The command -data-list-register-values now accepts an optional
+ "--skip-unavailable" option. When used, only the available registers
+ are displayed.
+
* New system-wide configuration scripts
A GDB installation now provides scripts suitable for use as system-wide
configuration scripts for the following systems:
+2013-06-20 Pedro Alves <pedro@codesourcery.com>
+
+ * gdb.texinfo (GDB/MI Data Manipulation)
+ <-data-list-register-values>: Document the --skip-unavailable
+ option.
+
2013-06-07 Yao Qi <yao@codesourcery.com>
* gdb.texinfo (Symbols): Add kindex and cindex for
@subsubheading Synopsis
@smallexample
- -data-list-register-values @var{fmt} [ ( @var{regno} )*]
+ -data-list-register-values
+ [ @code{--skip-unavailable} ] @var{fmt} [ ( @var{regno} )*]
@end smallexample
Display the registers' contents. @var{fmt} is the format according to
which the registers' contents are to be returned, followed by an optional
list of numbers specifying the registers to display. A missing list of
-numbers indicates that the contents of all the registers must be returned.
+numbers indicates that the contents of all the registers must be
+returned. The @code{--skip-unavailable} option indicates that only
+the available registers are to be returned.
Allowed formats for @var{fmt} are:
char **argv, int argc);
static int register_changed_p (int regnum, struct regcache *,
struct regcache *);
-static void output_register (struct frame_info *, int regnum, int format);
+static void output_register (struct frame_info *, int regnum, int format,
+ int skip_unavailable);
/* Command implementations. FIXME: Is this libgdb? No. This is the MI
layer that calls libgdb. Any operation used in the below should be
int regnum, numregs, format;
int i;
struct cleanup *list_cleanup;
+ int skip_unavailable = 0;
+ int oind = 0;
+ enum opt
+ {
+ SKIP_UNAVAILABLE,
+ };
+ static const struct mi_opt opts[] =
+ {
+ {"-skip-unavailable", SKIP_UNAVAILABLE, 0},
+ { 0, 0, 0 }
+ };
/* Note that the test for a valid register must include checking the
gdbarch_register_name because gdbarch_num_regs may be allocated
will change depending upon the particular processor being
debugged. */
- if (argc == 0)
+ while (1)
+ {
+ char *oarg;
+ int opt = mi_getopt ("-data-list-register-values", argc, argv,
+ opts, &oind, &oarg);
+
+ if (opt < 0)
+ break;
+ switch ((enum opt) opt)
+ {
+ case SKIP_UNAVAILABLE:
+ skip_unavailable = 1;
+ break;
+ }
+ }
+
+ if (argc - oind < 1)
error (_("-data-list-register-values: Usage: "
- "-data-list-register-values <format> [<regnum1>...<regnumN>]"));
+ "-data-list-register-values [--skip-unavailable] <format>"
+ " [<regnum1>...<regnumN>]"));
- format = (int) argv[0][0];
+ format = (int) argv[oind][0];
frame = get_selected_frame (NULL);
gdbarch = get_frame_arch (frame);
list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values");
- if (argc == 1)
+ if (argc - oind == 1)
{
/* No args, beside the format: do all the regs. */
for (regnum = 0;
|| *(gdbarch_register_name (gdbarch, regnum)) == '\0')
continue;
- output_register (frame, regnum, format);
+ output_register (frame, regnum, format, skip_unavailable);
}
}
/* Else, list of register #s, just do listed regs. */
- for (i = 1; i < argc; i++)
+ for (i = 1 + oind; i < argc; i++)
{
regnum = atoi (argv[i]);
&& regnum < numregs
&& gdbarch_register_name (gdbarch, regnum) != NULL
&& *gdbarch_register_name (gdbarch, regnum) != '\000')
- output_register (frame, regnum, format);
+ output_register (frame, regnum, format, skip_unavailable);
else
error (_("bad register number"));
}
do_cleanups (list_cleanup);
}
-/* Output register REGNUM's contents in the desired FORMAT. */
+/* Output one register REGNUM's contents in the desired FORMAT. If
+ SKIP_UNAVAILABLE is true, skip the register if it is
+ unavailable. */
static void
-output_register (struct frame_info *frame, int regnum, int format)
+output_register (struct frame_info *frame, int regnum, int format,
+ int skip_unavailable)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
struct ui_out *uiout = current_uiout;
- struct value *val;
+ struct value *val = get_frame_register_value (frame, regnum);
struct cleanup *tuple_cleanup;
+ if (skip_unavailable && !value_entirely_available (val))
+ return;
+
tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_int (uiout, "number", regnum);
if (format == 'N')
format = 0;
- val = get_frame_register_value (frame, regnum);
-
if (value_optimized_out (val))
error (_("Optimized out"));
+2013-06-20 Yao Qi <yao@codesourcery.com>
+
+ * gdb.trace/mi-trace-unavailable.exp: Set tracepoint on 'foo'
+ and set an action.
+ (test_trace_unavailable): Test command -data-list-register-values
+ in the context of traceframe and with option --skip-unavailable.
+ * gdb.trace/trace-unavailable.c (foo): New.
+ (main): Call it.
+ * gdb.mi/gdb2549.exp: Update matching pattern.
+
2013-06-19 Mike Frysinger <vapier@gentoo.org>
* gdb.arch/i386-avx.c (have_avx): Change __get_cpuid call to i386_cpuid.
proc register_tests_no_exec { } {
# Test the generic IDT chip.
mi_gdb_test "111-data-list-register-values" \
- ".*111\\^error,msg=\"-data-list-register-values: Usage: -data-list-register-values <format> \\\[<regnum1>...<regnumN>\\\]\"" \
+ ".*111\\^error,msg=\"-data-list-register-values: Usage: -data-list-register-values \\\[--skip-unavailable\\\] <format> \\\[<regnum1>...<regnumN>\\\]\"" \
"wrong arguments"
mi_gdb_test "111-data-list-register-values x" \
mi_gdb_test "-break-commands 3 \"collect array\" \"collect j\" \"end\" " \
{\^done} "set action"
+mi_gdb_test "-break-insert -a foo" \
+ "\\^done,bkpt=\{number=\"${decimal}\",type=\"tracepoint\".*\"\}" \
+ "insert tracepoint on foo"
+
+# Collect 'main' to make sure no registers are collected except PC.
+mi_gdb_test "-break-commands 4 \"collect main\" \"end\" " \
+ {\^done} "set action on tracepoint 4"
+
mi_gdb_test "-trace-start" {.*\^done} "trace start"
mi_send_resuming_command "exec-continue" "continuing to marker"
mi_expect_stop \
".*\\^done,variables=\\\[\{name=\"j\",arg=\"1\",type=\"int\",value=\"4\"\},\{name=\"s\",arg=\"1\",type=\"char \\\*\",value=\"<unavailable>\"\},\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
"-stack-list-variables --simple-values"
+ mi_gdb_test "-trace-find frame-number 1" \
+ ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"1\",frame=\{.*" \
+ "-trace-find frame-number 1"
+
+ set pcnum 0
+ if [is_amd64_regs_target] {
+ set pcnum 16
+ } elseif [is_x86_like_target] {
+ set pcnum 8
+ } else {
+ # Other ports support tracepoint should define the number
+ # of its own pc register.
+ }
+
+ if { $pcnum != 0 } {
+ global hex
+ # Test that register 0 and PC are displayed, and register
+ # 0 is unavailable.
+ mi_gdb_test "-data-list-register-values x 0 ${pcnum}" \
+ ".*\\^done,register-values=\\\[\{number=\"0\",value=\"<unavailable>\"\},\{number=\"${pcnum}\",value=\"${hex}\"\}\\\]" \
+ "-data-list-register-values x"
+
+ # Test that only available register PC is displayed.
+ mi_gdb_test "-data-list-register-values --skip-unavailable x 0 ${pcnum}" \
+ ".*\\^done,register-values=\\\[\{number=\"${pcnum}\",value=\"${hex}\"\}\\\]" \
+ "-data-list-register-values --skip-unavailable x"
+ }
+
# Don't issue command '-trace-find none' to return from
# tfind mode (examining trace frames) on purpose, in order
# to test that GDB is able to clear its tracing-related local state
array[1] = 'd';
}
+static void
+foo (void)
+{}
+
static void
marker (void)
{}
char s[4];
bar (4, s);
+ foo ();
marker ();
return 0;
}