+2013-08-27 Pedro Alves <pedro@codesourcery.com>
+ Yao Qi <yao@codesourcery.com>
+
+ * mi/mi-cmd-stack.c (list_args_or_locals): Adjust prototype.
+ (parse_no_frames_option): Remove.
+ (mi_cmd_stack_list_locals): Handle --skip-unavailable.
+ (mi_cmd_stack_list_args): Adjust.
+ (mi_cmd_stack_list_variables): Handle --skip-unavailable.
+ (list_arg_or_local): Add new parameter 'skip_unavailable'. Return
+ early if SKIP_UNAVAILABLE is true and ARG->val is unavailable.
+ Caller update.
+ (list_args_or_locals): New parameter 'skip_unavailable'.
+ Handle it.
+ * valprint.c (scalar_type_p): Rename to ...
+ (val_print_scalar_type_p): ... this. Make extern.
+ (val_print, value_check_printable): Adjust.
+ * valprint.h (val_print_scalar_type_p): Declare.
+ * value.c (value_entirely_unavailable): New function.
+ * value.h (value_entirely_unavailable): Declare.
+
+ * NEWS: Mention the new option "--skip-unavailable" to MI
+ commands '-stack-list-locals', '-stack-list-arguments' and
+ '-stack-list-variables'.
+
2013-08-27 Yao Qi <yao@codesourcery.com>
* mi/mi-cmd-stack.c (parse_no_frames_option): Remove.
** The new command -trace-frame-collected dumps collected variables,
computed expressions, tvars, memory and registers in a traceframe.
+ ** The commands -stack-list-locals, -stack-list-arguments and
+ -stack-list-variables now accept an option "--skip-unavailable".
+ When used, only the available locals or arguments 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-08-27 Pedro Alves <pedro@codesourcery.com>
+ Yao Qi <yao@codesourcery.com>
+
+ * gdb.texinfo (GDB/MI Stack Manipulation) <-stack-list-locals>:
+ Document new --skip-unavailable option.
+ <-stack-list-variables>: Document new --skip-unavailable option.
+
2013-08-26 Doug Evans <dje@google.com>
* gdb.texinfo (Maintenance Commands): "maint print objfiles" now takes
@subsubheading Synopsis
@smallexample
- -stack-list-arguments [ --no-frame-filters ] @var{print-values}
+ -stack-list-arguments [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
[ @var{low-frame} @var{high-frame} ]
@end smallexample
structures and unions. If the option @code{--no-frame-filters} is
supplied, then Python frame filters will not be executed.
+If the @code{--skip-unavailable} option is specified, arguments that
+are not available are not listed. Partially available arguments
+are still displayed, however.
Use of this command to obtain arguments in a single frame is
deprecated in favor of the @samp{-stack-list-variables} command.
@subsubheading Synopsis
@smallexample
- -stack-list-locals [ --no-frame-filters ] @var{print-values}
+ -stack-list-locals [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
@end smallexample
Display the local variable names for the selected frame. If
more detail. If the option @code{--no-frame-filters} is supplied, then
Python frame filters will not be executed.
+If the @code{--skip-unavailable} option is specified, local variables
+that are not available are not listed. Partially available local
+variables are still displayed, however.
+
This command is deprecated in favor of the
@samp{-stack-list-variables} command.
@subsubheading Synopsis
@smallexample
- -stack-list-variables [ --no-frame-filters ] @var{print-values}
+ -stack-list-variables [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
@end smallexample
Display the names of local variables and function arguments for the selected frame. If
structures and unions. If the option @code{--no-frame-filters} is
supplied, then Python frame filters will not be executed.
+If the @code{--skip-unavailable} option is specified, local variables
+and arguments that are not available are not listed. Partially
+available arguments and local variables are still displayed, however.
+
@subsubheading Example
@smallexample
enum what_to_list { locals, arguments, all };
-static void list_args_or_locals (enum what_to_list what,
+static void list_args_or_locals (enum what_to_list what,
enum print_values values,
- struct frame_info *fi);
+ struct frame_info *fi,
+ int skip_unavailable);
/* True if we want to allow Python-based frame filters. */
static int frame_filters = 0;
enum py_bt_status result = PY_BT_ERROR;
int print_value;
int oind = 0;
+ int skip_unavailable = 0;
+ int i;
if (argc > 1)
{
int i;
enum opt
{
- NO_FRAME_FILTERS
+ NO_FRAME_FILTERS,
+ SKIP_UNAVAILABLE,
};
static const struct mi_opt opts[] =
{
{"-no-frame-filters", NO_FRAME_FILTERS, 0},
+ {"-skip-unavailable", SKIP_UNAVAILABLE, 0},
{ 0, 0, 0 }
};
{
case NO_FRAME_FILTERS:
raw_arg = oind;
+ case SKIP_UNAVAILABLE:
+ skip_unavailable = 1;
break;
}
}
/* After the last option is parsed, there should be only
'print-values'. */
if (argc - oind != 1)
- error (_("-stack-list-locals: Usage: [--no-frame-filters] PRINT_VALUES"));
+ error (_("-stack-list-locals: Usage: [--no-frame-filters] "
+ "[--skip-unavailable] PRINT_VALUES"));
frame = get_selected_frame (NULL);
print_value = mi_parse_print_values (argv[oind]);
if "--no-frame-filters" has been specified from the command. */
if (! frame_filters || raw_arg || result == PY_BT_NO_FILTERS)
{
- list_args_or_locals (locals, print_value, frame);
+ list_args_or_locals (locals, print_value, frame,
+ skip_unavailable);
}
}
struct ui_out *uiout = current_uiout;
int raw_arg = 0;
int oind = 0;
+ int skip_unavailable = 0;
enum py_bt_status result = PY_BT_ERROR;
enum opt
{
NO_FRAME_FILTERS,
+ SKIP_UNAVAILABLE,
};
static const struct mi_opt opts[] =
{
{"-no-frame-filters", NO_FRAME_FILTERS, 0},
+ {"-skip-unavailable", SKIP_UNAVAILABLE, 0},
{ 0, 0, 0 }
};
case NO_FRAME_FILTERS:
raw_arg = oind;
break;
+ case SKIP_UNAVAILABLE:
+ skip_unavailable = 1;
+ break;
}
}
if (argc - oind != 1 && argc - oind != 3)
error (_("-stack-list-arguments: Usage: " \
- "[--no-frame-filters] PRINT_VALUES [FRAME_LOW FRAME_HIGH]"));
+ "[--no-frame-filters] [--skip-unavailable] "
+ "PRINT_VALUES [FRAME_LOW FRAME_HIGH]"));
if (argc - oind == 3)
{
QUIT;
cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
ui_out_field_int (uiout, "level", i);
- list_args_or_locals (arguments, print_values, fi);
+ list_args_or_locals (arguments, print_values, fi, skip_unavailable);
do_cleanups (cleanup_frame);
}
}
enum py_bt_status result = PY_BT_ERROR;
int print_value;
int oind = 0;
+ int skip_unavailable = 0;
if (argc > 1)
{
int i;
enum opt
{
- NO_FRAME_FILTERS
+ NO_FRAME_FILTERS,
+ SKIP_UNAVAILABLE,
};
static const struct mi_opt opts[] =
{
{"-no-frame-filters", NO_FRAME_FILTERS, 0},
+ {"-skip-unavailable", SKIP_UNAVAILABLE, 0},
{ 0, 0, 0 }
};
case NO_FRAME_FILTERS:
raw_arg = oind;
break;
+ case SKIP_UNAVAILABLE:
+ skip_unavailable = 1;
+ break;
}
}
}
/* After the last option is parsed, there should be only
'print-values'. */
if (argc - oind != 1)
- error (_("-stack-list-variables: Usage: " \
- "[--no-frame-filters] PRINT_VALUES"));
+ error (_("-stack-list-variables: Usage: [--no-frame-filters] " \
+ "[--skip-unavailable] PRINT_VALUES"));
frame = get_selected_frame (NULL);
print_value = mi_parse_print_values (argv[oind]);
if "--no-frame-filters" has been specified from the command. */
if (! frame_filters || raw_arg || result == PY_BT_NO_FILTERS)
{
- list_args_or_locals (all, print_value, frame);
+ list_args_or_locals (all, print_value, frame,
+ skip_unavailable);
}
}
WHAT and VALUES see list_args_or_locals.
Errors are printed as if they would be the parameter value. Use
- zeroed ARG iff it should not be printed according to VALUES. */
+ zeroed ARG iff it should not be printed according to VALUES. If
+ SKIP_UNAVAILABLE is true, only print ARG if it is available. */
static void
list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
- enum print_values values)
+ enum print_values values, int skip_unavailable)
{
struct cleanup *old_chain;
struct ui_out *uiout = current_uiout;
struct ui_file *stb;
- stb = mem_fileopen ();
- old_chain = make_cleanup_ui_file_delete (stb);
-
gdb_assert (!arg->val || !arg->error);
gdb_assert ((values == PRINT_NO_VALUES && arg->val == NULL
&& arg->error == NULL)
|| (arg->entry_kind == print_entry_values_only
&& (arg->val || arg->error)));
+ if (skip_unavailable && arg->val != NULL
+ && (value_entirely_unavailable (arg->val)
+ /* A scalar object that does not have all bits available is
+ also considered unavailable, because all bits contribute
+ to its representation. */
+ || (val_print_scalar_type_p (value_type (arg->val))
+ && !value_bytes_available (arg->val,
+ value_embedded_offset (arg->val),
+ TYPE_LENGTH (value_type (arg->val))))))
+ return;
+
+ stb = mem_fileopen ();
+ old_chain = make_cleanup_ui_file_delete (stb);
+
if (values != PRINT_NO_VALUES || what == all)
make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
/* Print a list of the objects for the frame FI in a certain form,
which is determined by VALUES. The objects can be locals,
- arguments or both, which is determined by WHAT. */
+ arguments or both, which is determined by WHAT. If SKIP_UNAVAILABLE
+ is true, only print the arguments or local variables whose values
+ are available. */
static void
list_args_or_locals (enum what_to_list what, enum print_values values,
- struct frame_info *fi)
+ struct frame_info *fi, int skip_unavailable)
{
struct block *block;
struct symbol *sym;
}
if (arg.entry_kind != print_entry_values_only)
- list_arg_or_local (&arg, what, values);
+ list_arg_or_local (&arg, what, values, skip_unavailable);
if (entryarg.entry_kind != print_entry_values_no)
- list_arg_or_local (&entryarg, what, values);
+ list_arg_or_local (&entryarg, what, values, skip_unavailable);
xfree (arg.error);
xfree (entryarg.error);
}
+2013-08-27 Yao Qi <yao@codesourcery.com>
+
+ * gdb.trace/entry-values.exp: Test unavailable entry value is
+ not shown when option '--skip-unavailable' is specified.
+ * gdb.trace/mi-trace-unavailable.exp (test_trace_unavailable):
+ Add tests for new option '--skip-unavailable'.
+
2013-08-27 Yao Qi <yao@codesourcery.com>
* lib/gdb.exp (gdb_remote_download): Don't pass $tofile to
# Since 'global2' is not collected, j@entry is expected to be 'unavailable'.
gdb_test "bt 1" "#0 .* foo \\(i=\[-\]?$decimal, i@entry=2, j=\[-\]?$decimal, j@entry=<unavailable>\\).*"
+# Test that unavailable "j@entry" is not shown when command option
+# --skip-unavailable is used.
+gdb_test "interpreter-exec mi \"-stack-list-arguments --skip-unavailable --simple-values\"" \
+ "\r\n\\^done,stack-args=\\\[frame={level=\"0\",args=\\\[{name=\"i\",type=\"int\",value=\".*\"},{name=\"i@entry\",type=\"int\",value=\"2\"},{name=\"j\",type=\"int\",value=\".*\"}\\\]},frame=.*\\\].*"
+
gdb_test "tfind" "Target failed to find requested trace frame\..*"
mi_gdb_test "-stack-list-locals --simple-values" \
".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
"-stack-list-locals --simple-values"
+ mi_gdb_test "-stack-list-locals --skip-unavailable --simple-values" \
+ ".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\}\\\]" \
+ "-stack-list-locals --skip-unavailable --simple-values"
# Test MI command '-stack-list-arguments'.
mi_gdb_test "-stack-list-arguments --simple-values" \
".*\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\{name=\"j\",type=\"int\",value=\"4\"\},\{name=\"s\",type=\"char \\\*\",value=\"<unavailable>\"\}\\\]\},.*\}.*" \
"-stack-list-arguments --simple-values"
+ mi_gdb_test "-stack-list-arguments --skip-unavailable --simple-values" \
+ ".*\\^done,stack-args=\\\[frame=\{level=\"0\",args=\\\[\{name=\"j\",type=\"int\",value=\"4\"\}\\\]\},.*\}.*" \
+ "-stack-list-arguments --skip-unavailable --simple-values"
# Test MI command '-stack-list-variables'.
mi_gdb_test "-stack-list-variables --simple-values" \
".*\\^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 "-stack-list-variables --skip-unavailable --simple-values" \
+ ".*\\^done,variables=\\\[\{name=\"j\",arg=\"1\",type=\"int\",value=\"4\"\},\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\}\\\]" \
+ "-stack-list-variables --skip-unavailable --simple-values"
mi_gdb_test "-trace-find frame-number 1" \
".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"1\",frame=\{.*" \
we want to print scalar arguments, but not aggregate arguments.
This function distinguishes between the two. */
-static int
-scalar_type_p (struct type *type)
+int
+val_print_scalar_type_p (struct type *type)
{
CHECK_TYPEDEF (type);
while (TYPE_CODE (type) == TYPE_CODE_REF)
/* Handle summary mode. If the value is a scalar, print it;
otherwise, print an ellipsis. */
- if (options->summary && !scalar_type_p (type))
+ if (options->summary && !val_print_scalar_type_p (type))
{
fprintf_filtered (stream, "...");
return;
if (value_entirely_optimized_out (val))
{
- if (options->summary && !scalar_type_p (value_type (val)))
+ if (options->summary && !val_print_scalar_type_p (value_type (val)))
fprintf_filtered (stream, "...");
else
val_print_optimized_out (stream);
extern void output_command_const (const char *args, int from_tty);
+extern int val_print_scalar_type_p (struct type *type);
+
#endif
return 0;
}
+int
+value_entirely_unavailable (struct value *value)
+{
+ /* We can only tell whether the whole value is available when we try
+ to read it. */
+ if (value->lazy)
+ value_fetch_lazy (value);
+
+ if (VEC_length (range_s, value->unavailable) == 1)
+ {
+ struct range *t = VEC_index (range_s, value->unavailable, 0);
+
+ if (t->offset == 0
+ && t->length == TYPE_LENGTH (value_enclosing_type (value)))
+ return 1;
+ }
+
+ return 0;
+}
+
void
mark_value_bytes_unavailable (struct value *value, int offset, int length)
{
whole object is unavailable. */
extern int value_entirely_available (struct value *value);
+/* Like value_entirely_available, but return false if any byte in the
+ whole object is available. */
+extern int value_entirely_unavailable (struct value *value);
+
/* Mark VALUE's content bytes starting at OFFSET and extending for
LENGTH bytes as unavailable. */