This is a fix for PR c++/17132.
If this new argument is set to EVAL_AVOID_SIDE_EFFECTS, then the object's
memory will not be read while picking the best overload match.
gdb/
* eval.c: Update all calls to find_overload_match.
* valarith.c: Likewise.
(value_user_defined_cpp_op, value_user_defined_op): New
argument NOSIDE. Update all callers.
* valops.c (find_overload_match): New argument NOSIDE.
* value.h (find_overload_match): Update signature.
gdb/testsuite
* gdb.cp/pr17132.cc: New file.
* gdb.cp/pr17132.exp: New file.
This constifies a few functions in cli-utils -- get_number_trailer and
friends -- and then fixes the fallout.
2014-07-30 Tom Tromey <tromey@redhat.com>
* breakpoint.c (map_breakpoint_numbers): Update.
* cli/cli-utils.c (get_number_trailer): Make "pp" const. Update.
(get_number_const): New function.
(get_number): Rewrite using get_number_const.
(init_number_or_range): Make "string" const.
(number_is_in_list): Make "list" const.
* cli/cli-utils.h (get_number_const): Declare.
(struct get_number_or_range_state) <string, end_ptr>: Now const.
(init_number_or_range, number_is_in_list): Update.
* printcmd.c (map_display_numbers): Update.
* value.c (value_from_history_ref): Constify.
* value.h (value_from_history_ref): Update.
Hasn't been used in years.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
* value.c (value_contents_equal): Delete function.
* value.h (value_contents_equal): Delete declaration.
It is valid in GNU C to have a VLA in a struct or union type, but gdb
did not handle this.
This patch adds support for these cases in the obvious way.
Built and regtested on x86-64 Fedora 20.
New tests included.
2014-06-04 Tom Tromey <tromey@redhat.com>
* ada-lang.c (ada_template_to_fixed_record_type_1): Use
value_from_contents_and_address_unresolved.
(ada_template_to_fixed_record_type_1): Likewise.
(ada_which_variant_applies): Likewise.
* value.h (value_from_contents_and_address_unresolved): Declare.
* value.c (value_from_contents_and_address_unresolved): New
function.
* gdbtypes.c (is_dynamic_type, resolve_dynamic_type)
<TYPE_CODE_STRUCT, TYPE_CODE_UNION>: New cases.
(resolve_dynamic_struct, resolve_dynamic_union): New functions.
2014-06-04 Tom Tromey <tromey@redhat.com>
* gdb.base/vla-datatypes.exp: Add tests for VLA-in-structure and
VLA-in-union.
* gdb.base/vla-datatypes.c (vla_factory): Add vla_struct,
inner_vla_struct, vla_union types. Initialize objects of those
types and compute their sizes.
* defs.h (enum lval_type): New enumerator "lval_xcallable".
* extension-priv.h (struct extension_language_ops): Add the
xmethod interface.
* extension.c (new_xmethod_worker, clone_xmethod_worker,
get_matching_xmethod_workers, get_xmethod_argtypes,
invoke_xmethod, free_xmethod_worker,
free_xmethod_worker_vec): New functions.
* extension.h: #include "common/vec.h".
New function declarations.
(struct xmethod_worker): New struct.
(VEC (xmethod_worker_ptr)): New vector type.
(xmethod_worker_ptr): New typedef.
(xmethod_worker_vec): Likewise.
* gdbtypes.c (gdbtypes_post_init): Initialize "xmethod" field of
builtin_type.
* gdbtypes.h (enum type_code): New enumerator TYPE_CODE_XMETHOD.
(struct builtin_type): New field "xmethod".
* valarith.c (value_ptradd): Assert that the value argument is not
lval_xcallable.
* valops.c (value_must_coerce_to_target): Return 0 for
lval_xcallable values.
* value.c (struct value): New field XM_WORKER in the field
LOCATION.
(value_address, value_raw_address): Return 0 for lval_xcallable
values.
(set_value_address): Assert that the value is not an
lval_xcallable.
(value_free): Free the associated xmethod worker when freeing
lval_xcallable values.
(set_value_component_location): Assert that the WHOLE value is not
lval_xcallable.
(value_of_xmethod, call_xmethod): New functions.
* value.h: Declare "struct xmethod_worker".
Declare new functions value_of_xmethod, call_xmethod.
This patch fixes a problem that prevented use of the Dwarf unwinders on SPU,
because dwarf2-frame.c common code did not support the situation where the
stack and/or frame pointer is maintained in a *vector* register. This is
because read_addr_from_reg is hard-coded to assume that such pointers can
be read from registers via a simple get_frame_register / unpack_pointer
operation.
Now, there *is* a routine address_from_register that calls into the
appropriate tdep routines to handle pointer values in "weird" registers
like on SPU, but it turns out I cannot simply change dwarf2-frame.c to
use address_from_register. This is because address_from_register uses
value_from_register to create a (temporary) value, and that routine
at some point calls get_frame_id in order to set up that value's
VALUE_FRAME_ID entry.
However, the dwarf2-frame.c read_addr_from_reg routine will be called
during early unwinding (to unwind the frame's CFA), at which point the
frame's ID is not actually known yet! This would cause an assert.
On the other hand, we may notice that VALUE_FRAME_ID is only needed in the
value returned by value_from_register if that value is later used as an
lvalue. But this is obviously never done to the temporary value used in
address_from_register. So, if we could change address_from_register to
not call value_from_register but instead accept constructing a value
that doesn't have VALUE_FRAME_ID set, things should be fine.
To do that, we can change the value_from_register callback to accept
a FRAME_ID instead of a FRAME; the only existing uses of the FRAME
argument were either to extract its frame ID, or its gdbarch. (To
keep a way of getting at the latter, we also change the callback's
type from "f" to "m".) Together with the required follow-on changes
in the existing value_from_register implementations (including the
default one), this seems to fix the problem.
As another minor interface cleanup, I've removed the explicit TYPE
argument from address_from_register. This routine really always
uses a default pointer type, and in the new implementation it -to
some extent- relies on that fact, in that it will now no longer
handle types that require gdbarch_convert_register_p handling.
gdb:
2014-04-17 Ulrich Weigand <uweigand@de.ibm.com>
* gdbarch.sh (value_from_register): Make class "m" instead of "f".
Replace FRAME argument with FRAME_ID.
* gdbarch.c, gdbarch.h: Regenerate.
* findvar.c (default_value_from_register): Add GDBARCH argument;
replace FRAME by FRAME_ID. No longer call get_frame_id.
(value_from_register): Update call to gdbarch_value_from_register.
* value.h (default_value_from_register): Update prototype.
* s390-linux-tdep.c (s390_value_from_register): Update interface
and call to default_value_from_register.
* spu-tdep.c (spu_value_from_register): Likewise.
* findvar.c (address_from_register): Remove TYPE argument.
Do not call value_from_register; use gdbarch_value_from_register
with null_frame_id instead.
* value.h (address_from_register): Update prototype.
* dwarf2-frame.c (read_addr_from_reg): Use address_from_register.
* dwarf2loc.c (dwarf_expr_read_addr_from_reg): Update for
address_from_register interface change.
While working on another patch I realized that value_aggregate_elt's
"name" parameter ought to be const. This patch implements this.
2014-04-14 Tom Tromey <tromey@redhat.com>
* valops.c (value_aggregate_elt, value_struct_elt_for_reference)
(value_namespace_elt, value_maybe_namespace_elt): Make "name"
const.
* value.h (value_aggregate_elt): Update.
PR python/15464
PR python/16113
* valops.c (value_struct_elt_bitpos): New function
* py-type.c (convert_field): Set 'name' attribute of a gdb.Field
object to 'None' if the field name is an empty string ("").
* python/py-value.c (valpy_getitem): Use 'bitpos' and 'type'
attribute to look for a field when 'name' is 'None'.
(get_field_type): New function
testsuite/
* gdb.python/py-type.c: Enhance test case.
* gdb.python/py-value-cc.cc: Likewise
* gdb.python/py-type.exp: Add new tests.
* gdb.python/py-value-cc.exp: Likewise
https://sourceware.org/ml/gdb-patches/2013-12/msg00144.html
The vector of unavailable parts of a value is currently byte based. Given
that we can model a value down to the bit level, we can potentially loose
information with the current implementation. After this patch we model the
unavailable information in bits.
gdb/ChangeLog
* dwarf2loc.c (read_pieced_value): Mark bits, not bytes
unavailable, use correct bit length.
* value.c (struct value): Extend comment on unavailable to
indicate that it is bit based.
(value_bits_available): New function.
(value_bytes_available): Call value_bits_available.
(value_entirely_available): Check against the bit length, not byte
length.
(mark_value_bits_unavailable): New function.
(mark_value_bytes_unavailable): Move contents to
mark_value_bits_unavailable, call to same.
(memcmp_with_bit_offsets): New function.
(value_available_contents_bits_eq): New function, takes the
functionality from value_available_contents_eq but uses
memcmp_with_bit_offsets now, and is bit not byte based.
(value_available_contents_eq): Move implementation into
value_available_contents_bits_eq, call to same.
(value_contents_copy_raw): Work on bits, not bytes.
(unpack_value_bits_as_long_1): Check availability in bits, not
bytes.
* value.h (value_bits_available): Declare new function.
(mark_value_bits_unavailable): Declare new function.
gdb/testsuite/ChangeLog
* gdb.trace/unavailable-dwarf-piece.c: New file.
* gdb.trace/unavailable-dwarf-piece.exp: New file.
Currently, in some scenarios, GDB prints <optimized out> when printing
outer frame registers. An <optimized out> register is a confusing
concept. What this really means is that the register is
call-clobbered, or IOW, not saved by the callee. This patch makes GDB
say that instead.
Before patch:
(gdb) p/x $rax $1 = <optimized out>
(gdb) info registers rax
rax <optimized out>
After patch:
(gdb) p/x $rax
$1 = <not saved>
(gdb) info registers rax
rax <not saved>
However, if for some reason the debug info describes a variable as
being in such a register (**), we still want to print <optimized out>
when printing the variable. IOW, <not saved> is reserved for
inspecting registers at the machine level. The patch uses
lval_register+optimized_out to encode the not saved registers, and
makes it so that optimized out variables always end up in
!lval_register values.
** See <https://sourceware.org/ml/gdb-patches/2012-08/msg00787.html>.
Current/recent enough GCC doesn't mark variables/arguments as being in
call-clobbered registers in the ranges corresponding to function
calls, while older GCCs did. Newer GCCs will just not say where the
variable is, so GDB will end up realizing the variable is optimized
out.
frame_unwind_got_optimized creates not_lval optimized out registers,
so by default, in most cases, we'll see <optimized out>.
value_of_register is the function eval.c uses for evaluating
OP_REGISTER (again, $pc, etc.), and related bits. It isn't used for
anything else. This function makes sure to return lval_register
values. The patch makes "info registers" and the MI equivalent use it
too. I think it just makes a lot of sense, as this makes it so that
when printing machine registers ($pc, etc.), we go through a central
function.
We're likely to need a different encoding at some point, if/when we
support partially saved registers. Even then, I think
value_of_register will still be the spot to tag the intention to print
machine register values differently.
value_from_register however may also return optimized out
lval_register values, so at a couple places where we're computing a
variable's location from a dwarf expression, we convert the resulting
value away from lval_register to a regular optimized out value.
Tested on x86_64 Fedora 17
gdb/
2013-10-02 Pedro Alves <palves@redhat.com>
* cp-valprint.c (cp_print_value_fields): Adjust calls to
val_print_optimized_out.
* jv-valprint.c (java_print_value_fields): Likewise.
* p-valprint.c (pascal_object_print_value_fields): Likewise.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full)
<DWARF_VALUE_REGISTER>: If the register was not saved, return a
new optimized out value.
* findvar.c (address_from_register): Likewise.
* frame.c (put_frame_register): Tweak error string to say the
register was not saved, rather than optimized out.
* infcmd.c (default_print_one_register_info): Adjust call to
val_print_optimized_out. Use value_of_register instead of
get_frame_register_value.
* mi/mi-main.c (output_register): Use value_of_register instead of
get_frame_register_value.
* valprint.c (valprint_check_validity): Likewise.
(val_print_optimized_out): New value parameter. If the value is
lval_register, print <not saved> instead.
(value_check_printable, val_print_scalar_formatted): Adjust calls
to val_print_optimized_out.
* valprint.h (val_print_optimized_out): New value parameter.
* value.c (struct value) <optimized_out>: Extend comment.
(error_value_optimized_out): New function.
(require_not_optimized_out): Use it. Use a different string for
lval_register values.
* value.h (error_value_optimized_out): New declaration.
* NEWS: Mention <not saved>.
gdb/testsuite/
2013-10-02 Pedro Alves <palves@redhat.com>
* gdb.dwarf2/dw2-reg-undefined.exp <pattern_rax_rbx_rcx_print,
pattern_rax_rbx_rcx_info>: Set to "<not saved>".
* gdb.mi/mi-reg-undefined.exp (opt_out_pattern): Delete.
(not_saved_pattern): New.
Replace use of the former with the latter.
gdb/doc/
2013-10-02 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Registers): Expand description of saved registers
in frames. Explain <not saved>.
This is the patch to add new option '--skip-unavailable' to MI
commands '-stack-list-{locals, arguments, variables}'. This patch
extends list_args_or_locals to add a new parameter 'skip_unavailable',
and don't list locals or arguments if values are unavailable and
'skip_unavailable' is true.
This is inspecting a trace frame (tfind mode), where only a few
locals have been collected.
-stack-list-locals, no switch vs new switch:
-stack-list-locals --simple-values
^done,locals=[{name="array",type="unsigned char [2]"},{name="i",type="int",value="<unavailable>"}]
-stack-list-locals --skip-unavailable --simple-values
^done,locals=[{name="array",type="unsigned char [2]"}]
-stack-list-arguments, no switch vs new switch:
-stack-list-arguments --simple-values
^done,stack-args=[frame={level="0",args=[{name="j",type="int",value="4"},{name="s",type="char *",value="<unavailable>"}]},frame={level="1",args=[]}]
-stack-list-arguments --skip-unavailable --simple-values
^done,stack-args=[frame={level="0",args=[{name="j",type="int",value="4"}]},frame={level="1",args=[]}]
-stack-list-variables, no switch vs new switch:
-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 --skip-unavailable --simple-values
^done,variables=[{name="j",arg="1",type="int",value="4"},{name="array",type="unsigned char [2]"}]
tests are added to test these new options.
gdb:
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'.
gdb/doc:
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.
gdb/testsuite:
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'.
in order to match GNU Coding Standards.
2013-08-13 Sergio Durigan Junior <sergiodj@redhat.com>
* value.h (create_internalvar_type_lazy): Adjust prototype
declaration.
This patch fixes PR symtab/15719.
The bug is that "watch -location" crashes on a certain expression.
The problem is that fetch_subexp_value is catching an exception.
For ordinary watchpoints this is ok; but for location watchpoints,
it is better for the exception to propagate.
Built and regtested on x86-64 Fedora 18.
New test case included.
PR symtab/15719:
* breakpoint.c (update_watchpoint, watchpoint_check)
(watch_command_1): Update.
* eval.c (fetch_subexp_value): Add "preserve_errors"
parameter.
* ppc-linux-nat.c (check_condition): Update.
* value.h (fetch_subexp_value): Update.
* gdb.base/watchpoint.c (struct foo5): New.
(nullptr): New global.
* gdb.base/watchpoint.exp (test_watch_location): Add test.
ada-lang.c:coerce_unspec_val_to_type does:
if (value_lazy (val)
|| TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
result = allocate_value_lazy (type);
else
{
result = allocate_value (type);
memcpy (value_contents_raw (result), value_contents (val),
TYPE_LENGTH (type));
}
set_value_component_location (result, val);
set_value_bitsize (result, value_bitsize (val));
set_value_bitpos (result, value_bitpos (val));
set_value_address (result, value_address (val));
set_value_optimized_out (result, value_optimized_out (val));
Notice that before value_optimized_out was made to auto-fetch lazy
values, VAL would end up still lazy if it was lazy on entry. It's not
really a problem here if VAL is lazy, and VAL->optimized_out is 0,
because RESULT is also left lazy. IOW, this just wants to copy the
VAL->optimized_out flag to RESULT->optimized_out, nothing else.
As a side-effect of the change in value_optimized_out, the following
testcase now regresses. Consider:
type Small is range -64 .. 63;
for Small'Size use 7;
type Arr is array (1..10) of Small;
pragma Pack (Arr);
type Arr_Ptr is access Arr;
An_Arr_Ptr : Arr_Ptr := new Arr'(10, 20, 30, 40, 50, 60, 62, 63,
-23, 42);
Trying to print one element of An_Arr_Ptr yields:
(gdb) p an_arr_ptr(3)
Cannot access memory at address 0x0
The patch adds the value_optimized_out_const function for that,
allowing us to avoid trying to fetch a value at a dummy address.
(I found this out by grepping for set_value_optimized_out and trying
to convert the uses I found to instead allocate the value with
allocate_optimized_out_value.)
Tested on x86_64 Fedora 17.
gdb/
2013-07-09 Pedro Alves <palves@redhat.com>
* ada-lang.c (coerce_unspec_val_to_type): Use
value_optimized_out_const.
* value.c (value_optimized_out_const): New function.
* value.h (value_optimized_out_const): New declaration.
Enum values rename as well. All uses updated.
* valprint.h (value_print_options): Rename member pretty to
pretty format. Rename member prettyprint_arrays to
prettyformat_arrays. Rename member prettyprint_structs to
prettyformat_structs. All uses updated.
(get_no_prettyformat_print_options): Renamed from
get_raw_print_options.
* valprint.c (get_no_prettyformat_print_options): Renamed from
get_raw_print_options. All callers updated.
(show_prettyformat_structs): Renamed from show_prettyprint_structs.
All callers updated.
(show_prettyformat_arrays): Renamed from show_prettyprint_arrays.
All callers updated.
(_initialize_valprint): Improve help text for "set print pretty" and
"set print arrays".
testsuite/
* gdb.base/default.exp: Update expected output of "show print array"
and "show print pretty".
PR tui/14880 shows a reproducer that triggers this assertion:
int
value_available_contents_eq (const struct value *val1, int offset1,
const struct value *val2, int offset2,
int length)
{
int idx1 = 0, idx2 = 0;
/* This routine is used by printing routines, where we should
already have read the value. Note that we only know whether a
value chunk is available if we've tried to read it. */
gdb_assert (!val1->lazy && !val2->lazy);
(top-gdb) bt
#0 internal_error (file=0x88a26c "../../src/gdb/value.c", line=549, string=0x88a220 "%s: Assertion `%s' failed.") at ../../src/gdb/utils.c:844
#1 0x000000000057b9cd in value_available_contents_eq (val1=0x10fa900, offset1=0, val2=0x10f9e10, offset2=0, length=8) at ../../src/gdb/value.c:549
#2 0x00000000004fd756 in tui_get_register (frame=0xd5c430, data=0x109a548, regnum=0, changedp=0x109a560) at ../../src/gdb/tui/tui-regs.c:736
#3 0x00000000004fd111 in tui_check_register_values (frame=0xd5c430) at ../../src/gdb/tui/tui-regs.c:521
#4 0x0000000000501884 in tui_check_data_values (frame=0xd5c430) at ../../src/gdb/tui/tui-windata.c:234
#5 0x00000000004f976f in tui_selected_frame_level_changed_hook (level=1) at ../../src/gdb/tui/tui-hooks.c:222
#6 0x00000000006f0681 in select_frame (fi=0xd5c430) at ../../src/gdb/frame.c:1490
#7 0x00000000005dd94b in up_silently_base (count_exp=0x0) at ../../src/gdb/stack.c:2268
#8 0x00000000005dd985 in up_command (count_exp=0x0, from_tty=1) at ../../src/gdb/stack.c:2280
#9 0x00000000004dc5cf in do_cfunc (c=0xd3f720, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:113
#10 0x00000000004df664 in cmd_func (cmd=0xd3f720, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:1888
#11 0x00000000006e43e1 in execute_command (p=0xc7e6c2 "", from_tty=1) at ../../src/gdb/top.c:489
The fix is to fetch the value before comparing the contents. The
comment additions to value.h explain why it can't be
value_available_contents_eq itself that fetches the contents.
Tested on x86_64 Fedora 17.
gdb/
2013-06-28 Pedro Alves <palves@redhat.com>
PR tui/14880
* tui/tui-regs.c (tui_get_register): Fetch register value contents
before checking whether they're available.
* value.c (value_available_contents_eq): Change comment.
* value.h (value_available_contents_eq): Expand comment.
pointer to expression string to parse_exp_1.
(create_excep_cond_exprs): Likewise.
* ax-gdb.c (agent_eval_command_one): Likewise.
(maint_agent_printf_command): Likewise.
Constify much of the string handling/parsing.
* breakpoint.c (set_breakpoint_condition): Pass const
pointer to expression string to parse_exp_1.
(update_watchpoint): Likewise.
(parse_cmd_to_aexpr): Constify string handling.
Pass const pointer to parse_exp_1.
(init_breakpoint_sal): Pass const pointer to parse_exp_1.
(find_condition_and_thread): Likewise.
Make TOK const.
(watch_command_1): Make "arg" const.
Constify string handling.
Copy the expression string instead of changing the input
string.
(update_breakpoint_location): Pass const pointer to
parse_exp_1.
* eval.c (parse_and_eval_address): Make "exp" const.
(parse_to_comma_and_eval): Make "expp" const.
(parse_and_eval): Make "exp" const.
* expression.h (parse_expression): Make argument const.
(parse_exp_1): Make first argument const.
* findcmd.c (parse_find_args): Treat "args" as const.
* linespec.c (parse_linespec): Pass const pointer to
linespec_expression_to_pc.
(linespec_expression_to_pc): Make "exp_ptr" const.
* parse.c (parse_exp_1): Make "stringptr" const.
Make a copy of the expression to pass to parse_exp_in_context until
this whole interface can be constified.
(parse_expression): Make "string" const.
* printcmd.c (ui_printf): Treat "arg" as const.
Handle const strings.
* tracepoint.c (validate_actionline): Pass const pointer to
all calls to parse_exp_1.
(encode_actions_1): Likewise.
* value.h (parse_to_comma_and_eval): Make argument const.
(parse_and_eval_address): Likewise.
(parse_and_eval): Likewise.
* varobj.c (varobj_create): Pass const pointer to parse_exp_1.
(varobj_set_value): Likewise.
* cli/cli-cmds.c (disassemble_command): Treat "arg" as const and
constify string handling.
Pass const pointers to parse_and_eval_address and
parse_to_comman_and_eval.
* cli/cli-utils.c (skip_to_space): Rename to ...
(skip_to_space_const): ... this. Handle const strings.
* cli/cli-utils.h (skip_to_space): Turn into macro which invokes
skip_to_space_const.
(skip_to_space_const): Declare.
* common/format.c (parse_format_string): Make "arg" const.
Handle const strings.
* common/format.h (parse_format_string): Make "arg" const.
* gdbserver/ax.c (ax_printf): Make "format" const.
* python/python.c (gdbpy_parse_and_eval): Do not make a copy
of the expression string.
gdb/
* sparc-tdep.c (sparc32_return_value): Handle writing return value when
using RETURN_VALUE_ABI_PRESERVES_ADDRESS.
* value.c (struct_return_convention): New function.
(using_struct_return): Implement in terms of struct_return_convention.
* value.h (struct_return_convention): Declare.
* stack.c (return_command): Allow successful overriding of the return
value when RETURN_VALUE_ABI_PRESERVES_ADDRESS.
* value.h: Remove unused argument 'lax' from the declaration of
find_overload_match.
* eval.c (value_subexp_standard): Do not pass a 'lax' argument
to find_overload_match.
* valarith.c (value_user_defined_cpp_op): Do not pass a 'lax'
argument to find_overload_match.
gdb/ChangeLog
* valarith.c (value_vector_widen): New function for replicating a
scalar into a vector.
(value_binop): Use value_vector_widen to widen scalar to vector
rather than casting, this better matches gcc C behaviour.
* valops.c (value_casst): Update logic for casting between vector
types, and for casting from scalar to vector, try to match gcc C
behaviour.
* value.h (value_vector_widen): Declare.
* opencl-lang.c (opencl_value_cast): New opencl specific casting
function, handle special case for casting scalar to vector.
(opencl_relop): Use opencl_value_cast.
(evaluate_subexp_opencl): Use opencl_value_cast instead of
value_cast, and handle BINOP_ASSIGN, UNOP_CAST, and UNOP_CAST_TYPE
in order to use opencl_value_cast.
gdb/testsuite/ChangeLog
* gdb.base/gnu_vector.c: New variable for use in tests.
* gdb.base/gnu_vector.exp: Update and extend tests to reflect
changes in scalar to vector casting and widening.
* gdb.python/py-type.c: New variables for use in tests.
* gdb.python/py-type.exp: Update vector related tests to reflect
changes in scalar to vector casting and widening.
Two modifications:
1. The addition of 2013 to the copyright year range for every file;
2. The use of a single year range, instead of potentially multiple
year ranges, as approved by the FSF.
(_initialize_breakpoint): Use it.
* value.c (complete_internalvar): New function.
* value.h (complete_internalvar): Declare.
testsuite
* gdb.base/condbreak.exp: Add tests for "condition" completion.
* breakpoint.h (bp_location): Add related_address member.
* inferior.h (get_return_value): Take a pointer to struct value
instead of struct type for the function requested.
* value.h (using_struct_return): Likewise.
* gdbarch.sh (return_value): Take a pointer to struct value
instead of struct type for the function requested.
* breakpoint.c (set_breakpoint_location_function): Initialize
related_address for bp_gnu_ifunc_resolver breakpoints.
* elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the
requested function's address to gdbarch_return_value.
* eval.c (evaluate_subexp_standard): Pass the requested
function's address to using_struct_return.
* infcall.c (call_function_by_hand): Pass the requested
function's address to using_struct_return and
gdbarch_return_value.
* infcmd.c (get_return_value): Take a pointer to struct value
instead of struct type for the function requested.
(print_return_value): Update accordingly.
(finish_command_continuation): Likewise.
* stack.c (return_command): Pass the requested function's
address to using_struct_return and gdbarch_return_value.
* value.c (using_struct_return): Take a pointer to struct value
instead of struct type for the function requested. Pass the
requested function's address to gdbarch_return_value.
* python/py-finishbreakpoint.c (finish_breakpoint_object):
New function_value member, replacing function_type.
(bpfinishpy_dealloc): Update accordingly.
(bpfinishpy_pre_stop_hook): Likewise.
(bpfinishpy_init): Likewise. Record the requested function's
address.
* mips-tdep.c (mips_fval_reg): New enum.
(mips_o32_push_dummy_call): For MIPS16 FP doubles do not swap
words put in GP registers.
(mips_o64_push_dummy_call): Update a comment.
(mips_o32_return_value): Take a pointer to struct value instead
of struct type for the function requested and use it to check if
using the MIPS16 calling convention. Return the designated
general purpose registers for floating-point values returned in
MIPS16 mode.
(mips_o64_return_value): Likewise.
* ppc-tdep.h (ppc_sysv_abi_return_value): Update prototype.
(ppc_sysv_abi_broken_return_value): Likewise.
(ppc64_sysv_abi_return_value): Likewise.
* alpha-tdep.c (alpha_return_value): Take a pointer to struct
value instead of struct type for the function requested.
* amd64-tdep.c (amd64_return_value): Likewise.
* amd64-windows-tdep.c (amd64_windows_return_value): Likewise.
* arm-tdep.c (arm_return_value): Likewise.
* avr-tdep.c (avr_return_value): Likewise.
* bfin-tdep.c (bfin_return_value): Likewise.
* cris-tdep.c (cris_return_value): Likewise.
* frv-tdep.c (frv_return_value): Likewise.
* h8300-tdep.c (h8300_return_value): Likewise.
(h8300h_return_value): Likewise.
* hppa-tdep.c (hppa32_return_value): Likewise.
(hppa64_return_value): Likewise.
* i386-tdep.c (i386_return_value): Likewise.
* ia64-tdep.c (ia64_return_value): Likewise.
* iq2000-tdep.c (iq2000_return_value): Likewise.
* lm32-tdep.c (lm32_return_value): Likewise.
* m32c-tdep.c (m32c_return_value): Likewise.
* m32r-tdep.c (m32r_return_value): Likewise.
* m68hc11-tdep.c (m68hc11_return_value): Likewise.
* m68k-tdep.c (m68k_return_value): Likewise.
(m68k_svr4_return_value): Likewise.
* m88k-tdep.c (m88k_return_value): Likewise.
* mep-tdep.c (mep_return_value): Likewise.
* microblaze-tdep.c (microblaze_return_value): Likewise.
* mn10300-tdep.c (mn10300_return_value): Likewise.
* moxie-tdep.c (moxie_return_value): Likewise.
* mt-tdep.c (mt_return_value): Likewise.
* ppc-linux-tdep.c (ppc_linux_return_value): Likewise.
* ppc-sysv-tdep.c (ppc_sysv_abi_return_value): Likewise.
(ppc_sysv_abi_broken_return_value): Likewise.
(ppc64_sysv_abi_return_value): Likewise.
* ppcnbsd-tdep.c (ppcnbsd_return_value): Likewise.
* rl78-tdep.c (rl78_return_value): Likewise.
* rs6000-aix-tdep.c (rs6000_return_value): Likewise.
* rx-tdep.c (rx_return_value): Likewise.
* s390-tdep.c (s390_return_value): Likewise.
* score-tdep.c (score_return_value): Likewise.
* sh-tdep.c (sh_return_value_nofpu): Likewise.
(sh_return_value_fpu): Likewise.
* sh64-tdep.c (sh64_return_value): Likewise.
* sparc-tdep.c (sparc32_return_value): Likewise.
* sparc64-tdep.c (sparc64_return_value): Likewise.
* spu-tdep.c (spu_return_value): Likewise.
* tic6x-tdep.c (tic6x_return_value): Likewise.
* v850-tdep.c (v850_return_value): Likewise.
* vax-tdep.c (vax_return_value): Likewise.
* xstormy16-tdep.c (xstormy16_return_value): Likewise.
* xtensa-tdep.c (xtensa_return_value): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/testsuite/
* gdb.base/return-nodebug.exp: Also test float and double types.
Tom Tromey <tromey@redhat.com>
* ax-gdb.c (gen_expr): Clean up code to handle internal variables
and to compile agent expressions.
* infrun.c (siginfo_make_value): New argument `ignore'.
(siginfo_funcs): New struct.
(_initialize_infrun): New argument when calling
`create_internalvar_type_lazy'.
* thread.c (thread_id_make_value): New argument `ignore'.
(thread_funcs): New struct.
(_initialize_thread): New argument when calling
`create_internalvar_type_lazy'.
* tracepoint.c (sdata_make_value): New argument `ignore'.
(sdata_funcs): New struct.
(_initialize_tracepoint): New argument when calling
`create_internalvar_type_lazy'.
* value.c (make_value): New struct.
(create_internalvar_type_lazy): New argument `data'.
(compile_internalvar_to_ax): New function.
(value_of_internalvar): Properly handling `make_value' case.
(clear_internalvar): Likewise.
(show_convenience): Adding `TRY_CATCH' block.
* value.h (internalvar_make_value): Delete, replace by...
(struct internalvar_funcs): ... this.
(create_internalvar_type_lazy) <fun>: Delete argument.
(create_internalvar_type_lazy) <funcs>, <data>: New arguments.
(compile_internalvar_to_ax): New function.
* windows-tdep.c (tlb_make_value): New argument `ignore'.
(tlb_funcs): New struct.
(_initialize_windows_tdep): New argument when calling
`create_internalvar_type_lazy'.
2012-04-14 Anton Gorenkov <xgsa@yandex.ru>
PR mi/13393
* gdb.texinfo (Print Settings): Extend the description for "set print
object".
(GDB/MI Variable Objects): Extend the description for -var-create and
-var-list-children.
gdb/testsuite/ChangeLog:
2012-04-14 Anton Gorenkov <xgsa@yandex.ru>
PR mi/13393
* gdb.mi/mi-var-rtti.cc: New file.
* gdb.mi/mi-var-rtti.exp: New file.
* lib/mi-support.exp (mi_varobj_update_with_child_type_change): New
function.
(mi_varobj_update_with_type_change): updated to avoid code duplication.
gdb/ChangeLog:
2012-04-14 Anton Gorenkov <xgsa@yandex.ru>
PR mi/13393
* value.c (value_actual_type): New function.
* value.h (value_actual_type): New declaration.
* varobj.c (update_type_if_necessary): New function.
(varobj_create): Call value_actual_type instead of
value_type.
(install_dynamic_child): distinct changed and type changed MI variable
objects.
(update_dynamic_varobj_children): Updated for install_dynamic_child
change. All callers updated.
(varobj_update): Support for MI variable object type change if
the value changed and RTTI is used to determine the type.
(create_child_with_value): Call value_actual_type instead of
value_type.
(adjust_value_for_child_access): Extended with a new parameter which
specify whether the given value should be casted to enclosing type.
All callers updated.
Consider the following declaration:
type Small is new Integer range 0 .. 2 ** 4 - 1;
type Simple_Array is array (1 .. 4) of Small;
pragma Pack (Simple_Array);
SA : Simple_Array := (1, 2, 3, 4);
Trying to change the value of one of the elements in the packed array
causes the debugger to crash:
(gdb) set sa(3) := 9
[1] 4880 segmentation fault gdb -q foo
The circumstances leading to the crash are as follow:
. ada_evaluate_subexp creates a value corresponding to "sa(3)".
. ada_evaluate_subexp then tries to assign 9 to this value, and
for this calls value_assign (via ada_value_assign).
. Because the array is packed, the destination value is 3 bits long,
and as a result, value_assign uses the parent to determine that
element byte address and offset:
| if (value_bitsize (toval))
| {
| struct value *parent = value_parent (toval);
|
| changed_addr = value_address (parent) + value_offset (toval);
The destination value (corresponding to "sa(3)") was incorrectly created
by ada-lang.c:ada_value_primitive_packed_val, because the "parent" was
left as NULL. So, when we try to dereference it to get the parent address,
GDB crashed.
The first part of the fix therefore consists in setting that field.
This required the addition of a new "setter" in value.[hc]. It fixes
the crash, but is still not sufficient for the assignment to actually
work.
The second part of the problem came from the fact that value_assign
seems to expect the "child"'s address to be equal to the parent's address,
with the difference being the offset. Unfortunately, this requirement was
not followed by ada_value_primitive_packed_val, so the second part of
the fix consisted in fixing that.
Still, this was not sufficient, because it caused a regression when
trying to perform an aggregate assignment of a packed array of packed
record. The key element here is the nesting of packed entities.
Looking at the way ada_value_primitive_packed_val creates the value
of each sub-component, one can see that the value's offset is set
to the offset compared to the start of the parent. This was meant to
match what value_primitive_field does as well.
So, with our array of records, if the record offset was 2, and if
the field we're interested in that record is at offset 1, the record
value's offset would be set to 2, and the field value's offset would
be set to 1. But the address for both values would be left to the
array's address. This is where things start breaking down, because
the value_address function for our field value would return the
address of the array + 1, instead of + 3.
This is what causes the final issue, here, because ada-lang.c's
value_assign_to_component needs to compute the offset of the
subcomponent compared to the top-level aggregate's start address
(the array in our case). And it does so by subtracting the array's
address from the sub-component's address. When you have two levels
of packed components, and the mid-level component is at an offset of
the top-level component, things didn't work, because the component's
address was miscomputed (the parent's offset is missing).
The fix consists is fixing value_address to match the work done by
value_primitive_field (where we ignore the parent's offset).
gdb/ChangeLog:
* value.h (set_value_parent): Add declaration.
* value.c (set_value_parent): New function.
(value_address): If VALUE->PARENT is not NULL, then use it as
the base address instead of VALUE->LOCATION.address.
* ada-lang.c (ada_value_primitive_packed_val): Keep V's address
the same as OBJ's address. Adjust V's offset accordingly.
Set V's parent.
gdb/testsuite/ChangeLog:
* gdb.ada/set_pckd_arr_elt: New testcase.
The purpose of this patch is to better support renamings in the
"info locals" command. Consider ...
procedure Foo is
GV : Integer renames Pck.Global_Variable;
begin
Increment (GV); -- STOP
end Foo;
... Pck.Global_Variable is just an integer. After having stopped at
the "STOP" line, "info locals" yields:
(gdb) info locals
gv = <error reading variable gv (Cannot access memory at address 0xffffffffffffffff)>
In reality, two things are happening:
(1) Variable "GV" does not exist, which is normal, since there is
"GV" the renaming of another variable;
(2) But to allow the user access to that renaming the same way
the code has, the compiler produces an artificial variable
whose name encodes the renaming:
gv___XR_pck__global_variable___XE
For practical reasons, the artificial variable itself is given
irrelevant types and addresses.
But the "info locals" command does not act as if it was a short-cut
of "foreach VAR in locals, print VAR". Instead it gets the value of
each VAR directly, which does not work in this case, since the variable
is artificial and needs to be decoded first.
This patch makes the "read_var_value" routine language-specific.
The old implementation of "read_var_value" gets renamed to
"default_read_var_value" and all languages now use it (unchanged
behavior), except for Ada. In Ada, the new function ada_read_var_value
checks if we have a renaming, and if so, evaluates its value, or else
defers to default_read_var_value.
gdb/ChangeLog:
* language.h (struct language_defn): New "method" la_read_var_value.
* findvar.c: #include "language.h".
(default_read_var_value): Renames read_var_value. Rewrite
function description.
(read_var_value): New function.
* value.h (default_read_var_value): Add prototype.
* ada-lang.c (ada_read_renaming_var_value, ada_read_var_value):
New functions.
(ada_language_defn): Add entry for la_read_var_value.
* c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c,
* m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update
language_defn structures to add entry for new la_read_var_value
field.
* c-valprint.c (c_value_print): Use value_rtti_indirect_type
instead of value_rtti_target_type.
* eval.c (evaluate_subexp_standard): Use value_rtti_indirect_type
instead of value_rtti_target_type.
* typeprint.c (whatis_exp): Use value_rtti_indirect_type instead of
value_rtti_target_type.
* valops.c (value_ind): Extract function readjust_indirect_value_type.
(value_rtti_target_type): Rename to ...
(value_rtti_indirect_type): ... here and make it indirect. Update
function comment.
* value.c (readjust_indirect_value_type): New function.
(coerce_ref): Support for enclosing type setting for references
with readjust_indirect_value_type.
* value.h (readjust_value_type): New declaration.
(value_rtti_target_type): Rename to ...
(value_rtti_indirect_type): ... here.
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
gdb/ChangeLog:
* value.h (read_frame_register_value): Add declaration.
* findvar.c (read_frame_register_value): New function.
(value_from_register): Use read_frame_register_value
instead of get_frame_register_value + value_contents_copy
to get value contents.
* eval.c (evaluate_subexp_standard): Do not construct
an array of types; pass the value array directly to
find_overload_match.
* gdbtypes.h (NULL_POINTER_CONVERSION_BADNESS): Declare.
(rank_function): Take an array of values instead of types.
(rank_one_type): Add struct value * parameter.
* gdbtypes.c (NULL_POINTER_CONVERSION_BADNESS): Define.
(rank_function): For each argument, pass the argument's
value to rank_one_type.
(rank_one_type): Add VALUE parameter.
If the parameter type is a pointer and the argument type
is an integer, return NULL_POINTER_CONVERSION_BADNESS if
VALUE is zero.
Update all calls to rank_one_type, passing NULL for new
VALUE parameter.
* valarith.c (value_user_defined_cpp_op): Do not construct
an array of types; pass the value array directly to
find_overload_match.
* valops.c (find_overload_method_list): Take an array of
values instead of types.
Save the type of OBJP for later use.
Update calls to find_oload_champ, and find_oload_champ_namespace.
(find_oload_champ_namespace): Take an array of values instead
of types.
(find_oload_champ_namespace_loop): Likewise.
(find_oload_champ): Likewise.
(classify_oload_match): Inspect all arguments
until INCOMPATIBLE is found. Return the worst badness found
otherwise.
(compare_parameters): Update call to rank_one_type.
* value.h (find_overload_match): Take an array of values instead
of types.