Commit Graph

41761 Commits

Author SHA1 Message Date
Philippe Waroquiers 62b1765c90 [OBVIOUS] enable frame-filter short help uses disable instead of enable
Without the patch:
  (gdb) apropos able frame-filter
  disable frame-filter -- GDB command to disable the specified frame-filter
  enable frame-filter -- GDB command to disable the specified frame-filter

With the patch:
  (gdb) apropos able frame-filter
  disable frame-filter -- GDB command to disable the specified frame-filter
  enable frame-filter -- GDB command to enable the specified frame-filter

Pushed as obvious
2018-09-18 00:19:51 +02:00
Tom Tromey ae292b3afc Do not pass -DNDEBUG to Python compilations in development mode
The Python CFLAGS include -DNDEBUG.  This was apparently done
intentionally -- setting the flags is done manually because, according
to a comment, python-config passes too many things to the compiler
(which is true).

Per PR python/20445, this patch changes configure so that -DNDEBUG is
only used by release builds.  This probably doesn't have very much
effect in practice, but I did see that some Python headers use assert,
so perhaps it will give some safety.

Tested by rebuilding and re-running gdb.python/*.exp on x86-64 Fedora 28.

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

	PR python/20445:
	* configure: Rebuild.
	* configure.ac: Conditionally use -DNDEBUG for Python.
2018-09-17 13:51:38 -06:00
Tom Tromey da658607ed Check for gmp when checking for mpfr
There was a report on irc that the gdb check for mpfr failed when only
static libraries are available.  The issue is that mpfr depends on
gmp, but this is not handled explicitly by gdb.

Ideally upstream would switch to pkg-config.  Or even more ideally, we
would incorporate pkg-config into the compiler and not mess with any
of this.

Meanwhile, this changes gdb's configure to add gmp to the link line
when checking for mpfr.

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

	* configure: Rebuild.
	* configure.ac: Use gmp as a library dependency when checking for
	mpfr.
2018-09-17 13:51:38 -06:00
Pedro Alves d35da542a7 [gdb/Python] Eliminate find_inferior_object
Commit 00431a78b2 ("Use thread_info and inferior pointers more
throughout") removed the declaration of find_inferior_object, but
missed removing the definition.

gdb/ChangeLog:
2018-09-17  Pedro Alves  <palves@redhat.com>

	* python/py-inferior.c (find_inferior_object): Delete.
2018-09-17 19:46:40 +01:00
Simon Marchi 461464f226 Fix use-after-move in compile/compile-cplus-types.c
Patch

  d82b3862f1 ("compile: Remove non-const reference parameters")

introduced a regression in compile/compile-cplus-types.c.  The new_scope
variable in compile_cplus_instance::enter_scope is used after it was
std::moved.  This patch fixes it by referring to the back of the vector
where it was moved instead.

gdb/ChangeLog:

	* compile/compile-cplus-types.c
	(compile_cplus_instance::enter_scope): Don't use new_scope after
	std::move.
2018-09-17 13:11:07 -04:00
Tom Tromey e6cd1dc1e6 Update get_standard_cache_dir for macOS
On macOS the usual cache directory is ~/Library/Caches.  This patch
changes get_standard_cache_dir to use that instead of XDG.

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

	* common/pathstuff.c (get_standard_cache_dir): Use
	~/Library/Caches on macOS.
	* common/pathstuff.h (get_standard_cache_dir): Update comment.

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

	* gdb.texinfo (Index Files): Update for cache directory change on
	macOS.
2018-09-17 08:43:12 -06:00
Simon Marchi 8588b35692 python: Make gdb.execute("show commands") work (PR 23669)
Since commit

  56bcdbea2b ("Let gdb.execute handle multi-line commands")

trying to use a command like gdb.execute("show commands") in Python
fails.  GDB ends up trying to run the "commands" command.

The reason is that GDB gets confused with the special "commands"
command.  In process_next_line, the lookup_cmd_1 function returns the
cmd_list_element representing the "commands" sub-command of "show".
Lower, we check the cmd_list_element to see if it matches various
control commands by name, including the "commands" command.  This is
where we wrongfully conclude that the executed command must be
"commands", when in reality it was "show commands".

The fix proposed in this patch removes the comparisons by name, instead
comparing the cmd_list_element object by pointer with the objects
created at initialization time.

Tested on the buildbot, though on a single builder (Fedora-x86_64-m64).

gdb/ChangeLog:

	PR python/23669
	* breakpoint.c (commands_cmd_element): New.
	(_initialize_breakpoint): Assign commands_cmd_element.
	* breakpoint.h (commands_cmd_element): New.
	* cli/cli-script.c (while_cmd_element, if_command,
	define_cmd_element): New.
	(command_name_equals): Remove.
	(process_next_line): Compare commands by pointer, not by name.
	(_initialize_cli_script): Assign the various cmd_list_element
	variables.
	* compile/compile.c (compile_cmd_element): New.
	(_initialize_compile): Assign compile_cmd_element.
	* compile/compile.h (compile_cmd_element): New.
	* guile/guile.c (guile_cmd_element): New.
	(install_gdb_commands): Assign guile_cmd_element.
	* guile/guile.h (guile_cmd_element): New.
	* python/python.c (python_cmd_element): New.
	(_initialize_python): Assign python_cmd_element.
	* python/python.h (python_cmd_element): New.
	* tracepoint.c (while_stepping_cmd_element): New.
	(_initialize_tracepoint): Assign while_stepping_cmd_element.
	* tracepoint.h (while_stepping_cmd_element): New.

gdb/testsuite/ChangeLog:

	PR python/23669
	* gdb.python/python.exp: Test gdb.execute("show commands").
2018-09-17 08:26:24 -04:00
Tom Tromey cb5248409d Make save_infcall_*_state return unique pointers
Simon pointed out that save_infcall_suspend_state and
save_infcall_control_state could return unique pointers.  This patch
implements this idea.

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

	* infrun.c (save_infcall_suspend_state): Return
	infcall_suspend_state_up.
	(save_infcall_control_state): Return infcall_control_state_up.
	* inferior.h (save_infcall_suspend_state)
	(save_infcall_control_state): Declare later.  Return unique
	pointers.
2018-09-17 00:42:19 -06:00
Tom Tromey 2d844eaf9c Remove release_stop_context_cleanup
This removes release_stop_context_cleanup, replacing it with a
stop_context destructor.  It also mildly c++-ifies this struct.

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

	* infrun.c (struct stop_context): Declare constructor,
	destructor, "changed" method.
	(stop_context::stop_context): Rename from save_stop_context.
	(stop_context::~stop_context): Rename from
	release_stop_context_cleanup.
	(normal_stop): Update.
	(stop_context::changed): Rename from stop_context_changed.  Return
	bool.
2018-09-17 00:42:19 -06:00
Tom Tromey c7c4d3fa80 Remove two infrun cleanups
This removes a couple of cleanups from infrun by introducing a couple
of unique_ptr specializations.

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

	* inferior.h (struct infcall_suspend_state_deleter): New.
	(infcall_suspend_state_up): New typedef.
	(struct infcall_control_state_deleter): New.
	(infcall_control_state_up): New typedef.
	(make_cleanup_restore_infcall_suspend_state)
	(make_cleanup_restore_infcall_control_state): Don't declare.
	* infcall.c (call_function_by_hand_dummy): Update.
	* infrun.c (do_restore_infcall_suspend_state_cleanup)
	(make_cleanup_restore_infcall_suspend_state): Remove.
	(do_restore_infcall_control_state_cleanup)
	(make_cleanup_restore_infcall_control_state): Remove.
2018-09-17 00:42:18 -06:00
Tom Tromey ee841dd8fe Use new and delete for struct infcall_control_state
This changes infrun.c to use new and delete for infcall_control_state.

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

	* gdbthread.h (struct thread_control_state): Add initializer.
	(class thread_info) <control>: Remove initializer.
	* inferior.h (struct inferior_control_state): Add initializer.
	(class inferior) <control>: Remove initializer.
	(exit_inferior_1): Update.
	* infrun.c (struct infcall_control_state): Add constructors.
	(save_infcall_control_state): Use new.
	(restore_infcall_control_state, discard_infcall_control_state):
	Use delete.
2018-09-17 00:42:18 -06:00
Tom Tromey 117f580a97 Remove cleanup from infrun.c
This removes a cleanup from infrun.c by taking advantage of the
previous patch to introduce a use of unique_xmalloc_ptr.

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

	* infrun.c (struct infcall_suspend_state) <registers>: Now a
	unique_ptr.
	<siginfo_data>: Now a unique_xmalloc_ptr.
	(save_infcall_suspend_state, restore_infcall_suspend_state)
	(discard_infcall_suspend_state)
	(get_infcall_suspend_state_regcache): Update.
2018-09-17 00:42:17 -06:00
Tom Tromey dd848631cb Use new and delete for struct infcall_suspend_state
This changes infrun.c to use new and delete for infcall_suspend_state.
This enables the coming cleanups.

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

	* gdbthread.h (struct thread_suspend_state): Add initializers.
	(class thread_info) <suspend>: Remove initializer.
	* infrun.c (struct infcall_suspend_state): Add initializers.
	(save_infcall_suspend_state): Use new.
	(discard_infcall_suspend_state): Use delete.
2018-09-17 00:42:17 -06:00
Tom Tromey 1a3389079d Don't steal references in the gdb Python code
Some Python APIs steal references from their caller, and the refcount
checker supports this via an attribute.

However, in gdb with C++ we have a better idiom available: we can use
std::move on a gdbpy_ref<> instead.  This makes the semantics obvious
at the point of call, and is safer at runtime as well, because the
callee's gdbpy_ref<> will be emptied.

This patch changes the reference-stealing code in gdb to use rvalue
references instead.

Tested on x86-64 Fedora 28.

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

	* python/python-internal.h (CPYCHECKER_STEALS_REFERENCE_TO_ARG):
	Remove.
	* python/py-varobj.c (py_varobj_iter_ctor): Change pyiter to
	rvalue reference.  Remove CPYCHECKER_STEALS_REFERENCE_TO_ARG.
	(py_varobj_iter_new): Likewise.
	(py_varobj_get_iterator): Use gdbpy_ref.
2018-09-16 23:48:21 -06:00
Tom Tromey 4a137fec2e Simplify uses of thread_to_thread_object
An review by Simon of an earlier showed a few spots related to
thread_to_thread_object that could be simplified.  This also detected
a latent bug, where thread_to_thread_object was inconsistent about
setting the Python exception before a NULL return.

Tested on x86-64 Fedora 28.

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

	* python/py-threadevent.c (py_get_event_thread): Simplify.
	* python/py-inferior.c (infpy_thread_from_thread_handle):
	Return immediately after calling thread_to_thread_object.  Use
	Py_RETURN_NONE.
	(thread_to_thread_object): Set the exception on a NULL return.
2018-09-16 23:36:54 -06:00
Simon Marchi 8ff03f0bfb Sort objects in gdb and gdbserver Makefiles
Tom mentioned this a while ago, as a way to give you a cheap sense of
progression in your build, as all object files will be built
alphabetically (including the directory part).  I tried it and I think
it's nice.

gdb/ChangeLog:

	* Makefile.in (LIBGDB_OBS): Sort COMMON_OBS.

gdb/gdbserver/ChangeLog:

	* Makefile.in (gdbserver$(EXEEXT)): Sort OBS.
	(gdbreplay$(EXEEXT)): Sort GDBREPLAY_OBS.
	($(IPA_LIB)): Sort IPA_OBJS.
2018-09-16 20:34:56 -04:00
Simon Marchi a1cd91dc2f gdbserver/Makefile.in: Remove ADD_DEPS
ADD_DEPS is defined nowhere, so I presume it's not useful.  If I'm wrong
and this is actually used, there should be a comment explaining where it
comes from.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Remove references to $(ADD_DEPS).
2018-09-16 20:34:56 -04:00
Tom Tromey 94c8b7253a Remove CPYCHECKER_RETURNS_BORROWED_REF
CPYCHECKER_RETURNS_BORROWED_REF is not used, and I think should never
be used.  This patch removes it.

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

	* python/python-internal.h (CPYCHECKER_RETURNS_BORROWED_REF):
	Remove.
2018-09-16 07:25:57 -06:00
Tom Tromey db1337cc83 Change thread_to_thread_object to return a new reference
This changes thread_to_thread_object to return a new reference and
fixes up all the callers.

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

	* python/python-internal.h (thread_to_thread_object): Change
	return type.
	* python/py-inferior.c (thread_to_thread_object): Return a new
	reference.
	(infpy_thread_from_thread_handle): Update.
	* python/py-infthread.c (gdbpy_selected_thread): Update.
	* python/py-stopevent.c (create_stop_event_object): Update.
	* python/py-threadevent.c (py_get_event_thread): Return a new
	reference.
	(py_get_event_thread): Update.
	* python/py-event.h (py_get_event_thread): Change return type.
	* python/py-continueevent.c (create_continue_event_object):
	Update.
2018-09-16 07:25:57 -06:00
Tom Tromey 0a9db5ad8a Change objfile_to_objfile_object to return a new reference
This changes objfile_to_objfile_object to return a new references and
fixes up all the uses.

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

	* python/py-progspace.c (pspy_get_objfiles): Update.
	* python/python-internal.h (objfile_to_objfile_object): Change
	return type.
	* python/py-newobjfileevent.c (create_new_objfile_event_object):
	Update.
	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
	Update.
	* python/python.c (gdbpy_get_current_objfile): Update.
	(gdbpy_objfiles): Update.
	* python/py-objfile.c (objfpy_get_owner, gdbpy_lookup_objfile):
	Update.
	(objfile_to_objfile_object): Return a new reference.
	* python/py-symtab.c (stpy_get_objfile): Update.
	* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
	Update.
2018-09-16 07:25:56 -06:00
Tom Tromey 3c7aa30778 Change pspace_to_pspace_object to return a new reference
This changes pspace_to_pspace_object to return a new reference and
fixes up all the callers.

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

	* python/py-inferior.c (infpy_get_progspace): Update.
	* python/python-internal.h (pspace_to_pspace_object): Change
	return type.
	* python/py-newobjfileevent.c
	(create_clear_objfiles_event_object): Update.
	* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers):
	Update.
	* python/python.c (gdbpy_get_current_progspace): Update.
	(gdbpy_progspaces): Update.
	* python/py-progspace.c (pspace_to_pspace_object): Return a new
	reference.
	* python/py-objfile.c (objfpy_get_progspace): Update.
	* python/py-prettyprint.c (find_pretty_printer_from_progspace):
	Update.
2018-09-16 07:25:56 -06:00
Tom Tromey 8743a9cdd2 Add more methods to gdb.Progspace
There are a number of global functions in the gdb Python module which
really should be methods on Progspace.  This patch adds new methods to
Progspace and then redefines these globals in terms of these new
methods.

This version has been rebased on the related changes that Simon
recently put in.

Built and regtested on x86-64 Fedora 28.

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

	* python/lib/gdb/__init__.py (current_progspace, objfiles)
	(solib_name, block_for_pc, find_pc_line): New functions.
	(execute_unwinders): Update.
	* python/py-block.c (gdbpy_block_for_pc): Remove.
	* python/py-inferior.c (infpy_get_progspace): New function.
	(inferior_object_getset) <progspace>: Add.
	* python/py-progspace.c (pspy_objfiles): Rewrite.
	(pspy_solib_name, pspy_block_for_pc)
	(pspy_find_pc_line, pspy_is_valid): New functions.
	(progspace_object_methods): Add entries for solib_name,
	block_for_pc, find_pc_line, is_valid.
	* python/python-internal.h (gdbpy_block_for_pc)
	(build_objfiles_list): Don't declare.
	* python/python.c: Don't include solib.h.
	(gdbpy_solib_name, gdbpy_find_pc_line)
	(gdbpy_get_current_progspace, build_objfiles_list)
	(gdbpy_objfiles): Remove.
	(GdbMethods) <current_progspace, objfiles, block_for_pc,
	solib_name, find_pc_line>: Remove entries.

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

	* python.texi (Basic Python): Update docs for find_pc_line,
	solib_name.
	(Progspaces In Python): Update docs for current_progspace.
	Document block_for_pc, find_pc_line, is_valid, nsolib_name.
	Move method documentation before example.
2018-09-16 06:52:37 -06:00
Tom Tromey 752312ba4e Use GNU style for metasyntactic variables in gdbserver
This changes a couple of places in gdbserver to use the GNU style for
metasyntactic variables.

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

	* remote-utils.c (remote_open): Use GNU style for metasyntactic
	variables.
	* gdbreplay.c (gdbreplay_usage): Use GNU style for metasyntactic
	variables.
2018-09-16 06:25:17 -06:00
Tom Tromey 65e65158c5 Use GNU style for metasyntactic variables in gdb
I searched for other spots that did not use the GNU style for
metasyntactic syntactic variables.  This patch fixes most of the ones
I found in gdb proper.  There are a few remaining in MI, but I was
unsure whether those should be touched.

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

	* top.c (new_ui_command): Use GNU style for metasyntactic
	variables.
	* breakpoint.c (stopat_command): Use GNU style for metasyntactic
	variables.
	* maint.c (maintenance_translate_address): Remove "<>" around
	text.
	* interps.c (interpreter_exec_cmd): Use GNU style for
	metasyntactic variables.
	* nto-procfs.c (nto_procfs_target_info): Use GNU style for
	metasyntactic variables.
	* tracepoint.c (tfind_range_command): Use GNU style for
	metasyntactic variables.
	(tfind_outside_command): Likewise.
	(_initialize_tracepoint): Likewise.
	* remote.c (extended_remote_target::create_inferior): Use GNU
	style for metasyntactic variables.
	* sparc64-tdep.c (adi_examine_command): Use GNU style for
	metasyntactic variables.
	(adi_assign_command): Likewise.

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

	* gdb.base/new-ui.exp (do_execution_tests): Update.
	* gdb.base/dbx.exp (test_breakpoints): Update.
2018-09-16 06:25:17 -06:00
Tom Tromey f4bab6ff22 Expand "show disassembler-options" output
I typed this:

    (gdb) help set disassembler-options
    Set the disassembler options.
    Usage: set disassembler-options OPTION [,OPTION]...

    See: 'show disassembler-options' for valid option values.

... so I tried what it said and got:

    (gdb) show disassembler-options
    The current disassembler options are ''

This surprised me a little, so this patch adds some text to explain
the situation when an architecture does not have disassembler options.

While there I noticed one more spot where gdb was not using the GNU
style for metasyntactic variables.  This patch fixes this as well.

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

	* disasm.c (show_disassembler_options_sfunc): Use GNU style for
	metasyntactic variables.  Print message if no disassembler options
	are available.
2018-09-16 06:25:16 -06:00
Tom Tromey cbaaa0cafc Change get_inferior_args to return const char *
I noticed that get_inferior_args should return const char *, because
it is just returning a reference to something owned by the inferior.

I'm checking this in.

gdb/ChangeLog
2018-09-15  Tom Tromey  <tom@tromey.com>

	* infcmd.c (get_inferior_args): Return const char *.
	* inferior.h (get_inferior_args): Return type now const.
	* linux-tdep.c (linux_fill_prpsinfo): Update.
	* procfs.c (procfs_target::make_corefile_notes): Update.
2018-09-15 16:31:58 -06:00
Tom Tromey a3a6aef409 Fix possible exception leak in python.c
In the Python code, gdb exceptions may not leak into the Python core.
execute_gdb_command was calling bpstat_do_actions outside of a
TRY/CATCH; which seemed risky.  I don't have a test case for this, but
if bpstat_do_actions could ever throw, it could crash gdb.

This patch introduces a new scope in order to preserve the current
semantics, so it is looks a bit bigger than it really is.

Tested on x86-64 Fedora 28.

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

	* python/python.c (execute_gdb_command): Call bpstat_do_actions
	inside the TRY.
2018-09-14 21:56:41 -06:00
Sandra Loosemore f70e088ff4 Provide type_align gdbarch function for nios2.
2018-09-14  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/
	* nios2-tdep.c (nios2_type_align): New.
	(nios2_gdb_arch_init): Install type_align hook.
2018-09-14 20:09:46 -07:00
Andrew Burgess 2fabdf3381 gdb: Don't leak memory with TYPE_ALLOC / TYPE_ZALLOC
This patch started as an observation from valgrind that GDB appeared
to be loosing track of some memory associated with types.  An example
valgrind stack would be:

  24 bytes in 1 blocks are possibly lost in loss record 419 of 5,361
     at 0x4C2EA1E: calloc (vg_replace_malloc.c:711)
     by 0x623D26: xcalloc (common-utils.c:85)
     by 0x623D65: xzalloc(unsigned long) (common-utils.c:95)
     by 0x72A066: make_function_type(type*, type**) (gdbtypes.c:510)
     by 0x72A098: lookup_function_type(type*) (gdbtypes.c:521)
     by 0x73635D: gdbtypes_post_init(gdbarch*) (gdbtypes.c:5439)
     by 0x727590: gdbarch_data(gdbarch*, gdbarch_data*) (gdbarch.c:5230)
     by 0x735B99: builtin_type(gdbarch*) (gdbtypes.c:5313)
     by 0x514D95: elf_rel_plt_read(minimal_symbol_reader&, objfile*, bfd_symbol**) (elfread.c:542)
     by 0x51662F: elf_read_minimal_symbols(objfile*, int, elfinfo const*) (elfread.c:1121)
     by 0x5168A5: elf_symfile_read(objfile*, enum_flags<symfile_add_flag>) (elfread.c:1207)
     by 0x8520F5: read_symbols(objfile*, enum_flags<symfile_add_flag>) (symfile.c:794)

When we look in make_function_type we find a call to TYPE_ZALLOC
(inside the INIT_FUNC_SPECIFIC macro).  It is this call to TYPE_ZALLOC
that is allocating memory with xcalloc, that is then getting lost.

The problem is tht calling TYPE_ALLOC or TYPE_ZALLOC currently
allocates memory from either the objfile obstack or by using malloc.
The problem with this is that types are allocated either on the
objfile obstack, or on the gdbarch obstack.

As a result, if we discard a type associated with an objfile then
auxiliary data allocated with TYPE_(Z)ALLOC will be correctly
discarded.  But, if we were ever to discard a gdbarch then any
auxiliary type data would be leaked.  Right now there are very few
places in GDB where a gdbarch is ever discarded, but it shouldn't hurt
to close down these bugs as we spot them.

This commit ensures that auxiliary type data is allocated from the
same obstack as the type itself, which should reduce leaked memory.

The one problem case that I found with this change was in eval.c,
where in one place we allocate a local type structure, and then used
TYPE_ZALLOC to allocate some space for the type.  This local type is
neither object file owned, nor gdbarch owned, and so the updated
TYPE_ALLOC code is unable to find an objstack to allocate space on.

My proposed solution for this issue is that the space should be
allocated with a direct call to xzalloc.  We could extend TYPE_ALLOC
to check for type->gdbarch being null, and then fall back to a direct
call to xzalloc, however, I think that making this rare case of a
local type require special handling is not a bad thing, this serves to
highlight that clearing up the memory will require special handling
too.

This special case of a local type is interesting as the types owner
field (contained within the main_type) is completely null.  While
reflecting on this I looked at how types use the get_type_arch
function.  It seems clear that, based on how this is used, it is never
intended that null will be returned from this function.  This only
goes to reinforce, how locally alloctaed types, with no owner, are
both special, and need to be handled carefully.  To help spot errors
earlier, I added an assert into get_type_arch that the returned arch
is not null.

Inside gdbarch.c I found a few other places where auxiliary type data
was being allocated directly on the heap rather than on the types
obstack.  I have fixed these to call TYPE_ALLOC now.

Finally, it is worth noting that as we don't clean up our gdbarch
objects yet, then this will not make much of an impact on the amount
of memory reported as lost at program termination time.  Memory
allocated for auxiliary type information is still not freed, however,
it is now on the correct obstack.  If we do ever start freeing our
gdbarch structures then the associated type data will be cleaned up
correctly.

Tested on X86-64 GNU/Linux with no regressions.

gdb/ChangeLog:

	* eval.c (fake_method::fake_method): Call xzalloc directly for a
	type that is neither object file owned, nor gdbarch owned.
	* gdbtypes.c (get_type_gdbarch): Add an assert that returned
	gdbarch is non-NULL.
	(alloc_type_instance): Allocate non-objfile owned types on the
	gdbarch obstack.
	(copy_type_recursive): Allocate TYPE_FIELDS and TYPE_RANGE_DATA
	using TYPE_ALLOC to ensure memory is allocated on the correct
	obstack.
	* gdbtypes.h (TYPE_ALLOC): Allocate space on either the objfile
	obstack, or the gdbarch obstack.
	(TYPE_ZALLOC): Rewrite using TYPE_ALLOC.
2018-09-14 23:10:09 +01:00
Tom Tromey b4b08fa2aa Remove an unnecessary block in call_function_by_hand_dummy
I noticed that call_function_by_hand_dummy has a block that only
exists to declare a variable, like:

    {
      int i;
      for (i = ...0)
	...
    }

This patch removes the unnecessary and the extra indentation by moving
the declaration into the "for".

gdb/ChangeLog
2018-09-14  Tom Tromey  <tom@tromey.com>

	* infcall.c (call_function_by_hand_dummy): Remove unnecessary
	block.
2018-09-14 07:11:50 -06:00
Tom Tromey 87b240d485 Make variable in get_startup_shell non-static
I noticed that a variable in get_startup_shell is "static".  However,
I couldn't see any reason it ought to be, so this removes the
"static".

gdb/ChangeLog
2018-09-14  Tom Tromey  <tom@tromey.com>

	* nat/fork-inferior.c (get_startup_shell): Remove "static".
2018-09-14 06:49:13 -06:00
Alan Hayward bf32645253 Testsuite: Add gdb_simple_compile
Simplfy gdb.exp by adding a function that will attempt to
compile a piece of code, then clean up, leaving the created
object.

gdb/testsuite

        * lib/gdb.exp (gdb_simple_compile): Add proc.
        (is_elf_target): Use gdb_simple_compile.
        (skip_altivec_tests): Likewise.
        (skip_vsx_tests): Likewise.
        (skip_tsx_tests): Likewise.
        (skip_btrace_tests): Likewise.
        (skip_btrace_pt_tests): Likewise.
        (gdb_can_simple_compile): Likewise.
        (gdb_has_argv0): Likewise.
        (gdb_target_symbol_prefix): Likewise.
        (target_supports_scheduler_locking): Likewise.
2018-09-14 09:56:52 +01:00
Tom Tromey 2361b0fb1d Generate more tags in gdb/testsuite/Makefile
I noticed that the TAGS target in gdb/testsuite/Makefile does not pick
up Tcl procs defined with proc_with_prefix or gdb_caching_proc.  This
patch fixes this by updating the regexp.

Tested in Emacs.

gdb/testsuite/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	* Makefile.in (TAGS): Recognize proc_with_prefix and
	gdb_caching_proc.
2018-09-13 16:30:48 -06:00
Tom Tromey 7d2215128b Make infpy_thread_from_thread_handle static
I noticed that infpy_thread_from_thread_handle is not static, but
should be.  This patch changes it.

gdb/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	* python/py-inferior.c (infpy_thread_from_thread_handle): Now
	static.
2018-09-13 16:23:52 -06:00
Tom Tromey 97e67fc620 Remove cleanup from try_open_exec_file
This removes a cleanup from try_open_exec_file, using std::string to
manage the storage instead.

gdb/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	* exec.c (try_open_exec_file): Use std::string.
2018-09-13 16:22:34 -06:00
Tom Tromey 803c08d083 Return std::string from gdb_bfd_errmsg
This changes gdb_bfd_errmsg to return a std::string, removing a
cleanup.  This approach may be slightly less efficient than the
previous code, but I don't believe this is very important in this
situation.

gdb/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	* utils.h (gdb_bfd_errmsg): Return std::string.
	* exec.c (exec_file_attach): Update.
	* compile/compile-object-load.c (compile_object_load): Update.
	* utils.c (gdb_bfd_errmsg): Return std::string.
2018-09-13 16:22:34 -06:00
Tom Tromey 5b4cbbe357 Remove cleanup from procfs.c
This removes the last remaining cleanup from procfs.c, replacing it
with a unique_ptr specialization.

gdb/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	* procfs.c (struct procinfo_deleter): New.
	(procinfo_up): New typedef.
	(do_destroy_procinfo_cleanup): Remove.
	(procfs_target::info_proc): Use procinfo_up.  Remove cleanups.
2018-09-13 16:22:33 -06:00
Tom Tromey db68fbe2f9 Remove cleanup from add_path
This removes a cleanup from add_path, replacing it with a use of
gdb::unique_xmalloc_ptr.  Note that this declaration had to be hoisted
somewhat, to avoid inteference from the "goto"s in this function.

gdb/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	* source.c (add_path): Use gdb::unique_xmalloc_ptr.
2018-09-13 16:22:33 -06:00
Simon Marchi 74d3fbbb3e python: Fix erroneous doc about gdb.objfiles()
The code implementing gdb.objfiles() returns a list of objfiles for the
current program space (the program space of the selected inferior).  The
documentation for the gdb.objfiles() Python method, however, states:

    Return a sequence of all the objfiles current known to GDB.

That sounds wrong to me.  I tried to phrase to be more precise.

gdb/doc/ChangeLog:

	* python.texi (Objfiles In Python): Update gdb.objfiles() doc.
2018-09-13 15:43:33 -04:00
Simon Marchi 0ae1a3211a python: Add Progspace.objfiles method
This patch adds an objfiles method to the Progspace object, which
returns a sequence of the objfiles associated to that program space.  I
chose a method rather than a property for symmetry with gdb.objfiles().

gdb/ChangeLog:

	* python/py-progspace.c (PSPY_REQUIRE_VALID): New macro.
	(pspy_get_objfiles): New function.
	(progspace_object_methods): New.
	(pspace_object_type): Add tp_methods callback.
	* python/python-internal.h (build_objfiles_list): New
	declaration.
	* python/python.c (build_objfiles_list): New function.
	(gdbpy_objfiles): Implement using build_objfiles_list.
	* NEWS: Mention the Progspace.objfiles method.

gdb/doc/ChangeLog:

	* python.texi (Program Spaces In Python): Document the
	Progspace.objfiles method.
	(Objfiles In Python): Mention that gdb.objfiles() is identical
	to gdb.selected_inferior().progspace.objfiles().

gdb/testsuite/ChangeLog:

	* gdb.python/py-progspace.exp: Test the Progspace.objfiles
	method.
2018-09-13 15:42:12 -04:00
Simon Marchi a40bf0c2e9 python: Add Inferior.progspace property
This patch adds a progspace property to the gdb.Inferior type, which
allows getting the gdb.Progspace object associated to that inferior.
In conjunction with the following patch, this will allow scripts iterate
on objfiles associated with a particular inferior.

gdb/ChangeLog:

	* python/py-inferior.c (infpy_get_progspace): New function.
	(inferior_object_getset): Add progspace property.
	* NEWS: Mention the new property.

gdb/doc/ChangeLog:

	* python.texi (Inferiors In Python): Document
	Inferior.progspace.
	(Program Spaces In Python): Document that
	gdb.current_progspace() is the same as
	gdb.selected_inferior().progspace.

gdb/testsuite/ChangeLog:

	* gdb.python/py-inferior.exp: Add tests for Inferior.progspace
	and a few other Inferior properties when the Inferior is no
	longer valid.
2018-09-13 15:42:12 -04:00
Tom Tromey 4a3fe98f88 Make Rust error message mention the field name
I noticed a spot in rust-lang.c where the placeholder "foo" was used
instead of the actual field name.  This patch fixes the bug.

gdb/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	PR rust/23650:
	* rust-lang.c (rust_evaluate_subexp): Use field name, not "foo".

gdb/testsuite/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	PR rust/23650:
	* gdb.rust/simple.exp: Add test for enum field access error.
2018-09-13 10:57:40 -06:00
Tom Tromey 098b2108a2 Fix crash with empty Rust enum
While testing my Rust compiler patch to fix the DWARF representation
of Rust enums (https://github.com/rust-lang/rust/pull/54004), I found
a gdb crash coming from one of the Rust test cases.

The bug here is that the new variant support in gdb does not handle
the case where there are no variants in the enum.

This patch fixes the problem in a straightforward way.  Note that the
new tests are somewhat lax because I did not want to try to fully fix
this corner case for older compilers.  If you think that's
unacceptable, let meknow.

Tested on x86-64 Fedora 28 using several versions of the Rust
compiler.  I intend to push this to the 8.2 branch as well.

gdb/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	PR rust/23626:
	* rust-lang.c (rust_enum_variant): Now static.
	(rust_empty_enum_p): New function.
	(rust_print_enum, rust_evaluate_subexp, rust_print_struct_def):
	Handle empty enum.

gdb/testsuite/ChangeLog
2018-09-13  Tom Tromey  <tom@tromey.com>

	PR rust/23626:
	* gdb.rust/simple.rs (EmptyEnum): New type.
	(main): Use it.
	* gdb.rust/simple.exp (test_one_slice): Add empty enum test.
2018-09-13 10:57:39 -06:00
Simon Marchi 1256af7d1a python: Provide textual representation for Inferior and Objfile
Printing a GDB Python object is notoriously not helpful:

>>> print(gdb.selected_inferior())
<gdb.Inferior object at 0x7fea59aed198>
>>> print(gdb.objfiles())
[<gdb.Objfile object at 0x7fea59b57c90>]

This makes printing debug traces more difficult than it should be.  This
patch provides some repr() implementation for these two types (more to
come if people agree with the idea, but I want to test the water first).
Here's the same example as above, but with this patch:

>>> print(gdb.selected_inferior())
<gdb.Inferior num=1>
>>> print(gdb.objfiles())
[<gdb.Objfile filename=/home/emaisin/build/binutils-gdb-gcc-git/gdb/test>]

I implemented repr rather than str, because when printing a list (or
another container I suppose), Python calls the repr method of the
elements.  This is useful when printing a list of inferiors or objfiles.
The print(gdb.objfiles()) above would not have worked if I had
implemented str.

I found this post useful to understand the difference between repr and
str:

  https://stackoverflow.com/questions/1436703/difference-between-str-and-repr

gdb/ChangeLog:

	* python/py-inferior.c (infpy_repr): New.
	(inferior_object_type): Register infpy_repr.
	* python/py-objfile.c (objfpy_repr): New.
	(objfile_object_type): Register objfpy_repr.

gdb/testsuite/ChangeLog:

	* gdb.python/py-inferior.exp: Test repr() of gdb.Inferior.
	* gdb.python/py-objfile.exp: Test repr() of gdb.Objfile.
	* gdb.python/py-symtab.exp: Update test printing an objfile.

gdb/doc/ChangeLog:

	* python.texi (Basic Python): Mention the string representation
	of GDB Python objects.
2018-09-13 11:54:38 -04:00
John Baldwin f117a62c5d Remove unused "tmp" variable.
gdb/ChangeLog:

	* fbsd-nat.c (fbsd_nat_target::info_proc): Remove unused variable.
2018-09-12 16:11:07 -07:00
John Baldwin 88f22c34d0 Fix a typo in a comment.
gdb/ChangeLog:

	* aarch64-fbsd-tdep.h (AARCH64_FBSD_SIZEOF_GREGSET): Fix comment
	typo.
2018-09-12 16:10:42 -07:00
Simon Marchi 4aa8e6c238 python: Add tests for trying to use an invalid Inferior object
This patch adds tests for trying to use property or methods on a
gdb.Inferior object that represents an inferior that does not exist
anymore.  We expect an exception to be thrown.

gdb/testsuite/ChangeLog:

	* gdb.python/py-inferior.exp: Test using an invalid gdb.Inferior
	object.
2018-09-12 18:27:57 -04:00
Sergio Durigan Junior 3c025cfe5e Move 'is_regular_file' from common-utils.c to filestuff.c
There is no reason for 'is_regular_file' to be in common-utils.c; it
belongs to 'filestuff.c'.  This commit moves the function definition
and its prototype to the appropriate files.

The motivation behind this move is a failure that happens on certain
cross-compilation environments when compiling the IPA library, due to
the way gnulib probes the need for a 'stat' call replacement.  Because
configure checks when cross-compiling are more limited, gnulib decides
that it needs to substitute the 'stat' calls its own 'rpl_stat';
however, the IPA library doesn't link with gnulib, which leads to an
error when compiling 'common-utils.c':

  ...
  /opt/x86-core2--musl--bleeding-edge-2018.09-1/bin/i686-buildroot-linux-musl-g++  -shared -fPIC -Wl,--soname=libinproctrace.so -Wl,--no-undefined -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os      -I. -I. -I./../common -I./../regformats -I./.. -I./../../include -I./../gnulib/import -Ibuild-gnulib-gdbserver/import -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized  -DGDBSERVER \
   -Wl,--dynamic-list=./proc-service.list -o libinproctrace.so ax-ipa.o common-utils-ipa.o errors-ipa.o format-ipa.o print-utils-ipa.o regcache-ipa.o remote-utils-ipa.o rsp-low-ipa.o tdesc-ipa.o tracepoint-ipa.o utils-ipa.o vec-ipa.o linux-i386-ipa.o linux-x86-tdesc-ipa.o arch/i386-ipa.o -ldl -pthread
  /opt/x86-core2--musl--bleeding-edge-2018.09-1/lib/gcc/i686-buildroot-linux-musl/8.2.0/../../../../i686-buildroot-linux-musl/bin/ld: common-utils-ipa.o: in function `is_regular_file(char const*, int*)':
  common-utils.c:(.text+0x695): undefined reference to `rpl_stat'
  collect2: error: ld returned 1 exit status
  Makefile:413: recipe for target 'libinproctrace.so' failed
  make[1]: *** [libinproctrace.so] Error 1
  ...

More details can also be found at:

  https://sourceware.org/ml/gdb-patches/2018-09/msg00304.html

The most simple fix for this problem is to move 'is_regular_file' to
'filestuff.c', which is not used by IPA.  This ends up making the
files more logically organized as well, since 'is_regular_file' is a
file operation.

No regressions found.

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

	* common/common-utils.c: Don't include '<sys/stat.h>'.
	(is_regular_file): Move to...
	* common/filestuff.c (is_regular_file): ... here.
	* common/common-utils.h (is_regular_file): Move to...
	* common/filestuff.h (is_regular_file): ... here.
2018-09-12 13:58:30 -04:00
Simon Marchi 3e68067fb2 Add debug output about skipping files and functions
While trying to create skips for libstdc++, I found myself debugging GDB
quite a bit, mostly to find out what the exact function name to match
is.  I thought it would make sense to have this information as debug
output.

This patch adds "set debug skip on|off".

gdb/ChangeLog:

	* skip.c (debug_skip): New variable.
	(skiplist_entry::do_skip_file_p): Add debug output.
	(skiplist_entry::do_skip_gfile_p): Likewise.
	(skiplist_entry::skip_function_p): Likewise.
	(_initialize_step_skip): Create debug command.
	* NEWS: Mention set/show debug skip.

gdb/doc/ChangeLog:

	* gdb.texinfo (Skipping Over Functions and Files): Document
	set/show debug skip.
2018-09-12 12:25:26 -04:00
Alan Hayward c221b2f770 Testsuite: Add gdb_can_simple_compile
Simplfy gdb.exp by adding a function that will attempt to
compile a piece of code, then clean up.

gdb/testsuite

	* lib/gdb.exp (gdb_can_simple_compile): Add proc.
	(support_complex_tests): Use gdb_can_simple_compile.
	(is_ilp32_target): Likewise.
	(is_lp64_target): Likewise.
	(is_64_target): Likewise.
	(is_amd64_regs_target): Likewise.
	(is_aarch32_target): Likewise.
	(gdb_int128_helper): Likewise.
2018-09-12 12:05:58 +01:00
Xavier Roirand d6be54ef73 Darwin: set startup-with-shell to off on Sierra and later.
On Mac OS X Sierra and later, the shell is not allowed to be
debug so add a check and disable startup with shell in that
case. This disabling is done temporary before forking
inferior and restored after the fork.

gdb/ChangeLog:

        * darwin-nat.c (should_disable_startup_with_shell):
        New function.
        (darwin_nat_target::create_inferior): Add call.

Change-Id: Ie4d9090f65fdf2e83ecf7a0f9d0647fb1c27cdcc
2018-09-11 15:42:18 +02:00
Xavier Roirand de1ec836c8 Darwin: fix SIGTRAP when debugging
Debugging a program under Darwin does not work:

(gdb) start
Temporary breakpoint 1 at 0x100000fb4: file /tmp/helloworld.c, line 1.
Starting program: /private/tmp/helloworld
[New Thread 0x2903 of process 60326]
During startup program terminated with signal SIGTRAP, Trace/breakpoint
trap.

Field signaled from darwin_thread_info is not initialized thus signal
sent to the debuggee is considered as not sent by GDB whereas it should.

This patch fixes this problem and also updates (change type and/or
initialize) other fields in the same structure at the same time.

gdb/ChangeLog:

        * darwin-nat.h (struct darwin_thread_info) <gdb_port,
	inf_port, msg_state>: Initialize.
        (struct darwin_thread_info) <signaled, single_step>: Change
        type and initialize.
        (struct darwin_thread_info) <event>: Initialize.

Change-Id: I0fe2a6985df9d0dfcc8a2a258a3ef70cfa19b403
2018-09-11 15:35:26 +02:00
Jan Kratochvil 6f1107b593 [testsuite] Fix dg-extract-results.sh path
There was a typo in patch:
commit 5a6996172e
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Mon Aug 6 16:05:16 2018 +0200
    Update dg-extract-results.* from gcc

gdb/testsuite/ChangeLog
2018-09-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* Makefile.in (check-parallel-racy): Fix dg-extract-results.sh path.
2018-09-11 12:59:52 +02:00
Sergio Durigan Junior e2fc52e745 Fix PR gdb/23558: Use system's 'getcwd' when cross-compiling GDB
This is a backport of a gnulib fix for the following bug:

  https://sourceware.org/bugzilla/show_bug.cgi?id=23558

The problem reported there is about the replacement of 'getcwd' when
cross-compiling GDB.  With our current gnulib copy, the mechanism for
deciding whether to use the system's 'getcwd' or gnulib's version is
too simplistic and pessimistic, so when cross-compiling we always end
up using gnulib's version, which has a limitation: it cannot handle
the situation when the parent directory doesn't have read permissions.

The solution is to backport the following gnulib commit:

  commit a96d2e67052c879b1bcc5bc461722beac75fc372
  Author: Bruno Haible <bruno@clisp.org>
  Date:   Thu Aug 23 21:13:19 2018 +0200

      getcwd: Add cross-compilation guesses.

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

	PR gdb/23555
	PR gdb/23558
	* gnulib/import/m4/getcwd-path-max.m4: Add cross-compilation
	guesses.
2018-09-10 13:52:24 -04:00
Sergio Durigan Junior 5e8754f90a Revert "Update gnulib to current upstream master"
This reverts commit 7a6dbc2fdb ("Update
gnulib to current upstream master").  It is needed because the gnulib
update caused problems with people using old GCC compilers (version
4.8, for example), which support C99 but don't default to using it.
Unfortunately this broke GDB for these users.  A more detailed report
of what happened can be found at:

  https://lists.gnu.org/archive/html/bug-gnulib/2018-08/msg00157.html

The reason for updating our gnulib copy was to fix PR gdb/23558.
Reverting this patch reintroduces the bug, so in order to fix it I
will submit a subsequent patch which cherry-picks the fix from gnulib.

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

	Revert:
	2018-08-29  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR gdb/23555
	PR gdb/23558
	* gnulib/aclocal.m4: Regenerate.
	* gnulib/config.in: Regenerate.
	* gnulib/configure: Regenerate.
	* gnulib/import/Makefile.am: Update.
	* gnulib/import/Makefile.in: Update.
	* gnulib/import/extra/snippet/_Noreturn.h: Rename to...
	* gnulib/import/_Noreturn.h: ... this.
	* gnulib/import/alloca.in.h: Update.
	* gnulib/import/extra/snippet/arg-nonnull.h: Rename to...
	* gnulib/import/arg-nonnull.h: ... this.
	* gnulib/import/assure.h: Update.
	* gnulib/import/at-func.c: Update.
	* gnulib/import/basename-lgpl.c: Update.
	* gnulib/import/extra/snippet/c++defs.h: Rename to...
	* gnulib/import/c++defs.h: ... this.
	* gnulib/import/canonicalize-lgpl.c: Update.
	* gnulib/import/cdefs.h: Update.
	* gnulib/import/chdir-long.c: Update.
	* gnulib/import/chdir-long.h: Update.
	* gnulib/import/cloexec.c: Update.
	* gnulib/import/cloexec.h: Update.
	* gnulib/import/close.c: Update.
	* gnulib/import/closedir.c: Update.
	* gnulib/import/config.charset: Update.
	* gnulib/import/dirent-private.h: Update.
	* gnulib/import/dirent.in.h: Update.
	* gnulib/import/dirfd.c: Update.
	* gnulib/import/dirname-lgpl.c: Update.
	* gnulib/import/dirname.h: Update.
	* gnulib/import/dosname.h: Update.
	* gnulib/import/dup-safer-flag.c: Update.
	* gnulib/import/dup-safer.c: Update.
	* gnulib/import/dup.c: Update.
	* gnulib/import/dup2.c: Update.
	* gnulib/import/errno.in.h: Update.
	* gnulib/import/error.c: Update.
	* gnulib/import/error.h: Update.
	* gnulib/import/exitfail.c: Update.
	* gnulib/import/exitfail.h: Update.
	* gnulib/import/extra/update-copyright: Update.
	* gnulib/import/fchdir.c: Update.
	* gnulib/import/fcntl.c: Update.
	* gnulib/import/fcntl.in.h: Update.
	* gnulib/import/fd-hook.c: Update.
	* gnulib/import/fd-hook.h: Update.
	* gnulib/import/fd-safer-flag.c: Update.
	* gnulib/import/fd-safer.c: Update.
	* gnulib/import/fdopendir.c: Update.
	* gnulib/import/filename.h: Update.
	* gnulib/import/filenamecat-lgpl.c: Update.
	* gnulib/import/filenamecat.h: Update.
	* gnulib/import/flexmember.h: Update.
	* gnulib/import/float+.h: Update.
	* gnulib/import/float.c: Update.
	* gnulib/import/float.in.h: Update.
	* gnulib/import/fnmatch.c: Update.
	* gnulib/import/fnmatch.in.h: Update.
	* gnulib/import/fnmatch_loop.c: Update.
	* gnulib/import/fpucw.h: Update.
	* gnulib/import/frexp.c: Update.
	* gnulib/import/frexpl.c: Update.
	* gnulib/import/fstat.c: Update.
	* gnulib/import/fstatat.c: Update.
	* gnulib/import/getcwd-lgpl.c: Update.
	* gnulib/import/getcwd.c: Update.
	* gnulib/import/getdtablesize.c: Update.
	* gnulib/import/getlogin_r.c: Update.
	* gnulib/import/getprogname.c: Update.
	* gnulib/import/getprogname.h: Update.
	* gnulib/import/gettext.h: Update.
	* gnulib/import/gettimeofday.c: Update.
	* gnulib/import/glob-libc.h: Update.
	* gnulib/import/glob.c: Update.
	* gnulib/import/glob.in.h: Update.
	* gnulib/import/glob_internal.h: Update.
	* gnulib/import/glob_pattern_p.c: Update.
	* gnulib/import/globfree.c: Update.
	* gnulib/import/hard-locale.c: Update.
	* gnulib/import/hard-locale.h: Update.
	* gnulib/import/intprops.h: Update.
	* gnulib/import/inttypes.in.h: Update.
	* gnulib/import/isnan.c: Update.
	* gnulib/import/isnand-nolibm.h: Update.
	* gnulib/import/isnand.c: Update.
	* gnulib/import/isnanl-nolibm.h: Update.
	* gnulib/import/isnanl.c: Update.
	* gnulib/import/itold.c: Update.
	* gnulib/import/libc-config.h: Update.
	* gnulib/import/limits.in.h: Update.
	* gnulib/import/localcharset.c: Update.
	* gnulib/import/localcharset.h: Update.
	* gnulib/import/localtime-buffer.c: Update.
	* gnulib/import/localtime-buffer.h: Update.
	* gnulib/import/lstat.c: Update.
	* gnulib/import/m4/00gnulib.m4: Update.
	* gnulib/import/m4/__inline.m4: Update.
	* gnulib/import/m4/absolute-header.m4: Update.
	* gnulib/import/m4/alloca.m4: Update.
	* gnulib/import/m4/builtin-expect.m4: Update.
	* gnulib/import/m4/canonicalize.m4: Update.
	* gnulib/import/m4/chdir-long.m4: Update.
	* gnulib/import/m4/close.m4: Update.
	* gnulib/import/m4/closedir.m4: Update.
	* gnulib/import/m4/configmake.m4: Update.
	* gnulib/import/m4/d-ino.m4: Update.
	* gnulib/import/m4/d-type.m4: Update.
	* gnulib/import/m4/dirent_h.m4: Update.
	* gnulib/import/m4/dirfd.m4: Update.
	* gnulib/import/m4/dirname.m4: Update.
	* gnulib/import/m4/double-slash-root.m4: Update.
	* gnulib/import/m4/dup.m4: Update.
	* gnulib/import/m4/dup2.m4: Update.
	* gnulib/import/m4/eealloc.m4: Update.
	* gnulib/import/m4/environ.m4: Update.
	* gnulib/import/m4/errno_h.m4: Update.
	* gnulib/import/m4/error.m4: Update.
	* gnulib/import/m4/exponentd.m4: Update.
	* gnulib/import/m4/exponentl.m4: Update.
	* gnulib/import/m4/extensions.m4: Update.
	* gnulib/import/m4/extern-inline.m4: Update.
	* gnulib/import/m4/fchdir.m4: Update.
	* gnulib/import/m4/fcntl-o.m4: Update.
	* gnulib/import/m4/fcntl.m4: Update.
	* gnulib/import/m4/fcntl_h.m4: Update.
	* gnulib/import/m4/fdopendir.m4: Update.
	* gnulib/import/m4/filenamecat.m4: Update.
	* gnulib/import/m4/flexmember.m4: Update.
	* gnulib/import/m4/float_h.m4: Update.
	* gnulib/import/m4/fnmatch.m4: Update.
	* gnulib/import/m4/fnmatch_h.m4: Update.
	* gnulib/import/m4/fpieee.m4: Update.
	* gnulib/import/m4/frexp.m4: Update.
	* gnulib/import/m4/frexpl.m4: Update.
	* gnulib/import/m4/fstat.m4: Update.
	* gnulib/import/m4/fstatat.m4: Update.
	* gnulib/import/m4/getcwd-abort-bug.m4: Update.
	* gnulib/import/m4/getcwd-path-max.m4: Update.
	* gnulib/import/m4/getcwd.m4: Update.
	* gnulib/import/m4/getdtablesize.m4: Update.
	* gnulib/import/m4/getlogin.m4: Update.
	* gnulib/import/m4/getlogin_r.m4: Update.
	* gnulib/import/m4/getpagesize.m4: Update.
	* gnulib/import/m4/getprogname.m4: Update.
	* gnulib/import/m4/gettimeofday.m4: Update.
	* gnulib/import/m4/glibc21.m4: Update.
	* gnulib/import/m4/glob.m4: Update.
	* gnulib/import/m4/glob_h.m4: Update.
	* gnulib/import/m4/gnulib-cache.m4: Update.
	* gnulib/import/m4/gnulib-common.m4: Update.
	* gnulib/import/m4/gnulib-comp.m4: Update.
	* gnulib/import/m4/gnulib-tool.m4: Update.
	* gnulib/import/m4/hard-locale.m4: Update.
	* gnulib/import/m4/include_next.m4: Update.
	* gnulib/import/m4/inttypes-pri.m4: Update.
	* gnulib/import/m4/inttypes.m4: Update.
	* gnulib/import/m4/isnand.m4: Update.
	* gnulib/import/m4/isnanl.m4: Update.
	* gnulib/import/m4/largefile.m4: Update.
	* gnulib/import/m4/limits-h.m4: Update.
	* gnulib/import/m4/localcharset.m4: Update.
	* gnulib/import/m4/locale-fr.m4: Update.
	* gnulib/import/m4/locale-ja.m4: Update.
	* gnulib/import/m4/locale-zh.m4: Update.
	* gnulib/import/m4/localtime-buffer.m4: Update.
	* gnulib/import/m4/longlong.m4: Update.
	* gnulib/import/m4/lstat.m4: Update.
	* gnulib/import/m4/malloc.m4: Update.
	* gnulib/import/m4/malloca.m4: Update.
	* gnulib/import/m4/math_h.m4: Update.
	* gnulib/import/m4/mbrtowc.m4: Update.
	* gnulib/import/m4/mbsinit.m4: Update.
	* gnulib/import/m4/mbsrtowcs.m4: Update.
	* gnulib/import/m4/mbstate_t.m4: Update.
	* gnulib/import/m4/memchr.m4: Update.
	* gnulib/import/m4/memmem.m4: Update.
	* gnulib/import/m4/mempcpy.m4: Update.
	* gnulib/import/m4/memrchr.m4: Update.
	* gnulib/import/m4/mkdir.m4: Update.
	* gnulib/import/m4/mkstemp.m4: Update.
	* gnulib/import/m4/mmap-anon.m4: Update.
	* gnulib/import/m4/mode_t.m4: Update.
	* gnulib/import/m4/msvc-inval.m4: Update.
	* gnulib/import/m4/msvc-nothrow.m4: Update.
	* gnulib/import/m4/multiarch.m4: Update.
	* gnulib/import/m4/nocrash.m4: Update.
	* gnulib/import/m4/off_t.m4: Update.
	* gnulib/import/m4/onceonly.m4: Update.
	* gnulib/import/m4/open-cloexec.m4: Update.
	* gnulib/import/m4/open.m4: Update.
	* gnulib/import/m4/openat.m4: Update.
	* gnulib/import/m4/opendir.m4: Update.
	* gnulib/import/m4/pathmax.m4: Update.
	* gnulib/import/m4/rawmemchr.m4: Update.
	* gnulib/import/m4/readdir.m4: Update.
	* gnulib/import/m4/readlink.m4: Update.
	* gnulib/import/m4/realloc.m4: Update.
	* gnulib/import/m4/rename.m4: Update.
	* gnulib/import/m4/rewinddir.m4: Update.
	* gnulib/import/m4/rmdir.m4: Update.
	* gnulib/import/m4/save-cwd.m4: Update.
	* gnulib/import/m4/secure_getenv.m4: Update.
	* gnulib/import/m4/setenv.m4: Update.
	* gnulib/import/m4/signal_h.m4: Update.
	* gnulib/import/m4/ssize_t.m4: Update.
	* gnulib/import/m4/stat-time.m4: Update.
	* gnulib/import/m4/stat.m4: Update.
	* gnulib/import/m4/std-gnu11.m4: Update.
	* gnulib/import/m4/stdbool.m4: Update.
	* gnulib/import/m4/stddef_h.m4: Update.
	* gnulib/import/m4/stdint.m4: Update.
	* gnulib/import/m4/stdio_h.m4: Update.
	* gnulib/import/m4/stdlib_h.m4: Update.
	* gnulib/import/m4/strchrnul.m4: Update.
	* gnulib/import/m4/strdup.m4: Update.
	* gnulib/import/m4/strerror.m4: Update.
	* gnulib/import/m4/string_h.m4: Update.
	* gnulib/import/m4/strstr.m4: Update.
	* gnulib/import/m4/strtok_r.m4: Update.
	* gnulib/import/m4/sys_socket_h.m4: Update.
	* gnulib/import/m4/sys_stat_h.m4: Update.
	* gnulib/import/m4/sys_time_h.m4: Update.
	* gnulib/import/m4/sys_types_h.m4: Update.
	* gnulib/import/m4/tempname.m4: Update.
	* gnulib/import/m4/time_h.m4: Update.
	* gnulib/import/m4/unistd-safer.m4: Update.
	* gnulib/import/m4/unistd_h.m4: Update.
	* gnulib/import/m4/warn-on-use.m4: Update.
	* gnulib/import/m4/wchar_h.m4: Update.
	* gnulib/import/m4/wchar_t.m4: Update.
	* gnulib/import/m4/wctype_h.m4: Update.
	* gnulib/import/m4/wint_t.m4: Update.
	* gnulib/import/malloc.c: Update.
	* gnulib/import/malloc/scratch_buffer.h: Update.
	* gnulib/import/malloc/scratch_buffer_grow.c: Update.
	* gnulib/import/malloc/scratch_buffer_grow_preserve.c: Update.
	* gnulib/import/malloc/scratch_buffer_set_array_size.c: Update.
	* gnulib/import/malloca.c: Update.
	* gnulib/import/malloca.h: Update.
	* gnulib/import/malloca.valgrind: Update.
	* gnulib/import/math.in.h: Update.
	* gnulib/import/mbrtowc.c: Update.
	* gnulib/import/mbsinit.c: Update.
	* gnulib/import/mbsrtowcs-impl.h: Update.
	* gnulib/import/mbsrtowcs-state.c: Update.
	* gnulib/import/mbsrtowcs.c: Update.
	* gnulib/import/memchr.c: Update.
	* gnulib/import/memmem.c: Update.
	* gnulib/import/mempcpy.c: Update.
	* gnulib/import/memrchr.c: Update.
	* gnulib/import/mkdir.c: Update.
	* gnulib/import/mkstemp.c: Update.
	* gnulib/import/msvc-inval.c: Update.
	* gnulib/import/msvc-inval.h: Update.
	* gnulib/import/msvc-nothrow.c: Update.
	* gnulib/import/msvc-nothrow.h: Update.
	* gnulib/import/open.c: Update.
	* gnulib/import/openat-die.c: Update.
	* gnulib/import/openat-priv.h: Update.
	* gnulib/import/openat-proc.c: Update.
	* gnulib/import/openat.c: Update.
	* gnulib/import/openat.h: Update.
	* gnulib/import/opendir.c: Update.
	* gnulib/import/pathmax.h: Update.
	* gnulib/import/pipe-safer.c: Update.
	* gnulib/import/rawmemchr.c: Update.
	* gnulib/import/readdir.c: Update.
	* gnulib/import/readlink.c: Update.
	* gnulib/import/realloc.c: Update.
	* gnulib/import/ref-add.sin: Update.
	* gnulib/import/ref-del.sin: Update.
	* gnulib/import/rename.c: Update.
	* gnulib/import/rewinddir.c: Update.
	* gnulib/import/rmdir.c: Update.
	* gnulib/import/same-inode.h: Update.
	* gnulib/import/save-cwd.c: Update.
	* gnulib/import/save-cwd.h: Update.
	* gnulib/import/scratch_buffer.h: Update.
	* gnulib/import/secure_getenv.c: Update.
	* gnulib/import/setenv.c: Update.
	* gnulib/import/signal.in.h: Update.
	* gnulib/import/stat-time.c: Update.
	* gnulib/import/stat-time.h: Update.
	* gnulib/import/stat-w32.c: Update.
	* gnulib/import/stat-w32.h: Update.
	* gnulib/import/stat.c: Update.
	* gnulib/import/stdbool.in.h: Update.
	* gnulib/import/stddef.in.h: Update.
	* gnulib/import/stdint.in.h: Update.
	* gnulib/import/stdio.in.h: Update.
	* gnulib/import/stdlib.in.h: Update.
	* gnulib/import/str-two-way.h: Update.
	* gnulib/import/strchrnul.c: Update.
	* gnulib/import/strdup.c: Update.
	* gnulib/import/streq.h: Update.
	* gnulib/import/strerror-override.c: Update.
	* gnulib/import/strerror-override.h: Update.
	* gnulib/import/strerror.c: Update.
	* gnulib/import/string.in.h: Update.
	* gnulib/import/stripslash.c: Update.
	* gnulib/import/strnlen1.c: Update.
	* gnulib/import/strnlen1.h: Update.
	* gnulib/import/strstr.c: Update.
	* gnulib/import/strtok_r.c: Update.
	* gnulib/import/sys_stat.in.h: Update.
	* gnulib/import/sys_time.in.h: Update.
	* gnulib/import/sys_types.in.h: Update.
	* gnulib/import/tempname.c: Update.
	* gnulib/import/tempname.h: Update.
	* gnulib/import/time.in.h: Update.
	* gnulib/import/unistd--.h: Update.
	* gnulib/import/unistd-safer.h: Update.
	* gnulib/import/unistd.in.h: Update.
	* gnulib/import/unsetenv.c: Update.
	* gnulib/import/verify.h: Update.
	* gnulib/import/extra/snippet/warn-on-use.h: Update.
	* gnulib/import/wchar.in.h: Update.
	* gnulib/import/wctype.in.h: Update.
	* gnulib/import/xalloc-oversized.h: Update.
	* gnulib/update-gnulib.sh (GNULIB_COMMIT_SHA1): Set to
	"53e2c179f26a890fa6685af4b6c1397ee370433b".
2018-09-10 13:52:24 -04:00
Simon Marchi 8ec235834d Remove unused variable in record-btrace.c
old_inferior_ptid is unused, this is caught by a gcc built from git
recently, not sure about previous versions:

/home/emaisin/src/binutils-gdb/gdb/record-btrace.c: In function ‘frame_info* get_thread_current_frame(thread_info*)’:
/home/emaisin/src/binutils-gdb/gdb/record-btrace.c:1974:10: error: unused variable ‘old_inferior_ptid’ [-Werror=unused-variable]
1974 |   ptid_t old_inferior_ptid;
     |          ^~~~~~~~~~~~~~~~~

gdb/ChangeLog:

	* record-btrace.c (get_thread_current_frame): Remove
	old_inferior_ptid.
2018-09-10 17:11:46 +01:00
Jerome Guitton 1f5d1570c0 (Ada) Fix resolving of homonym components in tagged types
ada_value_struct_elt is used when displaying a component (say, 'N') of
a record object (say, 'Obj') of type, say, 't1'. Now if Obj is tagged
(Ada parlance: "tagged types" are what other object-oriented languages
call "classes"), then 'N' may not be visible in the current view and
we need to look for it in its actual type. We do that at the same time
as resolving variable-length fields. This would typically be done by
the following call to ada_value_struct_elt, with the last parameter
check_tag set to 1:

      t1 = ada_to_fixed_type (ada_get_base_type (t1), NULL,
                              address, NULL, 1);

This is the general logic, but recently we introduced a special case
to handle homonyms. Different components may have the same name in a
tagged type.  For instance:

       type Top_T is tagged record
          N : Integer := 1;
       end record;

       type Middle_T is new Top.Top_T with record
          N : Character := 'a';
       end record;

Middle_T extends Top_T and both define a (different) component with
the same name ('N'). In such a case, using the actual type of a
Middle_T object would create a confusion, since we would have two
component 'N' in this actual type.

So, to handle homonyms, we convert t1 to the actual type *if
and only if* N cannot be found in the current view. For example, if Obj
has been created as a Middle_T but is seen as a Top_T'Class at our
point of execution, then "print Obj.N" will display the integer field
defined in Top_T's declaration.

Now, even if we find N in the current view, we still have to get a
fixed type: for instance, the record can be unconstrained and we still
need a fixed type to get the proper offset to each field. That is
to say, in this case:

   type Dyn_Top_T (Disc : Natural) is tagged record
      S : Integer_Array (1 .. Disc) := (others => Disc);
      N : Integer := 1;
   end record;

   type Dyn_Middle_T is new Dyn_Top.Dyn_Top_T with record
      N : Character := 'a';
      U : Integer := 42;
   end record;

If we have an object Obj of type Dyn_Middle_T and we want to display
U, we don't need to build, from its tag, a real type with all its real
fields. In other words, we don't need to add the parent components:
Disc, S, and the integer N. We only need to access U and it is
directly visible in Dyn_Middle_T. So no tag handling. However, we do
need to build a fixed-size type to have the proper offset to U (since
this offset to U depends on the size of Obj.S, which itself is dynamic
and depends on the value of Obj.Disc).

We accidentally lost some of this treatment when we introduced the
resolution of homonyms. This patch re-install this part by uncoupling
the tag resolution from the "fixing" of variable-length components.

This change also slightly simplifies the non-tagged case: in the
non-tagged case, no need to set check_tag to 1, since we already know
that there is no tag.

gdb/ChangeLog:

	* ada-lang.c (ada_value_struct_elt): Call ada_to_fixed_type
	with check_tag to 1 if and only if the type is tagged and the
	component being searched cannot been found in the current
	view. Otherwise, always call ada_to_fixed_type with
	check_tag to 0.

gdb/testsuite/ChangeLog:

	* gdb.ada/same_component_name: Add test for case of tagged record
	with variable-length fields.
2018-09-10 11:37:52 -04:00
Xavier Roirand d91e9ea81d (Ada) Cleanup code by using ada_is_access_to_unconstrained_array call.
This patch just avoids code duplication by using a function we
introduced recently (ada_is_access_to_unconstrained_array).

gdb/ChangeLog:

    * ada-lang.c (ada_is_access_to_unconstrained_array): Remove static
    declaration.
    * ada-lang.h: add ada_is_access_to_unconstrained_array prototype.
    * ada-varobj.c (ada_varobj_get_number_of_children,
    ada_varobj_describe_child, ada_value_is_changeable_p): Cleanup code.

Tested on x86_64-linux.
No new testcase provided, as this is just a refactoring.
2018-09-10 11:35:58 -04:00
Xavier Roirand cc330e39bc (Ada) Fix printing of access to unconstrained arrays
Using this Ada code:

    type String_Access is access String;
    type Array_Of_String is array (1 .. 2) of String_Access;
    Aos : Array_Of_String := (new String'("ab"), new String'("cd"));

When debugging with GDB, printing each Aos element displays:

    (gdb) print Aos(1)
    $2 = "ab"
    (gdb) print Aos(2)
    $3 = "cd"

Whereas it should display:

    (gdb) print Aos(1)
    $2 = (foo_r118_024.string_access) 0x635018
    (gdb) print Aos(2)
    $3 = (foo_r118_024.string_access) 0x635038

Notice that printing the entire array works:

(gdb) print Aos
$1 = (0x635018, 0x635038)

The problem was located in ada_value_print function and due to the fact
that the value_type used in this function was based on
value_enclosing_type rather than value_type itself.
In our example, the difference between the value_type and the
value_enclosing_type of the value is that the value_type contains an
additional typedef layer which is not present in the value_enclosing_type.
This typedef layer is GNAT's way to specify that the element is, at the
source level, an access to the unconstrained array, rather than the
unconstrained array.
Moreover, the value_enclosing_type is not really needed in that case and
the value_type can be used instead in this function, and this patch fixes
this.

gdb/ChangeLog:

    * ada-valprint.c (ada_value_print): Use type instead of
    enclosing type.

testsuite/ChangeLog:

    * gdb.ada/access_to_unbounded_array.exp: New testcase.
    * gdb.ada/access_to_unbounded_array/foo.adb: New file.
    * gdb.ada/access_to_unbounded_array/pack.adb: New file.
    * gdb.ada/access_to_unbounded_array/pack.ads: New file.

Tested: x86_64-linux
2018-09-10 11:34:59 -04:00
Xavier Roirand b9c50e9a9a (Ada/MI) Fix -var-evaluate-expression for access to unconstrained arrays
Using this Ada code:

   type String_Access is access String;
   type Array_Of_String is array (1 .. 2) of String_Access;
   Aos : Array_Of_String := (new String'("ab"), new String'("cd"));

In GDB/MI mode, create a variable which type is Aos, evaluate it:

(gdb) -var-create var1 * Aos
^done,name="var1",numchild="2",value="[2]",type="bar.array_of_string",thread-id="1",has_more="0"

Now print it:

(gdb) -var-list-children 1 var1
^done,numchild="2",children=[child={name="var1.1",exp="1",numchild="1",value="[2] \"ab\"", type="bar.string_access",thread-id="1"},child={name="var1.2",exp="2",numchild="1",value="[2] \"cd\"", type="bar.string_access",thread-id="1"}],has_more="0"

But printed fields "value" are wrong, since it should be:

^done,numchild="2",children=[child={name="var1.1",exp="1",numchild="1",value="0x634018",type="bar.string_access",thread-id="1"},child={name="var1.2",exp="2",numchild="1",value="0x634038",type="bar.string_access",thread-id="1"}],has_more="0"^M

Print each child of var1:

(gdb) -var-evaluate-expression var1.1
^done,value="[2] \"ab\""
(gdb) -var-evaluate-expression var1.2
^done,value="[2] \"cd\""

Whereas it should be

(gdb) -var-evaluate-expression var1.1
^done,value="0x635018"
(gdb) -var-evaluate-expression var1.2
^done,value="0x635038"

This patch fixes this.

gdb/ChangeLog:

        * ada-lang.c (ada_value_subscript): Handle case when parameter is
        an array of access to unconstrained array.

testsuite/ChangeLog

        * gdb.ada/mi_string_access.exp: New testcase.
        * gdb.ada/mi_string_access/bar.adb: New file.
        * gdb.ada/mi_string_access/pck.adb: New file.
        * gdb.ada/mi_string_access/pck.asd: New file.

Tested on x86_64-linux.
2018-09-10 11:33:32 -04:00
Xavier Roirand 736ade86ea (Ada) New function ada_is_access_to_unconstrained_array
Add a new function to check if a given type is an access to an
unconstrained array. This function contains code that is present only
once in the current sources but will be used in a future patch.

gdb/ChangeLog:

        * ada-lang.c (ada_is_access_to_unconstrained_array): New function.
        (ada_check_typedef): Use it.

Tested on x86_64-linux.
2018-09-10 11:32:00 -04:00
Xavier Roirand 2963898f38 (Ada) Fix -var-list-children MI command for union type
Using this Ada code:

   type Union_Type (A : Boolean := False) is record
      case A is
         when True  => B : Integer;
         when False => C : Float;
      end case;
   end record;
   pragma Unchecked_Union (Union_Type);
   Ut : Union_Type := (A => True, B => 3);

In GDB/MI mode, once creating a varobj from variable "Ut" as follow:

(gdb) -var-create var1 * ut
^done,name="var1",numchild="2",value="{...}",type="foo.union_type",thread-id="1",has_more="0"

Printing the list of its children displays:

(gdb) -var-list-children 1 var1
^error,msg="Duplicate variable object name"

Whereas it should be

(gdb) -var-list-children 1 var1
^done,numchild="2",children=[child={name="var1.b",exp="b",numchild="0",value="3",type="integer",thread-id="1"},child={name="var1.c",exp="c",numchild="0",value="4.20389539e-45",type="float",thread-id="1"}],has_more="0"

The problem occurs because ada_varobj_describe_struct_child wasn't
handling unions.  This patch fixes this.

gdb/ChangeLog:

        * ada-varobj.c (ada_varobj_describe_struct_child)
        (ada_varobj_describe_child): Handle union case like struct one.

testsuite/ChangeLog

        * gdb.ada/mi_var_union.exp: New testcase.
        * gdb.ada/mi_var_union/bar.adb: New file.
        * gdb.ada/mi_var_union/pck.adb: New file.
        * gdb.ada/mi_var_union/pck.asd: New file.

Tested on x86_64-linux.
2018-09-10 11:30:50 -04:00
Tom Tromey 849cba3b83 Remove periods from Python section titles
This removes the remaining trailing periods from the Python section
titles.  I thought these looked weird and I don't this is generally
done in the gdb documentation.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	* python.texi (Frames In Python, Blocks In Python)
	(Symbols In Python, Symbol Tables In Python)
	(Lazy Strings In Python): Remove periods from section titles.
2018-09-10 07:44:29 -06:00
Tom Tromey 27a9fec6aa Swap two sentences in the Pretty Printing API node
I thought the start of the Pretty Printing API node read a bit
strangely.  This patch swaps the first two sentences, which seems
better.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	* python.texi (Pretty Printing API): Swap sentence order.
2018-09-10 07:44:28 -06:00
Tom Tromey 9da10427dd Mention virtual tables in Python dynamic_type documentation
PR python/16461 asks that the Python dynamic_type documentation
mention virtual tables; this patch implements that request.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/16461:
	* python.texi (Values From Inferior): Mention use of virtual
	table.
2018-09-10 07:44:28 -06:00
Tom Tromey 0d2a583976 Small typo fix in Basic Python node
I noticed that the decode_line documentation did not have parens
around the argument:

 -- Function: gdb.decode_line [expression]

This patch fixes this oversight.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	* python.texi (Basic Python): Parenthesize argument to
	decode_line.
2018-09-10 07:44:27 -06:00
Tom Tromey 05c6bdc1a9 Mention Python versions in the documentation
This updates python.texi to note that gdb can be compiled against
either major version of Python.  It also removes the "execfile"
example, because that is specific to Python 2.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	* python.texi (Python): Mention Python versions.  Don't mention
	execfile.
2018-09-10 07:44:27 -06:00
Tom Tromey e7b5068cc2 Update Python unwinder documentation
PR python/19808 points out a few issues in the Python unwinder
documentation.  This patch update the documentation for
create_unwind_info and read_register to address the issues noted, and
adds a cautionary note about writing an unwinder.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/19808:
	* python.texi (Unwinding Frames in Python): Rewrite
	create_unwind_info documentation.  Update read_register
	documentation and add a note about unwinder caution.
2018-09-10 07:44:26 -06:00
Tom Tromey fb5af5e335 Fix gdb.events.inferior_call documentation
PR python/18909 points out that the gdb.events.inferior_call
documentation was incorrect.  This patch brings it in line with the
code.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/18909:
	* python.texi (Events In Python): Fix inferior_call
	documentation.
2018-09-10 07:44:26 -06:00
Tom Tromey 521b499b96 Update Python frame filter documentation
This fixes a few frame filter documentation omissions noted in
PR python/17752.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/17752:
	* python.texi (Frame Filter API): Remove period from subsection
	title.  Mention 100 as good default priority.
	(Frame Decorator API): Remove period from subsection title.
	Mention FrameDecorator module.
2018-09-10 07:44:25 -06:00
Tom Tromey 4a5a194ae8 Reword gdb.GdbError text
PR python/23108 points out that the gdb.GdbError documentation is
somewhat difficult to find.  The exception is apparently just
mentioned in passing.  This patch introduces a new table and adds a
bit more text to try to make it more obvious.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/23108:
	* python.texi (Exception Handling): Rearrange gdb.GdbError text
	and add a table.
2018-09-10 07:44:25 -06:00
Tom Tromey f5a476a7b1 Avoid warnings from makeinfo
"make info" gives a number of warnings about the use of a "." in
@ref-like commands.  These come from the ".info" suffix.  I think this
suffix is redundant, and removing the suffix also removes the warning.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Compilation): Use "gcc", not "gcc.info", in @xref.
	(Machine Code): Use "binutils", not "binutils.info", in @pxref.
	(Separate Debug Files): Use "ld", not "ld.info", in @ref.
	* python.texi (Objfiles In Python): Use "ld", not "ld.info", in @ref.
2018-09-10 07:44:24 -06:00
Tom Tromey a154931ef1 Fix help text for "python" command
PR python/18380 points out that the example in the "help python" text
will only work in Python 2.  This changes the example to be valid
syntax for both Python 2 and Python 3.

gdb/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/18380:
	* python/python.c (_initialize_python): Make example in "python"
	help work in Python 3.
2018-09-10 07:44:24 -06:00
Tom Tromey 60c0454d3d Document that Frame.block can throw
PR python/16484 points out that Frame.block can throw an exception,
but this is not documented.

This patch fixes the documentation.  Changing Frame.block to return
None would be nice, but I suspect it's too late for that change.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/16484:
	* python.texi (Frames In Python): Document that Frame.block can
	throw.
2018-09-10 07:44:23 -06:00
Tom Tromey 088a96da05 Fix typo in pretty-printer example
PR python/23487 points out that the "disable pretty-printer" example
has a typo that makes it incorrect.  This patch fixes the typo.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/23487:
	* gdb.texinfo (Pretty-Printer Commands): Fix typo in example.
2018-09-10 07:44:23 -06:00
Tom Tromey 22eb9e92ea Update Python Block.end documentation
PR python/16033 points out that Block.end doesn't describe whether it
is inclusive or exclusive.  This patch fixes the documentation.

gdb/doc/ChangeLog
2018-09-10  Tom Tromey  <tom@tromey.com>

	PR python/16033:
	* python.texi (Blocks In Python): Document that Block.end is
	exclusive.
2018-09-10 07:44:22 -06:00
Eli Zaretskii 23c4651c06 Fix "make install-strip" failure to install gdb-add-index.sh
gdb/ChangeLog:
2018-09-10  Eli Zaretskii  <eliz@gnu.org>

	* Makefile.in (transformed_name): Use INSTALL_SCRIPT instead of
	INSTALL_PROGRAM to install gdb-add-index.sh.  Don't append
	$(EXEEXT) to the script, as it is not a program.
2018-09-10 10:14:04 +03:00
Simon Marchi a5c5eda7e4 python: Make two functions return gdbpy_ref<>
I noticed that we release a gdbpy_ref in pretty_print_one_value only to
create it again later.  This patch fills the gap by returning a
gdbpy_ref all the way.

gdb/ChangeLog:

	* python/py-prettyprint.c (pretty_print_one_value): Return
	gdbpy_ref<>.
	(print_string_repr): Adjust.
	(apply_varobj_pretty_printer): Return gdbpy_ref<>.
	* python/python-internal.h (apply_varobj_pretty_printer): Return
	gdbpy_ref<>.
	* varobj.c (varobj_value_get_print_value): Adjust.
2018-09-09 08:13:17 +01:00
Tom Tromey 1aac008f1c Make py-prettyprint.exp test names unique
I noticed that the py-prettyprint.exp test names were not unique.
This patch fixes the problem via with_test_prefix.

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

	* gdb.python/py-prettyprint.exp: Use with_test_prefix.
2018-09-08 21:47:53 -06:00
Tom Tromey 332cf4c925 Allow a pretty-printer without a to_string method
PR python/16047 points out that, while the documentation says that the
to_string method is optional for a pretty-printer, the code disagrees
and throws an exception.  This patch fixes the problem.  varobj is
already ok here.

Tested on x86-64 Fedora 26.

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

	PR python/16047:
	* python/py-prettyprint.c (pretty_print_one_value): Check for
	to_string method.

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

	PR python/16047:
	* gdb.python/py-prettyprint.py (pp_int_typedef3): New class.
	(register_pretty_printers): Register new printer.
	* gdb.python/py-prettyprint.exp (run_lang_tests): Add int_type3
	test.
	* gdb.python/py-prettyprint.c (int_type3): New typedef.
	(an_int_type3): New global.
2018-09-08 20:49:15 -06:00
Joel Brobecker 424da6cf3b (Ada) fix handling of expression with parameterless function call
Consider the following function, which takes no parameter and returns
an integer:

    function Something return Integer;

For the purpose of this discussion, our function has been implemented
to always return 124:

    function Something return Integer is
    begin
       return 124;
    end Something;

In Ada, such function can been called without using the parentheses.
For instance, in the statement below, variable My_Value is assigned
the returned value from the call to Something:

    My_Value := Something;

The Ada expression interpeter in GDB supports this case, as we can
see below:

    (gdb) print something
    $1 = 124

However, we get fairly strange results when trying to use this feature
as part of a larger expression. For instance:

    (gdb) print something + 1
    $2 = 248

The problem occurs while doing the resolution pass of the expression.
After prefixying the expression, we obtain the following expression:

    0  BINOP_ADD
    1    OP_VAR_VALUE          Block @0x2021550, symbol @0x20213a0 (pck.something)
    5    OP_LONG               Type @0x1e3c170 (int), value 1 (0x1)

The resolution pass is then expected to remove the OP_VAR_VALUE
entry, and replace it with an OP_FUNCALL. This is what the call
to replace_operator_with_call in ada-lang.c::resolve_subexp is
expected to do:

      if (deprocedure_p
          && (TYPE_CODE (SYMBOL_TYPE (exp->elts[pc + 2].symbol))
              == TYPE_CODE_FUNC))
        {
          replace_operator_with_call (expp, pc, 0, 0,
                                      exp->elts[pc + 2].symbol,
                                      exp->elts[pc + 1].block);
          exp = expp->get ();
        }

The problem is that we're passing OPLEN (zero -- 4th parameter in
the call), and so replace_operator_with_call ends up removing zero
element from our expression, and inserting the corresponding OP_FUNCALL
instead. As a result, instead of having the OP_LONG (1) as the second
argument of the BINOP_ADD, it is now the OP_VAR_VALUE that we were
meant to replace. That OP_VAR_VALUE then itself gets transformed into
an OP_FUNCALL, with the same issue, and eventually, the resolved
expression now looks like this:

     0  BINOP_ADD
     1    OP_FUNCALL            Number of args: 0
     4      OP_VAR_VALUE          Block @0x2021550, symbol @0x20213a0 (pck.something)
     8    OP_FUNCALL            Number of args: 0
    11      OP_VAR_VALUE          Block @0x2021550, symbol @0x20213a0 (pck.something)
    15  OP_VAR_VALUE          Block @0x2021550, symbol @0x20213a0 (pck.something)
    19  OP_LONG               Type @0x1e3c170 (int), value 1 (0x1)

This explains why we get twice the result of the function call
instead of its value plus one. The extra entries in the expression
at the end are just ignored.

This patch fixes the issue by calling replace_operator_with_call
with the correct OPLEN equal to the size of an OP_VAR_VALUE (4).

gdb/ChangeLog:

        * ada-lang.c (resolve_subexp): Pass correct OPLEN in call to
        replace_operator_with_call.

gdb/testsuite/ChangeLog:

        * gdb.ada/expr_with_funcall: New testcase.
2018-09-08 17:51:36 -04:00
Joel Brobecker 95f39a5b27 ada-lang.c::ada_value_cast: remove unnecessary parentheses
No other code change.

gdb/ChangeLog:

        * ada-lang.c (ada_value_cast): Remove unnecessary parentheses.
2018-09-08 17:50:00 -04:00
Joel Brobecker 16b9eb7bfa (Ada) slightly incorrect bounds for type of array indexed by enum
Consider the following code:

   type Enumerated is (Enum_A, Enum_B, Enum_C, Enum_Last);
   type Table is array (Enumerated) of Integer;
   --  Declare a variable of type Table to make sure the compiler
   --  does emit the debugging information for that type.
   V : Table := (others => 1);

Trying to print the type description of type Table, or of variable V
yields:

    (gdb) ptype v
    type = array (0 .. 3) of integer
    (gdb) ptype example.table
    type = array (0 .. 3) of integer

The compiler generates an XA type for the bounds...

 <1><cf6>: Abbrev Number: 13 (DW_TAG_structure_type)
    <cf7>   DW_AT_name        : example__table___XA

... whose member is described as being as:

 <2><cfe>: Abbrev Number: 14 (DW_TAG_member)
    <cff>   DW_AT_name        : example__enumerated
    <d05>   DW_AT_type        : <0xc69>

This leads us to DIE 0xc69, which is our enumeration type:

 <2><c69>: Abbrev Number: 4 (DW_TAG_enumeration_type)
    <c6a>   DW_AT_name        : example__enumerated

Normally, for arrays, we expect a range type, rather than an enumerated
type. However, for a situation like this, where the range of the array
index is the full enumeration type, it seems like a waste to require
an extra range layer.

Instead, looking at print_range, we see that we print the bounds
of our range using the target type:

       target_type = TYPE_TARGET_TYPE (type);
       if (target_type == NULL)
         target_type = type;
       [...]
       ada_print_scalar (target_type, lo, stream);
       fprintf_filtered (stream, " .. ");
       ada_print_scalar (target_type, hi, stream);

In this case, this causes us to use the enumerated type's subtype,
which is a plain integer type, hence the output we get. However,
there is no reason for using the target type, even in the TYPE_CODE_RANGE
situation. So this patch fixes the issue by simply printing the bounds
using the type being given, instead of its target type.

gdb/ChangeLog:

        * ada-typeprint.c (print_range): Print the bounds using TYPE
        rather than its TYPE_TARGET_TYPE.

A new test for this isn't necessary, as existing tests will demonstrate
this issue once a change in the compiler triggering the generation of
this type of debugging info gets pushed.
2018-09-08 17:49:10 -04:00
Joel Brobecker d8ce91275e minor reformatting in ada-lang.c::ada_to_fixed_value
The arguments in the call to ada_to_fixed_value_create where
improperly aligned. But I also noticed that all the arguments
do fit on a single-line (up to 79 characters). So this patch
just fixes the code by putting everything on that same line.

gdb/ChangeLog:

        * ada-lang.c (ada_to_fixed_value): Minor reformatting in
        call to ada_to_fixed_value_create.
2018-09-08 17:48:04 -04:00
Jerome Guitton 0d81f350ec Handle PPC64 function descriptor in Ada decoding
On PPC64, the entry point of the function "FN" is ".FN" when a function
descriptor is used. One of the consequences of this is that GDB then
presents the name of the function to the user (eg: in backtraces) with
the leading dot, which is a low-level internal detail that the user
should not be seeing.  The Ada decoding should strip it.

gdb/ChangeLog:

	* ada-lang.c (ada_decode): strip dot prefix in symbol name.

No testcase added, as a number of existing testcases should already
demonstrate that problem.
2018-09-08 17:47:11 -04:00
Joel Brobecker 57aff202b4 (Ada) "catch assert" spurious internal error
We noticed while debugging a program compiled without assertions
enabled and using an older compiler that inserting a catchpoint
on failed assertions would cause an internal error:

    (gdb) catch assert
    ../../src/gdb/ada-lang.c:13321: internal-error: ada_exception_sal:
    Assertion`sym != NULL' failed.
    A problem internal to GDB has been detected,

This is due to a combination of factors:

  1. With older versions of the compiler, the function used as a hook
     was provided by a unit that's different from the unit which
     provides the hooks for the other exception catchpoints.

  2. The program either does not use any assertion, or is compiled
     without the assertions enabled.

With newer versions of the compiler, all such functions are provided
by the same unit, so should normally always be available.  However,
there can still be reasons why this is not the case. Consider, for
instance, the case of a runtime compiled with -ffunction-sections,
in which case the hook might be eliminated unless assertions are
used and enabled.

So this patch transforms the internal error into a simple error.

gdb/ChangeLog:

        * ada-lang.c (ada_exception_sal): Replace gdb_assert calls
        by calls to error.

No testcase added, as the existing testcase gdb.ada/catch_ex.exp
should trigger it when using an older version of GNAT as the Ada
compiler.
2018-09-08 17:46:08 -04:00
Joel Brobecker fb44b1a737 (Ada) infinite loop when hitting unhandled exception catchpoint
When debugging a program compiled with an older version of GNAT,
hitting a catchpoint on unhandled exceptions can caused GDB to
got into an infinite loop. This happens while trying to find
the name of the exception that was raised. For that, it searches
for a frame corresponding to a specific function we know gets
called during the exeption handling.

In our particular case, the compiler was too old, and so GDB never
found that frame, and eventually got past the "main" subprogram,
all the way to system frames, where no symbol was available.
As a result, the code addresses could not be resolved into
a function name, leading to the infinite loop because of
a misplaced update of our loop variable "fi":

    while (fi != NULL)
      {
        char *func_name;
        enum language func_lang;

        find_frame_funname (fi, &func_name, &func_lang, NULL);
        if (func_name != NULL)
          {
            make_cleanup (xfree, func_name);

            if (strcmp (func_name,
                        data->exception_info->catch_exception_sym) == 0)
              break; /* We found the frame we were looking for...  */
            fi = get_prev_frame (fi);
          }
      }

