Commit Graph

41505 Commits

Author SHA1 Message Date
Jim Wilson 52a187f8e7 RISC-V: Add configure support for riscv*-linux*.
This adds the target and native configure support, and the NEWS entries for
the new target and native configurations.

	gdb/
	* Makefile.in (ALL_TARGET_OBS): Add riscv-linux-tdep.c.
	(ALLDEPFILES): Add riscv-linux-nat.c, and riscv-linux-tdep.c.
	* NEWS: Mention new GNU/Linux RISC-V target.
	* configure.host: Add riscv*-*-linux*.
	* configure.nat: Add riscv*.
	* configure.tgt: Add riscv*-*-linux*.
2018-08-09 13:37:45 -07:00
Jim Wilson 3c77f97eb0 RISC-V: Add native linux support.
Add initial native support for riscv*-linux*.

	gdb/
	* riscv-linux-nat.c: New file.
2018-08-09 13:35:24 -07:00
Jim Wilson 90ad36544c RISC-V: Add linux target support.
Add initial target support for riscv*-linux*.

	gdb/
	* riscv-linux-tdep.c: New file.
2018-08-09 13:33:36 -07:00
Andrew Burgess aff4e1751f gdb: Make infrun.c:resume function static
Make the infrun.c:resume function static, and update the header
comment on the infrun.c:proceed function.  There should be no user
visible change after this commit.

gdb/ChangeLog:

	* infrun.c (resume): Make static, add forward declaration.
	(proceed): Update header comment.
	* infrun.h (resume): Delete declaration.
2018-08-09 19:23:43 +01:00
Tom Tromey 06ab921988 Minor formatting fixes in riscv-tdep.h
This fixes some minor formatting issues in riscv-tdep.h, including one
pointed out by ARI.

ChangeLog
2018-08-09  Tom Tromey  <tom@tromey.com>

	* riscv-tdep.h: Minor formatting fixes.
2018-08-09 11:42:57 -06:00
Simon Marchi 83c8d318d1 Fix some gettext ARI warnings
ARI produces this warning for the lines touched in this patch:

  warning: gettext: All messages should be marked up with _.

However, in these cases, the message is not translatable (they are
syscall names).  Adding an extra set of parentheses silences the
warning.

gdb/ChangeLog:

	* common/scoped_mmap.c (mmap_file): Silence ARI warning.
	* dwarf-index-cache.c (create_dir_and_check): Likewise.
	(test_mkdir_recursive): Likewise.
	* dwarf-index-write.c (write_psymtabs_to_index): Likewise.
2018-08-09 13:17:56 -04:00
Andrew Burgess 5ff2bbae19 gdb: Check element of optimised out vla exists
If a vla is not in memory, and the upper bound is not defined, then we
can't know that an array element exists or not, and we should not try
to access the array element.  One case where this happens is for
arrays that have been optimised out, the array will then have
VALUE_LVAL of not_lval, and an undefined upper bound, if we then try
to access an element of this array we will index into random GDB
memory.

An argument could be made that even for arrays that are in inferior
memory, if the upper bound is not defined then we should not try to
access the array element, however, in some of the Fortran tests, it
seems as though we do rely indexing from a base address into an array
which has no bounds defined.  In this case GDBs standard protection
for detecting unreadable target memory prevents bad thing happening.

gdb/ChangeLog:

	* valarith.c (value_subscripted_rvalue): If an array is not in
	memory, and we don't know the upper bound, then we can't know that
	the requested element exists or not.

gdb/testsuite/ChangeLog:

	* gdb.base/vla-optimized-out.exp: Add new test.
2018-08-09 17:17:35 +01:00
Andrew Burgess e5bbcd0f04 gdb: Merge similar tests into a single test script
The three test scripts:

  gdb/testsuite/gdb.base/vla-optimized-out.exp
  gdb/testsuite/gdb.base/vla-optimized-out-o3.exp
  gdb/testsuite/gdb.base/vla-optimized-out-o3-strict.exp

are all pretty similar, with differences in the compile flags used,
and some of the expected results.

Instead of maintaining 3 files, merge them into a single test script,
and use parameters to control the test behaviour.

gdb/testsuite/ChangeLog:

	* gdb.base/vla-optimized-out-o3.exp: Delete.
	* gdb.base/vla-optimized-out-o3-strict.exp: Delete.
	* gdb.base/vla-optimized-out.exp: Extend to cover all of the
	deleted tests.
2018-08-09 17:17:34 +01:00
Simon Marchi fdbac7d8d1 Fix some comments in target.c
Fix a typo and add a missing one.

gdb/ChangeLog:

	* target.c (str_comma_list_concat_elem): Fix typo in comment.
	(target_options_to_string): Add comment.
2018-08-08 18:13:18 -04:00
Tom Tromey 83202f7ae8 Check result of "write"
Some distros enable _FORTIFY_SOURCE by default, which caught a failure
to check the result of "write" in scoped_mmap-selftests.c.  This patch
fixes the problem.

ChangeLog
2018-08-08  Tom Tromey  <tom@tromey.com>

	* unittests/scoped_mmap-selftests.c: Check result of "write".
2018-08-08 11:59:44 -06:00
Jim Wilson 5c720ed886 RISC-V: Add software single step support.
This adds software single step support that is needed by the linux native port.
This is modeled after equivalent code in the MIPS port.

This also fixes a few bugs in the compressed instruction decode support.  Some
instructions are RV32/RV64 specific, and this wasn't being checked.  Also, a
few instructions were accidentally using the non-compressed is_* function.

This has been tested on a HiFive Unleashed running Fedora, by putting a
breakpoint on start, typing stepi, and then holding down the return key until
it finishes, and observing that I see everything I expect to see along the way.
There is a problem in _dl_addr where I get into an infinite loop, but it seems
to be some synchronization code that doesn't agree with single step, so I have
to find the end of the loop, put a breakpoint there, continue, and then single
step again until the end.

	gdb/
	* riscv-tdep.c (enum opcode): Add jump, branch, lr, and sc opcodes.
	(decode_register_index_short): New.
	(decode_j_type_insn, decode_cj_type_insn): New.
	(decode_b_type_insn, decode_cb_type_insn): New.
	(riscv_insn::decode): Add support for jumps, branches, lr, and sc.  New
	local xlen.  Check xlen when decoding ambiguous compressed insns.  In
	compressed decode, use is_c_lui_insn instead of is_lui_insn, and
	is_c_sw_insn instead of is_sw_insn.
	(riscv_next_pc, riscv_next_pc_atomic_sequence): New.
	(riscv_software_single_step): New.
	* riscv-tdep.h (riscv_software_single_step): Declare.
2018-08-08 10:53:12 -07:00
Jim Wilson 411baa470e RISC-V: Make riscv_isa_xlen a global function.
This allows the function to be used from riscv OS files, which also need to
depend on XLEN size.

	gdb/
	* riscv-tdep.c (riscv_isa_xlen): Drop static.
	* riscv-tdep.h (riscv_isa_xlen): Add extern declaration.
2018-08-08 10:51:40 -07:00
Andrew Burgess 9d4a934ce6 gdb: Fix assert for extended-remote target (PR gdb/18050)
Consider the following GDB session:

   (gdb) target extended-remote :2347
   (gdb) file /path/to/exe
   (gdb) set remote exec-file /path/to/exe
   (gdb) set detach-on-fork off
   (gdb) break breakpt
   (gdb) run
   # ... hits breakpoint
   (gdb) info inferiors
     Num  Description       Executable
   * 1    process 17001     /path/to/exe
     2    process 17002     /path/to/exe
   (gdb) kill
   (gdb) info inferiors
     Num  Description       Executable
   * 1    <null>            /path/to/exe
     2    process 17002     /path/to/exe
   (gdb) target extended-remote :2348
   ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
   A problem internal to GDB has been detected,
   further debugging may prove unreliable.

Or, from bug PR gdb/18050:

   (gdb) start
   (gdb) add-inferior -exec /path/to/exe
   (gdb) target extended-remote :2347
   ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
   A problem internal to GDB has been detected,
   further debugging may prove unreliable.

The issue is calling target.c:dispose_inferior with a killed inferior in
the inferior list.  This assertion is fixed in this commit.

The new test for this issue only runs on platforms that support
'detach-on-fork', and when using
'--target_board=native-extended-gdbserver'.

gdb/ChangeLog:

	PR gdb/18050:
	* target.c (dispose_inferior): Don't dispose of inferiors that are
	already killed.

gdb/testsuite/ChangeLog:

	PR gdb/18050:
	* gdb.server/extended-remote-restart.c: New file.
	* gdb.server/extended-remote-restart.exp: New file.
2018-08-08 13:14:45 +01:00
Szabolcs Nagy ff36536c92 Fix gdb/remote.c build failure
Add const qualifier to fix

/S/gdb/common/gdb_locale.h:35:27: error: deprecated conversion from string constant to 'char*' [-Werror=write-strings]
 # define _(String) (String)
                           ^
/S/gdb/remote.c:12844:19: note: in expansion of macro '_'
   char *err_msg = _("Tracepoint packet too large for target.");
                   ^
gdb/ChangeLog:

	* remote.c (remote_target::download_tracepoint): Change char* to
	const char*.
2018-08-08 11:31:11 +01:00
Simon Marchi 045cf01286 Fix gdb.fortran/nested-funcs.exp failure
Commit 87d6a7aa93 ("Add DWARF index cache") broke
gdb.fortran/nested-funcs.exp.  Because of the new "set index-cache"
command, the expression "set index = 42" now fails:

  set index = 42
  Undefined set index-cache command: "= 42".  Try "help set index-cache".
  (gdb) PASS: gdb.fortran/nested-funcs.exp: set index = 42

Fix it by changing it to "set variable index = 42".  Also, use
gdb_test_no_output to confirm that it worked (since that particular test
wrongfully passed).

gdb/testsuite/ChangeLog:

	* gdb.fortran/nested-funcs.exp: Replace "set index = 42" with
	"set variable index = 42".
2018-08-07 22:46:37 -04:00
Simon Marchi 09ce46f230 Make target_options_to_string return an std::string
Return an std::string instead of a char *, saving some manual freeing.

I only manually tested with "set debug target 1" and "set debug lin-lwp
1", since this only deals with debug output.

gdb/ChangeLog:

	* target.h (target_options_to_string): Return an std::string.
	* target.c (str_comma_list_concat_elem): Return void, use
	std::string.
	(do_option): Likewise.
	(target_options_to_string): Return an std::string.
	* linux-nat.c (linux_nat_target::wait): Adjust.
	* target-debug.h (target_debug_print_options): Adjust.
2018-08-07 21:38:27 -04:00
Tom Tromey 9c61296405 Allow CPPFLAGS to be set on the make command line
While looking into PR build/8751 (which seems to be fixed), I noticed
that it's not possible to change CPPFLAGS for gdb on the "make"
command line.  It's reasonable to want to do this sometimes, and I
think this patch should suffice.

gdb/ChangeLog
2018-08-07  Tom Tromey  <tom@tromey.com>

	* Makefile.in (CPPFLAGS): New variable.
	(INTERNAL_CPPFLAGS): Use it.
2018-08-07 16:39:13 -06:00
Simon Marchi 7d11235d04 Add doc and news for DWARF index cache
New in v3:

- Address Eli's comments.

This patch adds doc and news for the feature introduced by the previous
patch.

gdb/ChangeLog:

	* NEWS: Mention the index cache.

gdb/doc/ChangeLog:

	* gdb.texinfo (Index Files Speed Up GDB): Add section about
	symbol index cache.
2018-08-07 18:15:28 -04:00
Simon Marchi 87d6a7aa93 Add DWARF index cache
New in v3:

- Remove things related to the dwarf-5 format.
- Fix compilation on mingw (scoped_mmap.c).

GDB can generate indexes for DWARF debug information, which, when
integrated in the original binary, can speed up loading object files.
This can be done using the gdb-add-index script or directly by the
linker itself.  However, not many people know about this.  And even
among those who do, because it requires additional steps, I don't know a
lot of people who actually go through that trouble.

To help make using the DWARF index more transparent, this patch
introduces a DWARF index cache.  When enabled, loading an index-less
binary in GDB will automatically save an index file in ~/.cache/gdb.
When loading that same object file again, the index file will be looked
up and used to load the DWARF index.  You therefore get the benefit of
the DWARF index without having to do additional manual steps or
modifying your build system.  When an index section is already present
in the file, GDB will prefer that one over looking up the cache.

When doing my edit-compile-debug cycle, I often debug multiple times the
same build, so the cache helps reducing the load time of the debug
sessions after the first one.

- The saved index file is exactly the same as the output of the "save
  gdb-index" command.  It is therefore the exact same content that would
  be found in the .gdb_index or .debug_names section.  We just leave it
  as a standalone file instead of merging it in the binary.

- The cache is just a directory with files named after the object
  file's build-id.  It is not possible to save/load the index for an
  object file without build-id in the cache.

- The cache uses the gdb index format.  The problem with the dwarf-5
  format is that we can generate an addendum to the .debug_str section
  that you're supposed to integrate to the original binary.  This
  complicates a little bit loading the data from the cached index files,
  so I would leave this for later.

- The size taken up by ~/.cache/gdb is not limited.  I was thinking we
  could add configurable limit (like ccache does), but that would come
  after.  Also, maybe a command to flush the cache.

- The cache is disabled by default.  I think once it's been out there
  and tested for a while, it could be turned on by default, so that
  everybody can enjoy it.

- The code was made to follow the XDG specification: if the
  XDG_CACHE_HOME environment variable, it is used, otherwise it falls
  back to ~/.cache/gdb.  It is possible to change it using "set
  index-cache directory".  On other OSes than GNU/Linux, ~/.cache may
  not be the best place to put such data.  On macOS it should probably
  default to ~/Library/Caches/...  On Windows, %LocalAppData%/...  I
  don't intend to do this part, but further patches are welcome.

- I think that we need to be careful that multiple instances of GDB
  don't interfere with each other (not far fetched at all if you run GDB
  in some automated script) and the cache is always coherent (either the
  file is not found, or it is found and entirely valid).  Writing the
  file directly to its final location seems like a recipe for failure.
  One GDB could read a file in the index while it is being written by
  another GDB.  To mitigate this, I made write_psymtabs_to_index write
  to temporary files and rename them once it's done.  Two GDB instances
  writing the index for the same file should not step on each other's
  toes (the last file to be renamed will stay).  A GDB looking up a file
  will only see a complete file or no file.  Also, if GDB crashes while
  generating the index file, it will leave a work-in-progress file, but
  it won't be picked up by other instances looking up in the cache.

gdb/ChangeLog:

	* common/pathstuff.h (get_standard_cache_dir): New.
	* common/pathstuff.c (get_standard_cache_dir): New.
	* build-id.h (build_id_to_string): New.
	* dwarf-index-common.h (INDEX4_SUFFIX, INDEX5_SUFFIX,
	DEBUG_STR_SUFFIX): Move to here.
	* dwarf-index-write.c (INDEX4_SUFFIX, INDEX5_SUFFIX,
	DEBUG_STR_SUFFIX): Move from there.
	(write_psymtabs_to_index): Make non-static, add basename
	parameter.  Write to temporary files, rename when done.
	(save_gdb_index_command): Adjust call to
	write_psymtabs_to_index.
	* dwarf2read.h (dwarf2_per_objfile) <index_cache_res>: New
	field.
	* dwarf2read.c (dwz_file) <index_cache_res>: New field.
	(get_gdb_index_contents_from_cache): New.
	(get_gdb_index_contents_from_cache_dwz): New.
	(dwarf2_initialize_objfile): Read index from cache.
	(dwarf2_build_psymtabs): Save to index.
	* dwarf-index-cache.h: New file.
	* dwarf-index-cache.c: New file.
	* dwarf-index-write.h: New file.

gdb/testsuite/ChangeLog:

	* boards/index-cache-gdb.exp: New file.
	* gdb.dwarf2/index-cache.exp: New file.
	* gdb.dwarf2/index-cache.c: New file.
	* gdb.base/maint.exp: Check if we are using the index cache.
