* findvar.c (read_var_value): Never return NULL, throw an error
	instead.  Update the function comment.  State symbol name in the error
	messages.
	* python/py-frame.c (frapy_read_var): Remove handling of NULL from
	read_var_value.
	* stack.c (print_frame_args): Likewise.
	* valops.c (value_of_variable): Likewise.
This commit is contained in:
Jan Kratochvil 2011-09-08 15:26:08 +00:00
parent b99b5f66e1
commit 8afd712c6f
5 changed files with 41 additions and 43 deletions

View File

@ -1,3 +1,13 @@
2011-09-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* findvar.c (read_var_value): Never return NULL, throw an error
instead. Update the function comment. State symbol name in the error
messages.
* python/py-frame.c (frapy_read_var): Remove handling of NULL from
read_var_value.
* stack.c (print_frame_args): Likewise.
* valops.c (value_of_variable): Likewise.
2011-09-08 Jan Kratochvil <jan.kratochvil@redhat.com> 2011-09-08 Jan Kratochvil <jan.kratochvil@redhat.com>
* stack.c (print_frame_args): New variable except. Wrap * stack.c (print_frame_args): New variable except. Wrap

View File

@ -409,7 +409,7 @@ symbol_read_needs_frame (struct symbol *sym)
/* Given a struct symbol for a variable, /* Given a struct symbol for a variable,
and a stack frame id, read the value of the variable and a stack frame id, read the value of the variable
and return a (pointer to a) struct value containing the value. and return a (pointer to a) struct value containing the value.
If the variable cannot be found, return a zero pointer. */ If the variable cannot be found, throw error. */
struct value * struct value *
read_var_value (struct symbol *var, struct frame_info *frame) read_var_value (struct symbol *var, struct frame_info *frame)
@ -477,7 +477,8 @@ read_var_value (struct symbol *var, struct frame_info *frame)
case LOC_ARG: case LOC_ARG:
addr = get_frame_args_address (frame); addr = get_frame_args_address (frame);
if (!addr) if (!addr)
return 0; error (_("Unknown argument list address for `%s'."),
SYMBOL_PRINT_NAME (var));
addr += SYMBOL_VALUE (var); addr += SYMBOL_VALUE (var);
v = allocate_value_lazy (type); v = allocate_value_lazy (type);
break; break;
@ -489,7 +490,8 @@ read_var_value (struct symbol *var, struct frame_info *frame)
argref = get_frame_args_address (frame); argref = get_frame_args_address (frame);
if (!argref) if (!argref)
return 0; error (_("Unknown argument list address for `%s'."),
SYMBOL_PRINT_NAME (var));
argref += SYMBOL_VALUE (var); argref += SYMBOL_VALUE (var);
ref = value_at (lookup_pointer_type (type), argref); ref = value_at (lookup_pointer_type (type), argref);
addr = value_as_address (ref); addr = value_as_address (ref);
@ -504,7 +506,8 @@ read_var_value (struct symbol *var, struct frame_info *frame)
break; break;
case LOC_TYPEDEF: case LOC_TYPEDEF:
error (_("Cannot look up value of a typedef")); error (_("Cannot look up value of a typedef `%s'."),
SYMBOL_PRINT_NAME (var));
break; break;
case LOC_BLOCK: case LOC_BLOCK:
@ -530,7 +533,8 @@ read_var_value (struct symbol *var, struct frame_info *frame)
frame); frame);
if (regval == NULL) if (regval == NULL)
error (_("Value of register variable not available.")); error (_("Value of register variable not available for `%s'."),
SYMBOL_PRINT_NAME (var));
addr = value_as_address (regval); addr = value_as_address (regval);
v = allocate_value_lazy (type); v = allocate_value_lazy (type);
@ -540,7 +544,8 @@ read_var_value (struct symbol *var, struct frame_info *frame)
regval = value_from_register (type, regno, frame); regval = value_from_register (type, regno, frame);
if (regval == NULL) if (regval == NULL)
error (_("Value of register variable not available.")); error (_("Value of register variable not available for `%s'."),
SYMBOL_PRINT_NAME (var));
return regval; return regval;
} }
} }
@ -561,7 +566,7 @@ read_var_value (struct symbol *var, struct frame_info *frame)
msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL); msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
if (msym == NULL) if (msym == NULL)
return 0; error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var));
if (overlay_debugging) if (overlay_debugging)
addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (msym), addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (msym),
SYMBOL_OBJ_SECTION (msym)); SYMBOL_OBJ_SECTION (msym));
@ -580,7 +585,8 @@ read_var_value (struct symbol *var, struct frame_info *frame)
return allocate_optimized_out_value (type); return allocate_optimized_out_value (type);
default: default:
error (_("Cannot look up value of a botched symbol.")); error (_("Cannot look up value of a botched symbol `%s'."),
SYMBOL_PRINT_NAME (var));
break; break;
} }