If FUNC_NAME is NULL, then FI never gets updated ever after!

gdb/ChangeLog:

        * ada-lang.c (ada_unhandled_exception_name_addr_from_raise):
        Move update of loop variable "fi".

No testcase added, as the existing testcase gdb.ada/catch_ex.exp
should trigger it when using an older version of GNAT as the Ada
compiler.
2018-09-08 17:45:25 -04:00
Joel Brobecker 2a62dfa93f (Ada) assigning packed array aggregate with variable as component
Consider a variable "PRA" defined as a packed array of packed
records as follow:

   subtype Int is Integer range 0 .. 7;
   type Packed_Rec is record
      X, Y : Int;
      W    : Integer;
   end record;
   pragma Pack (Packed_Rec);
   type Packed_RecArr is array (Integer range <>) of Packed_Rec;
   pragma Pack (Packed_RecArr);

   PRA : Packed_RecArr (1 .. 3);

Consider also a variable "PR", which is a Packed_Rec record,
declared as follow:

   PR : Packed_Rec := (2, 2, 2);

Trying to assign a new value to PRA using an aggregate expression
where one of the components is our variable PR yields the wrong
result on big-endian machines (e.g. on ppc-linux):

    (gdb) p pra := (pr, (2,2,2), (2,2,2))
    $6 = ((x => 1, y => 0, w => 8), [...]

On the other hand, replacing "pr" by "(2,2,2)" does work.

I tracked the issue down to the bit offset we use to extract
the value of "PR" and copy it inside PRA. in value_assign_to_component,
we have:

  if (gdbarch_bits_big_endian (get_type_arch (value_type (container))))
    move_bits ([target buffer], [bit offset in target buffer],
               [source buffer where PR is stored],
               TYPE_LENGTH (value_type (component)) * TARGET_CHAR_BIT - bits,
               bits, 1);

The issue is with the third-to-last argument, which provides the bit
offset where the value of PR is stored relative to its start address,
and therefore the bit offset relative to the start of the source
buffer passed as the previous argument.

In our case, component is a 38bit packed record whose TYPE_LENGTH
is 5 bytes, so the bit-offset that gets calculated is 2 (bits).
However, that formula only really applies to scalars, whereas
in our case, we have a record (struct). The offset in the non-scalar
case should be zero.

gdb/ChangeLog:

        * ada-lang.c (value_assign_to_component): In the case of
        big-endian targets, extract the bits of the given VAL
        using an src_offset of zero if container is not a scalar.

gdb/testsuite/ChangeLog:

        * gdb.ada/packed_array_assign: New testcase.
2018-09-08 17:44:36 -04:00
John Darrington d1908f2d6b gdb: Add builtin types for 24 bit integers.
Add int24 and uint24.  These are used by the upcoming S12Z target, but will be
needed for any arch which features 24 bit registers.

* gdb/gdbtypes.h (struct builtin_type): New members builtin_int24
  and builtin_uint24;
* gdb/gdbtypes.c: Initialize them.
* gdb/doc/gdb.texinfo (Predefined Target Types): Mention types int24 and uint24.
2018-09-08 13:21:30 +02:00
Andrew Burgess 96b6697fd8 gdb/testsuite: Make test names unique in gdb.base/watchpoint.exp
Extend test names and add test name prefixes to make test names
unique.

gdb/testsuite/ChangeLog:

	* gdb.base/watchpoint.exp (test_complex_watchpoint): Extend test
	names, and add test prefixes to make test names unique.
2018-09-07 14:06:53 +01:00
Simon Ser 739ab2e92e Generate NT_PROCSTAT_{AUXV,VMMAP,PS_STRINGS} in FreeBSD coredumps
gcore generates NT_AUXV and NT_FILE notes for Linux targets.  On
FreeBSD auxv is stored in a NT_PROCSTAT_AUXV section, virtual memory
mappings are stored in a NT_PROCSTAT_VMMAP, and both are prefixed with
the struct size.  In addition, store a NT_PROCSTAT_PS_STRINGS note
saving the initial location of the argv[] and environment[] arrays.

gdb/ChangeLog:

	PR gdb/23105
	* fbsd-nat.c (fbsd_nat_target::xfer_partial): Add support for
	TARGET_OBJECT_FREEBSD_VMMAP and TARGET_OBJECT_FREEBSD_PS_STRINGS.
	* fbsd-tdep.c (fbsd_make_note_desc): New.
	(fbsd_make_corefile_notes): Write NT_PROCSTAT_AUXV,
	NT_PROCSTAT_VMMAP and NT_PROCSTAT_PS_STRINGS notes.
	* target.h (enum target_object) Add FreeBSD-specific
	TARGET_OBJECT_FREEBSD_VMMAP and TARGET_OBJECT_FREEBSD_PS_STRINGS.
2018-09-06 15:07:59 -07:00
Simon Marchi d82b3862f1 compile: Remove non-const reference parameters
As mentioned here:

  https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Avoid_non-const_reference_parameters.2C_use_pointers_instead

we prefer to avoid non-const references.  This patch changes the
non-const references I could find in the compile/ directory, either by
making them rvalue-reference (&&) or changing them to pointers.

I'd say all the changes are pretty obvious, except the one in
compile_cplus_instance::enter_scope which might require more attention.

gdb/ChangeLog:

	* compile/compile-c.h (generate_c_for_variable_locations):
	Change reference to pointer.
	* compile/compile-c-support.c (compile_program) <compute>:
	Likewise.
	* compile/compile-c-symbols.c (generate_vla_size): Likewise.
	(generate_c_for_for_one_variable): Likewise
	(generate_c_for_variable_locations): Likewise
	* compile/compile-c-types.c (compile_c_instance::convert_type):
	Likewise
	* compile/compile-cplus-symbols.c (convert_one_symbol):
	std::move the scope passed to enter_scope.
	* compile/compile-cplus-types.c
	(compile_cplus_instance::enter_scope): Make parameter
	rvalue-reference.
	(compile_cplus_instance::new_scope): Change reference to
	pointer.
	(compile_cplus_instance::convert_type): Likewise
	(compile_cplus_convert_typedef): std::move the scope passed to
	enter_scope.
	(compile_cplus_convert_struct_or_union): Likewise.
	(compile_cplus_convert_enum): Likewise.
	(compile_cplus_convert_namespace): Likewise.
	* compile/compile-cplus.h (compile_cplus_instance)
	<enter_scope>: Make parameter rvalue-reference.
	* compile/compile-internal.h (compile_instance)
	<get_cached_type>: Likewise
	* compile/compile-loc2c.c (push): Likewise
	(pushf): Likewise
	(unary): Likewise
	(binary): Likewise
	(print_label): Likewise
	(pushf_register_address): Likewise
	(pushf_register): Likewise
	(do_compile_dwarf_expr_to_c): Likewise
	(compile_dwarf_expr_to_c): Likewise
	(compile_dwarf_bounds_to_c): Likewise
	* compile/compile.c (compile_instance::get_cached_type):
	Likewise
	* compile/compile.h (compile_dwarf_expr_to_c): Likewise.
	(compile_dwarf_bounds_to_c): Likewise
	* dwarf2loc.c (locexpr_generate_c_location): Likewise.
	(dwarf2_compile_property_to_c): Likewise
	* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise
	* symtab.h (struct symbol_computed_ops) <generate_c_location>:
	Likewise
2018-09-06 13:48:15 +01:00
Simon Marchi cc5a5ae5b7 Remove unused tui_win_element::highlight
gdb/ChangeLog:

	* tui/tui-data.h (struct tui_win_element) <highlight>: Remove.
	* tui/tui-data.c (init_content_element): Don't initialize it.
2018-09-06 13:35:53 +01:00
Simon Marchi 137be54029 Remove unused tui_win_info::detail::opaque
gdb/ChangeLog:

	* tui/tui-data.h (struct tui_win_info)
	<detail::opaque>: Remove.
	* tui/tui-data.c (init_win_info): Remove assignment.
2018-09-06 12:08:33 +01:00
Tom Tromey f1628857d7 Make -Wformat-nonliteral work with gcc
After looking into why the build failed for Simon but not for me, we
found that the underlying cause was due to how gcc treats
-Wformat-nonliteral.  gcc requires -Wformat to be given first; but
warning.m4 was not doing this, so -Wformat-nonliteral was not being
used.

This patch changes warning.m4 to account gcc's requirement.

This then showed that the target-float.c build change in the earlier
Makefile patch was also incorrect.  Simon didn't see this in his
build, but gcc now points it out.  So, this patch fixes this problem
as well.

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

	* warning.m4 (AM_GDB_WARNINGS): Add -Wformat when testing
	-Wformat-nonliteral.
	* target-float.c (host_float_ops<T>::to_string)
	(host_float_ops<T>::from_string): Use
	DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL.
	* configure: Rebuild.

gdb/gdbserver/ChangeLog
2018-09-05  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-09-05 21:47:33 -06:00
Simon Marchi af39b1c216 Disable -Wformat-nonliteral in parts of printcmd.c
commit 3322c5d9a1 ("Remove unneeded explicit .o targets") broke the
build with clang, because -Wno-format-nonliteral was in fact needed.
This patch fixes the problem by introducing
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL and using it in printcmd.c.  This
seems preferable to reverting the patch because now the warning
suppression is more targeted.

gdb/ChangeLog
2018-09-05  Simon Marchi  <simon.marchi@ericsson.com>

	* printcmd.c (printf_c_string): Use
	DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL.
	(printf_wide_c_string, printf_pointer, ui_printf): Likewise.

include/ChangeLog
2018-09-05  Simon Marchi  <simon.marchi@ericsson.com>

	* diagnostics.h (DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL): New macro.
2018-09-05 21:47:33 -06:00
Tom Tromey 081bca4d62 Remove unnecessary casts from cli-cmds.c
I noticed a couple of unnecessary casts in cli-cmds.c.  This patch
removes them.

Tested by rebuilding.  I'm checking this in.

gdb/ChangeLog
2018-09-05  Tom Tromey  <tom@tromey.com>

	* cli/cli-cmds.c (shell_escape, edit_command): Remove cast.
2018-09-05 09:23:22 -06:00
Tom de Vries e4a62c65fa [gdb/exp] Handle DW_OP_GNU_variable_value refs to abstract dies
Consider a vla variable 'a' in function f1:
...
 <2><1a7>: Abbrev Number: 11 (DW_TAG_variable)
    <1a8>   DW_AT_description : a
    <1aa>   DW_AT_abstract_origin: <0x311>
...
with abstract origin 'a':
...
 <2><311>: Abbrev Number: 3 (DW_TAG_variable)
    <312>   DW_AT_name        : a
    <317>   DW_AT_type        : <0x325>
...
and inherited abstract vla type:
...
 <1><325>: Abbrev Number: 9 (DW_TAG_array_type)
    <326>   DW_AT_type        : <0x33a>
 <2><32e>: Abbrev Number: 10 (DW_TAG_subrange_type)
    <32f>   DW_AT_type        : <0x2ea>
    <333>   DW_AT_upper_bound : 5 byte block: fd 1b 3 0 0
                                (DW_OP_GNU_variable_value: <0x31b>)
...
where the upper bound refers to this artificial variable D.1922 without location
attribute:
...
 <2><31b>: Abbrev Number: 8 (DW_TAG_variable)
    <31c>   DW_AT_description : (indirect string, offset: 0x39a): D.1922
    <320>   DW_AT_type        : <0x2ea>
    <324>   DW_AT_artificial  : 1
...

Currently, when we execute "p sizeof (a)" in f1, the upper bound is calculated
by evaluating the DW_OP_GNU_variable_value expression referring to D.1922, but
since that die doesn't have a location attribute, we get:
...
value has been optimized out
...

However, there's also artificial variable D.4283 that is sibling of vla
variable 'a', has artificial variable D.1922 as abstract origin, and has a
location attribute:
...
 <2><1ae>: Abbrev Number: 12 (DW_TAG_variable)
    <1af>   DW_AT_description : (indirect string, offset: 0x1f8): D.4283
    <1b3>   DW_AT_abstract_origin: <0x31b>
    <1b7>   DW_AT_location    : 11 byte block: 75 1 8 20 24 8 20 26 31 1c 9f
                                (DW_OP_breg5 (rdi):1; DW_OP_const1u: 32;
				 DW_OP_shl; DW_OP_const1u: 32; DW_OP_shra;
				 DW_OP_lit1; DW_OP_minus; DW_OP_stack_value)
...

The intended behaviour for DW_OP_GNU_variable_value is to find a die that
refers to D.1922 as abstract origin, has a location attribute and is
'in scope', so the expected behaviour is:
...
$1 = 6
...

The 'in scope' concept can be thought of as variable D.1922 having name
attribute "D.1922", and variable D.4283 inheriting that attribute, resulting
in D.4283 being declared with name "D.1922" alongside vla a in f1, and when we
lookup "DW_OP_GNU_variable_value D.1922", it should work as if we try to find
the value of a variable named "D.1922" on the gdb command line using
"p D.1922", and we should return the value of D.4283.

This patch fixes the case described above, by:
- adding a field abstract_to_concrete to struct dwarf2_per_objfile,
- using that field to keep track of which concrete dies are instances of an
  abstract die, and
- using that information when getting the value DW_OP_GNU_variable_value.

Build and reg-tested on x86_64-linux.

2018-09-05  Tom de Vries  <tdevries@suse.de>

	* dwarf2loc.c (sect_variable_value): Call indirect_synthetic_pointer
	with resolve_abstract_p == true.
	(indirect_synthetic_pointer): Add resolve_abstract_p parameter,
	defaulting to false. Propagate resolve_abstract_p to
	dwarf2_fetch_die_loc_sect_off.
	* dwarf2loc.h (dwarf2_fetch_die_loc_sect_off): Add resolve_abstract_p
	parameter, defaulting to false.
	* dwarf2read.c (read_variable): Add variable to abstract_to_concrete.
	(dwarf2_fetch_die_loc_sect_off): Add and handle resolve_abstract_p
	parameter.
	* dwarf2read.h (struct die_info): Forward-declare.
	(die_info_ptr): New typedef.
	(struct dwarf2_per_objfile): Add abstract_to_concrete field.

	* gdb.dwarf2/varval.exp: Add test.
2018-09-05 10:39:19 +02:00
Joel Brobecker 2b69821e70 Document the GDB 8.2 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 8.2 released.
2018-09-05 10:02:27 +02:00
Sergio Durigan Junior fcc9b044b7 Automatically update "aclocal_m4_deps" when updating gnulib
When we update gnulib using our "update-gnulib.sh" tool, it doesn't
automatically update the list of M4 files present at
gnulib/Makefile.in:aclocal_m4_deps.  This patch extends the tool to do
that.  It also puts "aclocal_m4_deps" in its own file (a Makefile
fragment), so that it's easier to update it programatically.

Tested by generating the file and diff'ing the results against the
current version of "aclocal_m4_deps".

gdb/ChangeLog:
2018-09-04  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gnulib/Makefile.in (aclocal_m4_deps): Move to
	"aclocal-m4-deps.mk".  Include file here.
	$(srcdir)/aclocal.m4: Add "configure.ac".
	* gnulib/aclocal-m4-deps.mk: New file.
	* gnulib/update-gnulib.sh: Automatically update
	"aclocal-m4-deps.mk".
2018-09-04 13:58:14 -04:00
Tom Tromey d53d543682 Remove --enable-multi-ice
gdb's configure script accepts --enable-multi-ice, but the code this
refers to is long gone.  This patch removes the option entirely.

gdb/ChangeLog
2018-09-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Remove multi-ice code.
2018-09-04 10:45:55 -06:00
Tom Tromey 8dc9fd87b0 Simplify ada-exp.o rule
The ada-exp.o rule no longer needs to pass -Wno-old-style-definition
to the compiler, as this option has no meaning in C++.  So, This patch
simplifies the explicit ada-exp.o rule in the Makefile.  The rule is
still needed because, according to the comment, ada-exp.c may appear
in the srcdir.

gdb/ChangeLog
2018-09-04  Tom Tromey  <tom@tromey.com>

	* Makefile.in (GDB_WARN_CFLAGS_NO_DEFS): Remove.
	(ada-exp.o): Update.
2018-09-04 10:45:55 -06:00
Tom Tromey 3322c5d9a1 Remove unneeded explicit .o targets
Makefile.in had special cases to compile printcmd.o and target-float.o
with a different set of warnings.  However, this is no longer
required, so this patch removes those rules.

gdb/ChangeLog
2018-09-04  Tom Tromey  <tom@tromey.com>

	* Makefile.in (printcmd.o, target-float.o): Remove.
	(GDB_WARN_CFLAGS_NO_FORMAT): Remove.
2018-09-04 10:45:54 -06:00
Tom Tromey ba2bf2aaba Remove obsolete comments from Makefiles
This removes an obsolete comment from Makefile.in.  This was copied
into gnulib/Makefile.in, so this removes that comment as well.

gdb/ChangeLog
2018-09-04  Tom Tromey  <tom@tromey.com>

	* gnulib/Makefile.in: Remove obsolete comment.
	* Makefile.in: Remove obsolete comment.
2018-09-04 10:45:54 -06:00
Gary Benson dd083ee23d Fix batch exit status test failure on Fedora 28
This commit adds calls to remote_close and clear_gdb_spawn_id to
gdb.base/batch-exit-status.exp, fixing failures reported by buildbot
on Fedora 28 where gdb_spawn_id not being reset by the previous test
caused default_gdb_spawn to return without spawning.

This commit also changes the test to use detect GDB's exit using
gdb_test_multiple expecting 'eof', rather than using 'wait -i' alone.
This means the testcase won't hang forever on failure as fixed in
gdb.base/quit.exp by commit 15763a09d4 ("Fix 'gdb.base/quit.exp
hangs forever' if the test fails").

gdb/testsuite/ChangeLog:

	* gdb.base/batch-exit-status.exp: Use gdb_test_multiple and expect
	'eof' before 'wait -i'.  Use remote_close and clear_gdb_spawn_id.
2018-09-04 15:29:20 +01:00
Andrew Burgess 6c9d681b07 gdb/riscv: Fix an ARI warning
This patch fixes an ARI violation in riscv-tdep.c (line ends with
'+').

gdb/ChangeLog:

	* riscv-tdep.c (riscv_frame_cache): Fix ARI warning, don't end a
	line with '+'.
2018-09-04 11:52:25 +01:00
Andrew Burgess 78a3b0fab8 gdb/riscv: Provide non-DWARF stack unwinder
Collects information during the prologue scan and uses this to unwind
registers when no DWARF information is available.

This patch has been tested by disabling the DWARF stack unwinders, and
running the complete GDB testsuite against a range of RISC-V targets.
The results are comparable to running with the DWARF unwinders in
place.

gdb/ChangeLog:

	* riscv-tdep.c: Add 'prologue-value.h' include.
	(struct riscv_unwind_cache): New struct.
	(riscv_debug_unwinder): New global.
	(riscv_scan_prologue): Update arguments, capture register details
	from prologue scan.
	(riscv_skip_prologue): Reformat arguments line, move end of
	prologue calculation into riscv_scan_prologue.
	(riscv_frame_cache): Update return type, create
	riscv_unwind_cache, scan the prologue, and fill in remaining cache
	details.
	(riscv_frame_this_id): Use frame id computed in riscv_frame_cache.
	(riscv_frame_prev_register): Use the trad_frame within the
	riscv_unwind_cache.
	(_initialize_riscv_tdep): Add 'set/show debug riscv unwinder'
	flag.
2018-09-03 15:48:41 +01:00
Andrew Burgess 23e60e7a4e gdb: Extend the trad-frame API
Adds two new functions to the trad-frame API and update the internals
of trad-frame to use the new functions.  These functions will be used
in later commits.

gdb/ChangeLog:

	* trad-frame.h (trad_frame_set_realreg): Declare.
	(trad_frame_set_addr): Declare.
	* trad-frame.c (trad_frame_set_realreg): Define new function.
	(trad_frame_set_addr): Define new function.
	(trad_frame_set_reg_realreg): Use new function.
	(trad_frame_set_reg_addr): Use new function.
2018-09-03 15:48:41 +01:00
Keith Seitz 5c889512f3 Fix ARI violations in c++compile
This patch fixes two violations of the ARI (use of ATTRIBUTE_UNUSED and
"%ll").

gdb/ChangeLog

	* compile/compile-cplus-types.c (compile_cplus_debug_output_1): Use
	pulongest instead of "%lld".
	* compile/compile-cplus-symbols.c (gcc_cplus_convert_symbol): Remove
	ATTRIBUTE_UNUSED.
2018-09-01 12:04:29 -07:00
Tom Tromey c8c8163573 Set TYPE_LENGTH on a variant part
gdb represents a DW_TAG_variant_part as a union.  While normally DWARF
would not set the size of a DW_TAG_variant_part, gdb's representation
requires the TYPE_LENGTH to be set.

This patch arranges to set the TYPE_LENGTH of a variant part if it has
not already been set.

This fixes some Rust regressions when testing against a version of
rustc that emits DW_TAG_variant_part.

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

	* dwarf2read.c (dwarf2_add_field): Set the TYPE_LENGTH of the
	variant part type.
2018-08-31 12:59:16 -06:00
Tom Tromey aef9346c25 Fix a small bug in gdb.rust/simple.rs
I noticed that gdb.rust/simple.rs had two local variables named "v".
This didn't previous cause problems, but with a newer rust compiler
this resulted in a test failure.  (It should have failed all along, so
I suppose earlier passes were due to a compiler bug.)

This patch renames the second variable.

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

	* gdb.rust/simple.rs: Rename second variable "v".
2018-08-31 12:59:16 -06:00
Pedro Alves 0c8885885a Regenerate gdbarch.h
The previous commit included a stale gdbarch.h from an earlier version
of that patch by mistake.

gdb/ChangeLog:
2018-08-31  Pedro Alves  <palves@redhat.com>

	* gdbarch.h: Regenerate.
2018-08-31 18:56:10 +01:00
Pedro Alves 7ea65f08fa Add comment describing continuable/steppable/non-steppable watchpoints
These weren't described anywhere in the sources.

gdb/ChangeLog:
2018-08-31  Pedro Alves  <palves@redhat.com>

	* gdbarch.sh (have_nonsteppable_watchpoint): Add comment.
	* target.h (Hardware watchpoint interfaces): Describe
	continuable/steppable/non-steppable watchpoints.
	* gdbarch.h, gdbarch.c: Regenerate.
2018-08-31 18:47:36 +01:00
Pedro Alves 7eb65fafed Eliminate target_have_continuable_watchpoint
target_have_continuable_watchpoint isn't used anywhere so remove it.
The property isn't necessary because checking for "continuable" is the
same as checking for "!steppable && !non-steppable".

gdb/ChangeLog:
2018-08-31  Pedro Alves  <palves@redhat.com>

	* nto-procfs.c (nto_procfs_target::have_continuable_watchpoint):
	Delete.
	* s390-linux-nat.c
	(s390_linux_nat_target::have_continuable_watchpoint): Delete.
	* target.h (target_ops::have_continuable_watchpoint): Delete.
	(target_have_continuable_watchpoint): Delete.
	* x86-nat.h (x86_nat_target::have_continuable_watchpoint): Delete.
	* target-delegates.c: Regenerate.
2018-08-31 18:47:12 +01:00
Sergio Durigan Junior dab999b116 Update gnulib/Makefile.in:aclocal_m4_deps
It was pointed by Pedro that gnulib/Makefile.in should be updated
accordingly after our local gnulib is also updated.  The specific part
that needs to be refreshed is the "aclocal_m4_deps" variable, which
lists the .m4 files present under the "gnulib/import/m4/" directory.
This patch does that.

No regressions introduced.

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

	* gnulib/Makefile.in (aclocal_m4_deps): Update according to
	the files present in "gnulib/import/m4/".
2018-08-31 12:01:32 -04:00
Andrew Burgess ff3a05b3f8 gdb/riscv: Extend instruction decode to cover more instructions
Extends the instruction decoder used during prologue scan and software
single step to cover more instructions.  These instructions are
encountered when running the current GDB testsuite with the DWARF
stack unwinders turned off.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_insn::decode): Decode c.addi4spn, c.sd,
	c.sw, c.swsp, and c.sdsp.
2018-08-30 16:35:55 +01:00
Andrew Burgess 0b3f9efc04 gdb/riscv: remove extra caching of misa register
The RISC-V had a mechanism in place to cache the contents of the misa
register per-inferior, the original intention behind this was to
reduce the number of times the misa register had to be read (as the
contents should be constant), but it was pointed out on the mailing
list[1] that the register cache will mean the register is only
accessed once each time GDB stops, and any additional caching is
probably just unneeded extra complexity.

As such, until it can be shown that there's a real need for additional
caching, this commit removes all of the additional caching of the misa
register, and just accesses the misa register like a normal register.

[1] https://sourceware.org/ml/gdb-patches/2018-03/msg00136.html

gdb/ChangeLog:

	* riscv-tdep.c (struct riscv_inferior_data): Delete.
	(riscv_read_misa_reg): Don't cache value read into inferior data.
	(riscv_new_inferior_data): Delete.
	(riscv_inferior_data_cleanup): Delete.
	(riscv_inferior_data): Delete.
	(riscv_invalidate_inferior_data): Delete.
	(_initialize_riscv_tdep): Remove initialisation of inferior data.
2018-08-30 16:35:54 +01:00
Andrew Burgess c67f2e1518 gdb: Ensure compiler doesn't optimise variable out in test
In the test gdb.base/funcargs.exp, there's this function:

    void recurse (SVAL a, int depth)
    {
      a.s = a.i = a.l = --depth;
      if (depth == 0)
        hitbottom ();
      else
        recurse (a, depth);
    }

The test script places a breakpoint in hitbottom, and runs the
executable which calls recurse with an initial depth of 4.

When GDB hits the breakpoint in hitbottom the testscript performs a
backtrace, and examines 'a' at each level.

The problem is that 'a' is not live after either the call to
'hitbottom' or the call to 'recurse', and as a result the test fails.

In the particular case I was looking at GCC for RISC-V 32-bit, the
variable 'a' is on the stack and GCC selects the register $ra (the
return address register) to hold the pointer to 'a'.  This is fine,
because, by the time the $ra register is needed to hold a return
address (calling hitbottom or recurse) then 'a' is dead.

In this patch I propose that a use of 'a' is added after the calls to
hitbottom and recurse, this should cause the compiler to keep 'a'
around, which should ensure GDB can find it.

gdb/testsuite/ChangeLog:

	* gdb.base/funcargs.c (use_a): New function.
	(recurse): Call use_a.
2018-08-30 16:33:49 +01:00
Simon Marchi a0dc02a6df Fix compile-cplus-types.c build errors
I see these errors when building with clang:

  CXX    compile/compile-cplus-types.o
/home/emaisin/src/binutils-gdb/gdb/compile/compile-cplus-types.c:306:56: error: cannot pass non-trivial object of type 'compile_scope' to variadic function; expected type from format string was 'void *' [-Wnon-pod-varargs]
        fprintf_unfiltered (gdb_stdlog, "leaving scope %p\n", current);
                                                       ~~     ^~~~~~~
/home/emaisin/src/binutils-gdb/gdb/compile/compile-cplus-types.c:1058:13: error: comparison of two values with different enumeration types ('enum_flags<gcc_cp_qualifiers>::enum_type' (aka 'gcc_cp_qualifiers') and 'gcc_cp_ref_qualifiers') [-Werror,-Wenum-compare]
  if (quals != GCC_CP_REF_QUAL_NONE)
      ~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~

Fix the first one by using host_address_to_string.

Fix the second one by comparing to 0 instead.  I think the current
comparison simply uses the wrong enum type.  Comparing to 0 seems like
the right thing to do, because we want to check whether any flags are
specified.

gdb/ChangeLog:

	* compile/compile-cplus-types.c
	(compile_cplus_instance::leave_scope): Take the address of scope
	object.
	(compile_cplus_instance::convert_qualified_base): Compare quals
	to 0.
2018-08-30 11:09:48 -04:00
Keith Seitz fdad7678b7 Use host_address_to_string in compile_cplus_instance::enter_scope
This patch fixes a problem being reported by the buildbot with an
invalid argument to a "%p" printf format. Instead of "%p", the
debug output is changed to use "%s" and host_address_to_string.

gdb/ChangeLog

	* compile/compile-cplus-types.c (compile_cplus_instance::enter_scope):
	Use "%s" and host_address_to_string instead of "%p" in printf.
2018-08-30 07:47:03 -07:00
Keith Seitz 078a020797 C++ compile support
This patch adds *basic* support for C++ to the compile feature.  It does
most simple type conversions, including everything that C compile does and
your basic "with-classes" type of C++.

I've written a new compile-support.exp support file which adds a new test
facility for automating and simplifying "compile print" vs "compile code"
testing.  See testsuite/lib/compile-support.exp and CompileExpression
for more on that.  The tests use this facility extensively.

This initial support has several glaring omissions:
- No template support at all
  I have follow-on patches for this, but they add much complexity
  to this "basic" support.  Consequently, they will be submitted separately.
- Cannot print functions
  The code template needs tweaking, and I simply haven't gotten to it yet.
- So-called "special function" support is not included
  Using constructors, destructors, operators, etc will not work. I have
  follow-on patches for that, but they require some work because of the
  recent churn in symbol searching.
- There are several test suite references to "compile/1234" bugs.
  I will file bugs and update the test suite's bug references before pushing
  these patches.

The test suite started as a copy of the original C-language support, but
I have written tests to exercise the basic functionality of the plug-in.

I've added a new option for outputting debug messages for C++ type-conversion
("debug compile-cplus-types").

gdb/ChangeLog:

	* Makefile.in (SUBDIR_GCC_COMPILE_SRCS): Add compile-cplus-symbols.c
	and compile-cplus-types.c.
	(HFILES_NO_SRCDIR): Add gcc-cp-plugin.h.
	* c-lang.c (cplus_language_defn): Set C++ compile functions.
	* c-lang.h (cplus_get_compile_context, cplus_compute_program):
	Declare.
	* compile/compile-c-support.c: Include compile-cplus.h.
	(load_libcompile): Templatize.
	(get_compile_context): "New" function.
	(c_get_compile_context): Use get_compile_context.
	(cplus_get_compile_context): New function.
	(cplus_push_user_expression, cplus_pop_user_expression)
	(cplus_add_code_header, cplus_add_input, cplus_compile_program)
	(cplus_compute_program): Define new structs/functions.
	* compile/compile-cplus-symmbols.c: New file.
	* compile/compile-cplus-types.c: New file.
	* compile/compile-cplus.h: New file.
	* compile/compile-internal.h (debug_compile_oracle, GCC_TYPE_NONE):
	Declare.
	* compile/compile-object-load.c (get_out_value_type): Use
	strncmp_iw when comparing symbol names.
	(compile_object_load): Add mst_bss and mst_data.
	* compile/compile.c (_initialize_compile): Remove
	-Wno-implicit-function-declaration from `compile_args'.
	* compile/gcc-cp-plugin.h: New file.
	* NEWS: Mention C++ compile support and new debug options.

gdb/testsuite/ChangeLog:

	* gdb.compile/compile-cplus-anonymous.cc: New file.
	* gdb.compile/compile-cplus-anonymous.exp: New file.
	* gdb.compile/compile-cplus-array-decay.cc: New file.
	* gdb.compile/compile-cplus-array-decay.exp: New file.
	* gdb.compile/compile-cplus-inherit.cc: New file.
	* gdb.compile/compile-cplus-inherit.exp: New file.
	* gdb.compile/compile-cplus-member.cc: New file.
	* gdb.compile/compile-cplus-member.exp: New file.
	* gdb.compile/compile-cplus-method.cc: New file.
	* gdb.compile/compile-cplus-method.exp: New file.
	* gdb.compile/compile-cplus-mod.c: "New" file.
	* gdb.compile/compile-cplus-namespace.cc: New file.
	* gdb.compile/compile-cplus-namespace.exp: New file.
	* gdb.compile/compile-cplus-nested.cc: New file.
	* gdb.compile/compile-cplus-nested.exp: New file.
	* gdb.compile/compile-cplus-print.c: "New" file.
	* gdb.compile/compile-cplus-print.exp: "New" file.
	* gdb.compile/compile-cplus-virtual.cc: New file.
	* gdb.compile/compile-cplus-virtual.exp: New file.
	* gdb.compile/compile-cplus.c: "New" file.
	* gdb.compile/compile-cplus.exp: "New" file.
	* lib/compile-support.exp: New file.

doc/ChangeLog:

	* gdb.texinfo (Compiling and injecting code in GDB): Document
	set/show "compile-oracle" and "compile-cplus-types" commands.
2018-08-29 15:12:24 -07:00
Keith Seitz fcaad03cc0 Add new search_symbols_multiple API
This patch adds a new symbol searching API based on linespec.c's parser
implementation.  This allows users to find "all* matching symbols instead
of the first found match (a la lookup_symbol).

gdb/ChangeLog:

	* linespec.c (collect_info::add_symbol): Make virtual.
	(struct symbol_searcher_collect_info): New struct.
	(symbol_searcher::find_all_symbols): New method.
	* symtab.h (class symbol_searcher): New class.
2018-08-29 15:12:23 -07:00
Keith Seitz 7e41c8db84 Use block_symbol in linespec APIs
This patch changes the linespec.c APIs to use block_symbol instead of just
a symbol.  lookup_symbol et al already return block_symbol's.

gdb/ChangeLog:

	* linespec.c (struct linespec) <function_symbols, label_symbols>:
	Change to vector of block_symbol.  Update all users.
	(struct collect_info) <symbols>: Likewise.
	(collect_info::add_symbol): Take block_symbol as argument.
	Update all callers.
	(decode_compound_collector) <m_symbols>: Change type to vector
	of block_symbol.  Update all users.
	(decode_compound_collector::operator ()): Change parameter type
	to block_symbol.
	(find_method, find_function_symbols, find_linespec_symbols)
	(find_label_symbols_in_block, find_label_symbols): Change symbol
	vectors to block_symbol vectors.
	* symtab.h (symbol_found_callback_ftype): Change parameter type to
	block_symbol.
2018-08-29 15:12:23 -07:00
Keith Seitz 63e8c3daad Remove VEC definitions from linespec.c
Since they are now no longer necessary, this patch removes the typedefs
and VEC definitions for bound_minimal_symbol_d and symbolp.

gdb/ChangeLog:

	* linespec.c (symbolp): Remove typedef and VEC definitions.
	(bound_minimal_symbol_d): Likewise.
2018-08-29 15:12:23 -07:00
Keith Seitz 4dedf84da9 Change decode_compound_collector to use std::vector
This patch changes decode_compound_collector to use std::vector instead of
VEC, eliminating a cleanup in the process.

gdb/ChangeLog:

	* linespec.c (decode_compound_collector::decode_compound_collector):
	Remove initialization for `m_symtabs'.
	(decode_compound_collector::release_symbols): Change return type
	to std::vector.  Update all callers.
	(class decode_compound_collector) <m_symbols>: Change type to
	std::vector.
	(lookup_prefix_sym): Change return type to std::vector.  Update all
	callers.
	(compare_symbols): Remove.
	(std_compare_symbols): Rename to `compare_symbols'.
	(find_method): Change `sym_classes' parameter to std::vector.
	Update all callers.  Use std::sort to sort sym_classes.
	(find_linespec_symbols): Remove cleanup.
2018-08-29 15:12:23 -07:00
Keith Seitz c2a031c582 Change `minimal_symbols' to std::vector in linespec.c structures
This patch converts linespec.c's linespec.label_symbols member from a
VEC to a std::vector.

gdb/ChangeLog:

	* linespec.c (struct linespec) <minimal_symbols>: Change type to
	std::vector.  Update all users.
	(convert_linespec_to_sals): Use std::sort to sort minimal symbols.
	(struct collect_info) <minimal_symbols>: Likewise.
	(compare_msymbols): Return bool.  Change parameters to const
	bound_minimal_symbol references.
	(find_method, find_function_symbols, find_linespec_symbols): Change
	`minsyms' parameter to std::vector.  Update all callers.
2018-08-29 15:12:23 -07:00
Keith Seitz 3553eadc8c Change `label_symbols' to std::vector in linespec.c structures
This patch converts linespec.c's linespec.label_symbols member from a
VEC to a std::vector.

gdb/ChangeLog:

	* linespec.c (struct linespec) <label_symbols>: Change type to
	std::vector.  Update all users.
	(find_label_symbols_in_block): Change `result' parameter to
	std::vector.  Update all callers.
	(find_label_symbols): Return std::vector.  Update all callers.
2018-08-29 15:12:23 -07:00
Keith Seitz 7243d0118a Change `function_symbols' to std::vector
This patch changes the `function_symbols'  members in linespec.c structures
from a VEC to a std::vector.

gdb/ChangeLog:

	* linespec.c (struct linespec) <function_symbols>: Change type to
	std::vector.  Update all users.
	(struct collect_info) <function_symbols>: Likewise.
	(convert_linespec_to_sals): Use std::sort to sort function_symbols.
	(std_compare_symbols): New function.
	(find_method, find_function_symbols, find_linespec_symbols)
	(find_label_symbols_in_block): Change `symbols' parameter to
	std::vector.  Update all callers.
	(find_label_symbols): Likewise for `function_symbols' and
	`label_funcs_ret'.
2018-08-29 15:12:23 -07:00
Keith Seitz 2a90824133 Change `file_symtabs' to std::vector
This patch changes the `file_symtabs' members in linespec.c structures
from a VEC to a std::vector (or unique_ptr thereof), eliminating a cleanup
in the process.

gdb/ChangeLog:

	* linespec.c (symtab_vector_up): Define.
	(struct linespec) <file_symtabs>: Change type to std::vector *.
	Update all uses.
	(struct collect_info) <file_symtabs>: Likewise.
	(collect_symtabs_from_filename): Return symtab_vector_up.
	Update all callers.
	(decode_objc): Remove cleanup.
	(symtab_collector::symtab_collector): Initialize `m_symtabs'.
	(symtab_collector::release_symtabs): Return symtab_vector_up.
	Update all callers.
	(class symtab_collector) <m_symtabs>: Change type to symtab_vector_up.
	Update all users.
	(collect_symtabs_from_filename, symtabs_from_filename): Return
	symtab_vector_up.  Update all callers.
2018-08-29 15:12:23 -07:00
Tom Tromey f6c4e3e8a3 Use core_addr_to_string_nz in csky_analyze_prologue
One of the buildbot builders had a failure on a recent try run:

../../binutils-gdb/gdb/csky-tdep.c: In function CORE_ADDR csky_analyze_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, CORE_ADDR, frame_info*, csky_unwind_cache*, lr_type_t):
../../binutils-gdb/gdb/csky-tdep.c:1107:23: error: format %lx expects argument of type long unsigned int, but argument 3 has type CORE_ADDR {aka long long unsigned int} [-Werror=format=]
        "0x%lx\n", addr);
                       ^