2018-08-07 18:14:20 -04:00
Simon Marchi 8a99096f31 Import gnulib's mkdir module
The following patch makes use of the mkdir function.  Import the mkdir
gnulib module to ensure proper operation on all platforms.

gdb/ChangeLog:

	* gnulib/aclocal.m4: Re-generate.
	* gnulib/config.in: Re-generate.
	* gnulib/configure: Re-generate.
	* gnulib/import/Makefile.am: Re-generate.
	* gnulib/import/Makefile.in: Re-generate.
	* gnulib/import/m4/gnulib-cache.m4: Re-generate.
	* gnulib/import/m4/gnulib-comp.m4: Re-generate.
	* gnulib/import/m4/mkdir.m4: New file.
	* gnulib/import/mkdir.c: New file.
	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkdir
	module.
2018-08-07 18:13:52 -04:00
Simon Marchi 5c831bb1eb Introduce mmap_file function
New in v2:

- As Tom pointed out, we don't need to keep the fd around after
  mmapping.  This simplifies things quite a bit, since we don't need a
  new class.  It's now just a function that returns a scoped_mmap.

We already have scoped_mmap, which is a thin RAII layer over mmap.  If
one simply wants to mmap an entire file for reading, it takes a bit of
boilerplate.  This patch introduces the mmap_file function to make this
easier.

gdb/ChangeLog:

	* Makefile.in (COMMON_SFILES): Add common/scoped_mmap.c.
	* common/scoped_mmap.c: New file.
	* common/scoped_mmap.h (destroy): New method.
	(~scoped_mmap, reset): Use destroy.
	(scoped_mmap): New move constructor.
	(mmap_file): New declaration.
	* unittests/scoped_mmap-selftests.c (test_normal,
	test_invalid_filename, run_tests): New functions.
	(_initialize_scoped_mmap_selftests): Register selftest.
2018-08-07 18:10:29 -04:00
Simon Marchi 4485a1c1d8 Make index reading functions more modular
New in v3:

- Remove changed to dwarf-5 functions.

The read_gdb_index_from_section and read_debug_names_from_section
functions read the index content, as their names state, from sections of
object files.  A following patch will make it possible to read index
content from standalone files.

This patch therefore decouples the code that reads the index content
from the code that processes that content.  Functions
dwarf2_read_gdb_index and dwarf2_read_debug_names receive callbacks that
are responsible for providing the index contents (for both the main file
and the potential dwz file).

gdb/ChangeLog:

	* dwarf2read.c (read_gdb_index_from_section): Rename to...
	(read_gdb_index_from_buffer): ... this.  Remove section
	parameter, add buffer parameter.
	(get_gdb_index_contents_ftype,
	get_gdb_index_contents_dwz_ftype): New typedefs.
	(dwarf2_read_gdb_index): Add callback parameters to get the
	index contents.
	(get_gdb_index_contents_from_section): New.
	(dwarf2_initialize_objfile): Update call to
	dwarf2_read_gdb_index.
2018-08-07 18:08:58 -04:00
Simon Marchi 528e15722b Replace some uses of xstrprintf with string_printf
This patch replaces some simple uses of xstrprintf with with
string_printf, removing the need to do manual memory freeing.

The change in ada-lang.c fixes an apparent memory leak.

Regtested on the buildbot.

gdb/ChangeLog:

	* common/filestuff.h (gdb_fopen_cloexec): New overload.
	(gdb_open_cloexec): Likewise.
	* nat/linux-osdata.c (command_from_pid): Use string_printf.
	(commandline_from_pid): Likewise.
	(linux_xfer_osdata_threads): Likewise.
	(linux_xfer_osdata_fds): Likewise.
	* ada-lang.c (is_package_name): Likewise.
	* auxv.c (procfs_xfer_auxv): Likewise.
	* breakpoint.c (print_one_breakpoint_location): Use
	uiout::field_fmt.
	(print_one_catch_solib): Use string_printf.
	* coff-pe-read.c (add_pe_exported_sym): Likewise.
	(add_pe_forwarded_sym): Likewise.
	* dwarf2read.c (create_type_unit_group): Likewise.
	(build_error_marker_type): Likewise.
	* infcall.c (get_function_name): Likewise.
	* valprint.c (print_converted_chars_to_obstack): Likewise.
	* xtensa-tdep.c (xtensa_register_type): Likewise.
2018-08-07 17:43:08 -04:00
Rainer Orth 96d68bd48c Support parallel make check with GNU make 4.2+
I noticed that make -jN check would run make check-single when using GNU
make 4.2.1.

In the end, it turned out that this is due to this change from the make
4.2 NEWS file:

* The amount of parallelism can be determined by querying MAKEFLAGS, even when
  the job server is enabled (previously MAKEFLAGS would always contain only
  "-j", with no number, when job server was enabled).

The fix is trivial: just accept an optional arg to -j in Makefile.in
(saw_dash_j).  Tested on i386-pc-solaris2.11 with just make and make
-j/-jN with both make 3.82 and 4.2.1.

	* Makefile.in (saw_dash_j): Allow for GNU make 4.2+ passing -jN in
	MAKEFLAGS.
2018-08-07 13:20:40 +02:00
Simon Marchi a7f25a84f4 Fix compilation failure in remote.c
A recent patch introduced a few of these:

/home/emaisin/src/binutils-gdb/gdb/remote.c:12862:19: error: format not a string literal and no format arguments [-Werror=format-security]
     error (err_msg);
                   ^

Fix them by replacing the call to error with

  error ("%s", err_msg);

gdb/ChangeLog:

	* remote.c (remote_target::download_tracepoint): Fix format
	string errors.
2018-08-06 16:57:24 -04:00
Pedro Franco de Carvalho 296956befe Allow larger regblock sizes when saving tracefiles
The tracefile.c:trace_save function assumes trace_regblock_size won't
be larger than the MAX_TRACE_UPLOAD constant, used to size the buffer
which holds trace data.  This can cause buffer overruns when this is
not the case.  This patch changes this function so that the larger
size is used to size the buffer.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* tracefile.c: Include common/byte-vector.h.
	(trace_save): Change type of buf to gdb::byte_vector.  Initialize
	with trace_regblock_size if needed.  Update uses of buf.
2018-08-06 16:43:28 -03:00
Pedro Franco de Carvalho a04b9d62a2 Variable size for regs mask in collection list
This patch changes collection_list to allow larger register masks.

The mask is changed from an array to a vector and is initialized to
hold the maximum possible remote register number.  The stringify
method is updated to resize temp_buf if needed.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* tracepoint.h (collection_list) <m_regs_mask>: Change type to
	std::vector<unsigned char>.
	* tracepoint.c (collection_list::collection_list): Remove
	m_regs_mask initializer from initializer list.  Resize
	m_regs_mask using the largest remote register number.
	(collection_list::add_remote_register): Remove size check on
	m_regs_mask.  Use at to access element.
	(collection_list::stringify): Change type of temp_buf to
	gdb::char_vector.  Update uses of temp_buf.  Resize if needed to
	stringify the register mask.  Use pack_hex_byte for the register
	mask.
2018-08-06 16:38:58 -03:00
Pedro Franco de Carvalho 4277c4b87a Use remote register numbers in tracepoint mask
Currently, tracepoint register masks in the QTDP packets include both
internal and remote register numbers, as well as pseudo-register
numbers.

This patch changes this so that the mask only includes remote register
numbers.

Register numbers from agent expressions are already set in the mask
using remote numbers.  Other tracepoint actions used internal numbers,
e.g. "collect $regs" or "collect $<pseudoreg>".  To handle pseudoreg
numbers, an empty agent expression is created and ax_reg_mask is
called for this expression and the pseudoreg.  This will cause the ax
to set its mask with the corresponding remote raw register
numbers (using ax_regs_mask, which calls
gdbarch_ax_pseudo_register_collect).

If ax_regs_mask and gdbarch_ax_pseudo_register_collect also generate
more ax bytecode, the ax is also appended to the collection list.  It
isn't clear that this was the original intent for
gdbarch_ax_pseudo_register_collect, and none of the arches seem to do
this, but if this changes in the future, it should work.

The patch also refactors the code used by validate_action line to
validate axs into a function that is now called from every place that
generates axs.  Previously, some parts of tracepoint.c that generated
axs didn't check if the ax length was greater than MAX_AGENT_EXPR_LEN.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* tracepoint.h (class collection_list) <add_register>: Remove.
	<add_remote_register, add_ax_registers, add_local_register>:
	Declare.
	<add_memrange>: Add scope parameter.
	* tracepoint.c (encode_actions_1): Likewise.
	(collection_list::add_register): Rename to ...
	(collection_list::add_remote_register): ... this.  Update
	comment.
	(collection_list::add_ax_registers, add_local_register): New
	methods.
	(collection_list::add_memrange): Add scope parameter.  Call
	add_local_register instead of add_register.
	(finalize_tracepoint_aexpr): New function.
	(collection_list::collect_symbol): Update calls to add_memrange.
	Call add_local_register instead of add_register.  Call
	add_ax_registers.  Call finalize_tracepoint_aexpr.
	(encode_actions_1): Get remote regnos for $reg action.  Call
	add_remote_register, add_ax_registers, and add_local_register.
	Update call to add_memrange.  Call finalize_tracepoint_aexpr.
	(validate_actionline): Call finalize_tracepoint_aexpr.
2018-08-06 16:36:36 -03:00
Pedro Franco de Carvalho 3df3a985a4 Use get_remote_packet_size in download_tracepoint
This patch changes the remote target to use the remote packet size to
build QTDP packets, and to check if there is enough room for the
packet.

I changed the function to raise an error if the packet is too small,
instead of aborting gdb (through xsnprintf).  It isn't clear if gdb
will be in a consistent state with respect to the stub after this,
since it's possible that some packets will be sent but not others, and
there could be an incomplete tracepoint on the stub.

The char array used to build the packets is changed to a
gdb::char_vector and sized with the result from
get_remote_packet_size.

When checking if the buffer is large enough to hold the tracepoint
condition agent expression, the length of the expression is multiplied
by two, since it is encoded with two hex digits per expression
byte.  For simplicity, I assume that the result won't overflow, which
can happen for very long condition expressions.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* remote.c (remote_target::download_tracepoint): Remove BUF_SIZE.
	Replace array buf with gdb::char_vector buf, of size
	get_remote_packet_size ().  Replace references to buf and
	BUF_SIZE to buf.data () and buf.size ().  Replace strcpy, strcat
	and xsnprintf with snprintf.  Raise errors if the buffer is too
	small.
2018-08-06 16:34:02 -03:00
Pedro Franco de Carvalho aa6f3694ce Remove trailing '-' from the last QTDP action packet
The has_more predicate in remote_target::download_tracepoint always
evaluates to true, so the last action packet will be sent with a
trailing '-'.  This patch changes the predicate to remove the last
trailing '-'.

gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* remote.c (remote_target::download_tracepoint): Fix the has_more
	predicate in the QTDP action list iteration.
2018-08-06 16:30:17 -03:00
Pedro Franco de Carvalho 05abfc39c7 Fix indentation in remote_target::download_tracepoint
gdb/ChangeLog:
2018-08-06  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>

	* remote.c (remote_target::download_tracepoint): Fix indentation
	in for block.
2018-08-06 16:27:47 -03:00
Rainer Orth 5a6996172e Update dg-extract-results.* from gcc
When looking at the gdb.sum file produced by dg-extract-results.sh on
Solaris 11/x86, I noticed some wrong sorting, like this:

PASS: gdb.ada/addr_arith.exp: print something'address + 0
PASS: gdb.ada/addr_arith.exp: print 0 + something'address
PASS: gdb.ada/addr_arith.exp: print something'address - 0
PASS: gdb.ada/addr_arith.exp: print 0 - something'address

Looking closer, I noticed that while dg-extract-results.sh had been
copied over from contrib in the gcc repo, the corresponding
dg-extract-results.py file had not.  The latter not only fixes the
sorting problem I'd observed, but is also way faster than the shell
version (like a factor of 50 faster).

Therefore I propose to update both files from the gcc repo.  The changes
to the .sh version are trivial, just counting the number of DejaGnu
ERROR lines, too.

The files are moved to toplevel contrib:

* This way, they can easily be used should someone decide to parallelize
  one or more of the binutils, gas, or ld testsuites.

* They are less easily overlooked for updates from the gcc repo when
  they reside in the same place in both.

* The test_summary script needs to live in contrib since the toplevel
  Makefile's mail-report.log target expects it there.

Tested on amd64-pc-solaris2.11 with

	make -j16 check
and
	make -j16 -k RACY_ITER=5 check


	gdb/testsuite:
	* dg-extract-results.sh: Move to toplevel contrib.
	* Makefile.in (check-parallel): Reflect dg-extract-results.sh move.
	* Makefile.in (check-parallel-racy): Likewise.

	contrib:
	* dg-extract-results.sh: Move from gdb/testsuite.
	Update from gcc repo.
	* dg-extract-results.py: New from gcc repo.
2018-08-06 16:05:16 +02:00
Rainer Orth 821a26825b Remove unused variables in procfs.c etc.
The recent patch to enable -Wunused-variable uncovered a couple of
instances in Solaris-specific files:

/vol/src/gnu/gdb/hg/master/dist/gdb/proc-api.c: In function ‘void _initialize_proc_api()’:
/vol/src/gnu/gdb/hg/master/dist/gdb/proc-api.c:422:28: error: unused variable ‘c’ [-Werror=unused-variable]
   struct cmd_list_element *c;
                            ^

/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In function ‘void procfs_init_inferior(target_ops*, int)’:
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:2895:12: error: unused variable ‘signals’ [-Werror=unused-variable]
   sigset_t signals;
            ^~~~~~~
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c: In member function ‘virtual char* procfs_target::make_corefile_notes(bfd*, int*)’:
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:3845:19: error: unused variable ‘old_chain’ [-Werror=unused-variable]
   struct cleanup *old_chain;
                   ^~~~~~~~~
/vol/src/gnu/gdb/hg/master/dist/gdb/procfs.c:3847:18: error: unused variable ‘fpregs’ [-Werror=unused-variable]
   gdb_fpregset_t fpregs;
                  ^~~~~~

Fixed as follows.  Tested on amd64-pc-solaris2.11, installed as obvious.

	* proc-api.c (_initialize_proc_api): Remove c, unused.
	* procfs.c (procfs_init_inferior): Remove signals, unused.
	(procfs_target::make_corefile_notes): Remove old_chain, fpregs,
	unused.
2018-08-06 13:54:34 +02:00
Andrew Burgess 5bd18990b0 gdb: Only run scheduler-locking tests if feature is supported
Not all targets support scheduler-locking.  Add a check to see if the
taraget supports scheduler locking, and if it doesn't, don't run the
scheduler-locking tests that will otherwise fail.

There are actually a set of tests that try to use scheduler-locking
however, in most of these cases the test will not be run on smaller
targets (those that might not support threads and scheduler-locking)
due to the targets lack of support for threads, or some other larger
feature.

In the gdb.mi/mi-cmd-param-changed.exp test though, there's no
dependence on threads, or any other larger feature, and so, for the
small target I was using the test would otherwise try to run, only to
fail due to lack of support for scheduler-locking.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (target_supports_scheduler_locking): New proc.
	* gdb.mi/mi-cmd-param-changed.exp: Only run scheduler locking
	tests if the target supports scheduler locking.
2018-08-06 08:52:08 +01:00
Andrew Burgess 9534733755 gdb: Avoid using W_STOPCODE(0) as this is ambiguous on MIPS
The MIPS target supports 127 signals, and this can create an ambiguity
in process wait statuses.  A status value of 0x007f could potentially
indicate a process that has exited with signal 127, or a process that
has stopped with signal 0.

In uClibc-ng the interpretation of 0x007f is that the process has
exited with signal 127 rather than stopped with signal 0, and so,
WIFSTOPPED (W_STOPCODE (0)) will be false rather than true as it would
be on most other platforms.

Given that it's pretty easy to avoid using W_STOPCODE (0), lets do that.

gdb/ChangeLog:

	* linux-nat.c (linux_nat_target::follow_fork): Avoid using
	'W_STOPCODE (0)' as this could be ambiguous.
