1. 17 Jan, 2019 1 commit
    • Tom Tromey's avatar
      Replace "the the" with "the" · 6471e7d2
      Tom Tromey authored
      This replaces "the the" with "the" in various comments.
      
      Tested by rebuilding.  This didn't test the solib-dsbt.c change, but
      it looks harmless.
      
      gdb/ChangeLog
      2019-01-17  Tom Tromey  <tromey@bapiya>
      
      	* valprint.c: Replace "the the" with "the".
      	* symtab.c: Replace "the the" with "the".
      	* solib.c: Replace "the the" with "the".
      	* solib-dsbt.c: Replace "the the" with "the".
      	* linespec.c: Replace "the the" with "the".
      	* dwarf2loc.h: Replace "the the" with "the".
      	* amd64-windows-tdep.c: Replace "the the" with "the".
      	* aarch64-tdep.c: Replace "the the" with "the".
      6471e7d2
  2. 01 Jan, 2019 1 commit
    • Joel Brobecker's avatar
      Update copyright year range in all GDB files. · 42a4f53d
      Joel Brobecker authored
      This commit applies all changes made after running the gdb/copyright.py
      script.
      
      Note that one file was flagged by the script, due to an invalid
      copyright header
      (gdb/unittests/basic_string_view/element_access/char/empty.cc).
      As the file was copied from GCC's libstdc++-v3 testsuite, this commit
      leaves this file untouched for the time being; a patch to fix the header
      was sent to gcc-patches first.
      
      gdb/ChangeLog:
      
      	Update copyright year range in all GDB files.
      42a4f53d
  3. 06 Sep, 2018 1 commit
    • Simon Marchi's avatar
      compile: Remove non-const reference parameters · d82b3862
      Simon Marchi authored
      As mentioned here:
      
        https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Avoid_non-const_reference_parameters.2C_use_pointers_instead
      
      we prefer to avoid non-const references.  This patch changes the
      non-const references I could find in the compile/ directory, either by
      making them rvalue-reference (&&) or changing them to pointers.
      
      I'd say all the changes are pretty obvious, except the one in
      compile_cplus_instance::enter_scope which might require more attention.
      
      gdb/ChangeLog:
      
      	* compile/compile-c.h (generate_c_for_variable_locations):
      	Change reference to pointer.
      	* compile/compile-c-support.c (compile_program) <compute>:
      	Likewise.
      	* compile/compile-c-symbols.c (generate_vla_size): Likewise.
      	(generate_c_for_for_one_variable): Likewise
      	(generate_c_for_variable_locations): Likewise
      	* compile/compile-c-types.c (compile_c_instance::convert_type):
      	Likewise
      	* compile/compile-cplus-symbols.c (convert_one_symbol):
      	std::move the scope passed to enter_scope.
      	* compile/compile-cplus-types.c
      	(compile_cplus_instance::enter_scope): Make parameter
      	rvalue-reference.
      	(compile_cplus_instance::new_scope): Change reference to
      	pointer.
      	(compile_cplus_instance::convert_type): Likewise
      	(compile_cplus_convert_typedef): std::move the scope passed to
      	enter_scope.
      	(compile_cplus_convert_struct_or_union): Likewise.
      	(compile_cplus_convert_enum): Likewise.
      	(compile_cplus_convert_namespace): Likewise.
      	* compile/compile-cplus.h (compile_cplus_instance)
      	<enter_scope>: Make parameter rvalue-reference.
      	* compile/compile-internal.h (compile_instance)
      	<get_cached_type>: Likewise
      	* compile/compile-loc2c.c (push): Likewise
      	(pushf): Likewise
      	(unary): Likewise
      	(binary): Likewise
      	(print_label): Likewise
      	(pushf_register_address): Likewise
      	(pushf_register): Likewise
      	(do_compile_dwarf_expr_to_c): Likewise
      	(compile_dwarf_expr_to_c): Likewise
      	(compile_dwarf_bounds_to_c): Likewise
      	* compile/compile.c (compile_instance::get_cached_type):
      	Likewise
      	* compile/compile.h (compile_dwarf_expr_to_c): Likewise.
      	(compile_dwarf_bounds_to_c): Likewise
      	* dwarf2loc.c (locexpr_generate_c_location): Likewise.
      	(dwarf2_compile_property_to_c): Likewise
      	* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise
      	* symtab.h (struct symbol_computed_ops) <generate_c_location>:
      	Likewise
      d82b3862
  4. 05 Sep, 2018 1 commit
    • Tom de Vries's avatar
      [gdb/exp] Handle DW_OP_GNU_variable_value refs to abstract dies · e4a62c65
      Tom de Vries authored
      Consider a vla variable 'a' in function f1:
      ...
       <2><1a7>: Abbrev Number: 11 (DW_TAG_variable)
          <1a8>   DW_AT_description : a
          <1aa>   DW_AT_abstract_origin: <0x311>
      ...
      with abstract origin 'a':
      ...
       <2><311>: Abbrev Number: 3 (DW_TAG_variable)
          <312>   DW_AT_name        : a
          <317>   DW_AT_type        : <0x325>
      ...
      and inherited abstract vla type:
      ...
       <1><325>: Abbrev Number: 9 (DW_TAG_array_type)
          <326>   DW_AT_type        : <0x33a>
       <2><32e>: Abbrev Number: 10 (DW_TAG_subrange_type)
          <32f>   DW_AT_type        : <0x2ea>
          <333>   DW_AT_upper_bound : 5 byte block: fd 1b 3 0 0
                                      (DW_OP_GNU_variable_value: <0x31b>)
      ...
      where the upper bound refers to this artificial variable D.1922 without location
      attribute:
      ...
       <2><31b>: Abbrev Number: 8 (DW_TAG_variable)
          <31c>   DW_AT_description : (indirect string, offset: 0x39a): D.1922
          <320>   DW_AT_type        : <0x2ea>
          <324>   DW_AT_artificial  : 1
      ...
      
      Currently, when we execute "p sizeof (a)" in f1, the upper bound is calculated
      by evaluating the DW_OP_GNU_variable_value expression referring to D.1922, but
      since that die doesn't have a location attribute, we get:
      ...
      value has been optimized out
      ...
      
      However, there's also artificial variable D.4283 that is sibling of vla
      variable 'a', has artificial variable D.1922 as abstract origin, and has a
      location attribute:
      ...
       <2><1ae>: Abbrev Number: 12 (DW_TAG_variable)
          <1af>   DW_AT_description : (indirect string, offset: 0x1f8): D.4283
          <1b3>   DW_AT_abstract_origin: <0x31b>
          <1b7>   DW_AT_location    : 11 byte block: 75 1 8 20 24 8 20 26 31 1c 9f
                                      (DW_OP_breg5 (rdi):1; DW_OP_const1u: 32;
      				 DW_OP_shl; DW_OP_const1u: 32; DW_OP_shra;
      				 DW_OP_lit1; DW_OP_minus; DW_OP_stack_value)
      ...
      
      The intended behaviour for DW_OP_GNU_variable_value is to find a die that
      refers to D.1922 as abstract origin, has a location attribute and is
      'in scope', so the expected behaviour is:
      ...
      $1 = 6
      ...
      
      The 'in scope' concept can be thought of as variable D.1922 having name
      attribute "D.1922", and variable D.4283 inheriting that attribute, resulting
      in D.4283 being declared with name "D.1922" alongside vla a in f1, and when we
      lookup "DW_OP_GNU_variable_value D.1922", it should work as if we try to find
      the value of a variable named "D.1922" on the gdb command line using
      "p D.1922", and we should return the value of D.4283.
      
      This patch fixes the case described above, by:
      - adding a field abstract_to_concrete to struct dwarf2_per_objfile,
      - using that field to keep track of which concrete dies are instances of an
        abstract die, and
      - using that information when getting the value DW_OP_GNU_variable_value.
      
      Build and reg-tested on x86_64-linux.
      
      2018-09-05  Tom de Vries  <tdevries@suse.de>
      
      	* dwarf2loc.c (sect_variable_value): Call indirect_synthetic_pointer
      	with resolve_abstract_p == true.
      	(indirect_synthetic_pointer): Add resolve_abstract_p parameter,
      	defaulting to false. Propagate resolve_abstract_p to
      	dwarf2_fetch_die_loc_sect_off.
      	* dwarf2loc.h (dwarf2_fetch_die_loc_sect_off): Add resolve_abstract_p
      	parameter, defaulting to false.
      	* dwarf2read.c (read_variable): Add variable to abstract_to_concrete.
      	(dwarf2_fetch_die_loc_sect_off): Add and handle resolve_abstract_p
      	parameter.
      	* dwarf2read.h (struct die_info): Forward-declare.
      	(die_info_ptr): New typedef.
      	(struct dwarf2_per_objfile): Add abstract_to_concrete field.
      
      	* gdb.dwarf2/varval.exp: Add test.
      e4a62c65
  5. 02 Jan, 2018 1 commit
  6. 14 Jul, 2017 1 commit
    • Simon Marchi's avatar
      ax-gdb: Remove unnecessary gdbarch parameters · 40f4af28
      Simon Marchi authored
      In multiple places, we pass the gdbarch as an argument to some
      functions, even though it's available in the agent_expr structure also
      passed to the same functions.  Remove these arguments and replace their
      usage with accesses to agent_expr::gdbarch.
      
      gdb/ChangeLog:
      
      	* dwarf2loc.h (dwarf2_compile_expr_to_ax): Remove gdbarch
      	parameter.
      	* symtab.h (struct symbol_computed_ops::tracepoint_var_ref):
      	Likewise.
      	* dwarf2loc.c (dwarf2_compile_expr_to_ax): Remove gdbarch
      	parameter, use agent_expr::gdbarch instead, update function
      	calls.
      	(locexpr_tracepoint_var_ref): Likewise.
      	(loclist_tracepoint_var_ref): Likewise.
      	* ax-gdb.c (gen_trace_static_fields): Likewise.
      	(gen_traced_pop): Likewise.
      	(gen_frame_args_address): Likewise.
      	(gen_frame_locals_address): Likewise.
      	(gen_var_ref): Likewise.
      	(gen_struct_ref_recursive): Likewise.
      	(gen_static_field): Likewise.
      	(gen_maybe_namespace_elt): Likewise.
      	(gen_expr): Likewise.
      	(gen_trace_for_var): Likewise.
      	(gen_trace_for_expr): Likewise.
      	(gen_trace_for_return_address): Likewise.
      40f4af28
  7. 16 Mar, 2017 1 commit
    • Andreas Arnez's avatar
      Big-endian targets: Don't ignore offset into DW_OP_stack_value · 7942e96e
      Andreas Arnez authored
      Recently I fixed a bug that caused a DW_OP_implicit_pointer with non-zero
      offset into a DW_OP_implicit_value to be handled incorrectly on big-endian
      targets.  GDB ignored the offset and copied the wrong bytes:
      
        https://sourceware.org/ml/gdb-patches/2017-01/msg00251.html
      
      But there is still a similar issue when a DW_OP_implicit_pointer points
      into a DW_OP_stack_value instead; and again, the offset is ignored.  There
      is an important difference, though: While implicit values are treated like
      blocks of data and anchored at the lowest-addressed byte, stack values
      traditionally contain integer numbers and are anchored at the *least
      significant* byte.  Also, stack values do not come in varying sizes, but
      are cut down appropriately when used.  Thus, on big-endian targets the
      scenario looks like this (higher addresses shown right):
      
        |<- - - - - Stack value - - - - - - ->|
                        |                     |
                        |<- original object ->|
                        |
                        | offset ->|####|
      			      ^^^^
                                    de-referenced
      			      implicit pointer
      
      (Note how the original object's size influences the position of the
      de-referenced implicit pointer within the stack value.  This is not the
      case for little-endian targets, where the original object starts at offset
      zero within the stack value.)
      
      This patch implements the logic indicated in the above diagram and adds an
      appropriate test case.  A new function dwarf2_fetch_die_type_sect_off is
      added; it is used for retrieving the original object's type, so its size
      can be determined.  That type is passed to dwarf2_evaluate_loc_desc_full
      via a new parameter.
      
      gdb/ChangeLog:
      
      	* dwarf2loc.c (indirect_synthetic_pointer): Get data type of
      	pointed-to DIE and pass it to dwarf2_evaluate_loc_desc_full.
      	(dwarf2_evaluate_loc_desc_full): New parameter subobj_type; rename
      	byte_offset to subobj_byte_offset.  Fix the handling of
      	DWARF_VALUE_STACK on big-endian targets when coming via an
      	implicit pointer.
      	(dwarf2_evaluate_loc_desc): Adjust call to
      	dwarf2_evaluate_loc_desc_full.
      	* dwarf2loc.h (dwarf2_fetch_die_type_sect_off): New declaration.
      	* dwarf2read.c (dwarf2_fetch_die_type_sect_off): New function.
      
      gdb/testsuite/ChangeLog:
      
      	* lib/dwarf.exp: Add support for DW_OP_implicit_pointer.
      	* gdb.dwarf2/nonvar-access.exp: Add test for stack value location
      	and implicit pointer into such a location.
      7942e96e
  8. 20 Feb, 2017 1 commit
    • Jan Kratochvil's avatar
      DWARF-5 basic functionality · 43988095
      Jan Kratochvil authored
      this is a kitchen-sink patch for everything that did not fit into its own
      patch.
      
      DWO is not yet implemented.
      
      gdb/ChangeLog
      2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
      
      	* defs.h (read_unsigned_leb128): New declaration.
      	* dwarf2loc.c (decode_debug_loclists_addresses): New function.
      	(decode_debug_loc_dwo_addresses): Update DEBUG_LOC_* to DW_LLE_*.
      	(dwarf2_find_location_expression): Call also
      	decode_debug_loclists_addresses.  Handle DWARF-5 ULEB128 length.
      	* dwarf2loc.h (dwarf2_version): New declaration.
      	* dwarf2read.c (struct dwarf2_per_objfile): Add loclists, line_str,
      	rnglists.
      	(dwarf2_elf_names): Add .debug_loclists, .debug_line_str,
      	.debug_rnglists.
      	(struct dwop_section_names): Add loclists_dwo.
      	(dwop_section_names): Add .debug_loclists.dwo.
      	(struct comp_unit_head): Add unit_type, signature, type_offset_in_tu.
      	(struct dwarf2_per_cu_data): Add dwarf_version.
      	(struct dwo_sections): Add loclists.
      	(struct attr_abbrev): Add implicit_const.
      	(read_indirect_line_string): New declaration.
      	(read_unsigned_leb128): Delete declaration.
      	(rcuh_kind): New definition.
      	(read_and_check_comp_unit_head): Change parameter
      	is_debug_types_section to section_kind.
      	(dwarf2_locate_sections): Handle loclists, line_str and rnglists.
      	(read_comp_unit_head): Change parameter abfd to section, add parameter
      	section_kind.  Handle DWARF-5.
      	(error_check_comp_unit_head): Accept also DWARF version 5.
      	(read_and_check_comp_unit_head): Change parameter
      	is_debug_types_section to section_kind.
      	(read_and_check_type_unit_head): Delete function.
      	(read_abbrev_offset): Handle DWARF-5.
      	(create_debug_type_hash_table): Add parameter section_kind.  Process
      	only DW_UT_type.  Use signature and type_offset_in_tu from struct
      	comp_unit_head.
      	(create_debug_types_hash_table): Update create_debug_type_hash_table
      	caller.
      	(create_all_type_units): Call create_debug_type_hash_table.
      	(read_cutu_die_from_dwo, init_cutu_and_read_dies): Change
      	read_and_check_type_unit_head caller to read_and_check_comp_unit_head
      	caller.
      	(skip_one_die): Handle DW_FORM_implicit_const.
      	(dwarf2_rnglists_process): New function.
      	(dwarf2_ranges_process): Call dwarf2_rnglists_process for DWARF-5.
      	(abbrev_table_read_table): Handle DW_FORM_implicit_const.
      	(read_attribute_value): Handle DW_FORM_implicit_const,
      	DW_FORM_line_strp.
      	(read_attribute): Handle DW_FORM_implicit_const.
      	(read_indirect_string_at_offset_from): New function from
      	read_indirect_string_at_offset.
      	(read_indirect_string_at_offset): Call
      	read_indirect_string_at_offset_from.
      	(read_indirect_line_string_at_offset): New function.
      	(read_indirect_string): New function comment.
      	(read_indirect_line_string): New function.
      	(read_unsigned_leb128): Make it global.
      	(dwarf2_string_attr): Handle DWARF-5.
      	(add_include_dir_stub, read_formatted_entries): New functions.
      	(dwarf_decode_line_header, dump_die_shallow, cu_debug_loc_section):
      	Handle DWARF-5.
      	(per_cu_header_read_in): Update read_comp_unit_head caller.
      	(dwarf2_version): New function.
      	* symfile.h (struct dwarf2_debug_sections): Add loclists, line_str and
      	rnglists.
      	* xcoffread.c (dwarf2_xcoff_names): Update struct dwarf2_debug_sections
      	fields.
      
      gdb/testsuite/ChangeLog
      2017-02-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
      
      	* gdb.dwarf2/dw2-error.exp (file $testfile): Update expected string.
      43988095
  9. 02 Feb, 2017 1 commit
    • Pedro Alves's avatar
      Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy · d7e74731
      Pedro Alves authored
      This patch starts from the desire to eliminate
      make_cleanup_ui_file_delete, but then goes beyond.  It makes ui_file &
      friends a real C++ class hierarchy, and switches temporary
      ui_file-like objects to stack-based allocation.
      
      - mem_fileopen -> string_file
      
      mem_fileopen is replaced with a new string_file class that is treated
      as a value class created on the stack.  This alone eliminates most
      make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
      (diffstat shows around 1k loc dropped.)
      
      string_file's internal buffer is a std::string, thus the "string" in
      the name.  This simplifies the implementation much, compared to
      mem_fileopen, which managed growing its internal buffer manually.
      
      - ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
      
      The new string_file class has a string() method that provides direct
      writable access to the internal std::string buffer.  This replaced
      ui_file_as_string, which forced a copy of the same data the stream had
      inside.  With direct access via a writable reference, we can instead
      move the string out of the string_stream, avoiding deep string
      copying.
      
      Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
      stream's string, and ui_file_obsavestring is replaced by
      obstack_copy0.
      
      With all those out of the way, getting rid of the weird ui_file_put
      mechanism was possible.
      
      - New ui_file::printf, ui_file::puts, etc. methods
      
      These simplify / clarify client code.  I considered splitting
      client-code changes, like these, e.g.:
      
        -  stb = mem_fileopen ();
        -  fprintf_unfiltered (stb, "%s%s%s",
        -		      _("The valid values are:\n"),
        -		      regdesc,
        -		      _("The default is \"std\"."));
        +  string_file stb;
        +  stb.printf ("%s%s%s",
        +	      _("The valid values are:\n"),
        +	      regdesc,
        +	      _("The default is \"std\"."));
      
      In two steps, with the first step leaving fprintf_unfiltered (etc.)
      calls in place, and only afterwards do a pass to change all those to
      call stb.printf etc..  I didn't do that split, because (when I tried),
      it turned out to be pointless make-work: the first pass would have to
      touch the fprintf_unfiltered line anyway, to replace "stb" with
      "&stb".
      
      - gdb_fopen replaced with stack-based objects
      
      This avoids the need for cleanups or unique_ptr's.  I.e., this:
      
            struct ui_file *file = gdb_fopen (filename, "w");
            if (filename == NULL)
       	perror_with_name (filename);
            cleanups = make_cleanup_ui_file_delete (file);
            // use file.
            do_cleanups (cleanups);
      
      is replaced with this:
      
            stdio_file file;
            if (!file.open (filename, "w"))
       	perror_with_name (filename);
            // use file.
      
      - odd contorsions in null_file_write / null_file_fputs around when to
        call to_fputs / to_write eliminated.
      
      - Global null_stream object
      
      A few places that were allocating a ui_file in order to print to
      "nowhere" are adjusted to instead refer to a new 'null_stream' global
      stream.
      
      - TUI's tui_sfileopen eliminated.  TUI's ui_file much simplified
      
      The TUI's ui_file was serving a dual purpose.  It supported being used
      as string buffer, and supported being backed by a stdio FILE.  The
      string buffer part is gone, replaced by using of string_file.  The
      'FILE *' support is now much simplified, by making the TUI's ui_file
      inherit from stdio_file.
      
      gdb/ChangeLog:
      2017-02-02  Pedro Alves  <palves@redhat.com>
      
      	* ada-lang.c (type_as_string): Use string_file.
      	* ada-valprint.c (ada_print_floating): Use string_file.
      	* ada-varobj.c (ada_varobj_scalar_image)
      	(ada_varobj_get_value_image): Use string_file.
      	* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
      	* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
      	* breakpoint.c (update_inserted_breakpoint_locations)
      	(insert_breakpoint_locations, reattach_breakpoints)
      	(print_breakpoint_location, print_one_detail_ranged_breakpoint)
      	(print_it_watchpoint): Use string_file.
      	(save_breakpoints): Use stdio_file.
      	* c-exp.y (oper): Use string_file.
      	* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
      	tee_file.
      	(pop_output_files): Use delete.
      	(handle_redirections): Use stdio_file and tee_file.
      	* cli/cli-setshow.c (do_show_command): Use string_file.
      	* compile/compile-c-support.c (c_compute_program): Use
      	string_file.
      	* compile/compile-c-symbols.c (generate_vla_size): Take a
      	'string_file &' instead of a 'ui_file *'.
      	(generate_c_for_for_one_variable): Take a 'string_file &' instead
      	of a 'ui_file *'.  Use string_file.
      	(generate_c_for_variable_locations): Take a 'string_file &'
      	instead of a 'ui_file *'.
      	* compile/compile-internal.h (generate_c_for_for_one_variable):
      	Take a 'string_file &' instead of a 'ui_file *'.
      	* compile/compile-loc2c.c (push, pushf, unary, binary)
      	(print_label, pushf_register_address, pushf_register)
      	(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
      	'ui_file *'.  Adjust.
      	* compile/compile.c (compile_to_object): Use string_file.
      	* compile/compile.h (compile_dwarf_expr_to_c)
      	(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
      	'ui_file *'.
      	* cp-support.c (inspect_type): Use string_file and obstack_copy0.
      	(replace_typedefs_qualified_name): Use string_file and
      	obstack_copy0.
      	* disasm.c (gdb_pretty_print_insn): Use string_file.
      	(gdb_disassembly): Adjust reference the null_stream global.
      	(do_ui_file_delete): Delete.
      	(gdb_insn_length): Use null_stream.
      	* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
      	* dwarf2loc.c (dwarf2_compile_property_to_c)
      	(locexpr_generate_c_location, loclist_generate_c_location): Take a
      	'string_file &' instead of a 'ui_file *'.
      	* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
      	* dwarf2read.c (do_ui_file_peek_last): Delete.
      	(dwarf2_compute_name): Use string_file.
      	* event-top.c (gdb_setup_readline): Use stdio_file.
      	* gdbarch.sh (verify_gdbarch): Use string_file.
      	* gdbtypes.c (safe_parse_type): Use null_stream.
      	* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
      	string_file.
      	* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
      	'string_file *' instead of a 'ui_file *'.
      	(gdbscm_arch_disassemble): Use string_file.
      	* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
      	* guile/scm-ports.c (class ioscm_file_port): Now a class that
      	inherits from ui_file.
      	(ioscm_file_port_delete, ioscm_file_port_rewind)
      	(ioscm_file_port_put): Delete.
      	(ioscm_file_port_write): Rename to ...
      	(ioscm_file_port::write): ... this.  Remove file_port_magic
      	checks.
      	(ioscm_file_port_new): Delete.
      	(ioscm_with_output_to_port_worker): Use ioscm_file_port and
      	ui_file_up.
      	* guile/scm-type.c (tyscm_type_name): Use string_file.
      	* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
      	Use string_file.
      	* infcmd.c (print_return_value_1): Use string_file.
      	* infrun.c (print_target_wait_results): Use string_file.
      	* language.c (add_language): Use string_file.
      	* location.c (explicit_to_string_internal): Use string_file.
      	* main.c (captured_main_1): Use null_file.
      	* maint.c (maintenance_print_architecture): Use stdio_file.
      	* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
      	* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
      	event_channel>: Change type to mi_console_file pointer.
      	* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
      	(mi_console_file_delete): Delete.
      	(struct mi_console_file): Delete.
      	(mi_console_file_magic): Delete.
      	(mi_console_file_new): Delete.
      	(mi_console_file::mi_console_file): New.
      	(mi_console_file_delete): Delete.
      	(mi_console_file_fputs): Delete.
      	(mi_console_file::write): New.
      	(mi_console_raw_packet): Delete.
      	(mi_console_file::flush): New.
      	(mi_console_file_flush): Delete.
      	(mi_console_set_raw): Rename to ...
      	(mi_console_file::set_raw): ... this.
      	* mi/mi-console.h (class mi_console_file): New class.
      	(mi_console_file_new, mi_console_set_raw): Delete.
      	* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
      	(mi_set_logging): Use delete and tee_file.  Adjust.
      	* mi/mi-main.c (output_register): Use string_file.
      	(mi_cmd_data_evaluate_expression): Use string_file.
      	(mi_cmd_data_read_memory): Use string_file.
      	(mi_cmd_execute, print_variable_or_computed): Use string_file.
      	* mi/mi-out.c (mi_ui_out::main_stream): New.
      	(mi_ui_out::rewind): Use main_stream and
      	string_file.
      	(mi_ui_out::put): Use main_stream and string_file.
      	(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
      	Allocate a 'string_file' instead.
      	(mi_out_new): Don't allocate a mem_fileopen stream here.
      	* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
      	(mi_ui_out::main_stream): Declare method.
      	* printcmd.c (eval_command): Use string_file.
      	* psymtab.c (maintenance_print_psymbols): Use stdio_file.
      	* python/py-arch.c (archpy_disassemble): Use string_file.
      	* python/py-breakpoint.c (bppy_get_commands): Use string_file.
      	* python/py-frame.c (frapy_str): Use string_file.
      	* python/py-framefilter.c (py_print_type, py_print_single_arg):
      	Use string_file.
      	* python/py-type.c (typy_str): Use string_file.
      	* python/py-unwind.c (unwind_infopy_str): Use string_file.
      	* python/py-value.c (valpy_str): Use string_file.
      	* record-btrace.c (btrace_insn_history): Use string_file.
      	* regcache.c (regcache_print): Use stdio_file.
      	* reggroups.c (maintenance_print_reggroups): Use stdio_file.
      	* remote.c (escape_buffer): Use string_file.
      	* rust-lang.c (rust_get_disr_info): Use string_file.
      	* serial.c (serial_open_ops_1): Use stdio_file.
      	(do_serial_close): Use delete.
      	* stack.c (print_frame_arg): Use string_file.
      	(print_frame_args): Remove local mem_fileopen stream, not used.
      	(print_frame): Use string_file.
      	* symmisc.c (maintenance_print_symbols): Use stdio_file.
      	* symtab.h (struct symbol_computed_ops) <generate_c_location>:
      	Take a 'string_file *' instead of a 'ui_file *'.
      	* top.c (new_ui): Use stdio_file and stderr_file.
      	(free_ui): Use delete.
      	(execute_command_to_string): Use string_file.
      	(quit_confirm): Use string_file.
      	* tracepoint.c (collection_list::append_exp): Use string_file.
      	* tui/tui-disasm.c (tui_disassemble): Use string_file.
      	* tui/tui-file.c: Don't include "ui-file.h".
      	(enum streamtype, struct tui_stream): Delete.
      	(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
      	(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
      	(tui_file::tui_file): New method.
      	(tui_file_fputs): Delete.
      	(tui_file_get_strbuf): Delete.
      	(tui_file::puts): New method.
      	(tui_file_adjust_strbuf): Delete.
      	(tui_file_flush): Delete.
      	(tui_file::flush): New method.
      	* tui/tui-file.h: Tweak intro comment.
      	Include ui-file.h.
      	(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
      	(tui_file_adjust_strbuf): Delete declarations.
      	(class tui_file): New class.
      	* tui/tui-io.c (tui_initialize_io): Use tui_file.
      	* tui/tui-regs.c (tui_restore_gdbout): Use delete.
      	(tui_register_format): Use string_stream.
      	* tui/tui-stack.c (tui_make_status_line): Use string_file.
      	(tui_get_function_from_frame): Use string_file.
      	* typeprint.c (type_to_string): Use string_file.
      	* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
      	(null_stream): New global.
      	(ui_file_delete): Delete.
      	(ui_file::ui_file): New.
      	(null_file_isatty): Delete.
      	(ui_file::~ui_file): New.
      	(null_file_rewind): Delete.
      	(ui_file::printf): New.
      	(null_file_put): Delete.
      	(null_file_flush): Delete.
      	(ui_file::putstr): New.
      	(null_file_write): Delete.
      	(ui_file::putstrn): New.
      	(null_file_read): Delete.
      	(ui_file::putc): New.
      	(null_file_fputs): Delete.
      	(null_file_write_async_safe): Delete.
      	(ui_file::vprintf): New.
      	(null_file_delete): Delete.
      	(null_file::write): New.
      	(null_file_fseek): Delete.
      	(null_file::puts): New.
      	(ui_file_data): Delete.
      	(null_file::write_async_safe): New.
      	(gdb_flush, ui_file_isatty): Adjust.
      	(ui_file_put, ui_file_rewind): Delete.
      	(ui_file_write): Adjust.
      	(ui_file_write_for_put): Delete.
      	(ui_file_write_async_safe, ui_file_read): Adjust.
      	(ui_file_fseek): Delete.
      	(fputs_unfiltered): Adjust.
      	(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
      	(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
      	(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
      	(set_ui_file_data): Delete.
      	(string_file::~string_file, string_file::write)
      	(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
      	(do_ui_file_as_string, ui_file_as_string): Delete.
      	(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
      	(struct mem_file): Delete.
      	(mem_file_new): Delete.
      	(stdio_file::stdio_file): New.
      	(mem_file_delete): Delete.
      	(stdio_file::stdio_file): New.
      	(mem_fileopen): Delete.
      	(stdio_file::~stdio_file): New.
      	(mem_file_rewind): Delete.
      	(stdio_file::set_stream): New.
      	(mem_file_put): Delete.
      	(stdio_file::open): New.
      	(mem_file_write): Delete.
      	(stdio_file_magic, struct stdio_file): Delete.
      	(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
      	(stdio_file::flush): New.
      	(stdio_file_read): Rename to ...
      	(stdio_file::read): ... this.  Adjust.
      	(stdio_file_write): Rename to ...
      	(stdio_file::write): ... this.  Adjust.
      	(stdio_file_write_async_safe): Rename to ...
      	(stdio_file::write_async_safe) ... this.  Adjust.
      	(stdio_file_fputs): Rename to ...
      	(stdio_file::puts) ... this.  Adjust.
      	(stdio_file_isatty): Delete.
      	(stdio_file_fseek): Delete.
      	(stdio_file::isatty): New.
      	(stderr_file_write): Rename to ...
      	(stderr_file::write) ... this.  Adjust.
      	(stderr_file_fputs): Rename to ...
      	(stderr_file::puts) ... this.  Adjust.
      	(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
      	(stderr_file::stderr_file): New.
      	(tee_file_magic): Delete.
      	(struct tee_file): Delete.
      	(tee_file::tee_file): New.
      	(tee_file_new): Delete.
      	(tee_file::~tee_file): New.
      	(tee_file_delete): Delete.
      	(tee_file_flush): Rename to ...
      	(tee_file::flush): ... this.  Adjust.
      	(tee_file_write): Rename to ...
      	(tee_file::write): ... this.  Adjust.
      	(tee_file::write_async_safe): New.
      	(tee_file_fputs): Rename to ...
      	(tee_file::puts): ... this.  Adjust.
      	(tee_file_isatty): Rename to ...
      	(tee_file::isatty): ... this.  Adjust.
      	* ui-file.h (struct obstack, struct ui_file): Don't
      	forward-declare.
      	(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
      	(ui_file_write_ftype)
      	(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
      	(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
      	(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
      	(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
      	(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
      	(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
      	(set_ui_file_fseek): Delete.
      	(ui_file_data, ui_file_delete, ui_file_rewind)
      	(struct ui_file): New.
      	(ui_file_up): New.
      	(class null_file): New.
      	(null_stream): Declare.
      	(ui_file_write_for_put, ui_file_put): Delete.
      	(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
      	Delete.
      	(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
      	(gdb_fopen, tee_file_new): Delete.
      	(struct string_file): New.
      	(struct stdio_file): New.
      	(stdio_file_up): New.
      	(struct stderr_file): New.
      	(class tee_file): New.
      	* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
      	of a 'ui_file *'.  Adjust.
      	* ui-out.h (class ui_out) <field_stream>: Likewise.
      	* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
      	(null_stream): Delete.
      	(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
      	Adjust.
      	* utils.h (struct ui_file): Delete forward declaration..
      	(make_cleanup_ui_file_delete, null_stream): Delete declarations.
      	(error_stream): Take a 'string_file &' instead of a
      	'ui_file *'.
      	* varobj.c (varobj_value_get_print_value): Use string_file.
      	* xtensa-tdep.c (xtensa_verify_config): Use string_file.
      	* gdbarch.c: Regenerate.
      d7e74731
  10. 01 Jan, 2017 1 commit
    • Joel Brobecker's avatar
      update copyright year range in GDB files · 61baf725
      Joel Brobecker authored
      This applies the second part of GDB's End of Year Procedure, which
      updates the copyright year range in all of GDB's files.
      
      gdb/ChangeLog:
      
              Update copyright year range in all GDB files.
      61baf725
  11. 01 Jan, 2016 1 commit
  12. 26 Oct, 2015 1 commit
    • Doug Evans's avatar
      PR symtab/17391 gdb internal error: assertion fails in regcache.c:178 · 0fde2c53
      Doug Evans authored
      gdb/ChangeLog:
      
      	* dwarf2-frame.c (dwarf2_restore_rule): Call dwarf_reg_to_regnum
      	instead of gdbarch_dwarf2_reg_to_regnum.
      	(dwarf2_frame_cache): Ditto.
      	(read_addr_from_reg): Call dwarf_reg_to_regnum_or_error instead of
      	gdbarch_dwarf2_reg_to_regnum.
      	(get_reg_value): Ditto.
      	(dwarf2_fetch_cfa_info): Ditto.
      	(dwarf2_frame_prev_register): Ditto.
      	* dwarf2loc.c: #include "complaints.h".
      	(dwarf_expr_read_addr_from_reg): Call dwarf_reg_to_regnum_or_error
      	instead of gdbarch_dwarf2_reg_to_regnum.
      	(dwarf_expr_get_reg_value): Ditto.
      	(read_pieced_value): Ditto.
      	(write_pieced_value): Ditto.
      	(dwarf2_evaluate_loc_desc_full): Ditto.
      	(dwarf_reg_to_regnum): New function.
      	(throw_bad_regnum_error): New function.
      	(dwarf_reg_to_regnum_or_error): Renamed from
      	dwarf2_reg_to_regnum_or_errorChange to take a ULONGEST regnum.
      	All callers updated.  Call throw_bad_regnum_error.
      	(locexpr_regname): Improve text of bad register number.
      	* dwarf2loc.h (dwarf_reg_to_regnum): Declare.
      	(dwarf_reg_to_regnum_or_error): Update prototype.
      	* dwarf2expr.c: #include "dwarf2loc.h".
      	(dwarf_block_to_sp_offset): Call dwarf_reg_to_regnum instead of
      	gdbarch_dwarf2_reg_to_regnum.
      	* gdbarch.sh (dwarf2_reg_to_regnum): Add comment.
      	* gdbarch.h: Regenerate.
      	* amd64-tdep.c (amd64_dwarf_reg_to_regnum): Remove warning for bad
      	register.
      	* avr-tdep.c (avr_dwarf_reg_to_regnum): Ditto.
      	* cris-tdep.c (cris_dwarf2_reg_to_regnum): Ditto.
      	* bfin-tdep.c (bfin_reg_to_regnum): Fix error checking.
      	* hppa-linux-tdep.c (hppa_dwarf_reg_to_regnum): Improve error checking.
      	Remove warning for bad register.
      	* hppa-tdep.c (hppa64_dwarf_reg_to_regnum): Ditto.
      	* i386-tdep.c (i386_svr4_dwarf_reg_to_regnum): Renamed from
      	i386_svr4_reg_to_regnum.  Return -1 for bad registers.
      	(i386_svr4_reg_to_regnum): New function.
      	(i386_gdbarch_init): Update call to set_gdbarch_dwarf2_reg_to_regnum.
      	* microblaze-tdep.c (microblaze_dwarf2_reg_to_regnum): Don't assert
      	on bad registers, return -1.
      	* msp430-tdep.c (msp430_dwarf2_reg_to_regnum): Improve error checking.
      	Remove warning for bad register.
      	* nios2-tdep.c: Add static assert for NIOS2_NUM_REGS.
      	(nios2_dwarf_reg_to_regnum): Fix off-by-one error.
      	Remove warning for bad register.  Return -1 for bad register.
      	* rl78-tdep.c (rl78_dwarf_reg_to_regnum): Don't flag an internal error
      	for bad register, return -1.
      	* rx-tdep.c (rx_dwarf_reg_to_regnum): Ditto.
      	* m68k-tdep.c (m68k_dwarf_reg_to_regnum): Fix error result.
      	* mep-tdep.c (mep_debug_reg_to_regnum): Ditto.
      	* mips-tdep.c (mips_stab_reg_to_regnum): Ditto.
      	(mips_dwarf_dwarf2_ecoff_reg_to_regnum): Ditto.
      	* mn10300-tdep.c (mn10300_dwarf2_reg_to_regnum): Remove warning
      	for bad regs.
      	* xtensa-tdep.c (xtensa_reg_to_regnum): Remove internal error for
      	bad regs.  Fix error result.
      	* stabsread.c (stab_reg_to_regnum): Watch for negative regno.
      	(reg_value_complaint): Update complaint text.
      	* mdebugread.c (reg_value_complaint): New function.
      	(mdebug_reg_to_regnum): Rewrite to watch for bad reg numbers.
      
      gdb/testsuite/ChangeLog:
      
      	* lib/dwarf.exp (_location): Add support for DW_OP_regx.
      	* gdb.dwarf2/bad-regnum.c: New file.
      	* gdb.dwarf2/bad-regnum.exp: New file.
      0fde2c53
  13. 25 Aug, 2015 1 commit
    • Pierre-Marie de Rodat's avatar
      DWARF: handle non-local references in nested functions · 63e43d3a
      Pierre-Marie de Rodat authored
      GDB's current behavior when dealing with non-local references in the
      context of nested fuctions is approximative:
      
        - code using valops.c:value_of_variable read the first available stack
          frame that holds the corresponding variable (whereas there can be
          multiple candidates for this);
      
        - code directly relying on read_var_value will instead read non-local
          variables in frames where they are not even defined.
      
      This change adds the necessary context to symbol reads (to get the block
      they belong to) and to blocks (the static link property, if any) so that
      GDB can make the proper decisions when dealing with non-local varibale
      references.
      
      gdb/ChangeLog:
      
      	* ada-lang.c (ada_read_var_value): Add a var_block argument
      	and pass it to default_read_var_value.
      	* block.c (block_static_link): New accessor.
      	* block.h (block_static_link): Declare it.
      	* buildsym.c (finish_block_internal): Add a static_link
      	argument.  If there is a static link, associate it to the new
      	block.
      	(finish_block): Add a static link argument and pass it to
      	finish_block_internal.
      	(end_symtab_get_static_block): Update calls to finish_block and
      	to finish_block_internal.
      	(end_symtab_with_blockvector): Update call to
      	finish_block_internal.
      	* buildsym.h: Forward-declare struct dynamic_prop.
      	(struct context_stack): Add a static_link field.
      	(finish_block): Add a static link argument.
      	* c-exp.y: Remove an obsolete comment (evaluation of variables
      	already start from the selected frame, and now they climb *up*
      	the call stack) and propagate the block information to the
      	produced expression.
      	* d-exp.y: Likewise.
      	* f-exp.y: Likewise.
      	* go-exp.y: Likewise.
      	* jv-exp.y: Likewise.
      	* m2-exp.y: Likewise.
      	* p-exp.y: Likewise.
      	* coffread.c (coff_symtab_read): Update calls to finish_block.
      	* dbxread.c (process_one_symbol): Likewise.
      	* xcoffread.c (read_xcoff_symtab): Likewise.
      	* compile/compile-c-symbols.c (convert_one_symbol): Promote the
      	"sym" parameter to struct block_symbol, update its uses and pass
      	its block to calls to read_var_value.
      	(convert_symbol_sym): Update the calls to convert_one_symbol.
      	* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update
      	call to read_var_value.
      	* dwarf2loc.c (block_op_get_frame_base): New.
      	(dwarf2_block_frame_base_locexpr_funcs): Implement the
      	get_frame_base method.
      	(dwarf2_block_frame_base_loclist_funcs): Likewise.
      	(dwarf2locexpr_baton_eval): Add a frame argument and use it
      	instead of the selected frame in order to evaluate the
      	expression.
      	(dwarf2_evaluate_property): Add a frame argument.  Update call
      	to dwarf2_locexpr_baton_eval to provide a frame in available and
      	to handle the absence of address stack.
      	* dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument.
      	* dwarf2read.c (attr_to_dynamic_prop): Add a forward
      	declaration.
      	(read_func_scope): Record any available static link description.
      	Update call to finish_block.
      	(read_lexical_block_scope): Update call to finish_block.
      	* findvar.c (follow_static_link): New.
      	(get_hosting_frame): New.
      	(default_read_var_value): Add a var_block argument.  Use
      	get_hosting_frame to handle non-local references.
      	(read_var_value): Add a var_block argument and pass it to the
      	LA_READ_VAR_VALUE method.
      	* gdbtypes.c (resolve_dynamic_range): Update calls to
      	dwarf2_evaluate_property.
      	(resolve_dynamic_type_internal): Likewise.
      	* guile/scm-frame.c (gdbscm_frame_read_var): Update call to
      	read_var_value, passing it the block coming from symbol lookup.
      	* guile/scm-symbol.c (gdbscm_symbol_value): Update call to
      	read_var_value (TODO).
      	* infcmd.c (finish_command_continuation): Update call to
      	read_var_value, passing it the block coming from symbol lookup.
      	* infrun.c (insert_exception_resume_breakpoint): Likewise.
      	* language.h (struct language_defn): Add a var_block argument to
      	the LA_READ_VAR_VALUE method.
      	* objfiles.c (struct static_link_htab_entry): New.
      	(static_link_htab_entry_hash): New.
      	(static_link_htab_entry_eq): New.
      	(objfile_register_static_link): New.
      	(objfile_lookup_static_link): New.
      	(free_objfile): Free the STATIC_LINKS hashed map if needed.
      	* objfiles.h: Include hashtab.h.
      	(struct objfile): Add a static_links field.
      	(objfile_register_static_link): New.
      	(objfile_lookup_static_link): New.
      	* printcmd.c (print_variable_and_value): Update call to
      	read_var_value.
      	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
      	* python/py-frame.c (frapy_read_var): Update call to
      	read_var_value, passing it the block coming from symbol lookup.
      	* python/py-framefilter.c (extract_sym): Add a sym_block
      	parameter and set the pointed value to NULL (TODO).
      	(enumerate_args): Update call to extract_sym.
      	(enumerate_locals): Update calls to extract_sym and to
      	read_var_value.
      	* python/py-symbol.c (sympy_value): Update call to
      	read_var_value (TODO).
      	* stack.c (read_frame_local): Update call to read_var_value.
      	(read_frame_arg): Likewise.
      	(return_command): Likewise.
      	* symtab.h (struct symbol_block_ops): Add a get_frame_base
      	method.
      	(struct symbol): Add a block field.
      	(SYMBOL_BLOCK): New accessor.
      	* valops.c (value_of_variable): Remove frame/block handling and
      	pass the block argument to read_var_value, which does this job
      	now.
      	(value_struct_elt_for_reference): Update calls to
      	read_var_value.
      	(value_of_this): Pass the block found to read_var_value.
      	* value.h (read_var_value): Add a var_block argument.
      	(default_read_var_value): Likewise.
      
      gdb/testsuite/ChangeLog:
      
      	* gdb.base/nested-subp1.exp: New file.
      	* gdb.base/nested-subp1.c: New file.
      	* gdb.base/nested-subp2.exp: New file.
      	* gdb.base/nested-subp2.c: New file.
      	* gdb.base/nested-subp3.exp: New file.
      	* gdb.base/nested-subp3.c: New file.
      63e43d3a
  14. 05 May, 2015 1 commit
    • Joel Brobecker's avatar
      Add valaddr support in dynamic property resolution. · c3345124
      Joel Brobecker authored
      This is the second part of enhancing the debugger to print the value
      of arrays of records whose size is variable when only standard DWARF
      info is available (no GNAT encoding). For instance:
      
         subtype Small_Type is Integer range 0 .. 10;
         type Record_Type (I : Small_Type := 0) is record
            S : String (1 .. I);
         end record;
         type Array_Type is array (Integer range <>) of Record_Type;
      
         A1 : Array_Type := (1 => (I => 0, S => <>),
                             2 => (I => 1, S => "A"),
                             3 => (I => 2, S => "AB"));
      
      Currently, GDB prints the following output:
      
              (gdb) p a1
              $1 = (
      
      The error happens while the ada-valprint module is trying to print
      the value of an element of our array. Because of the fact that
      the array's element (type Record_Type) has a variant size, the DWARF
      info for our array provide the array's stride:
      
           <1><749>: Abbrev Number: 10 (DW_TAG_array_type)
              <74a>   DW_AT_name        : (indirect string, offset: 0xb6d): pck__T18s
              <74e>   DW_AT_byte_stride : 16
              <74f>   DW_AT_type        : <0x6ea>
      
      And because our array has a stride, ada-valprint treats it the same
      way as packed arrays (see ada-valprint.c::ada_val_print_array):
      
        if (TYPE_FIELD_BITSIZE (type, 0) > 0)
          val_print_packed_array_elements (type, valaddr, offset_aligned,
                                           0, stream, recurse,
                                           original_value, options);
      
      The first thing that we should notice in the call above is that
      the "valaddr" buffer and the associated offset (OFFSET_ALIGNED)
      is passed, but that the corresponding array's address is not.
      This can be explained by looking inside val_print_packed_array_elements,
      where we see that the function unpacks each element of our array from
      the buffer alone (ada_value_primitive_packed_val), and then prints
      the resulting artificial value instead:
      
            v0 = ada_value_primitive_packed_val (NULL, valaddr + offset,
                                                 (i0 * bitsize) / HOST_CHAR_BIT,
                                                 (i0 * bitsize) % HOST_CHAR_BIT,
                                                 bitsize, elttype);
      
            [...]
                    val_print (elttype, value_contents_for_printing (v0),
                               value_embedded_offset (v0), 0, stream,
                               recurse + 1, v0, &opts, current_language);
      
      Of particular interest, here, is the fact that we call val_print
      with a null address, which is OK, since we're providing a buffer
      instead (value_contents_for_printing). Also, providing an address
      might not always possible, since packing could place elements at
      boundaries that are not byte-aligned.
      
      Things go south when val_print tries to see if there is a pretty-printer
      that could be applied. In particular, one of the first things that
      the Python pretty-printer does is to create a value using our buffer,
      and the given address, which in this case is null (see call to
      value_from_contents_and_address in gdbpy_apply_val_pretty_printer).
      
      value_from_contents_and_address, in turn immediately tries to resolve
      the type, using the given address, which is null. But, because our
      array element is a record containing an array whose bound is the value
      of one of its elements (the "s" component), the debugging info for
      the array's upper bound is a reference...
      
       <3><71a>: Abbrev Number: 7 (DW_TAG_subrange_type)
          <71b>   DW_AT_type        : <0x724>
          <71f>   DW_AT_upper_bound : <0x703>
      
      ... to component "i" of our record...
      
       <2><703>: Abbrev Number: 5 (DW_TAG_member)
          <704>   DW_AT_name        : i
          <706>   DW_AT_decl_file   : 2
          <707>   DW_AT_decl_line   : 6
          <708>   DW_AT_type        : <0x6d1>
          <70c>   DW_AT_data_member_location: 0
      
      ... where that component is located at offset 0 of the start
      of the record. dwarf2_evaluate_property correctly determines
      the offset where to load the value of the bound from, but then
      tries to read that value from inferior memory using the address
      that was given, which is null. See case PROP_ADDR_OFFSET in
      dwarf2_evaluate_property:
      
              val = value_at (baton->offset_info.type,
                              pinfo->addr + baton->offset_info.offset);
      
      This triggers a memory error, which then causes the printing to terminate.
      
      Since there are going to be situations where providing an address
      alone is not going to be sufficient (packed arrays where array elements
      are not stored at byte boundaries), this patch fixes the issue by
      enhancing the type resolution to take both address and data. This
      follows the same principle as the val_print module, where both
      address and buffer ("valaddr") can be passed as arguments. If the data
      has already been fetched from inferior memory (or provided by the
      debugging info in some form -- Eg a constant), then use that data
      instead of reading it from inferior memory.
      
      Note that this should also be a good step towards being able to handle
      dynamic types whose value is stored outside of inferior memory
      (Eg: in a register).
      
      With this patch, GDB isn't able to print all of A1, but does perform
      a little better:
      
          (gdb) p a1
          $1 = ((i => 0, s => , (i => 1, s => , (i => 2, s => )
      
      There is another issue which is independent of this one, and will
      therefore be patched separately.
      
      gdb/ChangeLog:
      
              * dwarf2loc.h (struct property_addr_info): Add "valaddr" field.
              * dwarf2loc.c (dwarf2_evaluate_property): Add handling of
              pinfo->valaddr.
              * gdbtypes.h (resolve_dynamic_type): Add "valaddr" parameter.
              * gdbtypes.c (resolve_dynamic_struct): Set pinfo.valaddr.
              (resolve_dynamic_type_internal): Set pinfo.valaddr.
              Add handling of addr_stack->valaddr.
              (resolve_dynamic_type): Add "valaddr" parameter.
              Set pinfo.valaddr field.
              * ada-lang.c (ada_discrete_type_high_bound): Update call to
              resolve_dynamic_type.
              (ada_discrete_type_low_bound): Likewise.
              * findvar.c (default_read_var_value): Likewise.
              * value.c (value_from_contents_and_address): Likewise.
      c3345124
  15. 29 Jan, 2015 1 commit
    • Joel Brobecker's avatar
      gdb/DWARF: Support for arrays whose bound is a discriminant. · df25ebbd
      Joel Brobecker authored
      Consider the following declarations:
      
         type Array_Type is array (Integer range <>) of Integer;
         type Record_Type (N : Integer) is record
            A : Array_Type (1 .. N);
         end record;
         R : Record_Type := Get (10);
      
      It defines what Ada programers call a "discriminated record", where
      "N" is a component of that record called a "discriminant", and where
      "A" is a component defined as an array type whose upper bound is
      equal to the value of the discriminant.
      
      So far, we rely on a number of fairly complex GNAT-specific encodings
      to handle this situation. This patch is to enhance GDB to be able to
      print this record in the case where the compiler has been modified
      to replace those encodings by pure DWARF constructs.
      
      In particular, the debugging information generated for the record above
      looks like the following. "R" is a record..
      
              .uleb128 0x10   # (DIE (0x13e) DW_TAG_structure_type)
              .long   .LASF17 # DW_AT_name: "foo__record_type"
      
      ... whose is is of course dynamic (not our concern here)...
      
              .uleb128 0xd    # DW_AT_byte_size
              .byte   0x97    # DW_OP_push_object_address
              .byte   0x94    # DW_OP_deref_size
              .byte   0x4
              .byte   0x99    # DW_OP_call4
              .long   0x19b
              .byte   0x23    # DW_OP_plus_uconst
              .uleb128 0x7
              .byte   0x9     # DW_OP_const1s
              .byte   0xfc
              .byte   0x1a    # DW_OP_and
              .byte   0x1     # DW_AT_decl_file (foo.adb)
              .byte   0x6     # DW_AT_decl_line
      
      ... and then has 2 members, fist "n" (our discriminant);
      
              .uleb128 0x11   # (DIE (0x153) DW_TAG_member)
              .ascii "n\0"    # DW_AT_name
              .byte   0x1     # DW_AT_decl_file (foo.adb)
              .byte   0x6     # DW_AT_decl_line
              .long   0x194   # DW_AT_type
              .byte   0       # DW_AT_data_member_location
      
      ... and "A"...
      
              .uleb128 0x11   # (DIE (0x181) DW_TAG_member)
              .ascii "a\0"    # DW_AT_name
              .long   0x15d   # DW_AT_type
              .byte   0x4     # DW_AT_data_member_location
      
      ... which is an array ...
      
              .uleb128 0x12   # (DIE (0x15d) DW_TAG_array_type)
              .long   .LASF18 # DW_AT_name: "foo__record_type__T4b"
              .long   0x194   # DW_AT_type
      
      ... whose lower bound is implicitly 1, and the upper bound
      a reference to DIE 0x153 = "N":
      
              .uleb128 0x13   # (DIE (0x16a) DW_TAG_subrange_type)
              .long   0x174   # DW_AT_type
              .long   0x153   # DW_AT_upper_bound
      
      This patch enhanced GDB to understand references to other DIEs
      where the DIE's address is at an offset of its enclosing type.
      The difficulty was that the address used to resolve the array's
      type (R's address + 4 bytes) is different from the address used
      as the base to compute N's address (an offset to R's address).
      
      We're solving this issue by using a stack of addresses rather
      than a single address when trying to resolve a type. Each address
      in the stack corresponds to each containing level. For instance,
      if resolving the field of a struct, the stack should contain
      the address of the field at the top, and then the address of
      the struct.  That way, if the field makes a reference to an object
      of the struct, we can retrieve the address of that struct, and
      properly resolve the dynamic property references that struct.
      
      gdb/ChangeLog:
      
              * gdbtypes.h (struct dynamic_prop): New PROP_ADDR_OFFSET enum
              kind.
              * gdbtypes.c (resolve_dynamic_type_internal): Replace "addr"
              parameter by "addr_stack" parameter.
              (resolve_dynamic_range): Replace "addr" parameter by
              "stack_addr" parameter.  Update function documentation.
              Update code accordingly.
              (resolve_dynamic_array, resolve_dynamic_union)
              (resolve_dynamic_struct, resolve_dynamic_type_internal): Likewise.
              (resolve_dynamic_type): Update code, following the changes made
              to resolve_dynamic_type_internal's interface.
              * dwarf2loc.h (struct property_addr_info): New.
              (dwarf2_evaluate_property): Replace "address" parameter
              by "addr_stack" parameter.  Adjust function documentation.
              (struct dwarf2_offset_baton): New.
              (struct dwarf2_property_baton): Update documentation of
              field "referenced_type" to be more general. New field
              "offset_info" in union data field.
              * dwarf2loc.c (dwarf2_evaluate_property): Replace "address"
              parameter by "addr_stack" parameter.  Adjust code accordingly.
              Add support for PROP_ADDR_OFFSET properties.
              * dwarf2read.c (attr_to_dynamic_prop): Add support for
              DW_AT_data_member_location attributes as well.  Use case
              statements instead of if/else condition.
      
      gdb/testsuite/ChangeLog:
      
              * gdb.ada/disc_arr_bound: New testcase.
      
      Tested on x86_64-linux, no regression.
      df25ebbd
  16. 01 Jan, 2015 1 commit
  17. 12 Dec, 2014 3 commits
    • Tom Tromey's avatar
      the "compile" command · bb2ec1b3
      Tom Tromey authored
      This final patch adds the new "compile" command and subcommands, and
      all the machinery needed to make it work.
      
      A shared library supplied by gcc is used for all communications with
      gcc.  Types and most aspects of symbols are provided directly by gdb
      to the compiler using this library.
      
      gdb provides some information about the user's code using plain text.
      Macros are emitted this way, and DWARF location expressions (and
      bounds for VLA) are compiled to C code.
      
      This hybrid approach was taken because, on the one hand, it is better
      to provide global declarations and such on demand; but on the other
      hand, for local variables, translating DWARF location expressions to C
      was much simpler than exporting a full compiler API to gdb -- the same
      result, only easier to implement, understand, and debug.
      
      In the ordinary mode, the user's expression is wrapped in a dummy
      function.  After compilation, gdb inserts the resulting object code
      into the inferior, then calls this function.
      
      Access to local variables is provided by noting which registers are
      used by location expressions, and passing a structure of register
      values into the function.  Writes to registers are supported by
      copying out these values after the function returns.
      
      This approach was taken so that we could eventually implement other
      more interesting features based on this same infrastructure; for
      example, we're planning to investigate inferior-side breakpoint
      conditions.
      
      gdb/ChangeLog
      2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
      	    Jan Kratochvil  <jan.kratochvil@redhat.com>
      	    Tom Tromey  <tromey@redhat.com>
      
      	* NEWS: Update.
      	* symtab.h (struct symbol_computed_ops) <generate_c_location>: New
      	field.
      	* p-lang.c (pascal_language_defn): Update.
      	* opencl-lang.c (opencl_language_defn): Update.
      	* objc-lang.c (objc_language_defn): Update.
      	* m2-lang.c (m2_language_defn): Update.
      	* language.h (struct language_defn) <la_get_compile_instance,
      	la_compute_program>: New fields.
      	* language.c (unknown_language_defn, auto_language_defn)
      	(local_language_defn): Update.
      	* jv-lang.c (java_language_defn): Update.
      	* go-lang.c (go_language_defn): Update.
      	* f-lang.c (f_language_defn): Update.
      	* dwarf2loc.h (dwarf2_compile_property_to_c): Declare.
      	* dwarf2loc.c (dwarf2_compile_property_to_c)
      	(locexpr_generate_c_location, loclist_generate_c_location): New
      	functions.
      	(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update.
      	* defs.h (enum compile_i_scope_types): New.
      	(enum command_control_type) <compile_control>: New constant.
      	(struct command_line) <control_u>: New field.
      	* d-lang.c (d_language_defn): Update.
      	* compile/compile.c: New file.
      	* compile/compile-c-support.c: New file.
      	* compile/compile-c-symbols.c: New file.
      	* compile/compile-c-types.c: New file.
      	* compile/compile.h: New file.
      	* compile/compile-internal.h: New file.
      	* compile/compile-loc2c.c: New file.
      	* compile/compile-object-load.c: New file.
      	* compile/compile-object-load.h: New file.
      	* compile/compile-object-run.c: New file.
      	* compile/compile-object-run.h: New file.
      	* cli/cli-script.c (multi_line_command_p, print_command_lines)
      	(execute_control_command, process_next_line)
      	(recurse_read_control_structure): Handle compile_control.
      	* c-lang.h (c_get_compile_context, c_compute_program): Declare.
      	* c-lang.c (c_language_defn, cplus_language_defn)
      	(asm_language_defn, minimal_language_defn): Update.
      	* ada-lang.c (ada_language_defn): Update.
      	* Makefile.in (SUBDIR_GCC_COMPILE_OBS, SUBDIR_GCC_COMPILE_SRCS):
      	New variables.
      	(SFILES): Add SUBDIR_GCC_COMPILE_SRCS.
      	(HFILES_NO_SRCDIR): Add compile.h.
      	(COMMON_OBS): Add SUBDIR_GCC_COMPILE_OBS.
      	(INIT_FILES): Add SUBDIR_GCC_COMPILE_SRCS.
      	(compile.o, compile-c-types.o, compile-c-symbols.o)
      	(compile-object-load.o, compile-object-run.o, compile-loc2c.o)
      	(compile-c-support.o): New targets.
      
      gdb/doc/ChangeLog
      2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
      	    Jan Kratochvil  <jan.kratochvil@redhat.com>
      
      	* gdb.texinfo (Altering): Update.
      	(Compiling and Injecting Code): New node.
      
      gdb/testsuite/ChangeLog
      2014-12-12  Phil Muldoon  <pmuldoon@redhat.com>
      	    Jan Kratochvil  <jan.kratochvil@redhat.com>
      	    Tom Tromey  <tromey@redhat.com>
      
      	* configure.ac: Add gdb.compile/.
      	* configure: Regenerate.
      	* gdb.compile/Makefile.in: New file.
      	* gdb.compile/compile-ops.exp: New file.
      	* gdb.compile/compile-ops.c: New file.
      	* gdb.compile/compile-tls.c: New file.
      	* gdb.compile/compile-tls.exp: New file.
      	* gdb.compile/compile-constvar.S: New file.
      	* gdb.compile/compile-constvar.c: New file.
      	* gdb.compile/compile-mod.c: New file.
      	* gdb.compile/compile-nodebug.c: New file.
      	* gdb.compile/compile-setjmp-mod.c: New file.
      	* gdb.compile/compile-setjmp.c: New file.
      	* gdb.compile/compile-setjmp.exp: New file.
      	* gdb.compile/compile-shlib.c: New file.
      	* gdb.compile/compile.c: New file.
      	* gdb.compile/compile.exp: New file.
      	* lib/gdb.exp (skip_compile_feature_tests): New proc.
      bb2ec1b3
    • Jan Kratochvil's avatar
      export dwarf2_reg_to_regnum_or_error · d064d1be
      Jan Kratochvil authored
      This exports a utility function, dwarf2_reg_to_regnum_or_error, that
      was previously private to dwarf2loc.c.
      
      gdb/ChangeLog
      2014-12-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
      
      	* dwarf2loc.h (dwarf2_reg_to_regnum_or_error): Declare.
      	* dwarf2loc.c (dwarf2_reg_to_regnum_or_error): Rename from
      	translate_register.  Now public.
      	(dwarf2_compile_expr_to_ax): Update.
      d064d1be
    • Tom Tromey's avatar
      make dwarf_expr_frame_base_1 public · af945b75
      Tom Tromey authored
      This exports dwarf_expr_frame_base_1 so that other code can use it.
      
      gdb/ChangeLog
      2014-12-12  Tom Tromey  <tromey@redhat.com>
      	    Jan Kratochvil  <jan.kratochvil@redhat.com>
      
      	* dwarf2loc.c (dwarf_expr_frame_base_1): Remove declaration.
      	(dwarf_expr_frame_base): Update caller.
      	(dwarf_expr_frame_base_1): Rename to ...
      	(func_get_frame_base_dwarf_block): ... this and make it public.
      	(dwarf2_compile_expr_to_ax, locexpr_describe_location_piece): Update
      	callers.
      	* dwarf2loc.h (func_get_frame_base_dwarf_block): New declaration.
      af945b75
  18. 03 Sep, 2014 1 commit
  19. 18 Aug, 2014 1 commit
    • Joel Brobecker's avatar
      Add support for DW_OP_push_object_address. · 08412b07
      Joel Brobecker authored
      gdb/ChangeLog:
      
              * dwarf2expr.h (struct dwarf_expr_context_funcs): Uncomment
              field "get_object_address".
              * dwarf2expr.c (execute_stack_op): Add handling for
              DW_OP_push_object_address.
              * dwarf2loc.h (dwarf2_evaluate_property): Add "address" field.
              * dwarf2loc.c (struct dwarf_expr_baton): Add field "obj_address".
              (dwarf_expr_push_dwarf_reg_entry_value): Set baton_local.obj_address.
              (dwarf_expr_get_obj_addr): New function.
              (dwarf_expr_ctx_funcs): Add get_object_address field.
              (dwarf2_evaluate_loc_desc_full): Set baton.obj_address.
              (dwarf2_locexpr_baton_eval): Add parameter "addr".  Use it.
              (dwarf2_evaluate_property): Add parameter "address".  Use it.
              (needs_get_obj_addr): New function.
              (needs_frame_ctx_funcs): Add get_object_address field.
              (dwarf2_compile_expr_to_ax): Add DW_OP_push_object_address handling.
              * gdbtypes.c (resolve_dynamic_range): Add "addr" field.  Use it.
              (resolve_dynamic_array): Likewise.
      08412b07
  20. 30 Apr, 2014 1 commit
    • Siva Chandra's avatar
      Remove unused arguments to few functions in dwarf2loc.c and gdbtypes.c. · 1cfdf534
      Siva Chandra authored
      gdb/ChangeLog:
      
      	* dwarf2loc.c (dwarf2_locexpr_baton_eval,
      	dwarf2_evaluate_property): Remove unused CORE_ADDR argument.
      	Update all callers.
      	* dwarf2loc.h (dwarf2_evaluate_property): Update signature.
      	* gdbtypes.c (resolve_dynamic_range, resolve_dynamic_array):
      	Remove unused CORE_ADDR argument.  Update all callers.
      1cfdf534
  21. 14 Apr, 2014 1 commit
    • Sanimir Agovic's avatar
      type: add c99 variable length array support · 80180f79
      Sanimir Agovic authored
      The dwarf standard allow certain attributes to be expressed as dwarf
      expressions rather than constants. For instance upper-/lowerbound attributes.
      In case of a c99 variable length array the upperbound is a dynamic attribute.
      
      With this change c99 vla behave the same as with static arrays.
      
      1| void foo (size_t n) {
      2|   int ary[n];
      3|   memset(ary, 0, sizeof(ary));
      4| }
      
      (gdb) print ary
      $1 = {0 <repeats 42 times>}
      
      gdb/ChangeLog:
      
      	* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
      	(dwarf2_evaluate_property): New function.
      	* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
      	* dwarf2read.c (attr_to_dynamic_prop): New function.
      	(read_subrange_type): Use attr_to_dynamic_prop to read high bound
      	attribute.
      	* gdbtypes.c: Include dwarf2loc.h.
      	(is_dynamic_type): New function.
      	(resolve_dynamic_type): New function.
      	(resolve_dynamic_bounds): New function.
      	(get_type_length): New function.
      	(check_typedef): Use get_type_length to compute type length.
      	* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
      	(TYPE_LOW_BOUND_KIND): New macro.
      	(is_dynamic_type): New function prototype.
      	* value.c (value_from_contents_and_address): Call resolve_dynamic_type
      	to resolve dynamic properties of the type. Update comment.
      	* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
      80180f79
  22. 11 Apr, 2014 2 commits
    • Joel Brobecker's avatar
      Revert the entire VLA series. · 6b662e19
      Joel Brobecker authored
      This reverts the following patch series, as they cause some regresssions.
      
      commit 37c1ab67
      type: add c99 variable length array support
      
      	gdb/
      	* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
      	(dwarf2_evaluate_property): New function.
      	* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
      	* dwarf2read.c (attr_to_dynamic_prop): New function.
      	(read_subrange_type): Use attr_to_dynamic_prop to read high bound
      	attribute.
      	* gdbtypes.c: Include dwarf2loc.h.
      	(is_dynamic_type): New function.
      	(resolve_dynamic_type): New function.
      	(resolve_dynamic_bounds): New function.
      	(get_type_length): New function.
      	(check_typedef): Use get_type_length to compute type length.
      	* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
      	(TYPE_LOW_BOUND_KIND): New macro.
      	(is_dynamic_type): New function prototype.
      	* value.c (value_from_contents_and_address): Call resolve_dynamic_type
      	to resolve dynamic properties of the type. Update comment.
      	* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
      
      commit 26cb189f
      vla: enable sizeof operator to work with variable length arrays
      
      	gdb/
      	* eval.c (evaluate_subexp_for_sizeof) <OP_VAR_VALUE>: If the type
      	passed to sizeof is dynamic evaluate the argument to compute the length.
      
      commit 04b19544
      vla: enable sizeof operator for indirection
      
      	gdb/
      	* eval.c (evaluate_subexp_for_sizeof) <UNOP_IND>: Create an indirect
      	value and retrieve the dynamic type size.
      
      commit bcd629a4
      vla: update type from newly created value
      
      	gdb/
      	* ada-lang.c (ada_value_primitive_packed_val): Re-fetch type from value.
      	(ada_template_to_fixed_record_type_1): Likewise.
      	(ada_to_fixed_type_1): Likewise.
      	* cp-valprint.c (cp_print_value_fields_rtti): Likewise.
      	(cp_print_value): Likewise.
      	* d-valprint.c (dynamic_array_type): Likewise.
      	* eval.c (evaluate_subexp_with_coercion): Likewise.
      	* findvar.c (address_of_variable): Likewise.
      	* jv-valprint.c (java_value_print): Likewise.
      	* valops.c (value_ind): Likewise.
      	* value.c (coerce_ref): Likewise.
      
      commit b86138fb
      vla: print "variable length" for unresolved dynamic bounds
      
      	gdb/
      	* c-typeprint.c (c_type_print_varspec_suffix): Added
      	check for not yet resolved high bound. If unresolved, print
      	"variable length" string to the console instead of random
      	length.
      
      commit e1969afb
      vla: support for DW_AT_count
      
      	gdb/
      	* dwarf2read.c (read_subrange_type): Convert DW_AT_count to a dynamic
      	property and store it as the high bound and flag the range accordingly.
      	* gdbtypes.c (resolve_dynamic_bounds): If range is flagged as
      	RANGE_UPPER_BOUND_IS_COUNT assign low + high - 1 as the new high bound.
      	* gdbtypes.h (enum range_flags): New enum.
      	(struct range_bounds): Add flags member.
      
      commit 92b09522
      vla: resolve dynamic bounds if value contents is a constant byte-sequence
      
      	gdb/
      	* findvar.c (default_read_var_value): Resolve dynamic bounds if location
      	points to a constant blob.
      
      commit 3bce8237
      vla: evaluate operand of sizeof if its type is a vla
      
      	gdb/
      	* eval.c (evaluate_subexp_for_sizeof): Add enum noside argument.
      	(evaluate_subexp_standard): Pass noside argument.
      	(evaluate_subexp_for_sizeof) <BINOP_SUBSCRIPT>: Handle subscript case
      	if noside equals EVAL_NORMAL. If the subscript yields a vla type
      	re-evaluate subscript operation with EVAL_NORMAL to enable sideffects.
      	* gdbtypes.c (resolve_dynamic_bounds): Mark bound as evaluated.
      	* gdbtypes.h (enum range_flags): Add RANGE_EVALUATED case.
      
      	gdb/testsuite
      
      	* gdb.base/vla-sideeffect.c: New file.
      	* gdb.base/vla-sideeffect.exp: New file.
      
      commit 504f3432
      test: cover subranges with present DW_AT_count attribute
      
      	gdb/testsuite/
      	* gdb.dwarf2/count.exp: New file.
      
      commit 1a237e0e
      test: multi-dimensional c99 vla.
      
      	gdb/testsuite/
      	* gdb.base/vla-multi.c: New file.
      	* gdb.base/vla-multi.exp: New file.
      
      commit 024e13b4
      test: evaluate pointers to C99 vla correctly.
      
      	gdb/testsuite/
      	* gdb.base/vla-ptr.c: New file.
      	* gdb.base/vla-ptr.exp: New file.
      
      commit c8655f75
      test: basic c99 vla tests for C primitives
      
      	gdb/testsuite/
      	* gdb.base/vla-datatypes.c: New file.
      	* gdb.base/vla-datatypes.exp: New file.
      
      commit 58a84dcf
      test: add mi vla test
      
      	gdb/testsuite/
      	* gdb.mi/mi-vla-c99.exp: New file.
      	* gdb.mi/vla.c: New file.
      6b662e19
    • Sanimir Agovic's avatar
      type: add c99 variable length array support · 37c1ab67
      Sanimir Agovic authored
      The dwarf standard allow certain attributes to be expressed as dwarf
      expressions rather than constants. For instance upper-/lowerbound attributes.
      In case of a c99 variable length array the upperbound is a dynamic attribute.
      
      With this change c99 vla behave the same as with static arrays.
      
      1| void foo (size_t n) {
      2|   int ary[n];
      3|   memset(ary, 0, sizeof(ary));
      4| }
      
      (gdb) print ary
      $1 = {0 <repeats 42 times>}
      
      	* dwarf2loc.c (dwarf2_locexpr_baton_eval): New function.
      	(dwarf2_evaluate_property): New function.
      	* dwarf2loc.h (dwarf2_evaluate_property): New function prototype.
      	* dwarf2read.c (attr_to_dynamic_prop): New function.
      	(read_subrange_type): Use attr_to_dynamic_prop to read high bound
      	attribute.
      	* gdbtypes.c: Include dwarf2loc.h.
      	(is_dynamic_type): New function.
      	(resolve_dynamic_type): New function.
      	(resolve_dynamic_bounds): New function.
      	(get_type_length): New function.
      	(check_typedef): Use get_type_length to compute type length.
      	* gdbtypes.h (TYPE_HIGH_BOUND_KIND): New macro.
      	(TYPE_LOW_BOUND_KIND): New macro.
      	(is_dynamic_type): New function prototype.
      	* value.c (value_from_contents_and_address): Call resolve_dynamic_type
      	to resolve dynamic properties of the type. Update comment.
      	* valops.c (get_value_at, value_at, value_at_lazy): Update comment.
      37c1ab67
  23. 01 Jan, 2014 1 commit
  24. 06 May, 2013 1 commit
    • Tom Tromey's avatar
      * dwarf2loc.c (invalid_synthetic_pointer): Move earlier. · b6807d98
      Tom Tromey authored
      	(indirect_pieced_value): Call dwarf2_fetch_constant_bytes
      	if needed.
      	* dwarf2loc.h (dwarf2_fetch_constant_bytes): Declare.
      	* dwarf2read.c (write_constant_as_bytes)
      	(dwarf2_fetch_constant_bytes): New functions.
      gdb/testsuite
      	* gdb.dwarf2/implptrconst.c: New file.
      	* gdb.dwarf2/implptrconst.exp: New file.
      	* lib/dwarf.exp (Dwarf::_nz_quote): New proc.
      	(Dwarf::_handle_DW_FORM): Handle DW_FORM_block1.
      	(Dwarf::_location): Handle DW_OP_GNU_implicit_pointer.
      b6807d98
  25. 20 Mar, 2013 1 commit
    • Tom Tromey's avatar
      2013-03-20 Jan Kratochvil <jan.kratochvil@redhat.com> · f1e6e072
      Tom Tromey authored
      	    Tom Tromey  <tromey@redhat.com>
      
      	PR symtab/8421:
      	* coffread.c (coff_register_index): New global.
      	(process_coff_symbol, coff_read_enum_type): Set
      	SYMBOL_ACLASS_INDEX.
      	(_initialize_coffread): Initialize new global.
      	* dwarf2loc.c (locexpr_find_frame_base_location)
      	(dwarf2_block_frame_base_locexpr_funcs)
      	(loclist_find_frame_base_location)
      	(dwarf2_block_frame_base_loclist_funcs): New.
      	(dwarf_expr_frame_base_1): Call SYMBOL_BLOCK_OPS, remove internal_error.
      	(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Add location_has_loclist.
      	* dwarf2loc.h (dwarf2_block_frame_base_locexpr_funcs)
      	(dwarf2_block_frame_base_loclist_funcs): New.
      	* dwarf2read.c (dwarf2_locexpr_index, dwarf2_loclist_index)
      	(dwarf2_locexpr_block_index, dwarf2_loclist_block_index): New
      	globals.
      	(read_func_scope): Update.
      	(fixup_go_packaging, mark_common_block_symbol_computed)
      	(var_decode_location, new_symbol_full, dwarf2_const_value):
      	Set SYMBOL_ACLASS_INDEX.
      	(dwarf2_symbol_mark_computed): Likewise.  Add 'is_block' argument.
      	(_initialize_dwarf2_read): Initialize new globals.
      	* jit.c (finalize_symtab): Set SYMBOL_ACLASS_INDEX.
      	* jv-lang.c (add_class_symbol): Set SYMBOL_ACLASS_INDEX.
      	* mdebugread.c (mdebug_register_index, mdebug_regparm_index): New
      	globals.
      	(parse_symbol, psymtab_to_symtab_1): Set SYMBOL_ACLASS_INDEX.
      	(_initialize_mdebugread): Initialize new globals.
      	* psympriv.h (struct partial_symbol) <aclass>: Update comment.
      	* stabsread.c (patch_block_stabs): Set SYMBOL_ACLASS_INDEX.
      	(stab_register_index, stab_regparm_index): New globals.
      	(define_symbol, read_enum_type, common_block_end): Set
      	SYMBOL_ACLASS_INDEX.
      	(_initialize_stabsread): Initialize new globals.
      	* symtab.c (next_aclass_value, symbol_impl, symbol_impls): New
      	globals.
      	(MAX_SYMBOL_IMPLS): New define.
      	(register_symbol_computed_impl, register_symbol_block_impl)
      	(register_symbol_register_impl)
      	(initialize_ordinary_address_classes): New functions.
      	(_initialize_symtab): Call initialize_ordinary_address_classes.
      	* symtab.h (enum address_class) <LOC_FINAL_VALUE>: New constant.
      	(struct symbol_impl): New.
      	(SYMBOL_ACLASS_BITS): New define.
      	(struct symbol) <aclass, ops>: Remove fields.
      	<aclass_index>: New field.
      	(symbol_impls): Declare.
      	(SYMBOL_CLASS, SYMBOL_COMPUTED_OPS, SYMBOL_REGISTER_OPS): Redefine.
      	(SYMBOL_IMPL, SYMBOL_ACLASS_INDEX): New defines.
      	(register_symbol_computed_impl, register_symbol_block_impl)
      	(register_symbol_register_impl): Declare.
      	(struct symbol_computed_ops): Add location_has_loclist.
      	(struct symbol_block_ops): New.
      	(SYMBOL_BLOCK_OPS): New.
      	* xcoffread.c (process_xcoff_symbol): Set SYMBOL_ACLASS_INDEX.
      f1e6e072
  26. 01 Jan, 2013 1 commit
  27. 10 Dec, 2012 1 commit
    • Tom Tromey's avatar
      * dwarf2read.c (dwarf2_fetch_die_loc_sect_off): New function. · 8b9737bf
      Tom Tromey authored
      	(dwarf2_fetch_die_loc_cu_off): Rename from
      	dwarf2_fetch_die_location_block.  Rewrite to use
      	dwarf2_fetch_die_loc_sect_off.
      	* dwarf2loc.h (dwarf2_fetch_die_loc_sect_off): Declare.
      	(dwarf2_fetch_die_loc_cu_off): Rename.
      	* dwarf2loc.c (indirect_pieced_value): Use
      	dwarf2_fetch_die_loc_sect_off.
      	* dwarf2expr.h (struct dwarf_expr_context) <len, data>: Update
      	comment.
      	(struct dwarf_expr_piece) <v.ptr.die>: Now a sect_offset.
      	* dwarf2expr.c (add_piece): Update.
      	(execute_stack_op) <DW_OP_GNU_implicit_pointer>: Update comment.
      testsuite
      	* gdb.dwarf2/implptr-64bit.exp: Run tests with two CUs as well.
      	(test): Add "two_cu" argument.
      	* gdb.dwarf2/implptr-64bit.S: Move subprogram later; use ref_addr
      	for types; allow two CUs.
      8b9737bf
  28. 02 Aug, 2012 1 commit
    • Yao Qi's avatar
      gdb/ · ccce17b0
      Yao Qi authored
      	* dwarf2loc.c (entry_values_debug): Add 'unsigned'.
      	(_initialize_dwarf2loc): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* dwarf2loc.h: Update the declaration of 'entry_values_debug'.
      	* dwarf2read.c (dwarf2_die_debug): Add 'unsigned'.
      	(_initialize_dwarf2_read): Call add_setshow_zuinteger_cmd
      	instead of add_setshow_zinteger_cmd.
      	* darwin-nat.c (dwarwin_debug_flag): Add 'unsigned'.
      	(_initialize_darwin_inferior): Call add_setshow_zuinteger_cmd
      	instead of add_setshow_zinteger_cmd.
      	* frame.c (frame_debug): Add 'unsigned'.
      	(_intialize_frame): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* frame.h: Update the declaration of 'frame_debug'.
      	* gdbtypes.c (overload_debug): Add 'unsigned'.
      	(_initialize_gdbtypes): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* inferior.h: Update declaration of 'debug_infrun'.
      	* infrun.c (debug_infrun): Add 'unsigned'.
      	(_initialize_infrun): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* jit.c (jit_debug): Add 'unsigned'.
      	(_initialize_jit): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* linux-nat.c (debug_linux_nat): Add 'unsigned'.
      	(_initialize_linux_nat): Call add_setshow_zuinteger_cmd
      	instead of add_setshow_zinteger_cmd.
      	* linux-thread-db.c (libthread_db_debug): Add 'unsigned'.
      	(_initialize_thread_db): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* machoread.c (mach_o_debug_level): Add 'unsigned'.
      	(_initialize_machoread): Call add_setshow_zuinteger_cmd
      	instead of add_setshow_zinteger_cmd.
      	* mi/mi-cmd-var.c: Update the declaration of 'varobjdebug'.
      	* microblaze-tdep.c (microblaze_debug_flag): Add 'unsigned'.
      	(_initialize_microblaze_tdep): Call add_setshow_zuinteger_cmd
      	intead of add_setshow_zinteger_cmd.
      	* mips-tdep.c (mips_debug): Add 'unsigned'.
      	(_initialize_mips_tdep): Call add_setshow_zuinteger_cmd
      	instead of add_setshow_zinteger_cmd.
      	* monitor.c (monitor_debug): Add 'unsigned'.
      	(_initialize_remote_monitors): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* observer.c (observer_debug): Add 'unsigned'.
      	(_initialize_observer): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* parse.c (expressiondebug): Add 'unsigned'.
      	(_initialize_parse): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* record.c (record_debug): Add 'unsigned'.
      	(_initialize_record): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* record.h: Update the declaration of 'record_debug'.
      	* stap-probe.c (stap_expression_debug): Add 'unsigned'.
      	(_initialize_stap_probe): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* serial.c (global_serial_debug_p): Add 'unsigned'.
      	(_initialize_serial): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* solib-dsbt.c (solib_dsbt_debug): Add 'unsigned'.
      	(_initialize_dsbt_solib): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* solib-frv.c (solib_frv_debug): Add 'unsigned'.
      	(_initialize_frv_solib): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* target.c (targetdebug): Add 'unsigned'.
      	(initialize_targets): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* valops.c (overload_debug): Add 'unsigned'.
      	* varobj.c (varobjdebug): Add 'unsigned'.
      	(_initialize_varobj): Call add_setshow_zuinteger_cmd instead of
      	add_setshow_zinteger_cmd.
      	* xtensa-tdep.c (xtensa_debug_level): Add 'unsigned'.
      	(_initialize_xtensa_tdep): Call add_setshow_zuinteger_cmd
      	instead of add_setshow_zinteger_cmd.
      
      	* arch-utils.h: Remove the declaration of 'gdbarch_debug'.
      	* gdbarch.sh (gdbarch_debug): Add 'unsigned'.
      	(extern void _initialize_gdbarch): Call add_setshow_zuinteger_cmd
      	instead of add_setshow_zinteger_cmd.
      	* gdbarch.c, gdbarch.h: Re-generated.
      ccce17b0
  29. 26 Jul, 2012 1 commit
    • Siddhesh Poyarekar's avatar
      * dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Expand parameter · 56eb65bd
      Siddhesh Poyarekar authored
      	SIZE to size_t.
      	(dwarf2_evaluate_loc_desc): Likewise.
      	(dwarf2_loc_desc_needs_frame): Likewise.
      	(locexpr_describe_location_1): Likewise.
      	* dwarf2loc.h (struct dwarf2_locexpr_baton): Make SIZE as
      	size_t.
      	(struct dwarf2_loclist_baton): Likewise.
      	* dwarf2read.c (struct dwarf_block): Likewise.
      	(dump_die_shallow): Use pulongest to print dwarf_block.size.
      	(decode_locdesc): Expand SIZE and I to size_t.
      56eb65bd
  30. 22 May, 2012 1 commit
    • Doug Evans's avatar
      * dwarf2-frame.c (struct dwarf2_cie): Make initial_instructions, end · f664829e
      Doug Evans authored
      	"const gdb_byte *".
      	(struct dwarf2_fde): Make instructions, end "const gdb_byte *".
      	(execute_cfa_program): Update to match API of leb128 functions.
      	(read_1_byte, read_4_bytes, read_8_bytes): Make buf parameter
      	"const gdb_byte *".
      	(read_unsigned_leb128, read_signed_leb128): Delete.
      	(read_initial_length): Change type of buf argument to
      	"const gdb_byte *".
      	(read_encoded_value): Update to match API of leb128 functions.
      	(decode_frame_entry): Change result to "const gdb_byte *", and
      	similarly for "start" parameter.
      	(decode_frame_entry_1): Ditto.  Use new leb128 reader functions.
      	(dwarf2_build_frame_info): Change local frame_ptr to
      	"const gdb_byte *".
      	* dwarf2expr.c (safe_read_uleb128, safe_read_sleb128): Replaces
      	read_uleb128, read_sleb128.  All callers updated.
      	(safe_skip_leb128): New function.
      	(dwarf_block_to_dwarf_reg): Update to match API of leb128 functions.
      	Call gdb_read_uleb128, gdb_skip_leb128 instead of read_uleb128.
      	(dwarf_block_to_dwarf_reg_deref): Update to match API of leb128
      	functions.  Call gdb_read_uleb128, gdb_read_sleb128 instead of
      	read_uleb128, read_sleb128.
      	(dwarf_block_to_fb_offset, dwarf_block_to_sp_offset): Ditto.
      	(execute_stack_op): Update to match API of leb128 functions.
      	* dwarf2expr.h: #include "leb128.h".
      	(read_uleb128, read_sleb128): Delete.
      	(gdb_read_uleb128, gdb_read_sleb128, gdb_skip_leb128): New functions.
      	(safe_read_uleb128, safe_read_sleb128, safe_skip_leb128): Declare.
      	* dwarf2loc.c (debug_loc_kind): New enum.
      	(decode_debug_loc_addresses): New function.
      	(decode_debug_loc_dwo_addresses): New function.
      	(dwarf2_find_location_expression): Rewrite.
      	(dwarf2_compile_expr_to_ax): Update to match API of leb128 functions.
      	(locexpr_describe_location_piece): Ditto.
      	(disassemble_dwarf_expression): Ditto.
      	(locexpr_describe_location_1): Ditto.
      	(loclist_describe_location): Rewrite.
      	* dwarf2loc.h (dwarf2_loclist_baton): New member "from_dwo".
      	* dwarf2read.c (die_reader_specs): New member "buffer_end".
      	(dwarf2_section_buffer_overflow_complaint): Renamed from
      	dwarf2_macros_too_long_complaint.  All callers updated.
      	(skip_leb128): Delete.
      	(init_cu_die_reader): Initialize reader->buffer_end.
      	(skip_one_die): Replace call to skip_leb128 with safe_skip_leb128.
      	(skip_form_bytes): New arg buffer_end.  All callers updated.
      	Replace call to skip_leb128 with gdb_skip_leb128.
      	(skip_unknown_opcode): New arg mac_end.  All callers updated.
      	(fill_in_loclist_baton): Initialize baton->from_dwo.
      f664829e
  31. 28 Apr, 2012 1 commit
    • Doug Evans's avatar
      Initial support for Fission. http://gcc.gnu.org/wiki/DebugFission · 3019eac3
      Doug Evans authored
      	* symfile.c (default_symfile_relocate): Use sectp->owner instead of
      	objfile->obfd.
      	* symfile.h (dwarf2_debug_sections): New member addr.
      	* dwarf2expr.c (execute_stack_op): New case DW_OP_GNU_addr_index.
      	(ctx_no_get_addr_index): New function.
      	* dwarf2expr.h (dwarf_expr_context_funcs): New member get_addr_index.
      	(ctx_no_get_addr_index): Declare.
      	* dwarf2-frame.c (dwarf2_frame_ctx_funcs): Update.
      	* dwarf2loc.c (dwarf_expr_get_addr_index): New function.
      	(dwarf_expr_ctx_funcs): Update.
      	(needs_get_addr_index): New function.
      	(needs_frame_ctx_funcs): Update.
      	* dwarf2loc.h (dwarf2_read_addr_index): Declare.
      	* dwarf2read.c: #include "gdbcore.h".
      	(dwarf2_per_objfile): New members addr, dwo_files.
      	(dwarf2_elf_names): Add entry for addr.
      	(struct dwo_section_names): New type.
      	(dwo_section_names): New static global.
      	(dwarf2_cu): New members dwo_unit, addr_base, have_addr_base.
      	(dwarf2_per_cu_data): New member is_debug_types, all boolean uses of
      	old debug_types_section member updated to use this.
      	Rename member debug_types_section to info_or_types_section,
      	all uses updated.
      	(signatured_type): Rename member type_offset to type_offset_in_tu,
      	all uses updated.  New member type_offset_in_section.
      	(struct dwo_sections): New type.
      	(struct dwo_unit): New type.
      	(struct dwo_file): New type.
      	(die_reader_specs): New member dwo_file.
      	(dwarf2_locate_sections): Watch for .debug_addr.
      	(zlib_decompress_section): Use sectp->owner instead of objfile->obfd.
      	(dwarf2_read_section): Get bfd of section from bfd's asection,
      	instead of objfile.
      	(create_cus_from_index): Initialize the_cu->info_or_types_section.
      	(create_signatured_type_table_from_index): Initialize
      	sig_type->info_or_types_section.
      	(dw2_get_file_names): Statement lists for type units with DWO files
      	live in the DWO file.
      	(create_debug_types_hash_table): New function.
      	(create_all_type_units): Rewrite.
      	(init_cu_die_reader): New arg dwo_file, all callers updated.
      	(init_and_read_dies_worker): Get section from
      	this_cu->info_or_types_section.  Set sig_type->type_offset_in_section.
      	Watch for DW_AT_GNU_dwo_name and if present lookup the file and
      	continue reading the CU/TU from there.
      	(init_cutu_and_read_dies_no_follow): New arg dwo_file, all callers
      	updated.  Get section from this_cu->info_or_types_section.
      	(create_all_comp_units): Initialize this_cu->info_or_types_section.
      	(skip_one_die): New cases DW_FORM_GNU_addr_index,
      	DW_FORM_GNU_str_index.
      	(hash_dwo_file, eq_dwo_file): New functions.
      	(allocate_dwo_file_hash_table): New function.
      	(hash_dwo_unit, eq_dwo_unit): New functions.
      	(allocate_dwo_unit_table): New function.
      	(dwarf2_locate_dwo_sections): New function.
      	(struct create_dwo_info_table_data): New type.
      	(create_debug_info_hash_table_reader): New function.
      	(create_debug_info_hash_table): New function.
      	(try_open_dwo_file, open_dwo_file, init_dwo_file): New function.
      	(lookup_dwo_file): New function.
      	(lookup_dwo_comp_unit, lookup_dwo_type_unit): New functions.
      	(free_dwo_file, free_dwo_file_cleanup): New functions.
      	(free_dwo_file_from_slot, free_dwo_files): New functions.
      	(dwarf2_get_pc_bounds): Handle DW_FORM_GNU_addr_index.
      	(dwarf2_record_block_ranges): Ditto.
      	(read_partial_die): Ditto.
      	(process_enumeration_scope): Update to use type_offset_in_section.
      	(read_full_die_1): New function.
      	(read_full_die): Rewrite.
      	(read_attribute_value): New cases DW_FORM_GNU_addr_index,
      	DW_FORM_GNU_str_index.
      	(read_addr_index_1, read_addr_index): New functions.
      	(read_addr_index_from_leb128): New function.
      	(struct dwarf2_read_addr_index_data): New type.
      	(dwarf2_read_addr_index_reader): New function.
      	(dwarf2_read_addr_index): New function.
      	(read_str_index): New function.
      	(leb128_size): New function.
      	(dwarf_decode_line_header): Delete arg abfd, all callers updated.
      	If processing a type unit from a DWO file, get the line section
      	from the DWO file.
      	(var_decode_location): Watch for DW_OP_GNU_addr_index.
      	(dwarf2_const_value_attr): New cases DW_FORM_GNU_addr_index,
      	DW_FORM_GNU_str_index.
      	(lookup_die_type): Check whether section offset of type's die is
      	known before looking it up.  Remove assert.  Condition can
      	legimately happen for inter-cu type references.
      	(dwarf_attr_name): Handle Fission attributes.
      	(dwarf_form_name): Handle Fission forms.
      	(dump_die_shallow): New cases DW_FORM_GNU_addr_index,
      	DW_FORM_GNU_str_index.
      	(follow_die_sig): Update to use type_offset_in_section.
      	(decode_locdesc): New case DW_OP_GNU_addr_index.
      	(skip_form_bytes): New cases DW_FORM_GNU_addr_index,
      	DW_FORM_GNU_str_index.
      	(cu_debug_loc_section): New function.
      	(fill_in_loclist_baton, dwarf2_symbol_mark_computed): Call it.
      	(dwarf2_per_objfile_free): Unmap .debug_addr section.
      	Free DWO files if present.
      	* xcoffread.c (dwarf2_xcoff_names): Add .debug_addr.
      
      	testsuite/
      	* gdb.dwarf2/dw2-intercu.S (.Ltype_int2_in_cu2): Renamed from
      	.Ltype_int_in_cu2.  Use name "int2" instead of "int".
      	All uses updated.
      	* gdb.dwarf2/dw2-intercu.exp: Add "ptype int2" ahead of
      	"ptype func_cu1" to expand cu2 before cu1.
      3019eac3
  32. 19 Mar, 2012 1 commit
    • Jan Kratochvil's avatar
      gdb/ · b64f50a1
      Jan Kratochvil authored
      	Code cleanupp: Use cu_offset and sect_offset compile time type checking.
      	* dwarf2expr.c (add_piece, dwarf_get_base_type, execute_stack_op)
      	(ctx_no_dwarf_call, ctx_no_get_base_type): Use cu_offset and
      	sect_offset.
      	* dwarf2expr.h (cu_offset, sect_offset): New types.
      	(struct dwarf_expr_context_funcs) <dwarf_call>
      	(struct dwarf_expr_context_funcs) <get_base_type>: Use cu_offset and
      	sect_offset.
      	(struct dwarf_expr_context) <len>: Improve the comment.
      	(struct dwarf_expr_piece, ctx_no_dwarf_call, ctx_no_get_base_type): Use
      	cu_offset and sect_offset.
      	* dwarf2loc.c (per_cu_dwarf_call, dwarf_expr_dwarf_call)
      	(dwarf_expr_get_base_type, needs_frame_dwarf_call)
      	(dwarf2_compile_expr_to_ax, disassemble_dwarf_expression): Likewise.
      	* dwarf2loc.h: Include dwarf2expr.h.
      	(dwarf2_fetch_die_location_block, dwarf2_get_die_type): Use cu_offset
      	and sect_offset.
      	* dwarf2read.c (struct dwarf2_per_objfile) <debug_types_type_hash>:
      	Improve the comment.
      	(struct comp_unit_head, struct dwarf2_cu, struct dwarf2_per_cu_data)
      	(struct signatured_type, struct line_header, struct partial_die_info)
      	(struct die_info, find_partial_die, dwarf2_get_ref_die_offset)
      	(lookup_signatured_type_at_offset, dwarf2_find_containing_comp_unit)
      	(get_die_type_at_offset, create_cus_from_index)
      	(create_signatured_type_table_from_index, dw2_get_file_names)
      	(offset_in_cu_p, read_comp_unit_head, error_check_comp_unit_head)
      	(read_and_check_comp_unit_head, read_and_check_type_unit_head)
      	(create_debug_types_hash_table, process_psymtab_comp_unit)
      	(load_partial_comp_unit, create_all_comp_units)
      	(partial_die_parent_scope, partial_die_full_name, skip_one_die)
      	(load_full_comp_unit, dwarf2_physname, read_import_statement)
      	(inherit_abstract_dies, read_func_scope, read_call_site_scope)
      	(dwarf2_add_member_fn, process_enumeration_scope, read_module_type)
      	(read_typedef, die_hash, die_eq, read_full_die, dwarf2_read_abbrevs)
      	(load_partial_dies, read_partial_die, find_partial_die_in_comp_unit)
      	(find_partial_die, read_attribute_value, lookup_die_type)
      	(dump_die_shallow, store_in_ref_table): Use cu_offset and sect_offset.
      	(is_ref_attr): New function comment.
      	(dwarf2_get_ref_die_offset): New function comment, new variable retval.
      	Use cu_offset and sect_offset.
      	(follow_die_offset, follow_die_ref, dwarf2_fetch_die_location_block)
      	(dwarf2_get_die_type, follow_die_sig, lookup_signatured_type_at_offset)
      	(load_full_type_unit, read_signatured_type, per_cu_header_read_in)
      	(dwarf2_find_containing_comp_unit, struct dwarf2_offset_and_type)
      	(offset_and_type_hash, offset_and_type_eq, set_die_type)
      	(get_die_type_at_offset, partial_die_hash, partial_die_eq)
      	(write_one_signatured_type, write_psymtabs_to_index): Use cu_offset and
      	sect_offset.
      b64f50a1
  33. 08 Mar, 2012 1 commit
    • Jan Kratochvil's avatar
      gdb/ · 7fe25d9b
      Jan Kratochvil authored
      	Fix CU relative vs. absolute DIE offsets.
      	* dwarf2loc.h (dwarf2_fetch_die_location_block): Rename parameter
      	offset to offset_in_cu.
      	* dwarf2read.c (process_enumeration_scope): Add CU offset to
      	TYPE_OFFSET.
      	(dwarf2_fetch_die_location_block): Rename parameter offset to
      	offset_in_cu.  New variable offset, add CU offset to OFFSET_IN_CU.
      
      gdb/testsuite/
      	Fix CU relative vs. absolute DIE offsets.
      	* gdb.dwarf2/dw2-op-call.S: New compilation unit preceding the existing
      	one.
      7fe25d9b
  34. 05 Jan, 2012 1 commit
  35. 04 Jan, 2012 1 commit
  36. 12 Oct, 2011 1 commit
    • Jan Kratochvil's avatar
      gdb/ · 1d6edc3c
      Jan Kratochvil authored
      	Fix empty DWARF expressions DATA vs. SIZE conditionals.
      	* dwarf2loc.c (dwarf2_find_location_expression): Clear *LOCEXPR_LENGTH.
      	(dwarf_expr_frame_base_1): Indicate unavailability via zero *LENGTH.
      	(locexpr_tracepoint_var_ref): Check only zero SIZE, not zero DATA.
      	(loclist_read_variable, loclist_tracepoint_var_ref): Do not check for
      	zero DATA.
      	* dwarf2loc.h (struct dwarf2_locexpr_baton): Comment DATA vs. SIZE
      	validity.
      	* dwarf2read.c (struct dwarf_block): Comment DATA validity.
      	(dwarf2_fetch_die_location_block, dwarf2_symbol_mark_computed): Do not
      	clear DATA on zero SIZE.
      
      gdb/testsuite/
      	Fix empty DWARF expressions DATA vs. SIZE conditionals.
      	* gdb.dwarf2/dw2-op-call.S (arraycallnoloc, arraynoloc): New DIEs.
      	(loclist): New.
      	(4): New abbrev.
      	* gdb.dwarf2/dw2-op-call.exp: Remove variable srcfile and executable.
      	Use prepare_for_testing, remove clean_restart.
      	(p arraynoloc, p arraycallnoloc): New tests.
      1d6edc3c
  37. 09 Oct, 2011 1 commit
    • Jan Kratochvil's avatar
      gdb/ · 111c6489
      Jan Kratochvil authored
      	Recognize virtual tail call frames.
      	* Makefile.in (SFILES): Add dwarf2-frame-tailcall.c.
      	(HFILES_NO_SRCDIR): Add dwarf2-frame-tailcall.h.
      	(COMMON_OBS): Add dwarf2-frame-tailcall.o.
      	* dwarf2-frame-tailcall.c: New file.
      	* dwarf2-frame-tailcall.h: New file.
      	* dwarf2-frame.c: Include dwarf2-frame-tailcall.h.
      	(execute_cfa_program): New function comment.  Return INSN_PTR.  Reset
      	REGS.PREV only after CIE execution.
      	(struct dwarf2_frame_cache): New field tailcall_cache.
      	(dwarf2_frame_cache): New variables entry_pc, entry_cfa_sp_offset,
      	entry_cfa_sp_offset_p and instr.  Execute FDE instructions in two
      	parts, try to find entry_cfa_sp_offset.  Call
      	dwarf2_tailcall_sniffer_first.
      	(dwarf2_frame_prev_register): Call dwarf2_tailcall_prev_register_first
      	when appropriate.
      	(dwarf2_frame_dealloc_cache): New function.
      	(dwarf2_frame_sniffer): Preinitialize cache by dwarf2_frame_cache.
      	(dwarf2_frame_unwind): Install dwarf2_frame_dealloc_cache.
      	(dwarf2_signal_frame_unwind): Do not install dwarf2_frame_dealloc_cache.
      	(dwarf2_append_unwinders): Add dwarf2_tailcall_frame_unwind.
      	(dwarf2_frame_cfa): Support also dwarf2_tailcall_frame_unwind.
      	* dwarf2loc.c (func_addr_to_tail_call_list)
      	(tailcall_dump, call_sitep, VEC (call_sitep), chain_candidate)
      	(call_site_find_chain_1, call_site_find_chain): New.
      	* dwarf2loc.h (struct call_site_chain): New.
      	(call_site_find_chain): New declaration.
      	* frame.c (get_frame_address_in_block): Support also TAILCALL_FRAME.
      	* frame.h (enum frame_type): New entry TAILCALL_FRAME.
      	* python/py-frame.c (gdbpy_initialize_frames): Add TAILCALL_FRAME.
      	* stack.c (frame_info): Support also TAILCALL_FRAME.
      
      gdb/doc/
      	Recognize virtual tail call frames.
      	* gdb.texinfo (Optimized Code): Add reference to Tail Call Frames.
      	(Tail Call Frames): New node.
      	(Frames In Python): Add gdb.TAILCALL_FRAME.
      
      gdb/testsuite/
      	Recognize virtual tail call frames.
      	* gdb.arch/amd64-entry-value.cc (c, a, b, amb_z, amb_y, amb_x, amb)
      	(amb_b, amb_a): New.
      	(main): Call a and b.
      	* gdb.arch/amd64-entry-value.exp (tailcall: breakhere, tailcall: bt)
      	(tailcall: p i, tailcall: p j, set $sp0=$sp, up, p $sp0 == $sp, frame 3)
      	(p $sp0 + sizeof (void *) == $sp, ambiguous: breakhere, ambiguous: bt):
      	New tests.
      111c6489