../../binutils-gdb/gdb/csky-tdep.c:1419:12: error: format %lx expects argument of type long unsigned int, but argument 3 has type CORE_ADDR {aka long long unsigned int} [-Werror=format=]
        addr);
            ^

The fix is to use core_addr_to_string_nz rather than %lx in
csky-tdep.c.

Tested by rebuilding.  I'm checking this in.

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

	* csky-tdep.c (csky_analyze_prologue): Use
	core_addr_to_string_nz.
2018-08-29 15:33:23 -06:00
Tom Tromey 73c13fe69a Fix windows-nat.c for -Wnarrowing
Sergio pointed out that the Windows builder was failing due to the
-Wnarrowing patch, with:

../../binutils-gdb/gdb/windows-nat.c:301:27: error: narrowing conversion of '3221225477' from 'DWORD {aka long unsigned int}' to 'int' inside { } [-Wnarrowing]
   {-1, GDB_SIGNAL_UNKNOWN}};
                           ^
../../binutils-gdb/gdb/windows-nat.c:301:27: error: narrowing conversion of '3221225725' from 'DWORD {aka long unsigned int}' to 'int' inside { } [-Wnarrowing]
../../binutils-gdb/gdb/windows-nat.c:301:27: error: narrowing conversion of '2147483651' from 'DWORD {aka long unsigned int}' to 'int' inside { } [-Wnarrowing]
../../binutils-gdb/gdb/windows-nat.c:301:27: error: narrowing conversion of '2147483652' from 'DWORD {aka long unsigned int}' to 'int' inside { } [-Wnarrowing]
../../binutils-gdb/gdb/windows-nat.c:301:27: error: narrowing conversion of '3221225614' from 'DWORD {aka long unsigned int}' to 'int' inside { } [-Wnarrowing]