2018-08-06 08:49:39 +01:00
Tom de Vries 3fbbcf473a [gdb/testsuite] Fix regexp in py-rbreak.exp
This fails for me on openSUSE leap 15.0:
...
FAIL: gdb.python/py-rbreak.exp: check number of returned breakpoints is 11
...

The rbreak "" command expects 11 breaks, but I see two extra for
__libc_csu_fini and __libc_csu_init:
...
Breakpoint 13 at 0x4005b0: file elf-init.c, line 106.^M
Breakpoint 14 at 0x400540: file elf-init.c, line 68.^M
...

This patch fixes the failing test by excluding functions starting with an
underscore.

Tested on x86_64-linux.

2018-08-04  Tom de Vries  <tdevries@suse.de>

	* gdb.python/py-rbreak.exp: Fix rbreak regexp.
2018-08-04 11:40:18 +02:00
Sergio Durigan Junior 425699f52d Fix thinko when deciding whether to disable TCP's Nagle algorithm
This patch fixes a thinko that happened when I was implementing the
IPv6 support on GDB/gdbserver.  On certain situations, it is necessary
to disable TCP's Nagle algorithm (NODELAY).  For obvious reasons, this
only applies when we are dealing with a TCP connection.

While implementing the IPv6 patch, I noticed that the net_open
function (on gdb/ser-tcp.c) kept a flag indicating whether the
connection type was UDP or TCP.  I eliminated that flag, and started
using the 'struct addrinfo *' related to the successful connection
directly.  However, I made a mistake:

  if (success_ainfo->ai_socktype == IPPROTO_TCP)
                     ^^^^^^^^^^^
    {
      /* Disable Nagle algorithm.  Needed in some cases.  */
      int tmp = 1;

      setsockopt (scb->fd, IPPROTO_TCP, TCP_NODELAY,
		  (char *) &tmp, sizeof (tmp));
    }

The 'ai_socktype' field specifies the socket type (SOCK_STREAM or
SOCK_DGRAM), and not the protocol.  This test was always failing, and
the Nagle algorithm was never being disabled.

The obvious fix is to use the 'ai_protocol' field.  This is what this
patch does.

Huge "thank you" to Joel Brobecker who reported the regression (he was
experiencing an unusual delay while debugging a bare-metal program
running under QEMU) and helped me set up a proper reproducer for the
bug.

gdb/ChangeLog:
2018-08-03  Sergio Durigan Junior  <sergiodj@redhat.com>

	* ser-tcp.c (net_open): Fix thinko when deciding whether to
	disable TCP's Nagle algorithm (use "ai_protocol" instead of
	"ai_socktype").
2018-08-03 18:04:38 -04:00
Tom Tromey 3e1d3d8c24 Allow "info address" of a template parameter
PR symtab/16842 shows that gdb will crash when the user tries to
invoke "info address" of a template parameter.

The bug here is that dwarf2read.c does not set the symtab on the
template parameter symbols.  This is pedantically correct, given that
the template symbols do not appear in a symtab.  However, gdb
primarily uses the symtab backlink to find the symbol's objfile.  So,
this patch simply sets the symtab on these symbols.

Tested by the buildbot.

gdb/ChangeLog
2018-08-02  Tom Tromey  <tom@tromey.com>

	PR symtab/16842.
	* dwarf2read.c (read_func_scope): Set symtab on template parameter
	symbols.
	(process_structure_scope): Likewise.

gdb/testsuite/ChangeLog
2018-08-02  Tom Tromey  <tom@tromey.com>

	PR symtab/16842.
	* gdb.cp/temargs.exp: Test "info address" of a template
	parameter.
2018-08-02 16:12:42 -06:00
Xavier Roirand 1584354913 Fix kill issue leading to zombie process on MacOS Sierra
Starting with MacOS version Sierra, the gdb kill command
seems to work but inferior remains as zombie on the host.
Notice that, as zombie process, the inferior is not killable
by the user, nor by root.

The kill signal gdb sent to the inferior is not handled
in gdb as a signal sent by gdb thus no reply is made and
the process remains (since MacOS does not "release" the
inferior because no reply have been made to the signal
message).

This patch fixes this problem.

gdb/ChangeLog
2018-08-02  Xavier Roirand  <roirand@adacore.com>

	PR gdb/22629:
        * darwin-nat.c (darwin_kill_inferior): Fix handling of
        kill inferior.
2018-08-02 15:08:45 -06:00
Tom Tromey b5bddbbbbc Check results of get_darwin_inferior
I noticed that the existing kill-detach-inferiors-cmd.exp test was
causing gdb to crash on macOS 10.13.  The bug was that an inferior
that hadn't yet been started would cause get_darwin_inferior to return
NULL, and this was not checked.

I went through the places calling get_darwin_inferior and added checks
where appropriate.  This makes the test get a bit further.  Not all of
these spots are exercised by the test, but they seem safe enough in
any case.

gdb/ChangeLog
2018-08-02  Tom Tromey  <tom@tromey.com>

	* darwin-nat.c (find_inferior_task_it, darwin_find_thread)
	(darwin_suspend_inferior, darwin_resume_inferior)
	(darwin_decode_notify_message, darwin_resume_inferior_threads)
	(darwin_check_new_threads): Check result of get_darwin_inferior.
2018-08-02 15:08:44 -06:00
Joel Brobecker f61cfa0740 Document the GDB 8.1.1 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 8.1.1 released.
2018-07-31 07:59:44 -07:00
Jan Vrany 5abe0f0cc7 Fix segfault when invoking -var-info-path-expression on a dynamic varobj
Invoking -var-info-path-expression on a dynamic varobj lead either in wrong
(nonsense) result or to a segmentation fault in cplus_describe_child().
This was caused by the fact that varobj_get_path_expr() called
cplus_path_expr_of_child() ignoring the fact the parent of the variable
is dynamic. Then, cplus_describe_child() accessed the underlaying C type
members by index, causing (i) either wrong (nonsense) expression being
returned (since dynamic child may be completely arbibtrary value)
or (ii) segmentation fault (in case the index higher than number of
underlaying C type members.

This fixes the problem by checking whether a varobj is a child of a dynamic
varobj and, if so, reporting an error as described in documentation.

gdb/ChangeLog:

	* varobj.c (varobj_get_path_expr_parent): Report an error if
	parent is a dynamic varobj.

gdb/testsuite/Changelog:

	* gdb.python/py-mi-var-info-path-expression.c: New file.
	* gdb.python/py-mi-var-info-path-expression.py: New file.
	* gdb.python/py-mi-var-info-path-expression.exp: New file.
2018-07-31 10:13:41 -04:00
Simon Marchi 472fa5eec2 Re-generate gnulib import
I noticed that re-generating our gnulib import introduced some changes.
I supposed that this comes from the recent upgrade to autoconf 2.69
(though I haven't checked).

Tested by rebuilding on GNU/Linux x86-64 and mingw (cross-compiled from
GNU/Linux).

gdb/ChangeLog:

	* gnulib/aclocal.m4: Re-generate.
	* gnulib/config.in: Re-generate.
	* gnulib/configure: Re-generate.
	* gnulib/import/Makefile.in: Re-generate.
	* gnulib/import/m4/gnulib-comp.m4: Re-generate.
	* gnulib/import/m4/onceonly.m4: Re-generate.
2018-07-31 10:09:10 -04:00
Simon Marchi 1c28969efc Delete test target descriptions when exiting
Looking at the address sanitizer output, this was a quite low hanging
fruit.  We create target_desc objects for testing that we never free.
Saving them in unique_ptrs takes care of it.

I created a small struct to hold these because I thought it would help
readability.

gdb/ChangeLog:

	* target-descriptions.c (struct xml_test_tdesc): New.
	(xml_tdesc): Change type to std::vector<xml_test_tdesc>.
	(record_xml_tdesc): Update.
	(maintenance_check_xml_descriptions): Update.
	* target-descriptions.h (record_xml_tdesc): Update comment.
2018-07-31 10:06:00 -04:00
Sergio Durigan Junior fb66cde8a4 Match any kind of error after "cannot resolve name" on lib/gdbserver-support.exp:gdbserver_start
On commit:

commit 7f1f7e2393
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Fri Jul 13 16:20:34 2018 -0400

    Expect for another variant of error message when gdbserver cannot resolve hostname

I extended the regular expression being used to identify whether
gdbserver could not resolve a (host)name.  This was needed because the
error message being printed had a different variation across some
systems.  However, as it turns out, I've just noticed that the message
has yet another variation:

  target remote tcp8:123:2353
  tcp8:123:2353: cannot resolve name: System error
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  tcp8:123:2353: No such file or directory.
  (gdb) FAIL: gdb.server/server-connect.exp: tcp8: connect to gdbserver using tcp8:123

which is causing FAILs on some systems (namely, Fedora-i686 on
BuildBot).

So instead of trying to predict everything that can be printed, I
decided to just match anything after the "cannot resolve name: " part.
This patch implements that.

Regression tested on the BuildBot.

gdb/testsuite/ChangeLog:
2018-07-30  Sergio Durigan Junior  <sergiodj@redhat.com>

	* lib/gdbserver-support.exp (gdbserver_start): Match any kind of
	error after "cannot resolve name" string.
2018-07-30 17:16:20 -04:00
Andrew Burgess c8f2dc0dc9 gdb: Fix sizeof for dynamic types other than arrays
In commit:

   commit 37cc0caeca
   Date:   Wed Jul 18 13:38:35 2018 +0200
   [gdb/exp] Interpret size of vla with unknown size as <optimized out>

All dynamic types are treated as arrays in the 'sizeof' code path,
which means that structures can incorrectly be treated as arrays.
This can cause a failure in the gdb.base/vla-datatypes.exp test
script.

This commit adds a check that we do have an array before checking the
array bounds, and I also check that the array index type is dynamic
too.  This second check probably isn't strictly necessary, but
shouldn't hurt, a non-dynamic index type shouldn't have undefined high
bound.

gdb/ChangeLog:

	* eval.c (evaluate_subexp_for_sizeof): Check for array type before
	checking array bounds are defined.
2018-07-30 19:51:53 +01:00
Tom Tromey 463c08d160 Fix crash with -D_GLIBCXX_DEBUG
I noticed a buildbot failure where gdb crashed in info-os.exp, when
compiled with -D_GLIBCXX_DEBUG:

    (gdb) info os procgroups
    /usr/include/c++/7/bits/stl_algo.h:4834:
    Error: comparison doesn't meet irreflexive requirements, assert(!(a < a)).
    Objects involved in the operation:
	iterator::value_type "< operator type" {
	  type = pid_pgid_entry;
	}

The bug here is that pid_pgid_entry::operator< violates the C++
irreflexivity rule; that is, that an object cannot be less than
itself.

Tested locally by re-running info-os.exp.

gdb/ChangeLog
2018-07-30  Tom Tromey  <tom@tromey.com>

	* nat/linux-osdata.c (pid_pgid_entry::operator<): Fix
	irreflexivity violation.
2018-07-30 08:33:26 -06:00
Tom Tromey dba7455e76 Remove old lint code
This removes dead code that, according to the comments, existed to
placate lint.  I don't think this has been relevant in a long time,
and certainly not since gdb switched to C++.

Tested by rebuilding.

ChangeLog
2018-07-30  Tom Tromey  <tom@tromey.com>

	* cli/cli-decode.c (lookup_cmd): Remove lint code.
	* value.c (unpack_long): Remove lint code.
	* valops.c (value_ind): Remove lint code.
	* valarith.c (value_x_binop, value_x_unop, value_equal)
	(value_pos): Remove lint code.
2018-07-30 08:29:47 -06:00
Andrew Burgess c708f4d256 gdb: Don't call gdb_load_shlib unless GDB is running
The gdb_load_shlib function will, on remote targets, try to run some
GDB commands.  This obviously isn't going to work unless GDB is
running.

The gdb.trace/tspeed.exp test calls gdb_load_shlib before starting
GDB.  Don't do that.

The failure that's triggered is actually DeJaGNU complaining that the
variable $use_gdb_stub doesn't exist, this is only created when GDB is
started.  Something like this should trigger a failure:

  make check-gdb \
    RUNTESTFLAGS="--target_board=remote-gdbserver-on-localhost \
                  gdb.trace/tspeed.exp"

This commit also adds a check to gdb_load_shlib that GDB is running.
The check is always performed, so this should catch cases where a GDB
developer adds a use of gdb_load_shlib but doesn't test their code
with a remote target.

gdb/testsuite/ChangeLog:

	* gdb.trace/tspeed.exp: Only call gdb_load_shlib after gdb has
	started.
	* lib/gdb.exp (gdb_load_shlib): Call perror if GDB is not running.
2018-07-28 20:21:50 +01:00
Tom de Vries 37cc0caeca [gdb/exp] Interpret size of vla with unknown size as <optimized out>
At -O3 -g -gstrict-dwarf, gcc generates for an optimized out vla 'a' a
DW_TAG_variable with type DW_TAG_array_type containing one
DW_TAG_subrange_type, but without DW_AT_upper_bound or DW_AT_count, which
makes the upper bound value 'unknown':
...
	.uleb128 0x15   # (DIE (0x161) DW_TAG_variable)
        .long   0xec    # DW_AT_abstract_origin
        .long   0x170   # DW_AT_type
	...
        .uleb128 0xa    # (DIE (0x170) DW_TAG_array_type)
        .long   0x110   # DW_AT_type
        .long   0x17f   # DW_AT_sibling
        .uleb128 0x17   # (DIE (0x179) DW_TAG_subrange_type)
        .long   0xc6    # DW_AT_type
        .byte   0       # end of children of DIE 0x170
...

But gdb prints '0' for the size of 'a':
...
/gdb ./vla-1.exe -batch -ex "b f1" -ex "run" -ex "p sizeof(a)"
Breakpoint 1 at 0x4004c0: f1. (2 locations)

Breakpoint 1, f1 (i=<optimized out>) at vla-1.c:18
18      }
$1 = 0
...
while <optimized out> would be more appropriate.

This patch fixes that in evaluate_subexp_for_sizeof.

Build and reg-tested on x86_64-linux.

2018-07-28  Tom de Vries  <tdevries@suse.de>

	* eval.c (evaluate_subexp_for_sizeof): Interpret size of dynamic type
	with undefined upper bound as <optimized out>.

	* gdb.base/vla-optimized-out-o3-strict.exp: New file.
2018-07-28 10:16:30 +02:00
Sergio Durigan Junior 129eb0f1f1 Improve gcore manpage and clarify "-o" option
Ref.: https://bugs.debian.org/904628

It has been reported that gcore's manpage is a bit imprecise when it
comes to two things:

- It doesn't explicity say that the command accepts more than one PID
  on its CLI.

- It fails to mention that the argument passed through the "-o" option
  is actually a prefix that will be used to compose the corefile's
  filename, and not the actual filename.

I decided to give it a try and rewrite parts of the text to further
clarify these two points.  I ended up rewording the "Description"
section because, IMHO, it was a bit confuse to understand.

To make things consistent, I've also renamed the "$name" variable in
the gcore.in script, and expanded the usage text.

gdb/doc/ChangeLog:
2018-07-27  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.texinfo (gcore man): Rewrite "Description" and "-o"
	option sections to further clarify that gcore can take more
	than one PID, and that "-o" is used to specify a prefix, not a
	filename.

gdb/ChangeLog:
2018-07-27  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gcore.in: Rename variable "name" to "prefix".  Expand
	"usage" text.
2018-07-27 15:56:54 -04:00
Jon Turney 6af79d7b5a
Fix Cygwin compilation after target_ops C++ conversion.
After f6ac5f3d "Convert struct target_ops to C++", we need to explicitly use
the global namespace when calling ::close() from windows_nat_target methods,
as that object has a close() method.

gdb/ChangeLog:

2018-07-14  Jon Turney  <jon.turney@dronecode.org.uk>

	* windows-nat.c (windows_nat_target::create_inferior): Update to
	call close() in global namespace.
2018-07-26 22:26:27 +01:00
Tom Tromey 7974897237 Make psymbols and psymtabs independent of the program space
This patch finally makes partial symbols and partial symtabs
independent of the program space.

Specifically:

It changes add_psymbol_to_list to accept a section index, and changes
the psymbol readers to pass this.  At the same time it removes the
code to add the objfile's section offset to the psymbol.

It adds an objfile argument to the psymtab textlow and texthigh
accessors and changes some code to use the raw variants instead.

It removes the "relocate" method from struct quick_symbol_functions,
as it is no longer needed any more.

It changes partial_symbol::address so that the relevant offset is now
applied at the point of use.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tom@tromey.com>

	* dwarf-index-write.c (add_address_entry): Don't add objfile
	offsets.
	* dbxread.c (find_stab_function): Rename from
	find_stab_function_addr.  Return a bound_minimal_symbol.
	(read_dbx_symtab): Use raw_text_low, raw_text_high.
	Don't add objfile offsets.
	(end_psymtab): Use raw_text_low, raw_text_high,
	MSYMBOL_VALUE_RAW_ADDRESS.
	(read_ofile_symtab): Update.
	(process_one_symbol): Update.
	* dwarf2read.c (create_addrmap_from_index): Don't add objfile
	offsets.
	(dw2_relocate): Remove.
	(dw2_find_pc_sect_symtab): Bias PC by the text offset before
	searching addrmap.
	(dwarf2_gdb_index_functions, dwarf2_debug_names_functions):
	Update.
	(process_psymtab_comp_unit_reader, add_partial_symbol)
	(add_partial_subprogram, dwarf2_ranges_read): Update.
	(load_partial_dies): Update.
	(add_address_entry): Don't add objfile offsets.
	(dwarf2_build_include_psymtabs): Update.
	(create_addrmap_from_aranges): Don't add objfile offsets.
	(dw2_find_pc_sect_compunit_symtab): Update.
	* mdebugread.c (parse_symbol): Don't add objfile offsets.
	(parse_lines): Remove 'pst' parameter, replace with 'textlow'.
	Update.
	(parse_partial_symbols): Don't add objfile offsets.  Use
	raw_text_low, raw_text_high.  Update.
	(handle_psymbol_enumerators, psymtab_to_symtab_1): Update.
	* objfiles.c (objfile_relocate1): Don't relocate psymtabs_addrmap
	or call 'relocate' quick function.  Clear psymbol_map.
	* psympriv.h (struct partial_symbol) <address>: Add section
	offset.
	<set_unrelocated_address>: Rename from set_address.
	<raw_text_low, raw_text_high>: New methods.
	<text_low, text_high>: Add objfile parameter.
	(add_psymbol_to_bcache): Add 'section' parameter.  Call
	set_unrelocated_address.
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
	(find_pc_psymbol): Update.
	(fixup_psymbol_section, relocate_psymtabs): Remove.
	(dump_psymtab, psym_functions): Update.
	(add_psymbol_to_bcache, add_psymbol_to_list): Add 'section'
	parameter.
	(maintenance_info_psymtabs, maintenance_check_psymtabs): Update.
	(start_psymtab_common): Update.
	* symfile-debug.c (debug_qf_relocate): Remove.
	(debug_sym_quick_functions): Update.
	* symfile.h (struct quick_symbol_functions) <relocate>: Remove.
	* xcoffread.c (scan_xcoff_symtab): Don't add objfile offsets.
	Update.
2018-07-26 09:18:31 -06:00
Tom Tromey 52948f01e4 Add validity bits for psymtab high and low fields
Right now some psymtab code checks whether a psymtab's textlow or
texthigh fields are valid by comparing against 0.

I imagine this is mildly wrong in the current environment, but once
psymtabs are relocated dynamically, it will no longer be correct,
because it will be much more normal to see a psymtab with a textlow of
zero -- this will just mean it appears at the start of the text
section.

This patch introduces validity bits to handle this situation more
nicely, and changes users of the code to follow.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (end_psymtab): Use text_high_valid and
	text_low_valid.
	* mdebugread.c (parse_partial_symbols): Use text_low_valid.
	(psymtab_to_symtab_1): Use text_high_valid and text_low_valid.
	* psympriv.h (struct partial_symtab) <m_text_low, m_text_high>:
	Update comment.
	<text_low_valid, text_high_valid>: New fields.
	<set_text_low, set_text_high>: Update.
	* xcoffread.c (scan_xcoff_symtab): Use text_low_valid.
2018-07-26 09:18:31 -06:00
Tom Tromey 4ae976d1df Introduce accessors for psymtab high and low fields
This introduces accessors for the partial symbol table textlow and
texthigh fields.  This lets us later arrange to relocate these values
at their point of use.

I did this conversion by renaming the fields.  I didn't rename the
fields back afterward, thinking that on the off chance that someone
has a patch touching this area, then a merge would helpfully break
their compile.

I looked at making the fields private, but this interferes with the
memset in allocate_psymtab, and I didn't want to chase this down.
This conversion can be done later if need be.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tom@tromey.com>

	* dbxread.c (read_dbx_symtab, end_psymtab, read_ofile_symtab):
	Update.
	* dwarf2read.c (dwarf2_create_include_psymtab): Don't initialize
	textlow and texthigh fields.
	(process_psymtab_comp_unit_reader, dwarf2_build_include_psymtabs):
	Update.
	* mdebugread.c (parse_lines, parse_partial_symbols)
	(psymtab_to_symtab_1): Update.
	* psympriv.h (struct partial_symtab) <m_text_low, m_text_high>:
	Rename fields.  Update comment.  Now private.
	<text_low, text_high, set_text_low, set_text_high>: New methods.
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
	(find_pc_sect_psymbol, relocate_psymtabs, dump_psymtab)
	(start_psymtab_common, maintenance_info_psymtabs)
	(maintenance_check_psymtabs): Update.
	* xcoffread.c (xcoff_end_psymtab): Don't initialize textlow and
	texthigh fields.
	(scan_xcoff_symtab): Update.
2018-07-26 09:18:30 -06:00
Tom Tromey 02e9e7f7e2 Introduce partial_symbol::address
This introduces a partial_symbol::address method.  This method takes
an objfile argument.  This is necessary so that we can later relocate
a partial symbol at its point of use.  It also adds an accessor to
compute the unrelocated value; and a method to be used for setting the
field.

Note that the new method doesn't actually perform any relocation yet.
That will come in a subsequent patch.  However, the comments are
written to reflect the intended, rather than the temporary, semantics.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tromey@redhat.com>

	* psympriv.h (struct partial_symbol) <unrelocated_address,
	address, set_address>: New methods.
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymbol)
	(fixup_psymbol_section, relocate_psymtabs): Update.
	(print_partial_symbols): Add 'objfile' parameter.  Update.
	(dump_psymtab, add_psymbol_to_bcache, psym_fill_psymbol_map):
	Update.