View File

@ -467,14 +467,6 @@ frapy_read_var (PyObject *self, PyObject *args)
} }
GDB_PY_HANDLE_EXCEPTION (except); GDB_PY_HANDLE_EXCEPTION (except);
if (!val)
{
PyErr_Format (PyExc_ValueError,
_("Variable cannot be found for symbol '%s'."),
SYMBOL_NATURAL_NAME (var));
return NULL;
}
return value_to_value_object (val); return value_to_value_object (val);
} }

View File

@ -330,6 +330,9 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
TRY_CATCH (except, RETURN_MASK_ERROR) TRY_CATCH (except, RETURN_MASK_ERROR)
{ {
const struct language_defn *language;
struct value_print_options opts;
/* Avoid value_print because it will deref ref parameters. /* Avoid value_print because it will deref ref parameters.
We just want to print their addresses. Print ??? for We just want to print their addresses. Print ??? for
args whose address we do not know. We pass 2 as args whose address we do not know. We pass 2 as
@ -338,29 +341,21 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
recurse. */ recurse. */
val = read_var_value (sym, frame); val = read_var_value (sym, frame);
annotate_arg_value (val == NULL ? NULL : value_type (val)); annotate_arg_value (value_type (val));
if (val) /* Use the appropriate language to display our symbol,
{ unless the user forced the language to a specific
const struct language_defn *language; language. */
struct value_print_options opts; if (language_mode == language_mode_auto)
language = language_def (SYMBOL_LANGUAGE (sym));
/* Use the appropriate language to display our symbol,
unless the user forced the language to a specific
language. */
if (language_mode == language_mode_auto)
language = language_def (SYMBOL_LANGUAGE (sym));
else
language = current_language;
get_raw_print_options (&opts);
opts.deref_ref = 0;
opts.summary = summary;
common_val_print (val, stb->stream, 2, &opts, language);
ui_out_field_stream (uiout, "value", stb);
}
else else
ui_out_text (uiout, "???"); language = current_language;
get_raw_print_options (&opts);
opts.deref_ref = 0;
opts.summary = summary;
common_val_print (val, stb->stream, 2, &opts, language);
ui_out_field_stream (uiout, "value", stb);
} }
if (except.reason < 0) if (except.reason < 0)
{ {

View File

@ -1488,7 +1488,6 @@ value_repeat (struct value *arg1, int count)
struct value * struct value *
value_of_variable (struct symbol *var, struct block *b) value_of_variable (struct symbol *var, struct block *b)
{ {
struct value *val;
struct frame_info *frame; struct frame_info *frame;
if (!symbol_read_needs_frame (var)) if (!symbol_read_needs_frame (var))
@ -1509,11 +1508,7 @@ value_of_variable (struct symbol *var, struct block *b)
} }
} }
val = read_var_value (var, frame); return read_var_value (var, frame);
if (!val)
error (_("Address of symbol \"%s\" is unknown."), SYMBOL_PRINT_NAME (var));
return val;
} }
struct value * struct value *