Looking into this, I found two things.

First, in struct xlate_exception, it is better to have "them" be of
type DWORD, as that's the type actually in use.

Second, struct xlate_exception and xlate are not used in this file,
because the code in windows_nat_target::resume is #if'd out.

This patch changes the type of "them", but also similarly #if's out
this object.

In order to avoid a narrowing warning from the -1 entry, at Pedro's
suggestion I have removed this and changed windows_nat_target::resume
to use ranged for.

Tested by rebuilding using the mingw toolchain on x86-64 Fedora 28.  I
also tested it by temporarily removing the "#if 0"s and rebuilding.

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

	* windows-nat.c (struct xlate_exception) <them>: Change type to
	DWORD.
	(xlate): Fix formatting.  Remove last entry.
	(struct xlate_exception, xlate): Comment out.
	(windows_nat_target::resume): Use ranged for.
2018-08-29 14:24:54 -06:00
Jim Wilson 4d3928d7e0 Fix riscv-linux native gdb build failure.
The linux kernel uses NT_PRFPREG.  Glibc before BZ 14890 defines NT_FPREGSET.
After it defines both.  Avoid glibc version dependency by using the gdb header
file instead of the glibc header file, and the macro name that gdb defines
which is NT_FPREGSET.

	gdb/
	* riscv-linux-nat.c: Include elf/common.h instead of elf.h.
	(riscv_linux_nat_target::fetch_registers): Use NT_FPREGSET instead
	of NT_PRFPREG.
	(riscv_linux_nat_target::store_registers): Likewise.
