/* Implementation of the GDB variable objects API.
- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
- Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+ 2009 Free Software Foundation, Inc.
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
#include "wrapper.h"
#include "gdbcmd.h"
#include "block.h"
+#include "valprint.h"
#include "gdb_assert.h"
#include "gdb_string.h"
if (frame_addr == (CORE_ADDR) 0)
return NULL;
- while (1)
+ for (frame = get_current_frame ();
+ frame != NULL;
+ frame = get_prev_frame (frame))
{
- frame = get_prev_frame (frame);
- if (frame == NULL)
- return NULL;
if (get_frame_base_address (frame) == frame_addr)
return frame;
}
+
+ return NULL;
}
struct varobj *
struct value *value = NULL;
int expr_len;
- /* Parse and evaluate the expression, filling in as much
- of the variable's data as possible */
+ /* Parse and evaluate the expression, filling in as much of the
+ variable's data as possible. */
- /* Allow creator to specify context of variable */
- if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
- fi = deprecated_safe_get_selected_frame ();
+ if (has_stack_frames ())
+ {
+ /* Allow creator to specify context of variable */
+ if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
+ fi = get_selected_frame (NULL);
+ else
+ /* FIXME: cagney/2002-11-23: This code should be doing a
+ lookup using the frame ID and not just the frame's
+ ``address''. This, of course, means an interface
+ change. However, with out that interface change ISAs,
+ such as the ia64 with its two stacks, won't work.
+ Similar goes for the case where there is a frameless
+ function. */
+ fi = find_frame_addr_in_frame_chain (frame);
+ }
else
- /* FIXME: cagney/2002-11-23: This code should be doing a
- lookup using the frame ID and not just the frame's
- ``address''. This, of course, means an interface change.
- However, with out that interface change ISAs, such as the
- ia64 with its two stacks, won't work. Similar goes for the
- case where there is a frameless function. */
- fi = find_frame_addr_in_frame_chain (frame);
+ fi = NULL;
/* frame = -2 means always use selected frame */
if (type == USE_SELECTED_FRAME)
if (varobj_value_is_changeable_p (var)
&& var->value && !value_lazy (var->value))
{
- free (var->print_value);
+ xfree (var->print_value);
var->print_value = value_get_print_value (var->value, var->format);
}
struct ui_file *stb;
struct cleanup *old_chain;
char *thevalue;
+ struct value_print_options opts;
if (value == NULL)
return NULL;
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
- common_val_print (value, stb, format_code[(int) format], 1, 0, 0,
- current_language);
+ get_formatted_print_options (&opts, format_code[(int) format]);
+ opts.deref_ref = 0;
+ common_val_print (value, stb, 0, &opts, current_language);
thevalue = ui_file_xstrdup (stb, &dummy);
do_cleanups (old_chain);
{
case TYPE_CODE_ARRAY:
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (target) > 0
- && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
+ && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
children = TYPE_LENGTH (type) / TYPE_LENGTH (target);
else
/* If we don't know how many elements there are, don't display
TRY_CATCH (e, RETURN_MASK_ERROR)
{
- if (TYPE_FIELD_STATIC (type, type_index))
+ if (field_is_static (&TYPE_FIELD (type, type_index)))
result = value_static_field (type, type_index);
else
result = value_primitive_field (value, 0, type_index, type);
{
int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
struct value *indval =
- value_from_longest (builtin_type_int, (LONGEST) real_index);
+ value_from_longest (builtin_type_int32, (LONGEST) real_index);
gdb_value_subscript (value, indval, cvalue);
}
/* Not a root var */
return NULL;
- back_to = make_cleanup_restore_current_thread (
- inferior_ptid, get_frame_id (deprecated_safe_get_selected_frame ()));
+ back_to = make_cleanup_restore_current_thread ();
/* Determine whether the variable is still around. */
if (var->root->valid_block == NULL || var->root->floating)
varp++;
}
- xfree (all_rootvarobj);
}
+ xfree (all_rootvarobj);
return;
}