2018-07-26 09:18:30 -06:00
Tom Tromey 8a6d423450 Change representation of psymbol to flush out accessors
This is the psymbol analog to the patch to change the representation
of minimal symbols:

    https://sourceware.org/ml/gdb-patches/2013-10/msg00524.html

It has the same rationale: namely, that we're going to change the code
to apply psymbol offsets at runtime.  This will be done by adding an
argument to the SYMBOL_VALUE_ADDRESS macro -- but since we can't
convert all the symbol types at once, we need a new approach.

Because gdb now is in C++, this patch changes partial_symbol to
inherit from general_symbol_info, rather than renaming the field.
This simplifies code in some places.

Also, as noted before, these macros implement a kind of "phony
polymorphism" that is not actually useful in practice; so this patch
removes the macros in favor of simply referring directly to members.
In a few cases -- obj_section in this patch and the symbol address in
the future -- methods will be used instead.

Note that this removes the blanket memset from add_psymbol_to_bcache.
This hasn't really been needed since bcache was modified to allow
holes in objects and since psymtab took advantage of that.  This
deletion was required due to changing partial_symbol to derive from
general_symbol_info.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tom@tromey.com>

	* dwarf-index-write.c (write_psymbols, debug_names::insert)
	(debug_names::write_psymbols): Update.
	* psympriv.h (struct partial_symbol): Derive from
	general_symbol_info.
	<obj_section>: New method.
	(PSYMBOL_DOMAIN, PSYMBOL_CLASS): Remove.n
	* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymtab)
	(find_pc_sect_psymbol, fixup_psymbol_section)
	(match_partial_symbol, lookup_partial_symbol, relocate_psymtabs)
	(print_partial_symbols, recursively_search_psymtabs)
	(compare_psymbols, psymbol_hash, psymbol_compare)
	(add_psymbol_to_bcache, maintenance_check_psymtabs)
	(psymbol_name_matches, psym_fill_psymbol_map): Update.
2018-07-26 09:18:29 -06:00
Tom Tromey 08994e1ddc Remove dead code in end_psymtab
I noticed that there is a bit of dead code in end_psymtab.
This deletes it.

Normally I would investigate a fix for the code.  However, considering
that the code has been this way a long time (since the first import to
sourceware) and considering that dbxread.c is not as important any
more, I think it's safe to just consider that there's no bug.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tromey@redhat.com>

	* dbxread.c (end_psymtab): Remove dead code.
2018-07-26 09:18:28 -06:00
Tom de Vries 63b4ecf76f [gdb/testsuite] Add comment in gdb.base/vla-optimized-out.c
2018-07-26  Tom de Vries  <tdevries@suse.de>

	* gdb.base/vla-optimized-out.c: Add comment about origin of test-case.
2018-07-26 10:22:22 +02:00
Andrew Burgess 3c3bb0580b gdb: Add switch to disable DWARF stack unwinders
Add a maintenance command to disable the DWARF stack unwinders.
Normal users would not need this feature, but it is useful to allow
extended testing of fallback stack unwinding strategies, for example,
prologue scanners.

This is a partial implementation of the idea discussed in pr gdb/8434,
which talks about a generic ability to disable any frame unwinder.

Being able to arbitrarily disable any frame unwinder would be a more
complex patch, and I was unsure how useful such a feature would really
be, however, I can see (and have) a real need to disable DWARF
unwinders.  That's why this patch only targets that specific set of
unwinders.

If in the future we find ourselves adding more switches to disable
different unwinders, then we should probably move to a more generic
solution, and remove this patch.

gdb/ChangeLog:

	* dwarf2-frame-tailcall.c (tailcall_frame_sniffer): Exit early if
	DWARF unwinders are disabled.
	* dwarf2-frame.c: Add dwarf2read.h include.
	(dwarf2_frame_sniffer): Exit early if DWARF unwinders are
	disabled.
	(dwarf2_frame_unwinders_enabled_p): Define.
	(show_dwarf_unwinders_enabled_p): New function.
	(_initialize_dwarf2_frame): Register switch to control DWARF
	unwinder use.
	* dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Declare.
	* dwarf2read.c (set_dwarf_cmdlist): Remove static keyword.
	(show_dwarf_cmdlist): Remove static keyword.
	* dwarf2read.h (set_dwarf_cmdlist): Declare.
	(show_dwarf_cmdlist): Declare.
	* NEWS: Document new feature.

gdb/doc/ChangeLog:

	* gdb.texinfo (Maintenance Commands): Add description of
	maintenance command to control dwarf unwinders.

gdb/testsuite/ChangeLog:

	* gdb.base/maint.exp: Add check that dwarf unwinders control flag
	is visible.
2018-07-26 08:53:02 +01:00
Tom de Vries 9e7f3bbbbf [gdb/breakpoints] Fix sigsegv in info prog at exec catchpoint
With the test-case contained in this patch and compiled for debug we run into
a segfault with trunk gdb:
...
$ gdb catch-follow-exec -batch -ex "catch exec" \
  -ex "set follow-exec-mode new" -ex "run" -ex "info prog"
Catchpoint 1 (exec)
process xxx is executing new program: /usr/bin/ls
[New inferior 2 (process 0)]
[New process xxx]

Thread 2.1 "ls" hit Catchpoint 1 (exec'd /usr/bin/ls), in _start () from
  /lib64/ld-linux-x86-64.so.2
Segmentation fault (core dumped)
...

The patch fixes the segfault by returning an error in info_program_command
if get_last_target_status returns minus_one_ptid.

The test-case is non-standard, because the standard approach runs into
PR23368, a problem with gdb going to the background.

Build and reg-tested on x86_64-linux.

2018-07-26  Tom de Vries  <tdevries@suse.de>

	PR breakpoints/23366
	* infcmd.c (info_program_command): Handle ptid == minus_one_ptid.

	* gdb.base/catch-follow-exec.c: New test.
	* gdb.base/catch-follow-exec.exp: New file.
2018-07-26 00:56:41 +02:00
Tom de Vries 506f5c41ca [gdb/symtab] Warn about unresolved DW_AT_upper_bound/DW_AT_count
This patch generates a warning if DW_AT_upper_bound or DW_AT_count is defined,
but can't be translated.  This is triggered for current gcc in lto mode for
vla test-cases.

Build and reg-tested on x86_64-linux.

2018-07-26  Tom de Vries  <tdevries@suse.de>

	* dwarf2read.c (read_subrange_type): Warn if DW_AT_upper_bound or
	DW_AT_count can't be translated to a dynamic prop.
2018-07-26 00:08:52 +02:00
Tom de Vries 16f808ec99 [gdb/exp] Fix exception when printing optimized out vla
When compiling vla-optimized-out.c with -O3 and a recent gcc, and trying to
print the vla a in f1, we run into this gdb exception:
...
Cannot find matching parameter at DW_TAG_call_site 0x4003be at main
...

This is a regression introduced by 42dc7699a2 "[gdb/exp] Fix printing of type
of optimized out vla".

This patch fixes the regression by wrapping the ctx.eval call in
dwarf2_locexpr_baton_eval in try/catch, similar to what is done in
dwarf2_evaluate_loc_desc_full.

Build and reg-tested on x86_64-linux.

2018-07-25  Tom de Vries  <tdevries@suse.de>

	* dwarf2loc.c (dwarf2_locexpr_baton_eval): Wrap ctx.eval call in
	try/catch.

	* gdb.base/vla-optimized-out-o3.exp: New file.  Reuse
	vla-optimized-out.c.
2018-07-25 21:25:16 +02:00
Jan Vrany d7154a8d08 Notify about breakpoint modification when enabling/disabling single location
When a single breakpoint location enableness was modified by a CLI
command, observers were not notified about it. This issue is now fixed.

gdb/ChangeLog:

	* breakpoint.c (enable_disable_bp_num_loc): Notify observers.

gdb/testsuite/ChangeLog:

	* gdb.mi/mi-breakpoint-location-ena-dis.cc: New file.
	* gdb.mi/mi-breakpoint-location-ena-dis.exp: New file.
2018-07-25 13:47:16 -04:00
Joel Brobecker a45389f60d list Tom Tromey as GDB Global Maintainer
gdb/ChangeLog:

        * MAINTAINERS (Global Maintainers): Add Tom Tromey.
2018-07-25 08:27:39 -07:00
Keith Seitz 380618d68a Set CU language before processing any DIEs (symtab/23010 et al)
This patch is another attempt at really fixing the multitude of assertions
being seen where symbols of one language are being added to symbol lists of
another language.

In this specific case, the backtrace command (thread apply all bt full) that
is looking for the compunit containing the PC of the thread. That calls
get_prev_frame several times. This function calls (eventually)
dwarf2_frame_prev_register. That eventually ends up calling
find_pc_compunit_symtab.

In this function (find_pc_sect_compunit_symtab actually), we loop over all
compunits, calling the "quick" function dw2_find_pc_sect_compunit_symtab.
That function calls dw2_instantiate_symtab to read in all the CU's symbols.
Now the fun begins.

dw2_do_instantiate_symtab queues the per_cu for reading, using a default
"pretend" language of language_minimal with the expectation that this will
be set later.

The DIEs of this (only queued) CU are then processed.

The first DIE is DW_TAG_compile_unit. That's handled by read_file_scope.

(Nearly) The first thing read_file_scope does is:

  get_scope_pc_bounds (die, &lowpc, &highpc, cu);

This function loops over the children of the current DIE (a compile_unit),
looking for bounds. The first such child is a subprogram, and we attempt to
get its bounds. We use dwarf2_attr to get at DW_AT_high_pc.

This subprogram has DW_AT_specification set, so dwarf_attr (via
follow_die_ref/follow_die_offset) will follow that, but follow_die_offset
*also* attempts to load the containing CU for the spec DIE. That spec DIE
lives inside a CU that is a partial_unit and has no language attribute. So
it simply inherits the language from the CU that elicited the read. [That
all happens in follow_die_offset.]

The original CU's language is still language_minimal -- we haven't gotten to
the line in read_file_scope that actually sets the language yet!

And that is the cause of these problems. The call to prepare_one_comp_unit
needs to be the *first* thing that is done when reading a CU so that the
CU's language can be recorded (and inherited by any referenced
partial_units).