2018-08-29 10:52:42 -07:00
Sergio Durigan Junior 7a6dbc2fdb Update gnulib to current upstream master
It has been a while since we don't update our gnulib copy against
their upstream master branch, so I thought I'd propose this patch.  It
also fixes (at least) one bug reported against GDB:

  https://sourceware.org/bugzilla/show_bug.cgi?id=23558

The problem reported there is about the replacement of 'getcwd' when
cross-compiling GDB.  With our current gnulib copy, the mechanism for
deciding whether to use the system's 'getcwd' or gnulib's version is
too simplistic and pessimistic, so when cross-compiling we always end
up using gnulib's version, which has a limitation: it cannot handle
the situation when the parent directory doesn't have read permissions.

This has been reported against upstream gnulib and the fix has been
pushed here:

  https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=a96d2e67052c879b1bcc5bc461722beac75fc372

I regtested this patch on Fedora 28 x86-64, and there were no
regressions.

OK?

gdb/ChangeLog:

2018-08-29  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR gdb/23555
	PR gdb/23558
	* gnulib/aclocal.m4: Regenerate.
	* gnulib/config.in: Regenerate.
	* gnulib/configure: Regenerate.
	* gnulib/import/Makefile.am: Update.
	* gnulib/import/Makefile.in: Update.
	* gnulib/import/extra/snippet/_Noreturn.h: Rename to...
	* gnulib/import/_Noreturn.h: ... this.
	* gnulib/import/alloca.in.h: Update.
	* gnulib/import/extra/snippet/arg-nonnull.h: Rename to...
	* gnulib/import/arg-nonnull.h: ... this.
	* gnulib/import/assure.h: Update.
	* gnulib/import/at-func.c: Update.
	* gnulib/import/basename-lgpl.c: Update.
	* gnulib/import/extra/snippet/c++defs.h: Rename to...
	* gnulib/import/c++defs.h: ... this.
	* gnulib/import/canonicalize-lgpl.c: Update.
	* gnulib/import/cdefs.h: Update.
	* gnulib/import/chdir-long.c: Update.
	* gnulib/import/chdir-long.h: Update.
	* gnulib/import/cloexec.c: Update.
	* gnulib/import/cloexec.h: Update.
	* gnulib/import/close.c: Update.
	* gnulib/import/closedir.c: Update.
	* gnulib/import/config.charset: Update.
	* gnulib/import/dirent-private.h: Update.
	* gnulib/import/dirent.in.h: Update.
	* gnulib/import/dirfd.c: Update.
	* gnulib/import/dirname-lgpl.c: Update.
	* gnulib/import/dirname.h: Update.
	* gnulib/import/dosname.h: Update.
	* gnulib/import/dup-safer-flag.c: Update.
	* gnulib/import/dup-safer.c: Update.
	* gnulib/import/dup.c: Update.
	* gnulib/import/dup2.c: Update.
	* gnulib/import/errno.in.h: Update.
	* gnulib/import/error.c: Update.
	* gnulib/import/error.h: Update.
	* gnulib/import/exitfail.c: Update.
	* gnulib/import/exitfail.h: Update.
	* gnulib/import/extra/update-copyright: Update.
	* gnulib/import/fchdir.c: Update.
	* gnulib/import/fcntl.c: Update.
	* gnulib/import/fcntl.in.h: Update.
	* gnulib/import/fd-hook.c: Update.
	* gnulib/import/fd-hook.h: Update.
	* gnulib/import/fd-safer-flag.c: Update.
	* gnulib/import/fd-safer.c: Update.
	* gnulib/import/fdopendir.c: Update.
	* gnulib/import/filename.h: Update.
	* gnulib/import/filenamecat-lgpl.c: Update.
	* gnulib/import/filenamecat.h: Update.
	* gnulib/import/flexmember.h: Update.
	* gnulib/import/float+.h: Update.
	* gnulib/import/float.c: Update.
	* gnulib/import/float.in.h: Update.
	* gnulib/import/fnmatch.c: Update.
	* gnulib/import/fnmatch.in.h: Update.
	* gnulib/import/fnmatch_loop.c: Update.
	* gnulib/import/fpucw.h: Update.
	* gnulib/import/frexp.c: Update.
	* gnulib/import/frexpl.c: Update.
	* gnulib/import/fstat.c: Update.
	* gnulib/import/fstatat.c: Update.
	* gnulib/import/getcwd-lgpl.c: Update.
	* gnulib/import/getcwd.c: Update.
	* gnulib/import/getdtablesize.c: Update.
	* gnulib/import/getlogin_r.c: Update.
	* gnulib/import/getprogname.c: Update.
	* gnulib/import/getprogname.h: Update.
	* gnulib/import/gettext.h: Update.
	* gnulib/import/gettimeofday.c: Update.
	* gnulib/import/glob-libc.h: Update.
	* gnulib/import/glob.c: Update.
	* gnulib/import/glob.in.h: Update.
	* gnulib/import/glob_internal.h: Update.
	* gnulib/import/glob_pattern_p.c: Update.
	* gnulib/import/globfree.c: Update.
	* gnulib/import/hard-locale.c: Update.
	* gnulib/import/hard-locale.h: Update.
	* gnulib/import/intprops.h: Update.
	* gnulib/import/inttypes.in.h: Update.
	* gnulib/import/isnan.c: Update.
	* gnulib/import/isnand-nolibm.h: Update.
	* gnulib/import/isnand.c: Update.
	* gnulib/import/isnanl-nolibm.h: Update.
	* gnulib/import/isnanl.c: Update.
	* gnulib/import/itold.c: Update.
	* gnulib/import/libc-config.h: Update.
	* gnulib/import/limits.in.h: Update.
	* gnulib/import/localcharset.c: Update.
	* gnulib/import/localcharset.h: Update.
	* gnulib/import/localtime-buffer.c: Update.
	* gnulib/import/localtime-buffer.h: Update.
	* gnulib/import/lstat.c: Update.
	* gnulib/import/m4/00gnulib.m4: Update.
	* gnulib/import/m4/__inline.m4: Update.
	* gnulib/import/m4/absolute-header.m4: Update.
	* gnulib/import/m4/alloca.m4: Update.
	* gnulib/import/m4/builtin-expect.m4: Update.
	* gnulib/import/m4/canonicalize.m4: Update.
	* gnulib/import/m4/chdir-long.m4: Update.
	* gnulib/import/m4/close.m4: Update.
	* gnulib/import/m4/closedir.m4: Update.
	* gnulib/import/m4/configmake.m4: Update.
	* gnulib/import/m4/d-ino.m4: Update.
	* gnulib/import/m4/d-type.m4: Update.
	* gnulib/import/m4/dirent_h.m4: Update.
	* gnulib/import/m4/dirfd.m4: Update.
	* gnulib/import/m4/dirname.m4: Update.
	* gnulib/import/m4/double-slash-root.m4: Update.
	* gnulib/import/m4/dup.m4: Update.
	* gnulib/import/m4/dup2.m4: Update.
	* gnulib/import/m4/eealloc.m4: Update.
	* gnulib/import/m4/environ.m4: Update.
	* gnulib/import/m4/errno_h.m4: Update.
	* gnulib/import/m4/error.m4: Update.
	* gnulib/import/m4/exponentd.m4: Update.
	* gnulib/import/m4/exponentl.m4: Update.
	* gnulib/import/m4/extensions.m4: Update.
	* gnulib/import/m4/extern-inline.m4: Update.
	* gnulib/import/m4/fchdir.m4: Update.
	* gnulib/import/m4/fcntl-o.m4: Update.
	* gnulib/import/m4/fcntl.m4: Update.
	* gnulib/import/m4/fcntl_h.m4: Update.
	* gnulib/import/m4/fdopendir.m4: Update.
	* gnulib/import/m4/filenamecat.m4: Update.
	* gnulib/import/m4/flexmember.m4: Update.
	* gnulib/import/m4/float_h.m4: Update.
	* gnulib/import/m4/fnmatch.m4: Update.
	* gnulib/import/m4/fnmatch_h.m4: Update.
	* gnulib/import/m4/fpieee.m4: Update.
	* gnulib/import/m4/frexp.m4: Update.
	* gnulib/import/m4/frexpl.m4: Update.
	* gnulib/import/m4/fstat.m4: Update.
	* gnulib/import/m4/fstatat.m4: Update.
	* gnulib/import/m4/getcwd-abort-bug.m4: Update.
	* gnulib/import/m4/getcwd-path-max.m4: Update.
	* gnulib/import/m4/getcwd.m4: Update.
	* gnulib/import/m4/getdtablesize.m4: Update.
	* gnulib/import/m4/getlogin.m4: Update.
	* gnulib/import/m4/getlogin_r.m4: Update.
	* gnulib/import/m4/getpagesize.m4: Update.
	* gnulib/import/m4/getprogname.m4: Update.
	* gnulib/import/m4/gettimeofday.m4: Update.
	* gnulib/import/m4/glibc21.m4: Update.
	* gnulib/import/m4/glob.m4: Update.
	* gnulib/import/m4/glob_h.m4: Update.
	* gnulib/import/m4/gnulib-cache.m4: Update.
	* gnulib/import/m4/gnulib-common.m4: Update.
	* gnulib/import/m4/gnulib-comp.m4: Update.
	* gnulib/import/m4/gnulib-tool.m4: Update.
	* gnulib/import/m4/hard-locale.m4: Update.
	* gnulib/import/m4/include_next.m4: Update.
	* gnulib/import/m4/inttypes-pri.m4: Update.
	* gnulib/import/m4/inttypes.m4: Update.
	* gnulib/import/m4/isnand.m4: Update.
	* gnulib/import/m4/isnanl.m4: Update.
	* gnulib/import/m4/largefile.m4: Update.
	* gnulib/import/m4/limits-h.m4: Update.
	* gnulib/import/m4/localcharset.m4: Update.
	* gnulib/import/m4/locale-fr.m4: Update.
	* gnulib/import/m4/locale-ja.m4: Update.
	* gnulib/import/m4/locale-zh.m4: Update.
	* gnulib/import/m4/localtime-buffer.m4: Update.
	* gnulib/import/m4/longlong.m4: Update.
	* gnulib/import/m4/lstat.m4: Update.
	* gnulib/import/m4/malloc.m4: Update.
	* gnulib/import/m4/malloca.m4: Update.
	* gnulib/import/m4/math_h.m4: Update.
	* gnulib/import/m4/mbrtowc.m4: Update.
	* gnulib/import/m4/mbsinit.m4: Update.
	* gnulib/import/m4/mbsrtowcs.m4: Update.
	* gnulib/import/m4/mbstate_t.m4: Update.
	* gnulib/import/m4/memchr.m4: Update.
	* gnulib/import/m4/memmem.m4: Update.
	* gnulib/import/m4/mempcpy.m4: Update.
	* gnulib/import/m4/memrchr.m4: Update.
	* gnulib/import/m4/mkdir.m4: Update.
	* gnulib/import/m4/mkstemp.m4: Update.
	* gnulib/import/m4/mmap-anon.m4: Update.
	* gnulib/import/m4/mode_t.m4: Update.
	* gnulib/import/m4/msvc-inval.m4: Update.
	* gnulib/import/m4/msvc-nothrow.m4: Update.
	* gnulib/import/m4/multiarch.m4: Update.
	* gnulib/import/m4/nocrash.m4: Update.
	* gnulib/import/m4/off_t.m4: Update.
	* gnulib/import/m4/onceonly.m4: Update.
	* gnulib/import/m4/open-cloexec.m4: Update.
	* gnulib/import/m4/open.m4: Update.
	* gnulib/import/m4/openat.m4: Update.
	* gnulib/import/m4/opendir.m4: Update.
	* gnulib/import/m4/pathmax.m4: Update.
	* gnulib/import/m4/rawmemchr.m4: Update.
	* gnulib/import/m4/readdir.m4: Update.
	* gnulib/import/m4/readlink.m4: Update.
	* gnulib/import/m4/realloc.m4: Update.
	* gnulib/import/m4/rename.m4: Update.
	* gnulib/import/m4/rewinddir.m4: Update.
	* gnulib/import/m4/rmdir.m4: Update.
	* gnulib/import/m4/save-cwd.m4: Update.
	* gnulib/import/m4/secure_getenv.m4: Update.
	* gnulib/import/m4/setenv.m4: Update.
	* gnulib/import/m4/signal_h.m4: Update.
	* gnulib/import/m4/ssize_t.m4: Update.
	* gnulib/import/m4/stat-time.m4: Update.
	* gnulib/import/m4/stat.m4: Update.
	* gnulib/import/m4/std-gnu11.m4: Update.
	* gnulib/import/m4/stdbool.m4: Update.
	* gnulib/import/m4/stddef_h.m4: Update.
	* gnulib/import/m4/stdint.m4: Update.
	* gnulib/import/m4/stdio_h.m4: Update.
	* gnulib/import/m4/stdlib_h.m4: Update.
	* gnulib/import/m4/strchrnul.m4: Update.
	* gnulib/import/m4/strdup.m4: Update.
	* gnulib/import/m4/strerror.m4: Update.
	* gnulib/import/m4/string_h.m4: Update.
	* gnulib/import/m4/strstr.m4: Update.
	* gnulib/import/m4/strtok_r.m4: Update.
	* gnulib/import/m4/sys_socket_h.m4: Update.
	* gnulib/import/m4/sys_stat_h.m4: Update.
	* gnulib/import/m4/sys_time_h.m4: Update.
	* gnulib/import/m4/sys_types_h.m4: Update.
	* gnulib/import/m4/tempname.m4: Update.
	* gnulib/import/m4/time_h.m4: Update.
	* gnulib/import/m4/unistd-safer.m4: Update.
	* gnulib/import/m4/unistd_h.m4: Update.
	* gnulib/import/m4/warn-on-use.m4: Update.
	* gnulib/import/m4/wchar_h.m4: Update.
	* gnulib/import/m4/wchar_t.m4: Update.
	* gnulib/import/m4/wctype_h.m4: Update.
	* gnulib/import/m4/wint_t.m4: Update.
	* gnulib/import/malloc.c: Update.
	* gnulib/import/malloc/scratch_buffer.h: Update.
	* gnulib/import/malloc/scratch_buffer_grow.c: Update.
	* gnulib/import/malloc/scratch_buffer_grow_preserve.c: Update.
	* gnulib/import/malloc/scratch_buffer_set_array_size.c: Update.
	* gnulib/import/malloca.c: Update.
	* gnulib/import/malloca.h: Update.
	* gnulib/import/malloca.valgrind: Update.
	* gnulib/import/math.in.h: Update.
	* gnulib/import/mbrtowc.c: Update.
	* gnulib/import/mbsinit.c: Update.
	* gnulib/import/mbsrtowcs-impl.h: Update.
	* gnulib/import/mbsrtowcs-state.c: Update.
	* gnulib/import/mbsrtowcs.c: Update.
	* gnulib/import/memchr.c: Update.
	* gnulib/import/memmem.c: Update.
	* gnulib/import/mempcpy.c: Update.
	* gnulib/import/memrchr.c: Update.
	* gnulib/import/mkdir.c: Update.
	* gnulib/import/mkstemp.c: Update.
	* gnulib/import/msvc-inval.c: Update.
	* gnulib/import/msvc-inval.h: Update.
	* gnulib/import/msvc-nothrow.c: Update.
	* gnulib/import/msvc-nothrow.h: Update.
	* gnulib/import/open.c: Update.
	* gnulib/import/openat-die.c: Update.
	* gnulib/import/openat-priv.h: Update.
	* gnulib/import/openat-proc.c: Update.
	* gnulib/import/openat.c: Update.
	* gnulib/import/openat.h: Update.
	* gnulib/import/opendir.c: Update.
	* gnulib/import/pathmax.h: Update.
	* gnulib/import/pipe-safer.c: Update.
	* gnulib/import/rawmemchr.c: Update.
	* gnulib/import/readdir.c: Update.
	* gnulib/import/readlink.c: Update.
	* gnulib/import/realloc.c: Update.
	* gnulib/import/ref-add.sin: Update.
	* gnulib/import/ref-del.sin: Update.
	* gnulib/import/rename.c: Update.
	* gnulib/import/rewinddir.c: Update.
	* gnulib/import/rmdir.c: Update.
	* gnulib/import/same-inode.h: Update.
	* gnulib/import/save-cwd.c: Update.
	* gnulib/import/save-cwd.h: Update.
	* gnulib/import/scratch_buffer.h: Update.
	* gnulib/import/secure_getenv.c: Update.
	* gnulib/import/setenv.c: Update.
	* gnulib/import/signal.in.h: Update.
	* gnulib/import/stat-time.c: Update.
	* gnulib/import/stat-time.h: Update.
	* gnulib/import/stat-w32.c: Update.
	* gnulib/import/stat-w32.h: Update.
	* gnulib/import/stat.c: Update.
	* gnulib/import/stdbool.in.h: Update.
	* gnulib/import/stddef.in.h: Update.
	* gnulib/import/stdint.in.h: Update.
	* gnulib/import/stdio.in.h: Update.
	* gnulib/import/stdlib.in.h: Update.
	* gnulib/import/str-two-way.h: Update.
	* gnulib/import/strchrnul.c: Update.
	* gnulib/import/strdup.c: Update.
	* gnulib/import/streq.h: Update.
	* gnulib/import/strerror-override.c: Update.
	* gnulib/import/strerror-override.h: Update.
	* gnulib/import/strerror.c: Update.
	* gnulib/import/string.in.h: Update.
	* gnulib/import/stripslash.c: Update.
	* gnulib/import/strnlen1.c: Update.
	* gnulib/import/strnlen1.h: Update.
	* gnulib/import/strstr.c: Update.
	* gnulib/import/strtok_r.c: Update.
	* gnulib/import/sys_stat.in.h: Update.
	* gnulib/import/sys_time.in.h: Update.
	* gnulib/import/sys_types.in.h: Update.
	* gnulib/import/tempname.c: Update.
	* gnulib/import/tempname.h: Update.
	* gnulib/import/time.in.h: Update.
	* gnulib/import/unistd--.h: Update.
	* gnulib/import/unistd-safer.h: Update.
	* gnulib/import/unistd.in.h: Update.
	* gnulib/import/unsetenv.c: Update.
	* gnulib/import/verify.h: Update.
	* gnulib/import/extra/snippet/warn-on-use.h: Update.
	* gnulib/import/wchar.in.h: Update.
	* gnulib/import/wctype.in.h: Update.
	* gnulib/import/xalloc-oversized.h: Update.
	* gnulib/update-gnulib.sh (GNULIB_COMMIT_SHA1): Set to
	"53e2c179f26a890fa6685af4b6c1397ee370433b".
2018-08-29 12:27:19 -04:00
Gary Benson b0f492b90f Indicate batch mode failures by exiting with nonzero status
This commit causes GDB in batch mode to exit with nonzero status
if the last command to be executed fails.

gdb/ChangeLog:

	PR gdb/13000:
	* gdb/main.c (captured_main_1): Exit with nonzero status
	in batch mode if the last command to be executed failed.
	* NEWS: Mention the above.

gdb/testsuite/ChangeLog:

	PR gdb/13000:
	* gdb.base/batch-exit-status.exp: New file.
	* gdb.base/batch-exit-status.good-commands: Likewise.
	* gdb.base/batch-exit-status.bad-commands: Likewise.
2018-08-29 16:11:50 +01:00
Simon Marchi 2362e7f76a Remove newline at end of warning message
... to fix this ARI warning:

  gdb/csky-tdep.c:1612: gettext: trailing new line: A message should not have a trailing new line
  gdb/csky-tdep.c:1612:    warning (_("Invalid breakpoint address 0x%x is an odd number.\n"),

gdb/ChangeLog:

	* csky-tdep.c (csky_memory_insert_breakpoint): Remove newline at
	end of warning message.
2018-08-29 10:26:11 -04:00
Alan Hayward 36eb4c5f9b infcall-nested-structs: Test up to five fields
Aarch64 can pass structures of up to four members of identical
types in float registers (See AAPCS 5.3 and 5.4). Expand test to
cover this.

Remove the need to specify an additional sets of structures if tB
is not defined.

gdb/testsuite/
	* gdb.base/infcall-nested-structs.c (struct struct01): Remove.
	(struct struct02): Likewise.
	(struct struct03): Likewise.
	(struct struct04): Likewise.
	(struct struct_01_01): New struct.
	(struct struct_01_02): Likewise.
	(struct struct_01_03): Likewise.
	(struct struct_01_04): Likewise.
	(struct struct_02_01): Likewise.
	(struct struct_02_02): Likewise.
	(struct struct_02_03): Likewise.
	(struct struct_02_04): Likewise.
	(struct struct_04_01): Likewise.
	(struct struct_04_02): Likewise.
	(struct struct_04_03): Likewise.
	(struct struct_04_04): Likewise.
	(struct struct_05_01): Likewise.
	(struct struct_05_02): Likewise.
	(struct struct_05_03): Likewise.
	(struct struct_05_04): Likewise.
	(cmp_struct01): Remove function.
	(cmp_struct02): Likewise.
	(cmp_struct03): Likewise.
	(cmp_struct04): Likewise.
	(cmp_struct_01_01): Add Function.
	(cmp_struct_01_02): Likewise.
	(cmp_struct_01_03): Likewise.
	(cmp_struct_01_04): Likewise.
	(cmp_struct_02_01): Likewise.
	(cmp_struct_02_02): Likewise.
	(cmp_struct_02_03): Likewise.
	(cmp_struct_02_04): Likewise.
	(cmp_struct_04_01): Likewise.
	(cmp_struct_04_02): Likewise.
	(cmp_struct_04_03): Likewise.
	(cmp_struct_04_04): Likewise.
	(cmp_struct_05_01): Likewise.
	(cmp_struct_05_02): Likewise.
	(cmp_struct_05_03): Likewise.
	(cmp_struct_05_04): Likewise.
	(call_all): Add new structs.
	* gdb.base/infcall-nested-structs.exp: Likewise.
2018-08-29 11:43:53 +01:00
Alan Hayward 4f4aedebed Aarch64: Float register detection for return values
Use aapcs_is_vfp_call_or_return_candidate to detect float register
args.

gdb/
	PR gdb/22943:
	* aarch64-tdep.c (is_hfa_or_hva): Remove function.
	(aarch64_extract_return_value): Use
	aapcs_is_vfp_call_or_return_candidate.
	(aarch64_return_in_memory): Likewise.
	(aarch64_store_return_value): Likewise.
2018-08-29 11:41:45 +01:00
Alan Hayward 0e745c6011 Aarch64: Float register detection for _push_dummy_call
Use aapcs_is_vfp_call_or_return_candidate to detect float register
args, then pass in registers if there is room.

gdb/
	* aarch64-tdep.c
	(aapcs_is_vfp_call_or_return_candidate): Make static
	(pass_in_v_or_stack): Remove function.
	(pass_in_v_vfp_candidate): New function.
	(aarch64_push_dummy_call): Check for float register candidates.
2018-08-29 11:40:05 +01:00
Alan Hayward ea92689a17 Aarch64: Func to detect args passed in float regs
aapcs_is_vfp_call_or_return_candidate is as an eventual replacement
for is_hfa_or_hva.

This function is based on the GCC code
gcc/config/aarch64/aarch64.c:aarch64_vfp_is_call_or_return_candidate ()

gdb/
	* aarch64-tdep.c (HA_MAX_NUM_FLDS): New macro.
	(aapcs_is_vfp_call_or_return_candidate_1): New function.
	(aapcs_is_vfp_call_or_return_candidate): Likewise.
2018-08-29 11:28:10 +01:00
Simon Marchi ad202fcc22 Get rid of -Wodr warning (PR build/23399)
The PR reports that building with -Wodr -flto complains about different
versions of struct ipa_sym_addresses, in common/agent.c and
gdbserver/tracepoint.c.  This patch renames the version in common to
ipa_sym_addresses_common to avoid the name clash.  Because the IPA_SYM
assumed the name ipa_sym_addresses, it now requires the includer to
define the IPA_SYM_STRUCT_NAME macro to define the name of the structure
holding the IPA symbol addresses.

gdb/ChangeLog:

	PR build/23399
	* common/agent.c (IPA_SYM_STRUCT_NAME): Define.
	(struct ipa_sym_addresses): Rename to...
	(struct ipa_sym_addresses_common): ... this.
	* common/agent.h (IPA_SYM): Use IPA_SYM_STRUCT_NAME.

gdb/gdbserver/ChangeLog:

	PR build/23399
	* tracepoint.c (IPA_SYM_STRUCT_NAME): Define.
2018-08-28 17:23:16 -04:00
Philippe Waroquiers ead9aa39bf Modify gdb.base/commands.exp to test multi breakpoints command clearing.
gdb/testsuite/ChangeLog
2018-08-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/commands.exp: Test multi breakpoints command clearing.
2018-08-28 22:40:59 +02:00
Philippe Waroquiers 999700cd99 Fix regression for multi breakpoints command line clearing.
breakpoint.c is modified to fix the regression introduced
when clearing the commands of several breakpoints by giving an empty
list of commands, by just typing "end".
GDB should read an empty list of command once, but it reads
it for each breakpoint, as an empty list of command is NULL,
and NULL is interpreted as 'not having read the command list yet'.

The fix consists in having a boolean set to true once the
command list has been read.

gdb/ChangeLog

2018-08-26  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* breakpoint.c (commands_command_1): New boolean cmd_read
	to detect cmd was already read.
2018-08-28 22:40:59 +02:00
Tom Tromey 5fe3f3e463 Remove some uses of VEC from parsers
This changes some uses of VEC in a few parsers to std::vector instead.

Tested by the buildbot.

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

	* c-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
	(token_fifo): Now a std::vector.
	(yylex, c_parse): Update.
	* d-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
	(token_fifo): Now a std::vector.
	(yylex, d_parse): Update.
	* go-exp.y (struct token_and_value): Remove typedef and DEF_VEC.
	(token_fifo): Now a std::vector.
	(yylex, go_parse): Update.
2018-08-28 11:28:15 -06:00
Simon Marchi 858d8004b0 Implement struct type_stack with a vector
This patch changes the home-made stack implementation with a vector,
which makes it a bit more concise and readable.

Regtested on the buildbot.

gdb/ChangeLog:

	* parser-defs.h (struct type_stack) <elements>: Change type to
	std::vector<union type_stack_elt>.
	<depth, size>: Remove.
	* parse.c (parse_exp_in_context_1): Adjust.
	(type_stack_reserve): Remove.
	(check_type_stack_depth): Remove.
	(insert_into_type_stack): Adjust to std::vector.
	(insert_type): Likewise.
	(push_type): Likewise.
	(push_type_int): Likewise.
	(insert_type_address_space): Likewise.
	(pop_type): Likewise.
	(pop_type_int): Likewise.
	(pop_typelist): Likewise.
	(pop_type_stack): Likewise.
	(append_type_stack): Likewise.
	(push_type_stack): Likewise.
	(get_type_stack): Likewise.
	(type_stack_cleanup): Likewise.
	(push_typelist): Likewise.
	(follow_types): Likewise.
	(_initialize_parse): Likewise.
2018-08-28 11:13:26 -04:00
Hafiz Abid Qadeer 416a69af89 Mention csky target in the NEWS.
2018-08-28  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* NEWS: Mention csky target.
2018-08-28 12:11:39 +01:00
Hafiz Abid Qadeer 9d24df82ec Add support for new target 'csky'.
2018-08-28  Jiangshuai Li  <jiangshuai_li@c-sky.com>
	    Hafiz Abid Qadeer  <abidh@codesourcery.com>
	    Don Breazeal  <donb@codesourcery.com>

	* csky-linux-tdep.c: New file.
	* csky-tdep.c: Likewise.
	* csky-tdep.h: Likewise.
	* Makefile.in (ALL_TARGET_OBS): Add csky-linux-tdep.o and
	csky-tdep.o.
	(HFILES_NO_SRCDIR): Add csky-tdep.h.
	(ALLDEPFILES): Add csky-linux-tdep.c and csky-tdep.c
	* configure.tgt: Add csky support.
2018-08-28 12:08:11 +01:00
Jan Vrany 3bf9c013e4 MI: Fix printing of frame architecture with Python frame filters enabled
Commit 6d52907e22 (MI: Print frame architecture when printing frames
on an MI channel) added frame's architecture to MI frame output. However
the frame architecture was not correctly printed in the output of
"-stack-list-frames" with frame filters enabled (via "-enable-frame-filters").
This was because with frame filters enabled, the actual frame printing is
done in "py_print_frame" rather than "print_frame". This issue is now fixed.

gdb/Changelog:
2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* python/py-framefilter.c (py_print_frame): Print frame architecture
	when printing on an MI output.

gdb/testsuite/Changelog:
2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.python/py-framefilter-mi.exp: Update regexp to
	check for "arch" field in frame output.
2018-08-27 17:12:41 -04:00
Tom Tromey d3d8724aac Remove -Wno-narrowing from warnings.m4
This removes -Wno-narrowing from warnings.m4.
This is PR build/23087.

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

	PR build/23087:
	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Remove -Wno-narrowing.

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

	PR build/23087:
	* configure: Rebuild.
2018-08-27 12:00:12 -06:00
Tom Tromey 1885053bcb Avoid -Wnarrowing warnings in aarch64-linux-tdep.c
This avoids -Wnarrowing warnings in
aarch64_linux_iterate_over_regset_sections, by adding some casts to
int.

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

	* aarch64-linux-tdep.c
	(aarch64_linux_iterate_over_regset_sections) <sve_regmap>: Add
	casts to int.
2018-08-27 12:00:12 -06:00
Tom Tromey b4f183d23e Avoid -Wnarrowing warnings in gdbserver
This avoids -Wnarrowing warnings in gdbserver, by introducing some
casts to unsigned char.

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

	* linux-s390-low.c (s390_emit_ext, s390_emit_litpool)
	(s390_emit_const, s390_emit_reg, s390_emit_zero_ext)
	(s390_emit_stack_adjust, s390_emit_set_r2, s390x_emit_ext)
	(s390x_emit_const, s390x_emit_reg, s390x_emit_zero_ext)
	(s390x_emit_stack_adjust): Add casts to unsigned char.
2018-08-27 12:00:11 -06:00
Tom Tromey 8406672eca Avoid -Wnarrowing warnings in ppc64-tdep.c
This avoids -Wnarrowing warnings in ppc64-tdep.c, by adding a few
casts to unsigned.

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

	* ppc64-tdep.c (insn_d, insn_ds, insn_xfx): Add casts to
	unsigned.
	(ppc64_standard_linkage1, ppc64_standard_linkage2)
	(ppc64_standard_linkage3, ppc64_standard_linkage4)
	(ppc64_standard_linkage5, ppc64_standard_linkage6)
	(ppc64_standard_linkage7, ppc64_standard_linkage8): Add casts to
	unsigned.
2018-08-27 12:00:11 -06:00
Tom Tromey ec40cf90a0 Fix two -Wnarrowing warnings in xtensa-tdep.h
This fixes a couple of -Wnarrowing warnings in xtensa-tdep.h, by
introducing some casts to unsigned.

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

	* xtensa-tdep.h (XTREG_END): Add cast to unsigned.
	(XTENSA_GDBARCH_TDEP_INSTANTIATE): Likewise.
2018-08-27 12:00:10 -06:00
Tom Tromey 7bc02706c3 Avoid -Wnarrowing warnings in struct tramp_frame instances
This avoids -Wnarrowing warnings in struct tramp_frame instances,
replacing uses of -1 with a new ULONGEST_MAX.  It also redefined
TRAMP_SENTINEL_INSN to avoid the same warning.

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

	* tramp-frame.h (TRAMP_SENTINEL_INSN): Redefine.
	* tilegx-linux-tdep.c (tilegx_linux_rt_sigframe): Use
	ULONGEST_MAX.
	* tic6x-linux-tdep.c (tic6x_linux_rt_sigreturn_tramp_frame): Use
	ULONGEST_MAX.
	* sparc64-linux-tdep.c (sparc64_linux_rt_sigframe): Use
	ULONGEST_MAX.
	* sparc-linux-tdep.c (sparc32_linux_sigframe)
	(sparc32_linux_rt_sigframe): Use ULONGEST_MAX.
	* ppc-nbsd-tdep.c (ppcnbsd_sigtramp, ppcnbsd2_sigtramp): Use
	ULONGEST_MAX.
	* ppc-linux-tdep.c (ppc32_linux_sigaction_tramp_frame)
	(ppc64_linux_sigaction_tramp_frame)
	(ppc32_linux_sighandler_tramp_frame)
	(ppc64_linux_sighandler_tramp_frame): Use ULONGEST_MAX.
	* nios2-linux-tdep.c (nios2_r1_linux_rt_sigreturn_tramp_frame)
	(nios2_r2_linux_rt_sigreturn_tramp_frame): Use ULONGEST_MAX.
	* mn10300-linux-tdep.c (am33_linux_sigframe)
	(am33_linux_rt_sigframe): Use ULONGEST_MAX.
	* mips64-obsd-tdep.c (mips64obsd_sigframe): Use ULONGEST_MAX.
	* mips-linux-tdep.c (mips_linux_o32_sigframe)
	(mips_linux_o32_rt_sigframe, mips_linux_n32_rt_sigframe)
	(mips_linux_n64_rt_sigframe, micromips_linux_o32_sigframe)
	(micromips_linux_o32_rt_sigframe, micromips_linux_n32_rt_sigframe)
	(micromips_linux_n64_rt_sigframe): Use ULONGEST_MAX.
	* mips-fbsd-tdep.c (mips_fbsd_sigframe, mipsn32_fbsd_sigframe)
	(mips64_fbsd_sigframe): Use ULONGEST_MAX.
	* microblaze-linux-tdep.c
	(microblaze_linux_sighandler_tramp_frame): Use ULONGEST_MAX.
	* i386-nbsd-tdep.c (i386nbsd_sigtramp_sc16, i386nbsd_sigtramp_sc2)
	(i386nbsd_sigtramp_si2, i386nbsd_sigtramp_si31)
	(i386nbsd_sigtramp_si4): Use ULONGEST_MAX.
	* hppa-nbsd-tdep.c (hppanbsd_sigtramp_si4): Use ULONGEST_MAX.
	* common/common-types.h (ULONGEST_MAX): New define.
	(CORE_ADDR_MAX): Fix formatting.
	* bfin-linux-tdep.c (bfin_linux_sigframe): Use ULONGEST_MAX.
	* arm-obsd-tdep.c (armobsd_sigframe): Use ULONGEST_MAX.
	* arm-linux-tdep.c (arm_linux_sigreturn_tramp_frame)
	(arm_linux_rt_sigreturn_tramp_frame)
	(arm_eabi_linux_sigreturn_tramp_frame)
	(arm_eabi_linux_rt_sigreturn_tramp_frame)
	(thumb2_eabi_linux_sigreturn_tramp_frame)
	(thumb2_eabi_linux_rt_sigreturn_tramp_frame)
	(arm_linux_restart_syscall_tramp_frame)
	(arm_kernel_linux_restart_syscall_tramp_frame): Use ULONGEST_MAX.
	* arm-fbsd-tdep.c (arm_fbsd_sigframe): Use ULONGEST_MAX.
	* aarch64-linux-tdep.c (aarch64_linux_rt_sigframe): Use
	ULONGEST_MAX.
	* aarch64-fbsd-tdep.c (aarch64_fbsd_sigframe): Use ULONGEST_MAX.
2018-08-27 12:00:10 -06:00
Tom Tromey 70ab8ccd4f Use CORE_ADDR_MAX in various "breaks" arrays
Code like this:

  CORE_ADDR breaks[2] = {-1, -1};

... gives a warning with -Wnarrowing.  This patch changes all
instances of this to use CORE_ADDR_MAX instead.

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

	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Use
	CORE_ADDR_MAX.
	* mips-tdep.c (mips_deal_with_atomic_sequence)
	(micromips_deal_with_atomic_sequence): Use CORE_ADDR_MAX.
	* arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw)
	(arm_deal_with_atomic_sequence_raw): Use CORE_ADDR_MAX.
	* alpha-tdep.c (alpha_deal_with_atomic_sequence): Use
	CORE_ADDR_MAX.
	* aarch64-tdep.c (aarch64_software_single_step): Use
	CORE_ADDR_MAX.