Since a test reproducer for this has been so elusive, this patch also adds a
wrapper function around add_symbol_to_list which asserts when adding a
symbol of one language to a list containing symbols of a different language.

gdb/ChangeLog:
2017-07-24  Keith Seitz  <keiths@redhat.com>

        PR symtab/23010
        * dwarf2read.c (dw2_add_symbol_to_list): New function.
        (fixup_go_packaging, new_symbol): Use dw2_add_symbol_to_list
        instead of add_symbol_to_list.
        (read_file_scope): Call prepare_one_comp_unit before reading
        any other DIEs.
2018-07-24 12:48:58 -07:00
Simon Marchi 4b17aefe75 Fix indentation in scoped_mmap.h
gdb/ChangeLog:

	* common/scoped_mmap.h (class scoped_mmap): Fix indentation.
2018-07-24 14:14:17 -04:00
Tom Tromey 29d17e4773 Remove some unnecessary declarations and configury
configure checks for declarations of free, malloc, and realloc; but
the results are only used in a single spot: utils.c.  I think these
checks are long since obsolete, so this patch removes them.

Grepping the entire tree for these HAVE_DECL_ symbols, the only uses
of possible interest to gdb come from bfd/sysdep.h; but this is not
(nor should be) included by gdb.  (And furthermore I think the code
there is probably also obsolete.)

gdb/ChangeLog
2018-07-24  Tom Tromey  <tom@tromey.com>

	* utils.c (malloc, realloc, free): Don't declare.
	* configure, config.in: Rebuild.
	* configure.ac: Don't check for declarations of free, malloc, or
	realloc.
2018-07-24 11:12:04 -06:00
Simon Marchi cf4088a92f Remove some unused variables
Found using the newly-enabled -Wunused-variable.

gdb/ChangeLog:

	* aarch64-linux-nat.c
	(aarch64_linux_nat_target::stopped_data_address): Remove unused
	variable.
	* arm-linux-nat.c (fetch_regs): Likewise.
	(store_regs): Likewise.
	(fetch_vfp_regs): Likewise.
	(store_vfp_regs): Likewise.
	(arm_linux_nat_target::insert_hw_breakpoint): Likewise.
	(arm_linux_nat_target::remove_hw_breakpoint): Likewise.
	(arm_linux_nat_target::insert_watchpoint): Likewise.
	(arm_linux_nat_target::remove_watchpoint): Likewise.
	* mips-linux-nat.c (mips_linux_nat_target::insert_watchpoint):
	Likewise.
	* nat/aarch64-sve-linux-ptrace.c (aarch64_sve_get_sveregs):
	Likewise.
	* ppc-linux-nat.c (fetch_register): Likewise.
	(fetch_all_gp_regs): Likewise.
	(fetch_ppc_registers): Likewise.
	(store_all_gp_regs): Likewise.
	(store_ppc_registers): Likewise.
	(hwdebug_insert_point): Likewise.
	(can_use_watchpoint_cond_accel): Likewise.
	* remote-sim.c (gdb_os_write_stdout): Likewise.

gdb/gdbserver/ChangeLog:

	* linux-mips-low.c (mips_collect_ptrace_register): Remove unused
	variable.
	(mips_supply_ptrace_register): Likewise.
2018-07-22 23:23:11 -04:00
Tom Tromey a0de763e32 Add -Wunused-variable to warnings.m4
This adds -Wunused-variable to the build.  This required a special
check in configure in order to work around a bug in GCC 4.9.  Simon
ound the correct test to use, so I've added him to the ChangeLog.

gdb/ChangeLog
2018-07-22  Simon Marchi  <simon.marchi@polymtl.ca>
	    Tom Tromey  <tom@tromey.com>

	* warning.m4 (AM_GDB_WARNINGS): Add -Wunused-variable and special
	test for it.
	* configure: Rebuild.

gdb/gdbserver/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-07-22 13:20:07 -06:00
Tom Tromey 3b20124b3d Conditionally define xmltarget_${name} variable in regdat.sh
This changes regdat.sh to emit the xmltarget_${name} variable inside
the #ifndef IN_PROCESS_AGENT block.  This avoids a -Wunused-variable
warning for some builds.  Thanks to Pedro for investigating this one.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* regformats/regdat.sh: Define xmltarget_${name} inside
	#ifndef IN_PROCESS_AGENT.
2018-07-22 13:20:07 -06:00
Tom Tromey b0a7723d29 Remove unused variables from gdbserver
This removes a few unused variables from gdbserver.

The x86-tdesc.h change is a bit unusual for this series.  This file
was not defining the multiple-include guard symbol, so I've added that
here.  Also, it is hard to determine when i386_expedite_regs will be
needed, so this patch simply marks it ATTRIBUTE_UNUSED.

gdb/gdbserver/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* win32-low.c (win32_create_inferior): Remove unused variables.
	* gdbreplay.c (remote_open): Remove unused variable.
	* remote-utils.c (remote_prepare): Remove unused variable.
	* x86-tdesc.h (X86_TDESC_H): Define.
	(amd64_expedite_regs): Define conditionally.
	(i386_expedite_regs): Mark ATTRIBUTE_UNUSED.
	* linux-x86-tdesc.c (i386_tdescs): Move inside #if.
	* remote-utils.c (readchar): Remove unused variable.
2018-07-22 13:20:06 -06:00
Tom Tromey 8c8807f439 Remove unused declaration from value.c
This removes an unused declaration from value_fetch_lazy_bitfield.
Because it is not completely clear if the check_typedef call is needed
somewhere beneath this function, this is broken out into a separate
patch.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* value.c (value_fetch_lazy_bitfield): Remove unused variable.
2018-07-22 13:20:05 -06:00
Tom Tromey c486b6106a Pass the correct argument to the observer in reread_symbols
This is actually a patch I found via another route.  Joel had asked me
to write a test, but I still have not found the time to do this.
Meanwhile, -Wunused-variable also found this error.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* symfile.c (reread_symbols): Notify iter, not objfile.
2018-07-22 13:20:05 -06:00
Tom Tromey 494f80a932 Fix ravenscar-thread.c to use arch_ops
The change to turn target ops into methods accidentally introduced a
bug in ravenscar-thread.c, changing some calls that were using
"arch_ops" to use the target beneath.

This patch changes ravenscar-thread.c to use these variables where
appropriate.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* ravenscar-thread.c (ravenscar_thread_target::store_registers):
	Use arch_ops.
	(ravenscar_thread_target::prepare_to_store): Likewise.
2018-07-22 13:20:04 -06:00
Tom Tromey c51f6a54c2 Call value_fetch_lazy when needed in pretty-printers
This removes some unused variables, and replaces the calls to
value_contents_for_printing with a call to value_fetch_lazy, when
needed.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer): Remove
	unused variable.  Call value_fetch_lazy when needed.
	* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
	Remove unused variable.  Call value_fetch_lazy when needed.
2018-07-22 13:20:04 -06:00
Tom Tromey 374fd1fd7b Remove declarations from m32c-tdep.c
This removes some unused declarations from m32c-tdep.c.  Initially I
had thought that this entire code block was dead, but Simon pointed
out that it is not; so this patch simply removes some declarations.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* m32c-tdep.c (mark_dma): Return void.
	(make_regs): Remove unused declarations.
2018-07-22 13:20:03 -06:00
Tom Tromey d5e9a511c4 Call some functions in guile/ for effect
This changes a couple of spots in guile/ to remove a variable
declaration but to still call a function for effect.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* guile/scm-cmd.c (gdbscm_dont_repeat): Call
	cmdscm_get_valid_command_smob_arg_unsafe for effect.
	* guile/scm-block.c (gdbscm_make_block_syms_iter): Call
	bkscm_get_valid_block_smob_arg_unsafe for effect.
2018-07-22 13:20:03 -06:00
Tom Tromey 996d693a07 Use a previously unused variable in bfin-tdep.c
This changes bfin_push_dummy_call to use the result of check_typedef.
Calling check_typedef for effect was probably ok as well, but this
seemed a little nicer.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* bfin-tdep.c (bfin_push_dummy_call): Use arg_type, not
	value_type.
2018-07-22 13:20:02 -06:00
Tom Tromey 1576637036 Unused variable fixes related to conditional compilation
This patch fixes various unused variable warnings that are related to
conditional compilation.  In these cases, either the variable is now
protected by the same #if as its uses, or the declaration is simply
lowered into the conditionally-compiled block.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* windows-nat.c (saved_context): Conditionally define.
	* remote.c (remote_target::remote_btrace_maybe_reopen):
	Conditionally declare "warned".
	* inflow.c (sigquit_ours): Conditionally define.
	(new_tty): Move "tty" declaration inside #if.
	* guile/guile.c (guile_datadir): Conditionally define.
	* charset.c (set_be_le_names): Move some declarations inside #if.
	* btrace.c (parse_xml_btrace): Move "errcode" declaration inside
	#if.
	(parse_xml_btrace_conf): Likewise.
2018-07-22 13:20:02 -06:00
Tom Tromey f4e80e1301 Remove an unused variable from spu_get_overlay_table
This removes an unused variable from spu_get_overlay_table, replacing
it with an explanatory comment.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* spu-tdep.c (spu_get_overlay_table): Remove unused variable.
2018-07-22 13:20:01 -06:00
Tom Tromey 8d49165d83 Simple unused variable removals
This patch holds all the straightforward unused variable deletions.

gdb/ChangeLog
2018-07-22  Tom Tromey  <tom@tromey.com>

	* guile/scm-value.c (gdbscm_value_call): Remove unused variables.
	* guile/scm-math.c (vlscm_unop_gdbthrow, vlscm_binop_gdbthrow)
	(vlscm_convert_typed_value_from_scheme): Remove unused variable.
	* buildsym-legacy.c (get_macro_table): Remove unused variable.
	* stack.c (frame_apply_level_command): Remove unused variable.
	* tic6x-tdep.c (tic6x_push_dummy_call): Remove unused variable.
	* sparc64-tdep.c (adi_examine_command): Remove unused variable.
	* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Remove
	unused variable.
	* nios2-tdep.c (nios2_push_dummy_call): Remove unused variable.
	* mep-tdep.c (mep_push_dummy_call): Remove unused variable.
	* ada-lang.c (ada_lookup_symbol_list_worker): Remove unused
	variable.
	* amd64-tdep.c (amd64_supply_xsave): Remove unused variable.
	* arm-tdep.c (arm_record_data_proc_misc_ld_str): Remove unused
	variable.
	* breakpoint.c (check_no_tracepoint_commands, update_watchpoint):
	Remove unused variable.
	* cli/cli-script.c (recurse_read_control_structure): Remove unused
	variable.
	* common/tdesc.c (print_xml_feature::visit): Remove unused
	variable.
	* compile/compile-object-load.c (store_regs): Remove unused
	variables.
	* complaints.c (clear_complaints): Remove unused variable.
	* corelow.c (core_target_open): Remove unused variable.
	* fbsd-tdep.c (fbsd_core_info_proc_status): Remove unused
	variable.
	* guile/scm-frame.c (gdbscm_frame_read_var): Remove unused
	variable.
	* guile/scm-symtab.c (stscm_print_sal_smob): Remove unused
	variable.
	* guile/scm-type.c (gdbscm_field_baseclass_p): Remove unused
	variable.
	* guile/scm-utils.c (gdbscm_parse_function_args): Remove unused
	variable.
	* hppa-tdep.c (hppa_stub_frame_unwind_cache): Remove unused
	variable.
	* ia64-tdep.c (examine_prologue): Remove unused variable.
	* infcall.c (run_inferior_call): Remove unused variable.
	* inferior.c (exit_inferior): Remove unused variable.
	* infrun.c (infrun_thread_ptid_changed): Remove unused variable.
	* linespec.c (decode_line_2): Remove unused variable.
	* linux-nat.c (super_close): Remove.
	* linux-tdep.c (linux_info_proc): Remove unused variable.
	* mi/mi-main.c (mi_execute_command): Remove unused variable.
	* microblaze-linux-tdep.c (microblaze_linux_sigtramp_cache):
	Remove unused variable.
	* parse.c (find_minsym_type_and_address): Remove unused variable.
	* printcmd.c (info_symbol_command, printf_floating): Remove unused
	variable.
	* python/py-breakpoint.c (bppy_set_commands): Remove unused
	variable.
	* python/py-unwind.c (unwind_infopy_dealloc): Remove unused
	variables.
	* record-btrace.c (record_btrace_target::store_registers): Remove
	unused variable.
	(cmd_show_record_btrace_cpu): Remove unused variable.
	* riscv-tdep.c (riscv_register_reggroup_p)
	(riscv_push_dummy_call, riscv_return_value): Remove unused
	variable.
	* rust-exp.y (literal): Remove unused variable.
	* rust-lang.c (rust_evaluate_subexp) <OP_RUST_ARARAY>: Remove
	unused variable.
	<STRUCTOP_ANONYMOUS>: Likewise.
	* s390-linux-tdep.c (s390_linux_init_abi_31)
	(s390_linux_init_abi_64): Remove unused variable.
	* ser-ming2.c (ser_windows_read_prim, pipe_select_thread)
	(file_select_thread, net_windows_open, _initialize_ser_windows):
	Remove unused variables.
	* symtab.c (find_pc_sect_line): Remove unused variable.
	* target-memory.c (compute_garbled_blocks): Remove unused
	variable.
	(target_write_memory_blocks): Remove unused variable.
	* target.c (target_stack::unpush): Remove unused variables.
	* tracepoint.c (start_tracing, all_tracepoint_actions)
	(merge_uploaded_trace_state_variables)
	(print_one_static_tracepoint_marker): Remove unused variable.
	* unittests/basic_string_view/element_access/char/1.cc (test01):
	Remove unused variable.
	* windows-nat.c (windows_continue, windows_add_all_dlls)
	(do_initial_windows_stuff, windows_nat_target::create_inferior):
	Remove unused variables.
2018-07-22 13:20:01 -06:00
Simon Marchi 17cbafdbbe Fix -Wunused-variable warnings related to conditional compilation
Some variables are not used when !HAVE_ELF, so avoid declaring them in
that case.

gdb/ChangeLog:

	* arm-tdep.c (arm_gdbarch_init): Declare attr_arch and
	attr_profile in HAVE_ELF.
	* rs6000-tdep.c (bfd_uses_spe_extensions): Declare vector_abi in
	HAVE_ELF.
2018-07-21 22:23:33 -04:00
Simon Marchi 0ee6c332f3 Rename some frame unwind function parameters
I am currently working with these functions, and though this renaming
could help to reason about the code.  Some functions take a frame and
will return the value associated to that frame, others will return the
value associated to the previous frame.  Those usually conveniently
contain "unwind" in their name, but naming the variable next_frame
instead of frame helps remembering which frame we are dealing with.

I also included a little typo fix at the top of frame.h.

gdb/ChangeLog:

	* frame.c (frame_register_unwind): Change parameter name.
	(frame_unwind_register): Likewise.
	(frame_unwind_register_value): Likewise.
	(frame_unwind_register_signed): Likewise.
	(frame_unwind_register_unsigned): Likewise.
	* frame.h (frame_register_unwind): Likewise.
	(frame_unwind_register): Likewise.
	(frame_unwind_register_value): Likewise.
	(frame_unwind_register_signed): Likewise.
	(frame_unwind_register_unsigned): Likewise.
	(frame_unwind_arch): Likewise.