2018-08-27 12:00:09 -06:00
Tom Tromey 896a7aa6a1 Avoid -Wnarrowing warnings from quote_char()
This adds a couple of casts to avoid -Wnarrowing warnings coming from
the use of quote_char().

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

	* linespec.c (complete_linespec_component): Add cast to "char".
	* completer.c (completion_tracker::build_completion_result): Add
	cast to "char".
2018-08-27 12:00:09 -06:00
Simon Marchi dd33d41d54 Fix indentation in solist.h
gdb/ChangeLog:

	* solist.h (struct solist, struct target_so_ops): Fix
	indentation.
2018-08-26 20:06:21 -04:00
Simon Marchi c645cda49e Make ada_tasks_inferior_data::task_list an std::vector
This removes a VEC type.  It requires converting ada_tasks_inferior_data
to C++ (initializing fields, allocating with new).  It seems, however,
that the allocated ada_tasks_inferior_data structures are never freed
(that should be fixed separately).

gdb/ChangeLog:

	* ada-tasks.c (ada_task_info_s): Remove typedef.
	(DEF_VEC_O(ada_task_info_s)): Remove.
	(struct ada_tasks_inferior_data): Initialize fields.
	<task_list>: Make an std::vector.
	(get_ada_tasks_inferior_data): Allocate with new.
	(ada_get_task_number): Adjust.
	(get_task_number_from_id): Likewise.
	(valid_task_id): Likewise.
	(ada_get_task_info_from_ptid): Likewise.
	(iterate_over_live_ada_tasks): Likewise.
	(add_ada_task): Likewise.
	(read_known_tasks): Likewise.
	(ada_build_task_list): Likewise.
	(print_ada_task_info): Likewise.
	(info_task): Likewise.
	(task_command_1): Likewise.
2018-08-26 11:56:57 -04:00
Simon Marchi 39e7af3e4b Make ada-lang.c::add_angle_brackets return an std::string
This removes the need for manual memory management.  It may also be a
bit more efficient, since the returned string can be moved all the way
into the destination, in ada_lookup_name_info::matches.

gdb/ChangeLog:

	* ada-lang.c (add_angle_brackets): Return std::string.
2018-08-26 11:53:47 -04:00
Simon Marchi bbbbbceebc Initialize variable in py_get_event_thread
The pythread variable could be used without being initialized, fix it by
initializing it to nullptr.

gdb/ChangeLog:

	* python/py-threadevent.c (py_get_event_thread): Initialize
	pythread.
2018-08-25 11:52:24 -04:00
Pedro Alves d98fc15be2 gdb/python: Use copy-initialization more when possible
gdb/ChangeLog:
2018-08-24  Pedro Alves  <palves@redhat.com>

	* python/py-bpevent.c (create_breakpoint_event_object): Use
	copy-initialization.
	* python/py-continueevent.c (emit_continue_event): Use
	copy-initialization.
	* python/py-exitedevent.c (create_exited_event_object): Return a
	gdbpy_ref<>.
	(emit_exited_event): Use copy-initialization.
	* python/py-inferior.c (python_new_inferior)
	(python_inferior_deleted, add_thread_object): Use
	copy-initialization.
	* python/py-infevents.c (create_inferior_call_event_object)
	(create_register_changed_event_object)
	(create_memory_changed_event_object): Return a gdbpy_ref<>.
	(emit_inferior_call_event, emit_memory_changed_event)
	(emit_register_changed_event): Use copy-initialization.
	* python/py-newobjfileevent.c (create_new_objfile_event_object):
	Return a gdbpy_ref<>.
	(emit_new_objfile_event): Use copy-initialization.
	(create_clear_objfiles_event_object): Return a gdbpy_ref<>.
	(emit_clear_objfiles_event): Use copy-initialization.
	* python/py-signalevent.c (create_signal_event_object): Use
	copy-initialization.
	* python/py-threadevent.c (create_thread_event_object): Use
	copy-initialization.
2018-08-24 22:57:16 +01:00
Pedro Alves da3c873831 Fix 8.2 regression in gdb.python/py-evthreads.exp w/ gdbserver (PR gdb/23379)
This commit fixes a 8.1->8.2 regression exposed by
gdb.python/py-evthreads.exp when testing with
--target_board=native-gdbserver.

gdb.log shows:

  src/gdb/thread.c:93: internal-error: thread_info* inferior_thread(): Assertion `tp' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) FAIL: gdb.python/py-evthreads.exp: run to breakpoint 1 (GDB internal error)

A backtrace shows (frames #2 and #10 highlighted) that the assertion
fails when GDB is setting up the connection to the remote target, in
non-stop mode:

  #0  0x0000000000622ff0 in internal_error(char const*, int, char const*, ...) (file=0xc1ad98 "src/gdb/thread.c", line=93, fmt=0xc1ad20 "%s: Assertion `%s' failed.") at src/gdb/common/errors.c:54
  #1  0x000000000089567e in inferior_thread() () at src/gdb/thread.c:93
= #2  0x00000000004da91d in get_event_thread() () at src/gdb/python/py-threadevent.c:38
  #3  0x00000000004da9b7 in create_thread_event_object(_typeobject*, _object*) (py_type=0x11574c0 <continue_event_object_type>, thread=0x0)
      at src/gdb/python/py-threadevent.c:60
  #4  0x00000000004bf6fe in create_continue_event_object() () at src/gdb/python/py-continueevent.c:27
  #5  0x00000000004bf738 in emit_continue_event(ptid_t) (ptid=...) at src/gdb/python/py-continueevent.c:40
  #6  0x00000000004c7d47 in python_on_resume(ptid_t) (ptid=...) at src/gdb/python/py-inferior.c:108
  #7  0x0000000000485bfb in std::_Function_handler<void (ptid_t), void (*)(ptid_t)>::_M_invoke(std::_Any_data const&, ptid_t&&) (__functor=..., __args#0=...) at /usr/include/c++/7/bits/std_function.h:316
  #8  0x000000000089b416 in std::function<void (ptid_t)>::operator()(ptid_t) const (this=0x12aa600, __args#0=...)
      at /usr/include/c++/7/bits/std_function.h:706
  #9  0x000000000089aa0e in gdb::observers::observable<ptid_t>::notify(ptid_t) const (this=0x118a7a0 <gdb::observers::target_resumed>, args#0=...)
      at src/gdb/common/observable.h:106
= #10 0x0000000000896fbe in set_running(ptid_t, int) (ptid=..., running=1) at src/gdb/thread.c:880
  #11 0x00000000007f750f in remote_target::remote_add_thread(ptid_t, bool, bool) (this=0x12c5440, ptid=..., running=true, executing=true) at src/gdb/remote.c:2434
  #12 0x00000000007f779d in remote_target::remote_notice_new_inferior(ptid_t, int) (this=0x12c5440, currthread=..., executing=1)
      at src/gdb/remote.c:2515
  #13 0x00000000007f9c44 in remote_target::update_thread_list() (this=0x12c5440) at src/gdb/remote.c:3831
  #14 0x00000000007fb922 in remote_target::start_remote(int, int) (this=0x12c5440, from_tty=0, extended_p=0)
      at src/gdb/remote.c:4655
  #15 0x00000000007fd102 in remote_target::open_1(char const*, int, int) (name=0x1a4f45e "localhost:2346", from_tty=0, extended_p=0)
      at src/gdb/remote.c:5638
  #16 0x00000000007fbec1 in remote_target::open(char const*, int) (name=0x1a4f45e "localhost:2346", from_tty=0)
      at src/gdb/remote.c:4862

So on frame #10, we're marking a newly-discovered thread as running,
and that causes the Python API to emit a gdb.ContinueEvent.
gdb.ContinueEvent is a gdb.ThreadEvent, and as such includes the event
thread as the "inferior_thread" attribute.  The problem is that when
we get to frame #3/#4, we lost all references to the thread that is
being marked as running.  create_continue_event_object assumes that it
is the current thread, which is not true in this case.

Fix this by passing down the right thread in
create_continue_event_object.  Also remove
create_thread_event_object's default argument and have the only other
caller left pass down the right thread explicitly too.

gdb/ChangeLog:
2018-08-24  Pedro Alves  <palves@redhat.com>
	    Simon Marchi  <simon.marchi@ericsson.com>

	PR gdb/23379
	* python/py-continueevent.c: Include "gdbthread.h".
	(create_continue_event_object): Add intro comment.  Add 'ptid'
	parameter.  Use it to find thread to pass to
	create_thread_event_object.
	(emit_continue_event): Pass PTID down to
	create_continue_event_object.
	* python/py-event.h (py_get_event_thread): Declare.
	(create_thread_event_object): Remove default from 'thread'
	parameter.
	* python/py-stopevent.c (create_stop_event_object): Use
	py_get_event_thread.
	* python/py-threadevent.c (get_event_thread): Rename to ...
	(py_get_event_thread): ... this, make extern, add 'ptid' parameter
	and use it to find the thread.
	(create_thread_event_object): Assert that THREAD isn't null.
	Don't find the event thread here.
2018-08-24 22:13:30 +01:00
Kevin Buettner 450d1e88e3 Test case for functions with non-contiguous ranges
See comments in the new files for what this is about - I tried to
explain it all there.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-ranges-func.c: New file.
	* gdb.dwarf2/dw2-ranges-func.exp: New file.
2018-08-23 16:24:57 -07:00
Kevin Buettner 9644dc3a47 Relocate block range start and end addresses
gdb/ChangeLog:

	* objfiles.c (objfile_relocate1): Relocate start and end addresses
	for each range in a block.
2018-08-23 16:23:06 -07:00
Kevin Buettner 59adbf5d03 Introduce find_function_entry_range_from_pc and use it in infrun.c
An earlier version of this patch used the returned block in conjunction
with BLOCK_ENTRY_PC to set stop_func_start in fill_in_stop_func() in
infrun.c.  While I think this was the correct thing to do, changes
to find_inferior_partial_function could potentially end up with
stop_func_end < stop_func_start, which is definitely wrong.  For
this case, we want to set both stop_func_start and stop_func_end
to the start and end of the range containing the function's entry
pc.

I think that this functionality will be useful in many other places
too - it probably ought to be used in all of the various prologue
analyzers in GDB.

The change to infrun.c was simple: the call to
find_pc_partial_function was replaced with a call to
find_function_entry_range_from_pc.  The difference between these two
functions is that find_pc_partial_entry_function will (potentially)
return the start and end address corresponding to the range in which
PC is found, but find_function_entry_range_from_pc will (again,
potentially) return the start and end address of the range containing
the entry pc.  find_pc_partial_function has the property that
*ADDRESS <= PC < *ENDADDR.  This condition does not necessarily hold
for the outputs of find_function_entry_range_from_pc.

It should be noted that for functions which contain only a single
range, the outputs of find_pc_partial_function and
find_function_entry_range_from_pc are identical.

I think it might happen that find_function_entry_range_from_pc will come
to be used in place of many of the calls to find_pc_partial_function
within GDB.  Care must be taken in making this change, however, since
some of this code depends on the *ADDRESS <= PC < *ENDADDR property.

Finally, a note regarding the name: I had initially chosen a different
name with a find_pc_partial_ prefix, but Simon suggested the current
name citing the goal of eventually making naming consistent using
the form find_X_from_Y.  In this case X is "function_entry_range" and
Y is "pc".  Both the name and rationale made sense to me, so that's
how it came to be.

gdb/ChangeLog:

	* infrun.c (fill_in_stop_func): Use find_function_entry_range_from_pc
	in place of find_pc_partial_function.
	* blockframe.c (find_function_entry_range_from_pc): New function.
	* symtab.h (find_function_entry_range_from_pc): Declare and document.
2018-08-23 16:19:43 -07:00
Kevin Buettner 2b1ffcfd6f Use BLOCK_ENTRY_PC in place of most uses of BLOCK_START
This change/patch substitues BLOCK_ENTRY_PC for BLOCK_START in
places where BLOCK_START is used to obtain the address at which
execution should enter the block.  Since blocks can now contain
non-contiguous ranges, the BLOCK_START - which is still be the
very lowest address in the block - might not be the same as
BLOCK_ENTRY_PC.

There is a change to infrun.c which is less obvious and less mechanical.
I'm posting it as a separate patch.

gdb/ChangeLog:

	* ax-gdb.c (gen_var_ref): Use BLOCK_ENTRY_PC in place of
	BLOCK_START.
	* blockframe.c (get_pc_function_start): Likewise.
	* compile/compile-c-symbols.c (convert_one_symbol): Likewise.
	(gcc_symbol_address): Likewise.
	* compile/compile-object-run.c (compile_object_run): Likewise.
	* compile/compile.c (get_expr_block_and_pc): Likewise.
	* dwarf2loc.c (dwarf2_find_location_expression): Likewise.
	(func_addr_to_tail_call_list): Likewise.
	* findvar.c (default_read_var_value): Likewise.
	* inline-frame.c (inline_frame_this_id): Likewise.
	(skip-inline_frames): Likewise.
	* infcmd.c (until_next_command): Likewise.
	* linespec.c (convert_linespec_to_sals): Likewise.
	* parse.c (parse_exp_in_context_1): Likewise.
	* printcmd.c (build_address_symbolic): likewise.
	(info_address_command): Likewise.
	symtab.c (find_function_start_sal): Likewise.
	(skip_prologue_sal): Likewise.
	(find_function_alias_target): Likewise.
	(find_gnu_ifunc): Likewise.
	* stack.c (find_frame_funname): Likewise.
	* symtab.c (fixup_symbol_section): Likewise.
	(find_function_start_sal): Likewise.
	(skip_prologue_sal): Likewsie.
	(find_function_alias_target): Likewise.
	(find_gnu_ifunc): Likewise.
	* tracepoint.c (info_scope_command): Likewise.
	* value.c (value_fn_field): Likewise.
2018-08-23 16:19:18 -07:00
Kevin Buettner e94802301b Disassemble blocks with non-contiguous ranges
This patch adds support for disassembly of blocks with non-contiguous
ranges.  These blocks are printed as follows:

(gdb) disassemble foo
Dump of assembler code for function foo:
Address range 0x401136 to 0x401151:
   0x0000000000401136 <+0>:     push   %rbp
   0x0000000000401137 <+1>:     mov    %rsp,%rbp
   0x000000000040113a <+4>:     callq  0x401134 <bar>
   0x000000000040113f <+9>:     mov    0x2eef(%rip),%eax        # 0x404034 <e>
   0x0000000000401145 <+15>:    test   %eax,%eax
   0x0000000000401147 <+17>:    je     0x40114e <foo+24>
   0x0000000000401149 <+19>:    callq  0x401128 <foo+4294967282>
   0x000000000040114e <+24>:    nop
   0x000000000040114f <+25>:    pop    %rbp
   0x0000000000401150 <+26>:    retq
Address range 0x401128 to 0x401134:
   0x0000000000401128 <+-14>:   push   %rbp
   0x0000000000401129 <+-13>:   mov    %rsp,%rbp
   0x000000000040112c <+-10>:   callq  0x401126 <baz>
   0x0000000000401131 <+-5>:    nop
   0x0000000000401132 <+-4>:    pop    %rbp
   0x0000000000401133 <+-3>:    retq
End of assembler dump.

This is an actual dump from the test case that I constructed for
this work.  The ranges are printed in the order encountered in the
debug info. For the above example, note that the second range occupies
lower addresses than the first range.

Functions with contiguous ranges are still printed as follows:

(gdb) disassemble main
Dump of assembler code for function main:
   0x0000000000401151 <+0>:     push   %rbp
   0x0000000000401152 <+1>:     mov    %rsp,%rbp
   0x0000000000401155 <+4>:     callq  0x401136 <foo>
   0x000000000040115a <+9>:     mov    $0x0,%eax
   0x000000000040115f <+14>:    pop    %rbp
   0x0000000000401160 <+15>:    retq
End of assembler dump.

gdb/ChangeLog:

	* cli/cli-cmds.c (block.h): Include.
	(print_disassembly): Handle printing of non-contiguous blocks.
	(disassemble_current_function): Likewise.
	(disassemble_command): Likewise.
2018-08-23 16:16:07 -07:00
Kevin Buettner fc811edd39 Add support for non-contiguous blocks to find_pc_partial_function
This change adds an optional output parameter BLOCK to
find_pc_partial_function.  If BLOCK is non-null, then *BLOCK will be
set to the address of the block corresponding to the function symbol
if such a symbol was found during lookup.  Otherwise it's set to the
NULL value.  Callers may wish to use the block information to
determine whether the block contains any non-contiguous ranges.  The
caller may also iterate over or examine those ranges.

When I first started looking at the broken stepping behavior associated
with functions w/ non-contiguous ranges, I found that I could "fix"
the problem by disabling the find_pc_partial_function cache.  It would
sometimes happen that the PC passed in would be between the low and
high cache values, but would be in some other function that happens to
be placed in between the ranges for the cached function.  This caused
incorrect values to be returned.

So dealing with this cache turns out to be very important for fixing
this problem.  I explored three different ways of dealing with the
cache.

My first approach was to clear the cache when a block was encountered
with more than one range.  This would cause the non-cache pathway to
be executed on the next call to find_pc_partial_function.

Another approach, which I suspect is slightly faster, checks to see
whether the PC is within one of the ranges associated with the cached
block.  If so, then the cached values can be used.  It falls back to
the original behavior if there is no cached block.

The current approach, suggested by Simon Marchi, is to restrict the
low/high pc values recorded for the cache to the beginning and end of
the range containing the PC value under consideration.  This allows us
to retain the simple (and fast) test for determining whether the
memoized (cached) values apply to the PC passed to
find_pc_partial_function.

Another choice that had to be made regards setting *ADDRESS and
*ENDADDR.  There are three possibilities which might make sense:

1) *ADDRESS and *ENDADDR represent the lowest and highest address
   of the function.
2) *ADDRESS and *ENDADDR are set to the start and end address of
   the range containing the entry pc.
3) *ADDRESS and *ENDADDR are set to the start and end address of
   the range in which PC is found.

An earlier version of this patch implemented option #1.  I found out
that it's not very useful though and, in fact, returns results that
are incorrect when used in the context of determining the start and
end of the function for doing prologue analysis.  While debugging a
function in which the entry pc was in the second range (of a function
containing two non-contiguous ranges), I noticed that
amd64_skip_prologue called find_pc_partial_function - the returned
start address was set to the beginning of the first range.  This is
incorrect for this function.  What was also interesting was that this
first invocation of find_pc_partial_function correctly set the cache
for the PC on which it had been invoked, but a slightly later call
from skip_prologue_using_sal could not use this cached value because
it was now being used to lookup the very lowest address of the
function - which is in a range not containing the entry pc.

Option #2 is attractive as it would provide a desirable result
when used in the context of prologue analysis.  However, many callers,
including some which do prologue analysis want the condition
*ADDRESS <= PC < *ENDADDR to hold.  This will not be the case when
find_pc_partial_function is called on a PC that's in a non-entry-pc
range.  A later patch to this series adds
find_function_entry_range_from_pc as a wrapper of
find_pc_partial_function.

Option #3 causes the *ADDRESS <= PC < *ENDADDR property to hold.  If
find_pc_partial_function is called with a PC that's within entry pc's
range, then it will correctly return the limits of that range.  So, if
the result of a minsym search is passed to find_pc_partial_function
to find the limits, then correct results will be achieved.  Returned
limits (for prologue analysis) won't be correct when PC is within some
other (non-entry-pc) range.  I don't yet know how big of a problem
this might be; I'm guessing that it won't be a serious problem - if a
compiler generates functions which have non-contiguous ranges, then it
also probably generates DWARF2 CFI which makes a lot of the old
prologue analysis moot.

I've implemented option #3 for this version of the patch.  I don't see
any regressions for x86-64.  Moreover, I don't expect to see
regressions for other targets either simply because
find_pc_partial_function behaves the same as it did before for the
contiguous address range case.  That said, there may be some
adjustments needed if GDB encounters a function requiring prologue
analysis which occupies non-contiguous ranges.

gdb/ChangeLog:

	* symtab.h (find_pc_partial_function): Add new parameter `block'.
	* blockframe.c (cache_pc_function_block): New static global.
	(clear_pc_function_cache): Clear cache_pc_function_block.
	(find_pc_partial_function): Move comment to symtab.h.  Add
	support for non-contiguous blocks.
2018-08-23 16:13:44 -07:00
Kevin Buettner 2d5f09ec45 Record explicit block ranges from dwarf2read.c
This change sets BLOCK_RANGES for the block under consideration by
calling make_blockranges().  This action is performed in
dwarf2_record_block_ranges().

It should be noted that dwarf2_record_block_ranges() already does some
recording of the range via a call to record_block_range().  The ranges
recorded in that fashion end up in the address map associated with the
blockvector for the compilation unit's symtab.  Given an address, the
addrmap provides a fast way of finding the block containing that
address.  The address map does not, however, provide a convenient way
of determining which address ranges make up a particular block.

While reading a set of ranges, a vector of pairs is used to collect
the starting and ending addresses for each range in the block.  Once
all of the ranges for a block have been collected, make_blockranges()
is called to fill in BLOCK_RANGES for the block.

The ranges are stored for the block in the order that they're read
from the debug info.  For DWARF, the starting address of the first
range of the block will be the entry pc in cases where DW_AT_entry_pc
is not present.  (Well, that would ideally be the case.  At the moment
DW_AT_entry_pc is not being handled.)

gdb/ChangeLog:

	* dwarf2read.c (dwarf2_record_block_ranges): Fill in BLOCK_RANGES
	for block.
2018-08-23 16:12:15 -07:00
Kevin Buettner 26457a9cf3 Add block range data structure for blocks with non-contiguous address ranges
This patch does the following:

- Introduces a block range data structure which is accessed via
  a new field in struct block.
- Defines several macros for accessing block ranges.
- Defines a new function, make_blockrange, which is responsible for
  creating the new data structure.

It should be noted that some support for non-contiguous ranges already
existed in GDB in the form of blockvector addrmaps.  This support
allowed GDB to quickly find a block containing a particular address
even when the block consists of non-contiguous addresses.  See
find_block_in_blockvector() in block.c, dwarf2_record_block_ranges()
in dwarf2read.c, and record_block_range() in buildsym.c.

Addrmaps do not provide a convenient way to examine address ranges
associated with a particular block.  This data structure (and its
interface) is set up for quickly finding the value (which in this case
is a block) associated with a particular address.  The interface
does not include a method for doing a reverse mapping from blocks to
addresses.  A linear time mapping might be attempted via use of the
addrmap's foreach method, but this is not as straightforward as it
might first appear due to the fact that blocks corresponding to inline
function instances and lexical blocks w/ variables end up getting
interspersed in in the set of transitions.

Note:  If this approach is deemed to be too expensive in terms of
space, an alternate approach might be to attempt the linear time
mapping noted above.  find_pc_partial_function() needs to be able to
quickly know whether there are discontiguous ranges, so a flag for
this property would have to be added to struct block.  Also integral
to this set of changes is the concept of an "entry pc" which might be
different from the block's start address.  An entry_pc field would
also need to be added to struct block.  This does not result in any
space savings in struct block though since the space for the flag and
entry_pc use more space than the blockranges struct pointer that I've
added.  There would, however, be some space savings due to the fact
that the new data structures that I've added for this patch would not
need to be allocated.  (I happen to like the approach I've come up
with, but I wanted to mention another possibility just in case someone
does not.)

gdb/ChangeLog:

	* block.h (blockrange, blockranges): New struct declarations.
	(struct block): Add new field named `ranges'.
	(BLOCK_RANGES, BLOCK_NRANGES, BLOCK_RANGE, BLOCK_CONTIGUOUS_P)
	(BLOCK_RANGE_START, BLOCK_RANGE_END, BLOCK_ENTRY_PC): New
	macros for accessing ranges in struct block.
	(make_blockranges): New declaration.
	block.c (make_blockranges): New function.
2018-08-23 16:10:52 -07:00
Xavier Roirand 12a0d0f661 Darwin: fix bad loop incrementation
When reading symbols from the vector of oso files on Mac OS X
Darwin, a previous commit introduce a change in the loop and add
an increment at each loop iteration whereas this incrementation is
not needed since the increment or set of the loop control variable
is already done in the loop.

gdb/ChangeLog:

	* machoread.c (macho_symfile_read_all_oso): Remove uneeded
	incrementation.

Change-Id: I3a5a6deb4e9d834ee7d4217a62d90c2ffb7241bc
2018-08-23 11:17:15 -04:00
Simon Marchi d1012b8e33 Make read_program_headers_from_bfd return a gdb::byte_vector
This patch makes read_program_headers_from_bfd return a gdb::byte_vector
instead of a plain pointer.

gdb/ChangeLog:

	* solib-svr4.c (read_program_headers_from_bfd): Return
	gdb::optional<gdb::byte_vector>.
	(svr4_exec_displacement): Adjust.
2018-08-22 14:18:08 -04:00
Simon Marchi 17658d46e4 Make read_program_header return a gdb::byte_vector
While reading a recent patch, I found this spot where a gdb::byte_vector
could be used instead of an allocated buffer returned as a plain
pointer.

gdb/ChangeLog:

	* solib-svr4.c (read_program_header): Return
	gdb::optional<gdb::byte_vector>, remove p_sect_size param.
	(find_program_interpreter): Return
	gdb::optional<gdb::byte_vector>.
	(scan_dyntag_auxv): Adjust.
	(enable_break): Adjust.
	(svr4_exec_displacement): Adjust.
2018-08-22 14:17:57 -04:00
Simon Marchi 4e2aa47284 Restore behavior of disabling address randomization by default on GDBserver
Commit

  c12a508 ("Add client_state struct.")

inadvertently changed the default behavior of GDBserver wrt address
randomization.  The old disable_randomization global variable was
initialized to 1, whereas the corresponding field in the client_state
structure is initialized to 0.

This fixes

  make check TESTS="gdb.base/jit-simple.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
  make check TESTS="gdb.base/execl-update-breakpoints.exp" RUNTESTFLAGS="--target_board=native-gdbserver"

Note that the execl-update-breakpoints.exp would only fail on systems
where the toolchain emits position-independent executables by default
(otherwise the main executable position is never randomized, so the
value of disable_randomization didn't matter).

gdb/gdbserver/ChangeLog:

	PR gdb/23374
	PR gdb/23375
	* server.h (struct client_state) <disable_randomization>:
	Initialize to 1.
2018-08-22 13:37:05 -04:00
Simon Marchi ae739fe7b8 Fix restoring of inferior terminal settings
I noticed that the child_terminal_save_inferior function was not used
since the commit f6ac5f3d63 ("Convert struct target_ops to C++").  I
was able to make a little test program to illustrate the problem (see
test case).

I think we're just missing the override of the terminal_save_inferior
method in inf_child_target (along with the other terminal-related
methods).

Instead of creating a new test, I thought that gdb.base/term.exp was a
good candidate for testing that gdb restores properly the inferior's
terminal settings.

gdb/ChangeLog:

	* inf-child.h (inf_child_target) <terminal_save_inferior>: New.
	* inf-child.c (inf_child_target::terminal_save_inferior): New.

gdb/testsuite/ChangeLog:

	* gdb.base/term.exp: Compare terminal settings with values from
	the inferior.
	* gdb.base/term.c: Get and set terminal settings.
2018-08-22 11:09:45 -04:00
Simon Marchi 467dc1e2ea Replace xstrvprintf usages with string_vprintf
Most usages of xstrvprintf in GDB can be replaced with string_vprintf,
removing some manual memory management.

gdb/ChangeLog:

	* guile/scm-string.c (gdbscm_scm_from_printf): Use
	string_vprintf.
	* guile/scm-utils.c (gdbscm_printf): Likewise.
	* serial.c (serial_printf): Likewise.
	* xml-support.c (gdb_xml_parser::vdebug): Likewise.
2018-08-22 10:55:28 -04:00
Jan Vrany 6d52907e22 MI: Print frame architecture when printing frames on an MI channel
When printing frames on an MI channel also print the frame
architecture like in:

    (gdb)
    -stack-list-frames 3 3
    ^done,stack=
    [frame={level="3",addr="0x000107a4",func="foo",
      file="recursive2.c",fullname="/home/foo/bar/recursive2.c",
      line="14",arch="i386:x86_64"}]
   (gdb)

This is useful for MI clients that need to know the architecture in
order to perform further analysis, for example to use their own
disassembler to analyze machine code.

gdb/Changelog:
2018-08-22  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* stack.c (print_frame): Print frame architecture when printing on
        an MI output.
	* NEWS: Mention new "arch" attribute in frame output.

gdb/testsuite/Changelog
2018-08-22  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* lib/mi-support.exp (mi_expect_stop): Update regexp to
	accommodate new "arch" field in frame output.
	* gdb.mi/mi-return.exp: Likewise.
	* gdb.mi/mi-stack.exp: Likewise.
	* gdb.mi/mi-syn-frame.exp: Likewise.
	* gdb.mi/user-selected-context-sync.exp: Likewise.

gdb/doc/Changelog
2018-08-22  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.texinfo (The -stack-list-frames Command): Update description
	to mention "arch".
	Update MI examples throughout the document to contain "arch" in
	frame output.
2018-08-22 11:54:37 +01:00
Alan Hayward 9758a8f84b Aarch64 SVE VG is Vector Granule
...not Vector Gradient.

See: DWARF for the ARM® 64-bit Architecture (AArch64) with SVE support

gdb/
	* arch/aarch64.h (aarch64_regnum): Update comment.
2018-08-22 09:40:37 +01:00
Alan Hayward 1461bdac5c Add AArch64 SVE to NEWS and GDB manual
gdb/
	* NEWS: Add SVE to 8.2 section.

gdb/doc/
	* doc/gdb.texinfo (AArch64 SVE): New subsubsection.
2018-08-22 09:19:01 +01:00
Pedro Alves 4895f384b4 Don't throw Scheme exceptions with live std::vector objects
A complication with the Guile code is that we have two types of
exceptions to consider: GDB/C++ exceptions, and Guile/SJLJ exceptions.

Because Guile exceptions are SJLJ based, we must make sure to not have
live local variables of types with non-trivial dtors when a Guile
exception is thrown, because the dtors won't be run when a Guile
exceptions is thrown.

gdbscm_parse_function_args currently violates this:

 void
 gdbscm_parse_function_args (const char *func_name,
			     int beginning_arg_pos,
			     const SCM *keywords,
			     const char *format, ...)
 {
 ...
   /* Keep track of malloc'd strings.  We need to free them upon error.  */
   std::vector<char *> allocated_strings;
 ...
   for (char *ptr : allocated_strings)
     xfree (ptr);
   gdbscm_throw (status); /// dtor of "allocated_strings" is not run!
 }

This commit fixes the above making using of gdbscm_wrap.

It would be nice if we had a way to make it impossible to write such
code.  PR guile/23429 has an idea for that, if someone's interested.

gdb/ChangeLog:
2018-08-21  Pedro Alves  <palves@redhat.com>

	* guile/scm-utils.c (gdbscm_parse_function_args_1): New, factored
	out from gdbscm_parse_function_args.
	(gdbscm_parse_function_args): Rework to use gdbscm_wrap and
	gdbscm_parse_function_args_1.
2018-08-21 16:48:30 +01:00
Simon Marchi a4497d2f84 Remove unnecessary ternary operator in m32c-tdep.c
Bug 17816 pointed out a useless use of the ternary operator:

  case 0x0: sd.reg = (size == 1 ? &st->r0 : &st->r0); break;

I believe that this is right.  If size is 1, the instruction refers to
part of r0, while if size is 2, the instruction refers to the whole of
r0.

gdb/ChangeLog:

	PR gdb/17816
	* m32c-tdep.c (m32c_decode_srcdest4): Remove unnecessary ternary
	operator.
2018-08-21 10:47:47 -04:00
Simon Marchi c44deb735e Fix formatting in solib-svr4.c
Fix some formatting issues which I have missed during review.

gdb/ChangeLog:

	* solib-svr4.c (svr4_exec_displacement): Fix formatting.
2018-08-19 22:04:45 -04:00
Michael Spang be2d111a87 Fix debugging of stripped PIE executables with padded PT_TLS
Certain PIE executables produced by gold cannot be debugged by gdb after
being stripped. GDB requires program headers of PIE executables to match,
and those checks may fail due to adjustments made during stripping.

One case of this occurs because strip recomputes the memsz of PT_TLS and
does not add alignment, while gold does. This is another variant of PR
11786, so apply the same fix of relaxing the program header matching.

gdb/ChangeLog:

	PR gdb/11786
	* solib-svr4.c (svr4_exec_displacement): Ignore memsz fields
	for PT_TLS segments.

gdb/testsuite/ChangeLog:

	PR gdb/11786
	* gdb.base/gcore-tls-pie.c: New file.
	* gdb.base/gcore-tls-pie.exp: New file.
2018-08-19 11:00:39 -04:00
Kevin Buettner 7d140d1a0b Test case for DW_OP_GNU_variable_value
gdb/testsuite/ChangeLog:

	* gdb.dwarf2/varval.c: New file.
	* gdb.dwarf2/varval.exp: New file.
2018-08-18 13:02:08 -07:00
Kevin Buettner ae3a7c47e6 Add support of DW_OP_GNU_variable_value to DWARF assembler
gdb/testsuite/ChangeLog:

	* lib/dwarf.exp: Add support for DW_OP_GNU_variable_value.
2018-08-18 12:59:15 -07:00
Kevin Buettner a6b786da4e Add support for DW_OP_GNU_variable_value
This patch adds support for DW_OP_GNU_variable_value to GDB.

Jakub Jelinek provides a fairly expansive discussion of this DWARF
expression opcode in his GCC patch...

    https://gcc.gnu.org/ml/gcc-patches/2017-02/msg01499.html

It has also been proposed for addition to the DWARF Standard:

    http://www.dwarfstd.org/ShowIssue.php?issue=161109.2

If compiled with a suitable version of GCC, the test case associated
with GCC Bug 77589 uses DW_OP_GNU_variable_value in a DW_AT_byte_stride
expression.  Here's a link to the bug:

    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77589

This is what the DWARF looks like.  Look at the last line, which has
the DW_AT_byte_stride expression:

 <2><e1>: Abbrev Number: 12 (DW_TAG_variable)
    <e2>   DW_AT_name        : (indirect string, offset: 0x115): span.0
    <e6>   DW_AT_type        : <0x2e>
    <ea>   DW_AT_artificial  : 1
    <ea>   DW_AT_location    : 3 byte block: 91 b0 7f 	(DW_OP_fbreg: -80)
 ...
 <2><178>: Abbrev Number: 18 (DW_TAG_subrange_type)
    <179>   DW_AT_lower_bound : 4 byte block: 97 23 20 6 	(DW_OP_push_object_address; DW_OP_plus_uconst: 32; DW_OP_deref)
    <17e>   DW_AT_upper_bound : 4 byte block: 97 23 28 6 	(DW_OP_push_object_address; DW_OP_plus_uconst: 40; DW_OP_deref)
    <183>   DW_AT_byte_stride : 10 byte block: 97 23 18 6 fd e1 0 0 0 1e 	(DW_OP_push_object_address; DW_OP_plus_uconst: 24; DW_OP_deref; DW_OP_GNU_variable_value: <0xe1>; DW_OP_mul)

A patch to readelf, which I'm also submitting, is required to do this
decoding.

I found that GDB gave me the correct answer for "p c40pt(2)" once I
(correctly) implemented DW_OP_GNU_variable_value.

I also have test case (later in this series) which uses the DWARF
assembler and, therefore, do not rely on having a compiler with this
support.

gdb/ChangeLog:

	* dwarf2expr.h (struct dwarf_expr_context): Add virtual method
	dwarf_variable_value.
	* dwarf2-frame.c (class dwarf_expr_executor):
	Add override for dwarf_variable_value.
	* dwarf2loc.c (class dwarf_evaluate_loc_desc): Likewise.
	(class symbol_needs_eval_context): Likewise.
	(indirect_synthetic_pointer): Add forward declaration.
	(sect_variable_value): New function.
	(dwarf2_compile_expr_to_ax): Add case for DW_OP_GNU_variable_value.
	* dwarf2expr.c (dwarf_expr_context::execute_stack_op): Add case
	for DW_OP_GNU_variable_value.
2018-08-18 12:57:59 -07:00
Tom Tromey 89fbedf3ab Remove "repeat" argument from command_line_input
After the previous patch, all callers pass 0 as the repeat argument to
command_line_input.  So, this patch removes it.

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

	* top.c (read_command_file): Update.
	(command_line_input): Remove "repeat" argument.
	* ada-lang.c (get_selections): Update.
	* linespec.c (decode_line_2): Update.
	* defs.h (command_line_input): Remove argument.
	* cli/cli-script.c (read_next_line): Update.
	* python/py-gdb-readline.c: Update.
2018-08-17 16:39:06 -06:00
Tom Tromey 1258253330 Fix use-after-free in number_or_range_parser
-fsanitize=address showed a use-after-free in number_or_range_parser.

The cause was that handle_line_of_input could stash the input into
"saved_command_line", and then this could be freed by reentrant calls.

This fixes the bug by preventing commands that are read by "commands"
from being eligible for repeating.

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

	* cli/cli-script.c (read_next_line): Pass 0 as repeat argument to
	command_line_input.
2018-08-17 16:37:39 -06:00
Alan Hayward 2ecae92e23 Fix asm in testsuite/gdb.arch/aarch64-fp.c
Cannot assume result of first and third ldr will go into x0.
Rewrite asm to be clearer.

gdb/testsuite/

	PR gdb/18931:
	* gdb.arch/aarch64-fp.c (main): Fix asm registers.
2018-08-17 11:10:24 +01:00
Keith Seitz c1854f1d5a Use gdb_test_no_output for compile tests expected to pass
There is a small think-o in compile.exp:

if { $srcfile3 != "" } {
    gdb_test "p constvar" " = 3"
    gdb_test "info addr constvar" {Symbol "constvar" is constant\.}

    gdb_test "compile code globalvar = constvar;"; # INCORRECT
    gdb_test "print globalvar" " = 3" "print constvar value"
} else {
    untested "print constvar value"
}

The line marked INCORRECT runs a simple "compile code" which is expected
to succeed.  When this happens, the compile plug-in and GDB will not
output anything.  The use of gdb_test matches against anything.

This is certainly not the intent, and this patch corrects the two instances
of this in the file.  [The rest of gdb.compile looks okay.]

testsuite/ChangeLog:

	* gdb.compile/compile.exp: Use gdb_test_no_output for "compile code"
	tests expected to pass.
2018-08-16 17:00:16 -07:00
Tom Tromey 495143533a Use pulongest in aarch64-linux-tdep.c
While testing a patch on the buildbot, I got this error:

../../binutils-gdb/gdb/aarch64-linux-tdep.c: In function uint64_t aarch64_linux_core_read_vq(gdbarch*, bfd*):
../../binutils-gdb/gdb/aarch64-linux-tdep.c:285:29: error: format %ld expects argument of type long int, but argument 2 has type uint64_t {aka long long unsigned int} [-Werror=format=]

This patch avoids the problem by using pulongest rather than %ld.
This seems safe to me because, if aarch64-linux-tdep.c is included in
the build, then ULONGEST must be a 64-bit type.

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

	* aarch64-linux-tdep.c (aarch64_linux_core_read_vq): Use pulongest.
2018-08-15 10:05:01 -06:00
Jan Vrany 26fb3983d7 MI: Add -a option to the "-data-disassemble" command
The CLI "disassemble" command allows specifying a single address - in
that case the function surrounding that address is disassembled.

This commit adds this feature to the equivalent MI command
"-data-disassemble".

gdb/ChangeLog:
2018-08-14  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* mi/mi-cmd-disas.c (mi_cmd_disassemble): Add -a option.
	If used, use find_pc_partial_function to find address range
	to disassemble.
	* mi/mi-main.c (mi_cmd_list_features): Report
	"data-disassemble-a-option" feature.
	* NEWS: Mention new -data-disassemble option -a.

gdb/doc/ChangeLog:
2018-08-14  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.texinfo (GDB/MI Data Manipulation): Document
	"-data-disassemble -a addr".
	(GDB/MI Support Commands): Document "data-disassemble-a-option"
	feature.

gdb/testsuite/ChangeLog:
2018-08-14  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.mi/mi-disassemble.exp (test_disassembly_only): Add tests for
	-data-disassemble -a.
	(test_disassembly_bogus_args): Likewise.
2018-08-14 14:13:28 +01:00
Andrew Burgess 67943c005f gdb: Fix instability in thread groups test
In the test script gdb.mi/list-thread-groups-available.exp we ask GDB
to list all thread groups, and match the output against a
regexp. Occasionally, I would see this test fail.

The expected output is a list of entries, each entry looking roughly
like this:

  {id="<DECIMAL>",type="process",description="<STRING>",
   user="<STRING>",cores=["<DECIMAL>","<DECIMAL>",...]}

All the fields after 'id' and 'type' are optional, and the 'cores'
list can contain 1 or more "<DECIMAL>" entries.

On my machine (Running Fedora 27, kernel 4.17.3-100.fc27.x86_64)
usually the 'description' is a non-empty string, and the 'cores' list
has at least one entry in it.  But sometimes, very rarely, I'll see an
entry in the process group list where the 'description' is an empty
string, the 'user' is the string "?", and the 'cores' list is empty.
Such an entry looks like this:

   {id="19863",type="process",description="",user="?",cores=[]}

I believe that this is caused by the process exiting while GDB is
scanning /proc for process information.  The current code in
gdb/nat/linux-osdata.c is not (I think) resilient against exiting
processes.

This commit adjusts the regex that matches the 'cores' list so that an
empty list is acceptable, with this patch in place the test script
gdb.mi/list-thread-groups-available.exp never fails for me now.

I've only adjusted the cores regexp for the occasion when we have GDB
read information about all processes, its only in this case that we
might encounter an exiting process.  When we read information about
two known PIDs, that we know will not exit for the duration of the
test, we require that the core list be non-empty.

gdb/testsuite/ChangeLog:

	* gdb.mi/list-thread-groups-available.exp: Update test regexp.
2018-08-14 13:38:51 +01:00
Tom Tromey a97b53dda9 Define _FORTIFY_SOURCE in common-defs.h
This defines _FORTIFY_SOURCE in common-defs.h.  This seems like a
sensible safety measure, and also it may help avoid build problems
with -Wunused-result on distros that already define _FORTIFY_SOURCE by
default.

Tested by the buildbot.

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

	* common/common-defs.h (_FORTIFY_SOURCE): Define.
2018-08-13 10:02:00 -06:00
Alan Hayward 0c76e06d5c Parse SVE registers in aarch64 core file reading/writing
sve_regmap cannot be global static as the size is dependant on the current
vector length.

gdb/
	* aarch64-linux-tdep.c (aarch64_linux_supply_sve_regset): New function.
	(aarch64_linux_collect_sve_regset): Likewise.
	(aarch64_linux_iterate_over_regset_sections): Check for SVE.
	* regcache.h (regcache_map_entry_size): New function.
2018-08-13 11:02:22 +01:00
Alan Hayward b7fd65b9dc Detect SVE when reading aarch64 core files
The SVE section in a core file contains a header followed by the registers.
Add defines to easily access the header fields within a buffer.

gdb/
	* aarch64-linux-tdep.c (SVE_HEADER_SIZE_LENGTH): Add define.
	(SVE_HEADER_MAX_SIZE_LENGTH): Likewise.
	(SVE_HEADER_VL_LENGTH): Likewise.
	(SVE_HEADER_MAX_VL_LENGTH): Likewise.
	(SVE_HEADER_FLAGS_LENGTH): Likewise.
	(SVE_HEADER_RESERVED_LENGTH): Likewise.
	(SVE_HEADER_SIZE_OFFSET): Likewise.
	(SVE_HEADER_MAX_SIZE_OFFSET): Likewise.
	(SVE_HEADER_VL_OFFSET): Likewise.
	(SVE_HEADER_MAX_VL_OFFSET): Likewise.
	(SVE_HEADER_FLAGS_OFFSET): Likewise.
	(SVE_HEADER_RESERVED_OFFSET): Likewise.
	(SVE_HEADER_SIZE): Likewise.
	(aarch64_linux_core_read_vq): Add function.
	(aarch64_linux_core_read_description): Check for SVE section.
2018-08-13 10:51:45 +01:00
Alan Hayward a616bb9450 Split size in regset section iterators
In the existing code, when using the regset section iteration functions, the
size parameter is used in different ways.

With collect, size is used to create the buffer in which to write the regset.
(see linux-tdep.c::linux_collect_regset_section_cb).

With supply, size is used to confirm the existing regset is the correct size.
If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size.
Effectively, size is the minimum possible size of the regset.
(see corelow.c::get_core_register_section).

There are currently no targets with both REGSET_VARIABLE_SIZE and a collect
function.
In SVE, a corefile can contain one of two formats after the header, both of
which are different sizes. However, when writing a core file, we always want
to write out the full bigger size.

To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes.
This is done by adding supply_size and collect_size.

gdb/

	* aarch64-fbsd-tdep.c
	(aarch64_fbsd_iterate_over_regset_sections): Add supply_size and
	collect_size.
	* aarch64-linux-tdep.c
	(aarch64_linux_iterate_over_regset_sections): Likewise.
	* alpha-linux-tdep.c
	(alpha_linux_iterate_over_regset_sections):
	* alpha-nbsd-tdep.c
	(alphanbsd_iterate_over_regset_sections): Likewise.
	* amd64-fbsd-tdep.c
	(amd64fbsd_iterate_over_regset_sections): Likewise.
	* amd64-linux-tdep.c
	(amd64_linux_iterate_over_regset_sections): Likewise.
	* arm-bsd-tdep.c
	(armbsd_iterate_over_regset_sections): Likewise.
	* arm-fbsd-tdep.c
	(arm_fbsd_iterate_over_regset_sections): Likewise.
	* arm-linux-tdep.c
	(arm_linux_iterate_over_regset_sections): Likewise.
	* corelow.c (get_core_registers_cb): Likewise.
	(core_target::fetch_registers): Likewise.
	* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
	* frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise.
	* gdbarch.h (void): Regenerate.
	* gdbarch.sh: Add supply_size and collect_size.
	* hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise.
	* hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise.
	* hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise.
	* i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise.
	* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise.
	* i386-tdep.c (i386_iterate_over_regset_sections): Likewise.
	* ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise.
	* linux-tdep.c (linux_collect_regset_section_cb): Likewise.
	* m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise.
	* m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise.
	* m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise.
	* mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise.
	* mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise.
	* mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise.
	* mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise.
	* mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise.
	* nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise.
	* ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise.
	* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise.
	* ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise.
	* ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise.
	* riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise.
	* s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise.
	* score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise.
	* sh-tdep.c (sh_iterate_over_regset_sections): Likewise.
	* sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise.
	* tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise.
	* vax-tdep.c (vax_iterate_over_regset_sections): Likewise.
	* xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
2018-08-13 10:16:41 +01:00
Simon Marchi a9925d4f99 Fix forgotten xstrprintf -> string_printf change
The patch

  528e157 ("Replace some uses of xstrprintf with string_printf")

forgot to actually change an xstrprintf call to string_printf, this one
fixes it.

gdb/ChangeLog:

	* nat/linux-osdata.c (commandline_from_pid): Replace xstrprintf
	with string_printf.
2018-08-10 18:01:11 -04:00
Keith Seitz ad3a68e9b9 Use policies for code generation
This patch changes code generation procedures add_code_header,
add_code_footer, and several other language-specific code generation
functions into policies.

gdb/ChangeLog:
        * compile/compile-c-support.c (add_code_header, add_code_footer):
        Move into policy class.
        (c_push_user_expression, pop_user_expression_nop)
        (c_add_code_header, c_add_code_footer, c_add_input): New policy class.
        (compile_program): New host class.
        (c_compile_program): New typedef.
        (c_compute_porgram): Use c_compile_program.
2018-08-10 11:14:25 -07:00
Keith Seitz 0cfbf43085 Use unique_ptr for htabs
This patch updates the type-conversion caching in C compile to use
unique pointers.  This patch also removes the on-demand allocation of the
symbol error map in favor of initialization, simplifying the code.

gdb/ChangeLog
        * compile/compile-internal.h (compile_instance::~compile_instance):
        Remove calls to htab_delete.
        <m_type_map, m_symbol_err_map>: Switch type to htab_up.
        * compile.c (compile_instance::compile_instance): Initialize
        htab unique pointers.
        (compile_instance::get_cached_type, compile_instance::insert_type)
        (compile_instance::error_symbol_once): Update for unique_ptr.
2018-08-10 11:14:25 -07:00
Keith Seitz 946d3d10e7 Move compile_instance to compile.c
This simple patch moves any code related to compile_instance into
compile.c, reserving compile-c-* files strictly for C language support.

gdb/ChangeLog:
        * compile/compile-c-symbols.c (struct symbol_error)
        (hash_symbol_error, eq_symbol_error, del_symbol_error)
        (compile_instance::insert_symbol_error)
        (compile_instance::error_symbol_once): Move to ...
        * compile/compile.c: ... here.
2018-08-10 11:14:25 -07:00