2018-07-20 22:19:51 -04:00
Maciej W. Rozycki e2e31f1039 Update my e-mail address, limit maintenance to MIPS I-IV ISAs
binutils/
	* MAINTAINERS: Update my e-mail address, downgrade to MIPS I-IV
	ISA maintenance.

	gdb/
	* MAINTAINERS: Update my e-mail address, downgrade to MIPS I-IV
	ISA maintenance.

	sim/
	* MAINTAINERS: Update my e-mail address, downgrade to MIPS I-IV
	ISA maintenance.
2018-07-21 00:14:01 +01:00
Maciej W. Rozycki 2d38991535 MIPS/Linux/native: Convert to `get_ptrace_pid' for PID extraction
Use `get_ptrace_pid' to get the ptrace PID from `inferior_ptid' rather
than extracting it by hand.

	gdb/
	* mips-linux-nat.c (mips_linux_nat_target::read_description):
	Call `get_ptrace_pid' rather than extracting the ptrace PID by
	hand.
2018-07-20 17:28:08 +01:00
Keith Seitz cbb09508e4 Rename remaining members of buildsym_compunit to start with "m_"
This renames all the remaining members of buildsym_compunit to start
with "m_" to follow the general naming convention.

gdb/ChangeLog
2018-07-20  Keith Seitz  <keiths@redhat.com>

	* buildsym.h (struct buildsym_compunit) <m_objfile, m_subfiles,
	m_main_subfile, m_comp_dir, m_producer, m_debugformat,
	m_compunit_symtab, m_language>: Add "m_" prefix.
	Update all uses.
	* buildsym.c: Update all uses.
2018-07-20 09:42:56 -06:00
Tom Tromey bfe2e011c0 Remove record_line_ftype
The record_line_ftype typedef was only used in the DWARF reader, and
we removed those uses a few patches ago.  So, remove the typedef.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym-legacy.h (record_line): Don't use record_line_ftype.
	* buildsym.h (record_line_ftype): Remove typedef.
2018-07-20 09:42:56 -06:00
Tom Tromey 0e6f30610f Remove some unused buildsym functions
Now that the DWARF reader uses the builder-based API, we can remove a
few "legacy" functions that were only ever called by it.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym-legacy.h (augment_type_symtab): Don't declare.
	(end_expandable_symtab): Likewise.
	(end_symtab_get_static_block): Likewise.
	(end_symtab_from_static_block): Likewise.
	* buildsym-legacy.c (augment_type_symtab): Remove.
	(end_expandable_symtab): Remove.
	(end_symtab_get_static_block): Remove.
	(end_symtab_from_static_block): Remove.
2018-07-20 09:42:55 -06:00
Tom Tromey 804d27291b Convert the DWARF reader to new-style buildysm
This converts the DWARF reader to use the new-style buildsym API.  A
new buildsym_compunit is created for each CU and is used to construct
the symbol table.  In some cases the CU must be passed to functions
which previously did not accept it.  FWIW I tend to think that most
methods in the DWARF reader ought to be methods on the dwarf2_cu
object.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c: Include buildsym.h.
	(struct dwarf2_cu) <builder>: New method.
	(fixup_go_packaging): Update.
	(process_full_comp_unit, process_full_type_unit): Update.  Don't
	use scoped_free_pendings.
	(using_directives): Add "cu" parameter, remove "language".
	(read_import_statement, setup_type_unit_groups, )
	(read_func_scope, read_lexical_block_scope)
	(dwarf2_record_block_ranges, read_namespace): Update.
	(lnp_state_machine::lnp_state_machine): Add cu parameter.
	(lnp_state_machine::handle_end_sequence): Update.
	(class lnp_state_machine) <m_cu>: New member.
	<m_record_line_callback>: Remove.
	<m_currently_recording_lines>: New member.
	(lnp_state_machine::handle_set_file): Update.
	(noop_record_line): Remove.
	(dwarf_record_line_p): Add cu parameter.
	(dwarf_record_line_1, dwarf_finish_line): Likewise.
	(lnp_state_machine::record_line)
	(lnp_state_machine::lnp_state_machine)
	(lnp_state_machine::check_line_address, dwarf_decode_lines_1)
	(dwarf_decode_lines): Update.
	(dwarf2_start_subfile): Add cu parameter.
	(dwarf2_start_symtab, new_symbol): Update.
	(macro_start_file, dwarf_decode_macro_bytes): Add cu parameter.
	Remove dwarf2_per_objfile parameter.
	(dwarf_decode_macros): Update.
2018-07-20 09:42:54 -06:00
Tom Tromey 80e649fcac Parameterize cp_scan_for_anonymous_namespaces
This changes cp_scan_for_anonymous_namespaces to use the
buildsym_compunit API, rather than the function-based API.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* stabsread.c (define_symbol): Update.
	* buildsym-legacy.h (get_buildsym_compunit): Declare.
	* dwarf2read.c (new_symbol): Update.
	* cp-support.h (cp_scan_for_anonymous_namespaces): Update.
	* cp-namespace.c: Include buildsym.h.
	(cp_scan_for_anonymous_namespaces): Add "compunit" parameter.
	* buildsym-legacy.c (get_buildsym_compunit): New function.
2018-07-20 09:42:53 -06:00
Tom Tromey 0baae8dbd3 Introduce buildsym-legacy.h
This introduces a new header, buildsym-legacy.h, and changes all the
symbol readers to use it.  The idea is to put the function-based
interface, that relies on the buildsym_compunit global, into a
separate header.  Then when a symbol reader is updated to use the new
interface, it can simply not include buildsym-legacy.h, so it's easy
to be sure that the new API is used everywhere.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c: Include buildsym-legacy.h.
	* windows-nat.c: Include buildsym-legacy.h.
	* stabsread.c: Include buildsym-legacy.h.
	* mdebugread.c: Include buildsym-legacy.h.
	* buildsym-legacy.h: New file.
	* buildsym-legacy.c: New file, from buildsym.c.
	* go32-nat.c: Include buildsym-legacy.h.
	* dwarf2read.c: Include buildsym-legacy.h.
	* dbxread.c: Include buildsym-legacy.h.
	* cp-namespace.c: Include buildsym-legacy.h.
	* coffread.c: Include buildsym-legacy.h.
	* buildsym.h: Move some contents to buildsym-legacy.h.
	* buildsym.c: Include buildsym-legacy.h.  Move many functions to
	buildsym-legacy.c.
	* Makefile.in (HFILES_NO_SRCDIR): Add buildsym-legacy.h.
2018-07-20 09:42:53 -06:00
Tom Tromey ab209f6fa9 Move struct buildsym_compunit to buildsym.h
This moves struct buildsym_compunit to buildsym.h.  Now that the
members are private, and it no longer affects any global state in
buildsym.c, an instance can be used directly for symtab creation.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.h (struct buildsym_compunit): Move from buildsym.c.
	* buildsym.c (struct buildsym_compunit): Move to buildsym.h.
	(buildsym_compunit::buildsym_compunit)
	(buildsym_compunit::~buildsym_compunit)
	(buildsym_compunit::get_macro_table): Define.
2018-07-20 09:42:52 -06:00
Tom Tromey 74c72eac23 Remove reset_symtab_globals
This patch arranges for the remaining buildsym global --
buildsym_compunit -- to only be cleared by the wrapper functions, not
by methods on struct buildsym_compunit.  In the process,
reset_symtab_globals is removed.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (reset_symtab_globals): Remove.
	(buildsym_compunit::end_symtab_from_static_block): Update.
	(buildsym_compunit::augment_type_symtab): Update.
	(end_symtab_from_static_block): Call free_buildsym_compunit.
	(augment_type_symtab, end_symtab, end_expandable_symtab):
	Likewise.
2018-07-20 09:42:51 -06:00
Tom Tromey da6580e59c Do not use buildsym.h in some files
A few files no longer need to include buildsym.h.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* arch-utils.c: Do not include buildsym.h.
	* mipsread.c: Do not include buildsym.h.
	* machoread.c: Do not include buildsym.h.
	* elfread.c: Do not include buildsym.h.
2018-07-20 09:42:51 -06:00
Tom Tromey 4a2125f531 Add many methods to buildsym_compunit
This adds many methods to buildsym_compunit and makes the data members
private.  Essentially the entire buildsym API is now available as a
method on buildsym_compunit.  However, standalone functions are still
provided, as this is what the sybmol readers actually use.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (buildsym_compunit::buildsym_compunit): Do more
	initialization.
	(buildsym_compunit): Add new constructor.
	(struct buildsym_compunit) <get_last_source_file, finish_block,
	record_block_range, start_subfile, patch_subfile_names,
	push_subfile, pop_subfile, record_line, get_compunit_symtab,
	set_last_source_start_addr, get_last_source_start_addr,
	get_local_using_directives, set_local_using_directives,
	get_global_using_directives, outermost_context_p,
	get_current_context_stack, get_context_stack_depth,
	get_current_subfile, get_local_symbols, get_file_symbols,
	get_global_symbols, record_debugformat, record_producer,
	push_context, pop_context, end_symtab_get_static_block,
	end_symtab_from_static_block, end_symtab, end_expandable_symtab>:
	New public methods.
	<record_pending_block, finish_block_internal, make_blockvector,
	watch_main_source_file_lossage, end_symtab_with_blockvector>: New
	private methods.
	Update all users.
2018-07-20 09:42:50 -06:00
Tom Tromey 6b213a4778 Remove parameter from record_pending_block
This removes a redundant parameter from record_pending_block.  It also
moves record_pending_block earlier in the file, so that a forward
declaration is no longer needed.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (record_pending_block): Move earlier.  Remove objfile
	parameter.
	(finish_block_internal): Update.
2018-07-20 09:42:49 -06:00
Tom Tromey b80a981d08 Remove EXTERN from buildsym.h
Nothing in buildsym.h relies on the "EXTERN" method of
declaration/definition, so remove the traces.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.h (EXTERN): Don't define or undef.
	* buildsym.c (EXTERN): Don't define.
2018-07-20 09:42:49 -06:00
Tom Tromey ddb7060226 Remove a TODO
This removes a TODO comment -- the work has been done.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c: Remove TODO comment.
2018-07-20 09:42:48 -06:00
Tom Tromey b37dd3bcaa Remove buildsym_init
Now that buildsym_init does nothing, it can be removed.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* coffread.c (coff_symtab_read): Update.
	* xcoffread.c (xcoff_psymtab_to_symtab_1): Update.
	(xcoff_new_init): Update.
	* mipsread.c (mipscoff_new_init): Update.
	* mdebugread.c (mdebug_build_psymtabs): Update.
	* elfread.c (elf_new_init): Update.
	* dwarf2read.c (process_full_comp_unit, process_full_type_unit):
	Update.
	* dbxread.c (dbx_new_init, dbx_psymtab_to_symtab_1)
	(coffstab_build_psymtabs, elfstab_build_psymtabs)
	(stabsect_build_psymtabs): Update.
	* buildsym.h (buildsym_init): Don't declare.
	* buildsym.c: Update comment.
	(prepare_for_building): Remove.
	(start_symtab, restart_symtab): Update.
	(reset_symtab_globals): Update comment.
	(buildsym_init): Remove.
2018-07-20 09:42:47 -06:00
Tom Tromey e148f09d75 Move the symbol lists to buildsym_compunit
This moves the global symbol lists into buildsym_compunit, adds
accessors, and updates all the users.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab, process_xcoff_symbol): Update.
	* stabsread.c (patch_block_stabs, define_symbol, read_type)
	(read_enum_type, common_block_start, common_block_end)
	(cleanup_undefined_types_1, finish_global_stabs): Update.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (fixup_go_packaging, read_func_scope)
	(read_lexical_block_scope, new_symbol): Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read, process_coff_symbol)
	(coff_read_enum_type): Update.
	* buildsym.h (file_symbols, global_symbols, local_symbols): Don't
	declare.
	(get_local_symbols, get_file_symbols, get_global_symbols): New
	functions.
	* buildsym.c (~buildsym_compunit): Clean up m_file_symbols and
	m_global_symbols.
	<m_file_symbols, m_local_symbols, m_global_symbols>: New members.
	(~scoped_free_pendings): Update.
	(finish_block, prepare_for_building, reset_symtab_globals)
	(end_symtab_get_static_block, end_symtab_with_blockvector)
	(augment_type_symtab, push_context): Update.
	(get_local_symbols, get_file_symbols, get_global_symbols): New
	functions.
	(buildsym_init): Update.
2018-07-20 09:42:46 -06:00
Tom Tromey 93b8bea414 Set list_in_scope later in DWARF reader
Currently the DWARF reader sets the list_in_scope member of the CU
when first starting to process symbols.  Future changes will make this
assert -- code will not be able to refer to these lists until after
start_symtab has been called.  This patch prepares for the problem by
arranging to initialize list_in_scope in dwarf2_start_symtab.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (process_full_comp_unit): Do not set list_in_scope.
	(process_full_type_unit): Likewise.
	(dwarf2_start_symtab): Set list_in_scope.
2018-07-20 09:42:46 -06:00
Tom Tromey f62f6af5da Do not look at file symbols when reading psymtabs
The DWARF reader was setting the list_in_scope member when reading
partial symbols.  however, this member is only useful when reading
full symbols.  Future patches will make this assert, so remove these
unneeded initializations.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (process_psymtab_comp_unit_reader)
	(build_type_psymtabs_reader): Do not set list_in_scope.
2018-07-20 09:42:45 -06:00
Tom Tromey 1d376700df Remove free_pendings
buildsym.c currently keeps a free list of "struct pending"s.  However,
this didn't seem necessary to me, and so this patch removes the free
list.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (free_pendings): Remove.
	(add_symbol_to_list, scoped_free_pendings)
	(finish_block_internal, buildsym_init): Update.
2018-07-20 09:42:44 -06:00
Tom Tromey c233e9c641 Remove the "listhead" argument from finish_block
finish_block is only ever called with "&local_symbols" as the
"listhead" argument.  So, remove this argument.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab): Update.
	* dwarf2read.c (read_func_scope, read_lexical_block_scope):
	Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read): Update.
	* buildsym.h (finish_block): Update.
	* buildsym.c (finish_block): Remove "listhead" argument.
	(end_symtab_get_static_block): Update.
2018-07-20 09:42:44 -06:00
Tom Tromey 5ac045503d Move pending_blocks and pending_block_obstack to buildsym_compunit
This moves the pending_blocks and pending_block_obstack into
buildsym_compunit.

The obstack could perhaps be merged with the addrmap obstack, but I
did not do that in this series.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.h (class scoped_free_pendings): Remove constructor.
	* buildsym.c (struct buildsym_compunit) <free_pending_blocks>: New
	method.
	<m_pending_block_obstack, m_pending_blocks>: New members.
	(pending_block_obstack, pending_blocks): Remove.
	(scoped_free_pendings::scoped_free_pendings): Default.
	(~scoped_free_pendings): Update.
	(free_pending_blocks): Remove.
	(finish_block_internal, record_pending_block, make_blockvector)
	(end_symtab_get_static_block, augment_type_symtab, push_context)
	(buildsym_init): Update.
2018-07-20 09:42:43 -06:00
Tom Tromey 7ea05a7b63 Move pending addrmap globals to buildsym_compunit
This moves the pending addrmap-related globals into buildsym_compunit.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* buildsym.c (struct buildsym_compunit) <m_pending_addrmap,
	m_pending_addrmap_obstack, m_pending_addrmap_interesting>: New
	members.
	(pending_addrmap, pending_addrmap_obstack)
	(pending_addrmap_interesting): Remove.
	(scoped_free_pendings, record_block_range, make_blockvector)
	(prepare_for_building, reset_symtab_globals, buildsym_init):
	Update.
2018-07-20 09:42:43 -06:00
Tom Tromey 3c65e5b31c Move current_subfile to buildsym_compunit
This moves the global current_subfile into buildsym_compunit.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (process_linenos): Update.
	* stabsread.c (define_symbol, read_type, read_enum_type): Update.
	* mdebugread.c (psymtab_to_symtab_1): Update.
	* dwarf2read.c (setup_type_unit_groups)
	(lnp_state_machine::handle_set_file, dwarf_record_line_p)
	(lnp_state_machine::record_line, dwarf_decode_lines): Update.
	* dbxread.c (process_one_symbol): Update.
	* coffread.c (coff_symtab_read, enter_linenos)
	(process_coff_symbol): Update.
	* buildsym.h (current_subfile): Don't declare.
	(get_current_subfile): Declare.
	* buildsym.c (struct buildsym_compunit) <m_current_subfile>: New
	member.
	(start_subfile, free_buildsym_compunit, push_subfile)
	(prepare_for_building, start_symtab): Update.
	(get_current_subfile): New function.
2018-07-20 09:42:42 -06:00
Tom Tromey a60f3166aa Move the context stack to buildsym_compunit
This moves the context stack globals to be members of
buildsym_compunit, changing the type to a std::vector in the process.

Because the callers expect the context stack object to be valid after
being popped, at Simon's suggestion I've changed pop_context to return
the object rather than the pointer.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* coffread.c (coff_symtab_read): Update.
	* xcoffread.c (read_xcoff_symtab): Update.
	* dwarf2read.c (new_symbol): Update.
	(read_func_scope, read_lexical_block_scope): Update.
	* dbxread.c (process_one_symbol): Update.
	* buildsym.h (context_stack, context_stack_depth): Don't declare.
	(outermost_context_p): Remove macro.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): Declare.
	(pop_context): Return struct context_stack.
	* buildsym.c (struct buildsym_compunit) <m_context_stack: New
	member.
	(context_stack_size): Remove.
	(INITIAL_CONTEXT_STACK_SIZE): Remove.
	(prepare_for_building, end_symtab_get_static_block)
	(augment_type_symtab, push_context): Update.
	(pop_context): Return struct context_stack.
	(outermost_context_p, get_current_context_stack)
	(get_context_stack_depth): New functions.
	(buildsym_init): Update.
2018-07-20 09:42:41 -06:00
Tom Tromey 56ba65a047 Make the Rust parser pure
This makes the Rust parser a pure parser and removes all the
(non-constant) globals from rust-exp.y.  This seemed like a nice
simplification to me and I think it should probably be applied to all
the parsers.  Perhaps it would be good to go even one step farther and
have all parsers derive from parser_state.

Tested on x86-64 Fedora 26.

gdb/ChangeLog
2018-07-20  Tom Tromey  <tom@tromey.com>

	* rust-exp.y: Now a pure parser.  Update all rules.
	(%union): Move earlier.
	(current_parser, work_obstack): Remove globals.
	(rust_parser, ~rust_parser): Update.
	(class rust_parser) <copy_name, concat3, crate_name, super_name,
	lex_character, lex_number, lex_string, lex_identifier,
	rust_lookup_type, convert_params_to_types, convert_ast_to_type,
	convert_name, convert_params_to_expression,
	convert_ast_to_expression, ast_basic_type, ast_operation,
	ast_compound_assignment, rust_op, ast_literal, ast_dliteral,
	ast_structop, ast_structop_anonymous, ast_unary, ast_cast,
	ast_call_ish, ast_path, ast_string, ast_struct, ast_range,
	ast_array_type, ast_slice_type, ast_reference_type,
	ast_pointer_type, ast_function_type, ast_tuple_type>: New methods.
	(rust_parse): Update.
	(rustyyerror, rustyylex): Add parser parameter.
	(rust_lex_test_one, rust_lex_int_test, rust_lex_exception_test)
	(rust_lex_stringish_test, rust_lex_test_sequence)
	(rust_lex_test_trailing_dot, rust_lex_test_completion)
	(rust_lex_test_push_back, rust_lex_tests): Update.
2018-07-20 09:40:18 -06:00
Tom de Vries 232a00325b [gdb/testsuite] Make noclone conditional in vla-optimized-out.c
Make the noclone attribute on f1 in vla-optimized-out.c conditional.  This
makes the test-case by default identical to
gcc/testsuite/gcc.dg/guality/vla-1.c.

Tested on x86_64-linux.

2018-07-20  Tom de Vries  <tdevries@suse.de>

	* gdb.base/vla-optimized-out.c: Make noclone attribute conditional on
	NOCLONE macro.
	* gdb.base/vla-optimized-out.exp: Use additional_flags -DNOCLONE.
2018-07-20 17:04:02 +02:00
Pedro Alves 4c6933327e Eliminate remaining gdb/guile cleanups
The remaining gdb/guile cleanups all handle the memory returned by
gdbscm_scm_to_c_string.

This commit makes gdbscm_scm_to_c_string return a
gdb::unique_xmalloc_ptr instead of a naked pointer, and eliminates the
remaining cleanups.

gdb/ChangeLog:
2018-07-19  Pedro Alves  <palves@redhat.com>

	* guile/guile-internal.h (gdbscm_scm_to_c_string): Now returns a
	gdb::unique_xmalloc_ptr.
	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x):
	Adjust to use dbscm_wrap and gdb::unique_xmalloc_ptr.
	* guile/scm-exception.c (gdbscm_exception_message_to_string): Use
	copy-initialization.
	* guile/scm-pretty-print.c (ppscm_print_children): Use
	gdb::unique_xmalloc_ptr instead of cleanups.
	(gdbscm_apply_val_pretty_printer): Remove cleanups.
	* guile/scm-string.c (gdbscm_scm_to_c_string): Now returns a
	gdb::unique_xmalloc_ptr.
	* guile/scm-type.c (gdbscm_type_field, gdbscm_type_has_field_p):
	Adjust to use gdb::unique_xmalloc_ptr.
	* guile/scm-utils.c (extract_arg): Adjust.
	* guile/scm-value.c (gdbscm_value_field): Adjust to use
	gdb::unique_xmalloc_ptr instead of a cleanup.
2018-07-19 16:34:55 +01:00
Tom Tromey 4581dc8297 Remove make_cleanup_value_free_to_mark
Pedro's patch to introduce gdbscm_wrap removed the last caller of
make_cleanup_value_free_to_mark.  This patch removes this function.

I'm checking this in as obvious.  Tested by rebuilding, and by
grepping.

gdb/ChangeLog
2018-07-19  Tom Tromey  <tom@tromey.com>

	* utils.c (do_value_free_to_mark)
	(make_cleanup_value_free_to_mark): Remove.
	* utils.h (make_cleanup_value_free_to_mark): Remove.
2018-07-19 08:52:24 -06:00
Tom de Vries fbb1d502ee [gdb/testsuite] Fix regexp in list-thread-groups-available.exp
I ran into a gdb.mi/list-thread-groups-available.exp failure:
...
Running gdb/testsuite/gdb.mi/list-thread-groups-available.exp ...
FAIL: gdb.mi/list-thread-groups-available.exp:
        list available thread groups (unexpected output)
PASS: gdb.mi/list-thread-groups-available.exp:
        list available thread groups with filter
...
When doing an experiment of running it 100 times in a row, the failure
reproduced 3 times.

Analyzing the original failure led to insufficient quoting of square brackets
in a regexp.  This patch fixes the regexp, which resulted in 0 failures in a
100-in-a-row run.

Tested on x86_64-linux.

2018-07-19  Tom de Vries  <tdevries@suse.de>

	* gdb.mi/list-thread-groups-available.exp (cores_re): Fix quoting in
	regular	expression.
2018-07-19 16:51:22 +02:00
Pedro Alves 43cc6c3adb gdbscm_wrap, really forward args
Commit 557e56be26 ("Eliminate most remaining cleanups under
gdb/guile/") missed adding the && to Args to really forward the
arguments properly.  Noticed by inspection.

gdb/ChangeLog:
2018-07-19  Pedro Alves  <palves@redhat.com>

	* guile/guile-internal.h (gdbscm_wrap): Really make 'args' a
	forwarding reference.
2018-07-19 10:56:47 +01:00
Pedro Alves 3a5f2a48ff Eliminate cleanup in gdbscm_execute_gdb_command
Note: the "may be modified" comment is no longer true nowadays.

gdb/ChangeLog:
2018-07-18  Pedro Alves  <palves@redhat.com>

	* guile/guile.c (gdbscm_execute_gdb_command): Adjust to use
	gdbscm_wrap.  Use gdb::unique_xmalloc_ptr<char> instead of a
	cleanup.
2018-07-18 23:41:06 +01:00
Pedro Alves 557e56be26 Eliminate most remaining cleanups under gdb/guile/
The main complication with the Guile code is that we have two types of
exceptions to consider.  GDB/C++ exceptions, and Guile/SJLJ
exceptions.  Code that is facing the Guile interpreter must not throw
GDB exceptions, instead Scheme exceptions must be thrown.  Also,
because Guile exceptions are SJLJ based, Guile-facing code must not
use local objects with dtors, unless wrapped in a scope with a
TRY/CATCH, because the dtors won't otherwise be run when a Guile
exceptions is thrown.

This commit adds a new gdbscm_wrap wrapper function than encapsulates
a pattern I noticed in many of the functions using
GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS.  The wrapper is written
such that you can pass either a lambda to it, or a function plus a
variable number of forwarded args.  I used a lambda when its body
would be reasonably short, and a separate function in the larger
cases.

This also convers a few functions that were using
GDBSCM_HANDLE_GDB_EXCEPTION to use gdbscm_wrap too because they
followed a similar pattern.

A few cases of make_cleanup calls are replaced with explicit xfree
calls.  The make_cleanup/do_cleanups calls in those cases are
pointless, because do_cleanups won't be called when a Scheme exception
is thrown.

We also have a couple cases of Guile-facing code using RAII-type
objects to manage memory, but those are incorrect, exactly because
their dtor won't be called if a Guile exception is thrown.

gdb/ChangeLog:
2018-07-18  Pedro Alves  <palves@redhat.com>

	* guile/guile-internal.h: Add comment about mixing GDB and Scheme
	exceptions.
	(GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS): Delete.
	(gdbscm_wrap): New.
	* guile/scm-frame.c (gdbscm_frame_read_register): Use xfree
	directly instead of a cleanup.
	* guile/scm-math.c (vlscm_unop_gdbthrow): New, factored out from ...
	(vlscm_unop): ... this.  Reimplement using gdbscm_wrap.
	(vlscm_binop_gdbthrow): New, factored out from ...
	(vlscm_binop): ... this.  Reimplement using gdbscm_wrap.
	(vlscm_rich_compare): Use gdbscm_wrap.
	* guile/scm-symbol.c (gdbscm_lookup_symbol): Use xfree directly
	instead of a cleanup.
	(gdbscm_lookup_global_symbol): Use xfree directly instead of a
	cleanup.
	* guile/scm-type.c (gdbscm_type_field, gdbscm_type_has_field_p):
	Use xfree directly instead of a cleanup.
	* guile/scm-value.c (gdbscm_make_value, gdbscm_make_lazy_value):
	Adjust to use gdbscm_wrap and scoped_value_mark.
	(gdbscm_value_optimized_out_p): Adjust to use gdbscm_wrap.
	(gdbscm_value_address, gdbscm_value_dereference)
	(gdbscm_value_referenced_value): Adjust to use gdbscm_wrap and
	scoped_value_mark.
	(gdbscm_value_dynamic_type): Use scoped_value_mark.
	(vlscm_do_cast, gdbscm_value_field): Adjust to use gdbscm_wrap and
	scoped_value_mark.
	(gdbscm_value_subscript, gdbscm_value_call): Adjust to use
	gdbscm_wrap and scoped_value_mark.
	(gdbscm_value_to_string): Use xfree directly instead of a
	cleanup.  Move 'buffer' unique_ptr to TRY scope.
	(gdbscm_value_to_lazy_string): Use xfree directly instead of a
	cleanup.  Move 'buffer' unique_ptr to TRY scope.  Use
	scoped_value_mark.
	(gdbscm_value_fetch_lazy_x): Use gdbscm_wrap.
	(gdbscm_parse_and_eval): Adjust to use gdbscm_wrap and
	scoped_value_mark.
	(gdbscm_history_ref, gdbscm_history_append_x): Adjust to use
	gdbscm_wrap.
2018-07-18 22:55:59 +01:00
Tom de Vries 42dc7699a2 [gdb/exp] Fix printing of type of optimized out vla
Consider this snippet from gcc/testsuite/gcc.dg/guality/vla-1.c:
...
int __attribute__((noinline))
f1 (int i)
{
  char a[i + 1];
  a[0] = 5;             /* { dg-final { gdb-test .+1 "i" "5" } } */
  return a[0];          /* { dg-final { gdb-test . "sizeof (a)" "6" } } */
}
...

When we compile the test-case with -O1 -g, and query the size of optimized
out vla 'a', we get:
...
$ ./gdb -batch -ex "b f1" -ex "r" -ex "p sizeof (a)" vla-1.exe
Breakpoint 1 at 0x4004a8: file vla-1.c, line 17.

Breakpoint 1, f1 (i=i@entry=5) at vla-1.c:17
17        return a[0];
$1 = 0
...
while we expect a size of '6'.

The problem is that default_read_var_value does not resolve the dynamic type
of a variable if the variable is optimized out.

This patch fixes that, and consequently gdb prints '6', as expected.

Tested on x86_64-linux.

2018-07-18  Tom de Vries  <tdevries@suse.de>

	* findvar.c (default_read_var_value): Also resolve dynamic type for
	LOC_OPTIMIZED_OUT vars.

	* gdb.base/vla-optimized-out.c: New test.
	* gdb.base/vla-optimized-out.exp: New file.
2018-07-18 22:02:34 +02:00
Maciej W. Rozycki 6592ceed48 microMIPS: Add SYSCALL instruction decoding
Fix a bug with commit 4cc0665f24 ("microMIPS support"),
<https://sourceware.org/ml/gdb-patches/2012-05/msg00724.html>, and add
missing microMIPS SYSCALL instruction decoding needed to determine the
location to put a breakpoint at when single-stepping though a syscall.

	gdb/
	* mips-tdep.c (micromips_next_pc): Add SYSCALL instruction
	decoding.
2018-07-18 19:17:39 +01:00
Tom Tromey c6c6149af4 Return unique_xmalloc_ptr from gdbscm_scm_to_string
This changes gdbscm_scm_to_string to return a unique_xmalloc_ptr and
then fixes all the callers.  This allows for the removal of some
cleanups.

gdb/ChangeLog
2018-07-17  Tom Tromey  <tom@tromey.com>

	* guile/scm-param.c (pascm_set_func, pascm_show_func)
	(compute_enum_list, pascm_set_param_value_x)
	(gdbscm_parameter_value): Update.
	* guile/guile-internal.h (gdbscm_scm_to_string): Update.
	(gdbscm_scm_to_host_string): Update.
	* guile/scm-math.c (vlscm_convert_typed_value_from_scheme):
	Update.
	* guile/scm-cmd.c (cmdscm_add_completion): Update.
	* guile/scm-pretty-print.c (ppscm_print_string_repr): Update.
	* guile/scm-string.c (gdbscm_scm_to_string): Return
	unique_xmalloc_ptr.
	(gdbscm_scm_to_host_string): Likewise.
2018-07-17 13:21:48 -06:00
Tom Tromey a1a31cb8dc Return unique_xmalloc_ptr from gdbscm_safe_eval_string
This changes gdbscm_safe_eval_string to return a unique_xmalloc_ptr.
This allows for the removal of some cleanups.  It also fixes a
potential latent memory leak in gdbscm_set_backtrace.

gdb/ChangeLog
2018-07-17  Tom Tromey  <tom@tromey.com>

	* guile/guile.c (gdbscm_eval_from_control_command): Update.
	* guile/guile-internal.h (gdbscm_safe_eval_string): Update.
	* guile/scm-objfile.c (gdbscm_execute_objfile_script): Update.
	* guile/scm-safe-call.c (gdbscm_safe_eval_string): Return
	unique_xmalloc_ptr.
2018-07-17 13:21:47 -06:00
Tom Tromey 15bf30027b Change gdbscm_exception_message_to_string to return a unique_xmalloc_ptr
This changes gdbscm_exception_message_to_string to return a
unique_xmalloc_ptr, allowing for the removal of some cleanups.
unique_xmalloc_ptr was chosen because at the root of the call chains
is a function from Guile that returns a malloc'd string.

gdb/ChangeLog
2018-07-17  Tom Tromey  <tom@tromey.com>

	* guile/scm-param.c (pascm_signal_setshow_error): Update.
	* guile/guile-internal.h (gdbscm_exception_message_to_string):
	Update.
	* guile/scm-cmd.c (cmdscm_function): Update.
	* guile/scm-pretty-print.c
	(ppscm_print_exception_unless_memory_error): Update.
	* guile/scm-exception.c (gdbscm_exception_message_to_string):
	Return unique_xmalloc_ptr.
2018-07-17 13:21:47 -06:00
Tom Tromey 7eb1a66c26 Use std::string in ppscm_make_pp_type_error_exception
This changes ppscm_make_pp_type_error_exception to use std::string,
removing a cleanup.

gdb/ChangeLog
2018-07-17  Tom Tromey  <tom@tromey.com>

	* guile/scm-pretty-print.c (ppscm_make_pp_type_error_exception):
	Use string_printf.
2018-07-17 13:21:46 -06:00
Jim Wilson 27724bad00 RISC-V: Don't decrement pc after break.
gdb/
	* riscv-tdep.c (riscv_has_feature): Delete comment that refers to
	set_gdbarch_decr_pc_after_break.  Call riscv_read_misa_reg always.
	(riscv_gdbarch_init): Delete local has_compressed_isa.  Delete now
	unecessary braces after EF_RISCV_RVC test.  Delete call to
	set_gdbarch_decr_pc_after_break.
2018-07-17 09:44:42 -07:00
Jim Wilson ce73f31015 RISC-V: Correct legacy misa register number.
gdb/
	* riscv-tdep.h (DECLARE_CSR): Use RISCV_FIRST_CSR_REGNUM instead of
	RISCV_LAST_FP_REGNUM + 1.
	(RSICV_CSR_LEGACY_MISA_REGNUM): Add RISCV_FIRST_CSR_REGNUM.
2018-07-17 09:42:23 -07:00
Tom Tromey 056dec39ed Remove --disable-gdbcli
I think it doesn't really make sense to allow building gdb without the
CLI.  Perhaps at one time this was a goal, but libgdb is long gone and
the CLI is intrinsic to gdb.

So, this patch removes the implementation of this configure option.
It is still recognized (this is autoconf's default), but does nothing.

This simplifies configure.ac and Makefile.in a bit.

Tested by rebuilding.

gdb/ChangeLog
2018-07-17  Tom Tromey  <tom@tromey.com>

	* configure.ac: Remove --disable-gdbcli.
	* configure: Rebuild.
	* Makefile.in (SUBDIR_CLI_DEPS, SUBDIR_CLI_LDFLAGS)
	(SUBDIR_CLI_CFLAGS): Remove.
	(SFILES): Use SUBDIR_CLI_SRCS.
	(COMMON_OBS): Use SUBDIR_CLI_OBS.
2018-07-17 09:54:17 -06:00
Tom Tromey 4735f0edf4 Use scoped_free_pendings in coff_symtab_read
PR gdb/18624 concerns an assertion failure that occurs when setting a
breakpoint in a Go program on Windows.

What happens here is that coff_symtab_read uses buildsym but does not
instantiate scoped_free_pendings.  So, the struct pending objects are
never released.  Later, dwarf2read.c calls buildsym_init, which
asserts.

This patch fixes the problem by instantiating scoped_free_pendings in
coff_symtab_read.

Tested using the test executable from the PR.  I don't know how to
test this more fully.

gdb/ChangeLog
2018-07-17  Tom Tromey  <tom@tromey.com>

	PR gdb/18624:
	* coffread.c (coff_symtab_read): Use scoped_free_pendings.
2018-07-17 09:30:57 -06:00
Jim Wilson 117a0e996d RISC-V: Add osabi support.
gdb/
	* riscv-tdep.c (riscv_gdbarch_init): Call gdbarch_init_osabi.
2018-07-16 14:50:36 -07:00
Simon Marchi 8a67aaa818 Add missing ChangeLog entry
I forgot (yes, again) the ChangeLog entry in my latest patch.
2018-07-16 14:31:11 -04:00
Simon Marchi b4792091ca Remove unused variables in ia64*tdep.c
gdb/ChangeLog:

	* ia64-libunwind-tdep.c (libunwind_frame_cache): Remove unused
	variable.
	(libunwind_frame_sniffer): Likewise.
	(libunwind_frame_prev_register): Likewise.
	(libunwind_sigtramp_frame_sniffer): Likewise.
	* ia64-tdep.c (ia64_access_reg): Likewise.
	(ia64_access_rse_reg): Likewise.
	(ia64_libunwind_sigtramp_frame_this_id): Likewise.
	* ia64-vms-tdep.c (ia64_vms_find_proc_info_x): Likewise.
2018-07-16 14:30:30 -04:00
Simon Marchi ec74dcd894 Fix compilation error in ia64-vms-tdep.c with libunwind-ia64
I found this when doing a --enable-targets=all build with libunwind-ia64
properly configured.

  CXX    ia64-vms-tdep.o
/home/emaisin/src/binutils-gdb/gdb/ia64-vms-tdep.c: In function ‘int ia64_vms_find_proc_info_x(unw_addr_space_t, unw_word_t, unw_proc_info_t*, int, void*)’:
/home/emaisin/src/binutils-gdb/gdb/ia64-vms-tdep.c:79:33: error: invalid conversion from ‘void*’ to ‘gdb_byte* {aka unsigned char*}’ [-fpermissive]
                             pi->unwind_info, pi->unwind_info_size);
                                 ^
In file included from /home/emaisin/src/binutils-gdb/gdb/target.h:70:0,
                 from /home/emaisin/src/binutils-gdb/gdb/exec.h:23,
                 from /home/emaisin/src/binutils-gdb/gdb/gdbcore.h:29,
                 from /home/emaisin/src/binutils-gdb/gdb/ia64-vms-tdep.c:25:
/home/emaisin/src/binutils-gdb/gdb/target/target.h:35:12: note:   initializing argument 2 of ‘int target_read_memory(CORE_ADDR, gdb_byte*, ssize_t)’
 extern int target_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr,
            ^

gdb/ChangeLog:

	* ia64-vms-tdep.c (ia64_vms_find_proc_info_x): Add cast.
2018-07-16 14:15:37 -04:00
Simon Marchi a700e753e5 remote-sim.c: Remove unused variables
gdb/ChangeLog:

	* remote-sim.c (gdbsim_target::close,
	gdbsim_target::mourn_inferior): Remove unused variables.
2018-07-16 14:08:49 -04:00
Simon Marchi 8b411ff8d5 Add missing ChangeLog entry
I forgot to append the ChangeLog entry to the last commit...
2018-07-16 14:08:26 -04:00
Simon Marchi 5d691c8829 Fix compilation error in ia64-tdep.c with libunwind-ia64
Commit

  9018be22e0 ("Make target_read_alloc & al return vectors")

failed to update the code in ia64-tdep.c, for HAVE_LIBUNWIND_IA64_H.
This patch fixes that.

gdb/ChangeLog:

	* ia64-tdep.c (ktab_buf): New global.
	(getunwind_table): Return a gdb::optional<gdb::byte_vector>.
	(get_kernel_table): Adjust.
2018-07-16 13:59:39 -04:00
Tom Tromey edb0470b99 Use outermost_context_p in more places
This changes a few explicit checks of context_stack_depth to use
outermost_context_p instead.  This simplifies some future work.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (read_xcoff_symtab): Use outermost_context_p.
	* dwarf2read.c (using_directives, new_symbol): Use
	outermost_context_p.
	* dbxread.c (process_one_symbol): Use outermost_context_p.
	* coffread.c (coff_symtab_read): Use outermost_context_p.
2018-07-16 08:55:22 -06:00
Tom Tromey 6cccc9a891 Move the using directives to buildsym_compunit
This moves the globals local_using_directives and
global_using_directives to be members of buildsym_compunit, and adds
the necessary accessors.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (using_directives, read_func_scope)
	(read_lexical_block_scope): Update.
	* cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
	* buildsym.h (local_using_directives, global_using_directives):
	Don't declare.
	(get_local_using_directives, set_local_using_directives)
	(get_global_using_directives): Declare.
	* buildsym.c (struct buildsym_compunit) <m_local_using_directives,
	m_global_using_directives>: New members.
	(finish_block_internal, prepare_for_building)
	(reset_symtab_globals, end_symtab_get_static_block)
	(push_context): Update.
	(get_local_using_directives, set_local_using_directives)
	(get_global_using_directives): New functions.
	(buildsym_init): Update.
2018-07-16 08:55:22 -06:00
Tom Tromey 652788a731 Make free_pending_blocks static
free_pending_blocks can be static because scoped_free_pendings (et al)
arrange for it to be NULL in the "steady state".  This removes a
couple of unnecessary calls to free_pending_blocks and changes it to
be static.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_initial_scan): Don't call
	free_pending_blocks.
	* dbxread.c (dbx_symfile_read): Don't call free_pending_blocks.
	* buildsym.h (class scoped_free_pendings): Add constructor.
	(free_pending_blocks): Don't declare.
	* buildsym.c (scoped_free_pendings::scoped_free_pendings): New.
	(free_pending_blocks): Now static.
2018-07-16 08:55:21 -06:00
Tom Tromey 8419ee5331 Move the subfile stack to buildsym_compunit
This moves the global subfile_stack to be a member of
buildsym_compunit.  It also change this to be a std::vector, which
simplifies the code.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* buildsym.h (push_subfile, pop_subfile): Update declarations.
	* buildsym.c (struct buildsym_compunit) <m_subfile_stack>: New
	member.
	(struct subfile_stack): Remove.
	(subfile_stack): Remove.
	(push_subfile, pop_subfile, buildsym_init): Update.
2018-07-16 08:55:21 -06:00
Tom Tromey ccdac490bb Use gdb_assert in two places in buildsym.c
This changes buildsym.c to use gdb_assert rather than internal_error
in a couple of spots.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* buildsym.c (push_subfile): Use gdb_assert.
	(pop_subfile): Use gdb_assert.
2018-07-16 08:55:20 -06:00
Tom Tromey 43130d6f96 Remove merge_symbol_lists
I discovered that merge_symbol_lists is unused, so this removes it.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* buildsym.h (merge_symbol_lists): Remove.
	* buildsym.c (merge_symbol_lists): Remove.
2018-07-16 08:55:20 -06:00
Tom Tromey 77d6f1aa16 Move scan_file_globals declaration to stabsread.h
scan_file_globals is defined in stabsread.c, so move its declaration
to stabsread.h.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* stabsread.c (scan_file_globals): Update comment.
	* stabsread.h (scan_file_globals): Move from buildsym.h.
	* buildsym.h (scan_file_globals): Move to stabsread.h.
2018-07-16 08:55:19 -06:00
Tom Tromey 2c722d18f3 Remove buildsym_new_init
buildsym_new_init is just an alias for buildsym_init.  This removes
it.  In the long run buildsym_init will also go away; this patch just
helps make things a bit clearer in the meantime.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (xcoff_new_init): Update.
	* mipsread.c (mipscoff_new_init): Update.
	* mdebugread.c (mdebug_build_psymtabs): Update.
	* elfread.c (elf_new_init): Update.
	* dbxread.c (dbx_new_init, coffstab_build_psymtabs)
	(elfstab_build_psymtabs, stabsect_build_psymtabs): Update.
	* buildsym.h (buildsym_new_init): Don't declare.
	* buildsym.c (buildsym_new_init): Remove.
2018-07-16 08:55:19 -06:00
Tom Tromey 5985ac614d Move within_function to stabsread
The global within_function is only used by a few symbol readers.  This
patch moves the global out of buildsym and into stabsread, which
seemed like a better fit.  It also arranges for the existing readers
to clear the global at the appropriate time.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* stabsread.h (within_function): Move from buildsym.h.
	* stabsread.c (start_stabs): Clear within_function.
	* coffread.c (coff_start_symtab): Clear within_function.
	* buildsym.h (within_function): Move to stabsread.h.
	* buildsym.c (prepare_for_building): Update.
2018-07-16 08:55:18 -06:00
Tom Tromey 6b84eeb216 Move processing_gcc to stabsread
processing_gcc is also only used by stabsread -- it is set by the
DWARF reader, but this turns out not to be needed.  So, this patch
moves processing_gcc and removes the assignment from the DWARF reader.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* stabsread.h (processing_gcc_compilation): Move from buildsym.h.
	* dwarf2read.c (dwarf2_start_symtab): Don't set
	processing_gcc_compilation.
	* buildsym.h (processing_gcc_compilation): Move to stabsread.h.
2018-07-16 08:55:18 -06:00
Tom Tromey 2150c3ef04 Move some code from buildsym to stabsread
A few things that currently reside in buildsym.c turn out to be
specific to the stabs reader.  This patch moves these from
buildsym.[ch] to stabsread.[ch].

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* stabsread.h (HASHSIZE, hashname, symnum, next_symbol_text)
	(next_symbol_text_func): Move from buildsym.h.
	* stabsread.c (hashname): Move from buildsym.c.
	* buildsym.h (HASHSIZE, symnum, next_symbol_text)
	(next_symbol_text_func, hashname): Move to stabsread.h.
	* buildsym.c: Don't include bcache.h
	(hashname): Move to stasbread.c.
2018-07-16 08:55:17 -06:00
Tom Tromey 0ec44fc067 Make context_stack_size static in buildsym.c
context_stack_size is declared in buildsym.h, but only used in
buildsym.c.  This makes it static in buildsym.c.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* buildsym.h (context_stack_size): Don't declare.
	* buildsym.c (context_stack_size): New global.
2018-07-16 08:55:17 -06:00
Tom Tromey 81cc346dc9 Move processing_acc_compilation to dbxread.c
processing_acc_compilation is only used in dbxread.c, so move it
there.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* dbxread.c (processing_acc_compilation): New global.
	* buildsym.h (processing_acc_compilation): Don't declare.
2018-07-16 08:55:16 -06:00
Tom Tromey 2c99ee5c4f Move last_source_start_addr to buildsym_compunit
This moves the global last_source_start_addr into buildsym_compunit,
adding some accessors as well.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* xcoffread.c (aix_process_linenos, complete_symtab): Update.
	* dbxread.c (read_ofile_symtab): Update.
	* coffread.c (coff_start_symtab, coff_end_symtab): Update.
	* buildsym.h (last_source_start_addr): Remove.
	(set_last_source_start_addr, get_last_source_start_addr):
	Declare.
	* buildsym.c (buildsym_compunit::buildsym_compunit): Add last_addr
	parameter.
	(struct buildsym_compunit) <m_last_source_start_addr>: New
	member.
	(prepare_for_building): Remove start_addr parameter.
	(start_symtab, restart_symtab, end_symtab_get_static_block)
	(end_symtab_with_blockvector): Update.
	(set_last_source_start_addr, get_last_source_start_addr): New
	functions.
2018-07-16 08:55:16 -06:00
Tom Tromey 530fedbcbf Move have_line_numbers to buildsym_compunit
This moves the global have_line_numbers into buildsym_compunit.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* buildsym.c (struct buildsym_compunit) <m_have_line_numbers>: New
	member.
	(have_line_numbers): Remove.
	(record_line, prepare_for_building, end_symtab_get_static_block)
	(augment_type_symtab): Update.
2018-07-16 08:55:16 -06:00
Tom Tromey 6a976300e7 Move pending_macros to buildsym_compunit
This moves the pending_macros global into buildsym_compunit.

gdb/ChangeLog
2018-07-16  Tom Tromey  <tom@tromey.com>

	* buildsym.c (~buildsym_compunit): Free the macro table.
	(struct buildsym_compunit) <get_macro_table, release_macros>: New
	methods.
	<m_pending_macros>: New member.
	(pending_macros): Remove.
	(~scoped_free_pendings, get_macro_table, prepare_for_building)
	(reset_symtab_globals, end_symtab_get_static_block)
	(end_symtab_with_blockvector, augment_type_symtab)
	(buildsym_init): Update.
2018-07-16 08:55:15 -06:00