Commit Graph

39108 Commits

Author SHA1 Message Date
Simon Marchi ea480a306d Change field separator in gdbarch.sh
The fields in the description of the gdbarch interface are separated
using colons.  That becomes a problem if we want to use things like
std::vector in it. This patch changes the field separator to use
semicolons instead.

I think there's very little chance we'll ever want to use a semicolon in
one of the fields, but if you think another character would be more
appropriate, let me know.

gdb/ChangeLog:

	* gdbarch.sh: Use semi-colon as field separator instead of colon.
	* gdbarch.h: Re-generate.
2017-05-02 13:30:07 -04:00
Tim Wiederhake d050f7d7f4 Python: Introduce gdb.Instruction class
This adds a generic instruction class to Python and has gdb.RecordInstruction
inherit from it.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 14f819c8c5 Python: Move and rename gdb.BtraceFunction
Remove gdb.BtraceFunctionCall and replace by gdb.FunctionSegment.  Additionally,
rename prev_segment and next_segment to prev and next.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 0ed5da759e Python: Move and rename gdb.BtraceInstruction
Remove gdb.BtraceInstruction and replace by gdb.RecordInstruction.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 913aeadd9d Python: Introduce gdb.RecordGap class
As discussed here: https://sourceware.org/ml/gdb-patches/2017-04/msg00157.html

A gap is not an instruction and it should not pretend to be one.
gdb.Record.instruction_history is now a list of gdb.RecordInstruction and
gdb.RecordGap objects.  This allows the user to deal with Gaps in the record
in a more sane way.
2017-05-02 11:35:54 +02:00
Tim Wiederhake a3be24ad59 Python: Remove ptid from gdb.Record interface
As discussed here: https://sourceware.org/ml/gdb-patches/2017-04/msg00166.html
2017-05-02 11:35:54 +02:00
Tim Wiederhake ae20e79ae8 Python: Use correct ptid in btrace recording
The user would always get the instruction_history and function_call_history
objects of the current thread, not the thread for which the gdb.Record object
was created.

The attached testcase fails without this patch and passes with the patch.
2017-05-02 11:35:54 +02:00
Tim Wiederhake 8d0050ea19 Python: Fix indentation in py-record-btrace.c 2017-05-02 11:35:54 +02:00
Joel Brobecker 3f380b5027 gdb/MAINTAINERS: Move Daniel J and Mark to the Past Maintainers section.
gdb/ChangeLog:

        * MAINTAINERS: Move Daniel Jacobowitz and Mark Kettenis to
        the past maintainers section.
2017-05-01 10:02:51 -07:00
Sergio Durigan Junior 45ce1b47e4 Make environ.exp run on all platforms (and create info-program.exp)
This has been on my TODO list for a while.  There's a really old bug
about this (PR testsuite/8595), and there was no reason for
environ.exp to be specific for hppa* targets.  So this patch removes
this constraint, modernizes the testcase, and cleans up some things.
Most of the tests remained, and some were rewritten (especially the
one that checks if "show environment" works, which is something kind
of hard to do).

As a bonus, I'm adding a separated info-program.exp file containing
all the tests related to "info program" that were present on
environ.exp.

Tested locally, everything still passes.

gdb/testsuite/ChangeLog:
2017-04-28  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR testsuite/8595
	* gdb.base/environ.exp: Make test available in all architectures.
	Move bits related to "info program" testing to
	gdb.base/info-program.exp.  Rewrite tests to use the two new
	procedures mentione below.
	(test_set_show_env_var) New procedure.
	(test_set_show_env_var_equal): Likewise.
	* gdb.base/info-program.exp: New file.
2017-04-28 20:29:20 -04:00
Yao Qi 0749542484 Remove cleanup in get_return_value
With regcache ctor, we can use it to create local object in
get_return_value (), so that the cleanup can be removed.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

	* infcmd.c (get_return_value): Use regcache ctor, and remove
	cleanup.
2017-04-28 22:48:42 +01:00
Yao Qi deb1fa3eda Use tag dispatch regcache ctor in regcache_dup
This patch adds a tag dispatch ctor to create read-only regcache from
a write-through regcache, also this patch deletes copy ctor and
assignment operator.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>
	    Pedro Alves  <palves@redhat.com>

	* regcache.c (regcache::regcache): New tag dispatch ctor.
	(do_cooked_read): Moved above.
	(regcache_dup): Use the tag dispatch ctor..
	* regcache.h (regcache): Declare ctor, delete copy ctor and
	assignment operator, remove friend regcache_dup.
2017-04-28 22:48:42 +01:00
Yao Qi b421c83cb8 Simplify regcache_dup
regcache_dup, in fact, is to create a readonly regcache from a
non-readonly regcache.  This patch adds an assert that src is not
readonly.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

	* regcache.c (regcache_dup): Assert !src->m_readonly_p and
	call method save instead of regcache_cpy.
	* regcache.h (struct regcache): Make regcache_dup a friend.
2017-04-28 22:48:42 +01:00
Yao Qi ef79d9a3c6 Class-fy regcache
This patch moves regcache declaration to regcache.h, and converts
regcache apis to member functions, for example, regcache_invalidate
is changed to regcache::invalidate.

This patch also add "m_" prefix to these private fields.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

	* regcache.c (struct regcache): Move to regcache.h
	(regcache::arch): New method.
	(regcache_get_ptid): Update.
	(get_regcache_arch): Call arch method.
	(get_regcache_aspace): Call method aspace.
	(register_buffer): Change it to method.
	(regcache_save): Change it to regcache::save.
	(regcache_restore): Likewise.
	(regcache_cpy_no_passthrough): Remove the declaration.
	(regcache_cpy): Call methods restore and cpy_no_passthrough.
	(regcache_cpy_no_passthrough): Change it to method
	cpy_no_passthrough.
	(regcache_register_status): Change it to method
	get_register_status.
	(regcache_invalidate): Change it to method invalidate.
	(regcache_thread_ptid_changed): Use methods ptid and set_ptid.
	(regcache_raw_update): Change it to method raw_update.
	(regcache_raw_read): Likewise.
	(regcache_raw_read_signed): Likewise.
	(regcache_raw_read_unsigned): Likewise.
	(regcache_raw_write_signed): Likewise.
	(regcache_raw_write_unsigned): Likewise.
	(regcache_cooked_read): Likewise.
	(regcache_cooked_read_value): Likewise.
	(regcache_cooked_read_signed): Likewise.
	(regcache_cooked_read_unsigned): Likewise.
	(regcache_cooked_write_signed): Likewise.
	(regcache_cooked_write_unsigned): Likewise.
	(regcache_raw_set_cached_value): Likewise.
	(regcache_raw_write): Likewise.
	(regcache_cooked_write): Likewise.
	(regcache_xfer_part): Likewise.
	(regcache_raw_read_part): Likewise.
	(regcache_raw_write_part): Likewise.
	(regcache_cooked_read_part): Likewise.
	(regcache_cooked_write_part): Likewise.
	(regcache_raw_supply): Likewise.
	(regcache_raw_collect): Likewise.
	(regcache_transfer_regset): Likewise.
	(regcache_supply_regset): Likewise.
	(regcache_collect_regset): Likewise.
	(regcache_debug_print_register): Likewise.
	(enum regcache_dump_what): Move it to regcache.h.
	(regcache_dump): Change it to method dump.
	* regcache.h (enum regcache_dump_what): New.
	(class regcache): New.
	* target.c (target_fetch_registers): Call method
	debug_print_register.
	(target_store_registers): Likewise.
2017-04-28 22:48:42 +01:00
Simon Marchi f8fdb78eaf Class-ify lm_info_windows
This patch makes lm_info_windows a "real" class.  It initializes the field
and replaces XCNEW/xfree with new/delete.

gdb/ChangeLog:

	* windows-nat.c (struct lm_info_windows): Initialize field.
	(windows_make_so): Allocate lm_info_windows with new.
	(windows_free_so): Free lm_info_windows with delete.
2017-04-28 17:16:18 -04:00
Simon Marchi 9ccbfd7bc1 Class-ify lm_info_darwin
This patch makes lm_info_darwin a "real" class.  It initializes the
field and replaces XCNEW/xfree with new/delete.

gdb/ChangeLog:

	* solib-darwin.c (struct lm_info_darwin): Initialize field.
	(darwin_current_sos): Allocate lm_info_darwin with new, remove
	cleanup.
	(darwin_free_so): Free lm_info_darwin with delete.
2017-04-28 17:16:18 -04:00
Simon Marchi 76e75227c3 Class-ify lm_info_svr4
This patch makes lm_info_svr4 a "real" class.  It initializes fields,
uses bool and replaces XCNEW/xfree with new/delete.

The memcpy in svr4_copy_library_list is replaced by a usage of the
default copy constructor.

gdb/ChangeLog:

	* solib-svr4.h (struct lm_info_svr4): Initialize fields.
	<l_addr_p>: Change type to bool.
	* solib-svr4.c (lm_info_read): Allocate lm_info_svr4 with new.
	(svr4_free_so): Free lm_info_svr4 with delete.
	(svr4_copy_library_list): Replace memcpy with call to copy
	constructor.
	(library_list_start_library, svr4_default_sos): Allocate
	lm_info_svr4 with new.
2017-04-28 17:16:17 -04:00
Simon Marchi 51046d9e60 Class-ify lm_info_target
This patch makes lm_info_target a "real" class.  It adds a destructor,
uses std::string, initializes the fields and replaces XCNEW/xfree with
new/delete.

gdb/ChangeLog:

	* solib-target.c (struct lm_info_target): Add destructor,
	initialize fields.
	<name>: Change type to std::string.
	(library_list_start_library): Allocate lm_info_target with new.
	(solib_target_free_library_list): Free lm_info_target with
	delete.
	(solib_target_current_sos): Adapt to std::string.
	(solib_target_free_so): Free lm_info_target with delete.
2017-04-28 17:16:16 -04:00
Simon Marchi 4023ae762e Class-ify lm_info_frv
This patches makes lm_info_frv a "real" class.  It adds a destructor,
initializes the fields and replaces XCNEW/xfree with new/delete.

gdb/ChangeLog:

	* solib-frv.c (struct lm_info_frv): Add destructor, initialize
	fields.
	(frv_current_sos): Allocate lm_info_frv with new.
	(frv_relocate_main_executable): Free lm_info_frv with delete,
	allocate with new.
	(frv_clear_solib, frv_free_so): Free lm_info_frv with delete.
2017-04-28 17:16:16 -04:00
Simon Marchi af43057baf Fix indentation of lm_info_frv
This patch fixes the indentation of lm_info_frv, so that the real
changes of the following patch are not lost in the reformatting.

gdb/ChangeLog:

	* solib-frv.c (struct lm_info_frv): Fix indentation.
2017-04-28 17:16:15 -04:00
Simon Marchi b091120773 Class-ify lm_info_dsbt
This patches makes lm_info_dsbt a "real" class.  It introduces a
destructor, initializes the field and replaces XCNEW/xfree with
new/delete.

gdb/ChangeLog:

	* solib-dsbt.c (struct lm_info_dsbt): Add destructor, initialize
	map field.
	(dsbt_current_sos): Allocate lm_info_dsbt with new.
	(dsbt_relocate_main_executable): Free lm_info_dsbt with delete
	and allocate with new.
	(dsbt_clear_solib, dsbt_free_so): Free lm_info_dsbt with delete.
2017-04-28 17:16:14 -04:00
Simon Marchi 6c401f72e9 Class-ify lm_info_aix
This patch makes lm_info_aix a "real" class.  It uses std::string,
initializes fields in-class and replaces XCNEW/xfree with new/delete.
The solib_aix_new_lm_info can be replaced by using the default copy
constructor.

gdb/ChangeLog:

	* solib-aix.c (struct lm_info_aix): Initialize fields in-class.
	<filename, member_name>: Change type to std::string.
	(solib_aix_new_lm_info, solib_aix_xfree_lm_info): Remove.
	(library_list_start_library): Allocate lm_info_aix with new.
	(solib_aix_free_library_list, solib_aix_free_so): Free with delete.
	(solib_aix_current_sos): Adapt to std::string, copy lm_info_aix
	with copy constructor.
2017-04-28 17:16:14 -04:00
Simon Marchi d0e449a186 Make various lm_info implementations inherit from a base class
The lm_info structure is used to store target specific information about
mapped libraries.  It is currently defined as an opaque type in solist.h
and a pointer to it is included in solist, the target-agnostic object
representing a loaded shared library.  Multiple targets define their own
implementation of lm_info.

In anticipation of using C++ stuff (e.g. vector) in the lm_info objects,
we first need to avoid different definitions of classes with the same
name (which violates the one definition rule).  This patch does it by
having a base class (lm_info_base) from which all the specific lm_info
derive.  Each implementation is renamed to something that makes sense
(e.g. lm_info_aix for AIX).  The next logical step would probably be to
derive directly from so_list, it's not really obvious, so I'll keep that
for another day.

One special case is the Neutrino (nto) support.  It uses SVR4-style
libraries, but overrides some methods.  To do that, it needed to have
its own copy of SVR4's lm_info structure in nto-tdep.c, because it was
just not possible to put it in solib-svr4.h and include that file.  Over
time, that copy got out of sync, which is still the case today.  I can
only assume that the lm_addr function in nto-tdep.c is broken right now.
The first field of the old lm_info was a pointer (gdb_byte *), whereas
in the new lm_info it's an address in the inferior (CORE_ADDR).  Trying
to use that field today probably results in a crash.  With this
refactor, it's now possible to put lm_info_svr4 in solib-svr4.h and just
include it.  I have adapted the code in nto-tdep.c to that it builds,
but it's probably not correct.  Since I don't have the knowledge nor
setup to try this on Neutrino, somebody else would have to fix it.  But
I am confident that I am not making things worse than they already are.

gdb/ChangeLog:

	* solist.h (struct lm_info): Remove.
	(struct lm_info_base): New class.
	(struct so_list) <lm_info>: Change type to lm_info_base *.
	* nto-tdep.c (struct lm_info): Remove.
	(lm_addr): Adjust.
	* solib-aix.c (struct lm_info): Rename to ...
	(struct lm_info_aix): ... this.  Extend lm_info_base.
	(lm_info_p): Rename to ...
	(lm_info_aix_p): ... this, and adjust.
	(solib_aix_new_lm_info, solib_aix_xfree_lm_info,
	solib_aix_parse_libraries, library_list_start_library,
	solib_aix_free_library_list, solib_aix_parse_libraries,
	solib_aix_get_library_list,
	solib_aix_relocate_section_addresses, solib_aix_free_so,
	solib_aix_get_section_offsets,
	solib_aix_solib_create_inferior_hook, solib_aix_current_sos):
	Adjust.
	(struct solib_aix_inferior_data) <library_list>: Adjust.
	* solib-darwin.c (struct lm_info): Rename to ...
	(struct lm_info_darwin): ... this.  Extend lm_info_base.
	(darwin_current_sos, darwin_relocate_section_addresses): Adjust.
	* solib-dsbt.c (struct lm_info): Rename to ...
	(struct lm_info_dsbt): ... this.  Extend lm_info_base.
	(struct dsbt_info) <main_executable_lm_info): Adjust.
	(dsbt_current_sos, dsbt_relocate_main_executable, dsbt_free_so,
	dsbt_relocate_section_addresses): Adjust.
	* solib-frv.c (struct lm_info): Rename to ...
	(struct lm_info_frv): ... this.  Extend lm_info_base.
	(main_executable_lm_info): Adjust.
	(frv_current_sos, frv_relocate_main_executable, frv_free_so,
	frv_relocate_section_addresses, frv_fdpic_find_global_pointer,
	find_canonical_descriptor_in_load_object,
	frv_fdpic_find_canonical_descriptor): Adjust.
	* solib-svr4.c (struct lm_info): Move to solib-svr4.h, renamed
	to lm_info_svr4.
	(lm_info_read, lm_addr_check, svr4_keep_data_in_core,
	svr4_clear_so, svr4_copy_library_list,
	library_list_start_library, svr4_default_sos, svr4_read_so_list,
	svr4_current_sos, svr4_fetch_objfile_link_map,
	solist_update_incremental): Adjust.
	* solib-svr4.h (struct lm_info_svr4): Move here from
	solib-svr4.c.
	* solib-target.c (struct lm_info): Rename to ...
	(struct lm_info_target): ... this.  Extend lm_info_base.
	(lm_info_p): Rename to ...
	(lm_info_target_p): ... this.
	(solib_target_parse_libraries, library_list_start_segment,
	library_list_start_section, library_list_start_library,
	library_list_end_library, solib_target_free_library_list,
	solib_target_current_sos, solib_target_free_so,
	solib_target_relocate_section_addresses): Adjust.
	* windows-nat.c (struct lm_info): Rename to ...
	(struct lm_info_windows): ... this.  Extend lm_info_base.
	(windows_make_so, handle_load_dll, handle_unload_dll,
	windows_xfer_shared_libraries): Adjust.
2017-04-28 17:16:13 -04:00
Simon Marchi 434a402395 Standardize darwin's lm_info
Darwin's lm_info structure is used a little bit differently than the
other solib implementations.  The other implementations first allocate
an so_list object, then instanciate their specific lm_info structure,
and assign it to so_list::lm_info.

The Darwin implementation allocates both at the same time
(darwin_so_list).  This patch changes it to be like the others, so that
we'll be able to do some generalizations later.

gdb/ChangeLog:

	* solib-darwin.c (struct darwin_so_list): Remove.
	(darwin_current_sos): Allocate an so_list object instead of a
	darwin_so_list, separately allocate an lm_info object.
	(darwin_free_so): Free lm_info.
2017-04-28 17:16:12 -04:00
John Baldwin 428544e8ae Consistently use fprintf_filtered when displaying MIPS registers.
One line was using printf_filtered instead of fprintf_filtered
to the requested file.

gdb/ChangeLog:

	* mips-tdep.c (print_gp_register_row): Replace printf_filtered
	with fprintf_filtered.
2017-04-28 09:35:14 -07:00
Yao Qi 4621115fe5 Add constructor and destructor to regcache
This patch adds ctor and dtor to regcache.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

	* regcache.c (regcache::regcache): New function.
	(regcache::~regcache): New function.
	(regcache_xmalloc_1): Remove.
	(regcache_xmalloc): Call new regcache.
	(regcache_xfree): Call delete regcache.
	(get_thread_arch_aspace_regcache): Call new regcache.
2017-04-28 14:43:13 +01:00
Yao Qi 339053c29a Use ptid method lwp in mips_linux_new_thread
gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

	* mips-linux-nat.c (mips_linux_new_thread): Use ptid method
	lwp instead of ptid_get_lwp.
2017-04-28 09:50:51 +01:00
Yao Qi 7974a6050b [MIPS] Use lwpid from lwp_info instead of inferior_ptid
RAJESH reported that GDB gets "Couldn't write debug register: No such
process." on mips64 when GDB attaches to a multi threaded application.

Looks GDB nows PTRACE_GET_WATCH_REGS for inferior_ptid but
PTRACE_SET_WATCH_REGS for lwp->ptid, they may be different.

gdb:

2017-04-28  Yao Qi  <yao.qi@linaro.org>

	* mips-linux-nat.c (mips_linux_new_thread): Get lwpid from
	lwp_info instead of getting from inferior_ptid.
2017-04-28 09:33:16 +01:00
Keith Seitz e15c3eb45b Fix overload resolution involving rvalue references and cv qualifiers.
The following patch fixes several outstanding overload resolution problems
with rvalue references and cv qualifiers in the test suite. The tests for
these problems typically passed with one compiler version and failed with
another. This behavior occurs because of the ordering of the overloaded
functions in the debug info. So the first best match "won out" over the
a subsequent better match.

One of the bugs addressed by this patch is the failure of rank_one_type to
account for type equality of two overloads based on CV qualifiers.  This was
leading directly to problems evaluating rvalue reference overload quality,
but it is also highlighted in gdb.cp/oranking.exp, where two test KFAIL as
a result of this shortcoming.

I found the overload resolution code committed with the rvalue reference
patch (f9aeb8d49) needlessly over-complicated, and I have greatly simplified
it. This fixes some KFAILing tests in gdb.exp/rvalue-ref-overload.exp.

gdb/ChangeLog

	* gdbtypes.c (LVALUE_REFERENCE_TO_RVALUE_BINDING_BADNESS)
	DIFFERENT_REFERENCE_TYPE_BADNESS): Remove.
	(CV_CONVERSION_BADNESS): Define.
	(rank_one_type): Remove overly restrictive rvalue reference
	rank checks.
	Add cv-qualifier checks and subranks for type equality.
	* gdbtypes.h (REFERENCE_CONVERSION_RVALUE,
	REFERENCE_CONVERSION_CONST_LVALUE, CV_CONVERSION_BADNESS,
	CV_CONVERSION_CONST, CV_CONVERSION_VOLATILE): Declare.

gdb/testsuite/ChangeLog

	* gdb.cp/oranking.cc (test15): New function.
	(main): Call test15 and declare additional variables for testing.
	* gdb.cp/oranking.exp: Remove kfail status for "p foo4(&a)" and
	"p foo101('abc')" tests.
	* gdb.cp/rvalue-ref-overloads.exp: Remove kfail status for
	"lvalue reference overload" test.
	* gdb.cp/rvalue-ref-params.exp: Remove kfail status for
	"print value of f1 on Child&& in f2" test.
2017-04-27 15:58:54 -07:00
Simon Marchi 72bc1d2466 Add missing incref when creating Inferior Python object
The test py-inferior.exp fails when using a debug build of Python 3.6.  I don't
see it failing with my system's default Python, but it might be related to the
different memory allocation scheme used when doing a build with pydebug.

The issue is that we are missing a Py_INCREF in
inferior_to_inferior_object.  The PyObject_New function initializes the
object with a refcount of 1.  If we assume that this refcount
corresponds to the reference we are returning, then we are missing an
incref for the reference in the inferior data.

The counterpart for the incref that corresponds to the reference in the
inferior data is in py_free_inferior, in the form the gdbpy_ref instance.

Here's how I can get it to crash (with some debug output):

  $ ./gdb -nx -ex "set debug python 1"
  (gdb) add-inferior
  Added inferior 2
  (gdb) python infs = gdb.inferiors()
  Creating Python Inferior object inf = 1
  Creating Python Inferior object inf = 2
  (gdb) remove-inferiors 2
  py_free_inferior inf = 2
  infpy_dealloc inf = <unknown>
  (gdb) python infs = None
  Fatal Python error: Objects/tupleobject.c:243 object at 0x7f9cf1a568d8 has negative ref count -1

  Current thread 0x00007f9cf1b68780 (most recent call first):
    File "<string>", line 1 in <module>
  [1]    408 abort (core dumped)  ./gdb -nx -ex "set debug python 1"

After having created the inferiors object, their refcount is 1 (which
comes from PyObject_New), but it should be two.  The gdb inferior object
has a reference and the "infs" list has a reference.

When invoking remove-inferiors, py_free_inferior gets called.  It does
the decref that corresponds to the reference that the gdb inferior
object kept.  At this moment, the refcount drops to 0 and the object
gets deallocated, even though the "infs" list still has a reference.
When we set "infs" to None, Python tries to decref the already zero
refcount and the assert triggers.

With this patch, it looks better:

  (gdb) add-inferior
  Added inferior 2
  (gdb) python infs = gdb.inferiors()
  Creating Python Inferior object inf = 1
  Creating Python Inferior object inf = 2
  (gdb) remove-inferiors 2
  py_free_inferior inf = 2
  (gdb) python infs = None
  infpy_dealloc inf = <unknown>

gdb/ChangeLog:

	* python/py-inferior.c (inferior_to_inferior_object): Increment reference
	count when creating the object.
2017-04-27 17:03:25 -04:00
Ulrich Weigand 55bcecda57 Read corrrect auxiliary entry in AIX
Fix handling of XCOFF function auxiliary entries, in particular when
the xlc -qfuncsect or gcc -ffunction-sections compiler option is used
in AIX.  Also handle C_WEAKEXT storage class.

gdb/
2016-10-21  Sangamesh Mallayya  <sangamesh.swamy@in.ibm.com>
	    Ulrich Weigand  <uweigand@de.ibm.com>

	* xcoffread.c (read_xcoff_symtab): Read correct function auxiliary
	entry if xlc -qfuncsect or gcc -ffunction-sections compiler option
	is used in AIX.
	(read_xcoff_symtab): Handle C_WEAKEXT storage class.
	(process_xcoff_symbol): Likewise.
	(scan_xcoff_symtab): Likewise.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
2017-04-27 15:57:08 +02:00
Alan Hayward 5c99fcf803 Remove some MAX_REGISTER_SIZE uses in ia64-tdep.c
gdb/
	* ia64-tdep.c (examine_prologue): Use get_frame_register_unsigned.
	(ia64_sigtramp_frame_prev_register): Use read_memory_unsigned_integer.
	(ia64_access_reg): Use get_frame_register_unsigned.
	(ia64_access_rse_reg): Likewise.
	(ia64_libunwind_frame_prev_register): Likewise.
2017-04-27 11:38:14 +01:00
Jiong Wang b41c5a85a7 [gdbarch] New method "execute_dwarf_cfa_vendor_op" and migrate SPARC to it
Recently a feature called "return address signing" has been added to GCC to
prevent stack smash stack on AArch64.  For details please refer:

  https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00376.html

GDB needs to be aware of this feature so it can restore the original return
address which is critical for unwinding.

On compiler side, whenever return address, i.e. LR register, is mangled or
restored by hardware instruction, compiler is expected to generate a
DW_CFA_AARCH64_negate_ra_state to toggle return address signing status.

DW_CFA_AARCH64_negate_ra_state is using the same CFI number and
therefore need to be multiplexed with DW_CFA_GNU_window_save which was designed
for SPARC.

A new gdbarch method "execute_dwarf_cfa_vendor_op" is introduced by this patch.
It's parameters has been restricted to those only needed by SPARC and AArch64
for multiplexing DW_CFA_GNU_window_save which is a CFI operation takes none
operand.  Should any further DWARF CFI operation want to be multiplexed in the
future,  the parameter list can be extended.  Below is the current function
prototype.

   typedef int (gdbarch_execute_dwarf_cfa_vendor_op_ftype)
     (struct gdbarch *gdbarch, gdb_byte op, struct dwarf2_frame_state *fs);

DW_CFA_GNU_window_save support for SPARC is migrated to this new gdbarch
method by this patch.

gdb/
	* gdbarch.sh: New gdbarch method execute_dwarf_cfa_vendor_op.
	* gdbarch.c: Regenerated.
	* gdbarch.h: Regenerated.
	* dwarf2-frame.c (dwarf2_frame_state_alloc_regs): Made the
	visibility external.
	(execute_cfa_program): Call execute_dwarf_cfa_vendor_op for CFI
	between DW_CFA_lo_user and DW_CFA_high_user inclusive.
	(enum cfa_how_kind): Move to ...
	(struct dwarf2_frame_state_reg_info): Likewise.
	(struct dwarf2_frame_state): Likewise.
	* dwarf2-frame.h: ... here.
	(dwarf2_frame_state_alloc_regs): New declaration.
	* sparc-tdep.c (sparc_execute_dwarf_cfa_vendor_op): New function.
	(sparc32_gdbarch_init): Register execute_dwarf_cfa_vendor_op hook.
2017-04-26 14:05:03 +01:00
Alan Hayward c185f580b2 xtensa_pseudo_register_read/write - Use regcache_raw_read_unsigned
gdb/
	* xtensa-tdep.c (xtensa_pseudo_register_read): Use
	regcache_raw_read_unsigned.
	(xtensa_pseudo_register_write): Likewise.
2017-04-26 10:34:15 +01:00
Alan Hayward 19c4559475 nds32: Abort instead of returning REG_UNKNOWN
gdb/
	* nds32-tdep.c (nds32_pseudo_register_read): Abort on errors.
	(nds32_pseudo_register_write): Likewise.
2017-04-26 09:57:15 +01:00
Yao Qi 4658f12e9c Change readonly_p to bool
This patch changes readonly_p type to bool.

gdb:

2017-04-25  Yao Qi  <yao.qi@linaro.org>

	* regcache.c (struct regcache) <readonly_p>: Change its type
	to bool.
	(regcache_xmalloc_1): Update parameter type and callers update.
2017-04-25 21:32:05 +01:00
Yao Qi d581dda881 Change gdbarch_wchar_bit for AArch64 and ARM
The size of wchar_t on AArch64 and ARM is 4-byte, so we can use the
default value (4*TARGET_CHAR_BIT).

This patch fixes some fails in gdb.cp/wide_char_types.exp on
aarch64-linux.

gdb:

2017-04-25  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_gdbarch_init): Don't call
	set_gdbarch_wchar_bit.
	* arm-tdep.c (arm_gdbarch_init): Likewise.
2017-04-25 15:15:54 +01:00
Pedro Alves debed3db48 Fix build on gcc < 5 (std::is_trivially_copyable missing)
Ref: https://sourceware.org/ml/gdb-patches/2017-04/msg00660.html

Simply skip the poisoning on older compilers.

gdb/ChangeLog:
2017-04-25  Pedro Alves  <palves@redhat.com>

	* common/poison.h [!HAVE_IS_TRIVIALLY_COPYABLE] (IsRelocatable)
	(BothAreRelocatable, memcopy, memmove): Don't define.
	* common/traits.h (__has_feature, HAVE_IS_TRIVIALLY_COPYABLE): New
	macros.
2017-04-25 10:58:57 +01:00
Pedro Alves b0b92aeb38 Poison non-POD memset & non-trivially-copyable memcpy/memmove
This patch catches invalid initialization of non-POD types with
memset, at compile time.

This is what I used to catch the problems fixed by the previous
patches in the series:

  $ make -k 2>&1 | grep "deleted function"
  src/gdb/breakpoint.c:951:53: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = bp_location; <template-parameter-1-2> = void; size_t = long unsigned int]’
  src/gdb/breakpoint.c:7325:32: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = bp_location; <template-parameter-1-2> = void; size_t = long unsigned int]’
  src/gdb/btrace.c:1153:42: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = btrace_insn; <template-parameter-1-2> = void; size_t = long unsigned int]’
...

gdb/ChangeLog:
2017-04-25  Pedro Alves  <palves@redhat.com>

	* common/common-defs.h: Include "common/poison.h".
	* common/function-view.h: (Not, Or, Requires): Move to traits.h
	and adjust.
	* common/poison.h: New file.
	* common/traits.h: Include <type_traits>.
	(Not, Or, Requires): New, moved from common/function-view.h.
2017-04-25 01:46:19 +01:00
Pedro Alves 16c4d54a71 Don't memset non-POD types: struct breakpoint
Eh, struct breakpoint was made non-POD just today, with commit
d28cd78ad8 ("Change breakpoint event locations to
event_location_up").  :-)

  src/gdb/breakpoint.c: In function ‘void init_raw_breakpoint_without_location(breakpoint*, gdbarch*, bptype, const breakpoint_ops*)’:
  src/gdb/breakpoint.c:7447:28: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = breakpoint; <template-parameter-1-2> = void; size_t = long unsigned int]’
     memset (b, 0, sizeof (*b));
			      ^
  In file included from src/gdb/common/common-defs.h:85:0,
		   from src/gdb/defs.h:28,
		   from src/gdb/breakpoint.c:20:
  src/gdb/common/poison.h:56:7: note: declared here
   void *memset (T *s, int c, size_t n) = delete;
	 ^

gdb/ChangeLog:
2017-04-25  Pedro Alves  <palves@redhat.com>

	* breakpoint.h (struct breakpoint): In-class initialize all
	fields.  Make boolean fields "bool".
	* breakpoint.c (init_raw_breakpoint_without_location): Remove
	memset call and initializations no longer necessary.
2017-04-25 01:45:21 +01:00
Pedro Alves b5c3668253 Don't memset non-POD types: struct btrace_insn
struct btrace_insn is not a POD [1] so we shouldn't be using memset to
initialize it [2].

Use list-initialization instead, wrapped in a "pt insn to btrace insn"
function, which looks like just begging to be added next to the
existing pt_reclassify_insn/pt_btrace_insn_flags functions.

[1] - because its field "flags" is not POD, because enum_flags has a
non-trivial default ctor.

gdb/ChangeLog:
2017-04-25  Pedro Alves  <palves@redhat.com>

	* btrace.c (pt_btrace_insn_flags): Change parameter type to
	reference.
	(pt_btrace_insn): New function.
	(ftrace_add_pt): Remove memset call and use pt_btrace_insn.
2017-04-25 01:43:52 +01:00
Pedro Alves 5625a28641 Don't memset non-POD types: struct bp_location
struct bp_location is not a POD, so we shouldn't be using memset to
initialize it.

Caught like this:

  src/gdb/breakpoint.c: In function ‘bp_location** get_first_locp_gte_addr(CORE_ADDR)’:
  src/gdb/breakpoint.c:950:53: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = bp_location; <template-parameter-1-2> = void; size_t = long unsigned int]’
     memset (&dummy_loc, 0, sizeof (struct bp_location));
						       ^
  In file included from src/gdb/defs.h:28:0,
		   from src/gdb/breakpoint.c:20:
  src/gdb/common/common-defs.h:126:7: note: declared here
   void *memset (T *s, int c, size_t n) = delete;
	 ^

gdb/ChangeLog:
2017-04-25  Pedro Alves  <palves@redhat.com>

	* ada-lang.c (ada_catchpoint_location): Now a "class".  Remove
	"base" field and inherit from "bp_location" instead.  Add
	non-default ctor.
	(allocate_location_exception): Use new non-default ctor.
	* breakpoint.c (get_first_locp_gte_addr): Remove memset call.
	(init_bp_location): Convert to ...
	(bp_location::bp_location): ... this new ctor, and remove memset
	call.
	(base_breakpoint_allocate_location): Use the new non-default ctor.
	* breakpoint.h (bp_location): Now a class.  Declare default and
	non-default ctors.  In-class initialize all members.
	(init_bp_location): Remove declaration.
2017-04-25 01:43:06 +01:00
Pedro Alves 23bcc18f47 Don't memcpy non-trivially-copyable types: Make enum_flags triv. copyable
The delete-memcpy-with-non-trivial-types patch exposed many instances
of this problem:

  src/gdb/btrace.h: In function ‘btrace_insn_s* VEC_btrace_insn_s_quick_insert(VEC_btrace_insn_s*, unsigned int, const btrace_insn_s*, const char*, unsigned int)’:
  src/gdb/common/vec.h:948:62: error: use of deleted function ‘void* memmove(T*, const U*, size_t) [with T = btrace_insn; U = btrace_insn; <template-parameter-1-3> = void; size_t = long unsigned int]’
     memmove (slot_ + 1, slot_, (vec_->num++ - ix_) * sizeof (T));    \
								^
  src/gdb/common/vec.h:436:1: note: in expansion of macro ‘DEF_VEC_FUNC_O’
   DEF_VEC_FUNC_O(T)         \
   ^
  src/gdb/btrace.h:84:1: note: in expansion of macro ‘DEF_VEC_O’
   DEF_VEC_O (btrace_insn_s);
   ^
[...]
  src/gdb/common/vec.h:1060:31: error: use of deleted function ‘void* memcpy(T*, const U*, size_t) [with T = btrace_insn; U = btrace_insn; <template-parameter-1-3> = void; size_t = long unsigned int]’
	  sizeof (T) * vec2_->num);       \
				 ^
  src/gdb/common/vec.h:437:1: note: in expansion of macro ‘DEF_VEC_ALLOC_FUNC_O’
   DEF_VEC_ALLOC_FUNC_O(T)         \
   ^
  src/gdb/btrace.h:84:1: note: in expansion of macro ‘DEF_VEC_O’
   DEF_VEC_O (btrace_insn_s);
   ^

So, VECs (given it's C roots) rely on memcpy/memcpy of VEC elements to
be well defined, in order to grow/reallocate its internal elements
array.  This means that we can only put trivially copyable types in
VECs.  E.g., if a type requires using a custom copy/move ctor to
relocate, then we can't put it in a VEC (so we use std::vector
instead).  But, as shown above, we're violating that requirement.

btrace_insn is currently not trivially copyable, because it contains
an enum_flags field, and that is itself not trivially copyable.  This
patch corrects that, by simply removing the user-provided copy
constructor and assignment operator.  The compiler-generated versions
work just fine.

Note that std::vector relies on std::is_trivially_copyable too to know
whether it can reallocate its elements with memcpy/memmove instead of
having to call copy/move ctors and dtors, so if we have types in
std::vectors that weren't trivially copyable because of enum_flags,
this will make such vectors more efficient.

gdb/ChangeLog:
2017-04-25  Pedro Alves  <palves@redhat.com>

	* common/enum-flags.h (enum_flags): Don't implement copy ctor and
	assignment operator.
2017-04-25 01:42:03 +01:00
Yao Qi e1ba30532c Use floatformat_totalsize_bytes
The code can be replaced by floatformat_totalsize_bytes.

gdb:

2017-04-24  Yao Qi  <yao.qi@linaro.org>

	* doublest.c (convert_doublest_to_floatformat): Call
	floatformat_totalsize_bytes.
2017-04-24 21:29:12 +01:00
Tom Tromey 10f489e576 Use ui_out_emit_list
This changes some spots to use ui_out_emit_list.  This only touches
"easy" cases, where the cleanup was used in a block-structured way.
There's also one more use of ui_out_emit_tuple in here.

ChangeLog
2017-04-22  Tom Tromey  <tom@tromey.com>

	* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use
	ui_out_emit_list.
	* stack.c (print_frame): Use ui_out_emit_list.
	* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Use
	ui_out_emit_list.
	* mi/mi-main.c (print_one_inferior)
	(mi_cmd_data_list_register_names)
	(mi_cmd_data_list_register_values, mi_cmd_list_features)
	(mi_cmd_list_target_features, mi_cmd_trace_frame_collected): Use
	ui_out_emit_list.
	* mi/mi-interp.c (mi_on_normal_stop_1): Use ui_out_emit_list.
	(mi_output_solib_attribs): Use ui_out_emit_list,
	ui_out_emit_tuple.
	* mi/mi-cmd-var.c (varobj_update_one): Use ui_out_emit_list.
	* mi/mi-cmd-stack.c (mi_cmd_stack_list_frames)
	(mi_cmd_stack_list_args, list_args_or_locals): Use
	ui_out_emit_list.
	* disasm.c (do_assembly_only): Use ui_out_emit_list.
	* breakpoint.c (print_solib_event, output_thread_groups): Use
	ui_out_emit_list.
2017-04-22 09:47:01 -06:00
Tom Tromey 0092b74da6 Use ui_out_emit_tuple in more places in MI
This patch changes a few more spots in MI to use ui_out_emit_tuple.
These changes required the use of gdb::optional.

ChangeLog
2017-04-22  Tom Tromey  <tom@tromey.com>

	* mi/mi-main.c (print_variable_or_computed): Use ui_out_emit_tuple.
	* mi/mi-cmd-var.c (varobj_update_one): Use ui_out_emit_tuple.
	* mi/mi-cmd-stack.c (list_arg_or_local): Use ui_out_emit_tuple.
2017-04-22 09:47:00 -06:00
Tom Tromey a14a62ddff Use ui_out_emit_tuple in tracepoint.c
This changes some code in tracepoint.c to use ui_out_emit_tuple.  One
of these involved removing an otherwise unrelated cleanup (changing
type to std::string) and the other involved introducing a new block.

ChangeLog
2017-04-22  Tom Tromey  <tom@tromey.com>

	* tracepoint.c (tvariables_info_1)
	(print_one_static_tracepoint_marker): Use ui_out_emit_tuple.
2017-04-22 09:46:59 -06:00
Tom Tromey 46b9c12945 More uses of ui_out_emit_tuple
This patch adds a few more uses of ui_out_emit_tuple.  In these cases
a slightly more complicated change was needed.  This also adds
annotate_arg_emitter, for use in stack.c, to avoid having to introduce
a new scope and reindent the code for a single call.

ChangeLog
2017-04-22  Tom Tromey  <tom@tromey.com>

	* stack.c (print_frame_arg): Use ui_out_emit_tuple,
	annotate_arg_emitter.
	* breakpoint.c (print_mention_watchpoint)
	(print_mention_masked_watchpoint): Use ui_out_emit_tuple.
	* annotate.h (struct annotate_arg_emitter): New.
2017-04-22 09:46:59 -06:00
Tom Tromey 2e78302469 Use ui_out_emit_tuple
This patch changes various places to use ui_out_emit_tuple,
eliminating a number of cleanups.  This patch only tackles "easy"
cases, which are ones where the cleanups in question were
block-structured and did not involve any changes other than the
obvious replacement.

ChangeLog
2017-04-22  Tom Tromey  <tom@tromey.com>

	* record-btrace.c (record_btrace_insn_history)
	(record_btrace_insn_history_range, record_btrace_call_history)
	(record_btrace_call_history_range): Use ui_out_emit_tuple.
	* thread.c (do_captured_list_thread_ids, print_thread_info_1): Use
	ui_out_emit_tuple.
	* stack.c (print_frame_info): Use ui_out_emit_tuple.
	* solib.c (info_sharedlibrary_command): Use ui_out_emit_tuple.
	* skip.c (skip_info): Use ui_out_emit_tuple.
	* remote.c (show_remote_cmd): Use ui_out_emit_tuple.
	* progspace.c (print_program_space): Use ui_out_emit_tuple.
	* probe.c (info_probes_for_ops): Use ui_out_emit_tuple.
	* osdata.c (info_osdata): Use ui_out_emit_tuple.
	* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Use
	ui_out_emit_tuple.
	* mi/mi-main.c (print_one_inferior, list_available_thread_groups)
	(output_register, mi_cmd_data_read_memory)
	(mi_cmd_data_read_memory_bytes, mi_load_progress)
	(mi_cmd_trace_frame_collected): Use ui_out_emit_tuple.
	* mi/mi-cmd-var.c (mi_cmd_var_list_children, varobj_update_one):
	Use ui_out_emit_tuple.
	* mi/mi-cmd-stack.c (mi_cmd_stack_list_args): Use
	ui_out_emit_tuple.
	* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions)
	(mi_cmd_info_gdb_mi_command): Use ui_out_emit_tuple.
	* linux-thread-db.c (info_auto_load_libthread_db): Use
	ui_out_emit_tuple.
	* inferior.c (print_inferior): Use ui_out_emit_tuple.
	* gdb_bfd.c (print_one_bfd): Use ui_out_emit_tuple.
	* disasm.c (do_mixed_source_and_assembly_deprecated)
	(do_mixed_source_and_assembly): Use ui_out_emit_tuple.
	* cp-abi.c (list_cp_abis): Use ui_out_emit_tuple.
	* cli/cli-setshow.c (cmd_show_list): Use ui_out_emit_tuple.
	* breakpoint.c (print_one_breakpoint_location)
	(print_one_breakpoint): Use ui_out_emit_tuple.
	* auto-load.c (print_script, info_auto_load_cmd): Use
	ui_out_emit_tuple.
	* ada-tasks.c (print_ada_task_info): Use ui_out_emit_tuple.
2017-04-22 09:46:58 -06:00
Simon Marchi ebe553db6c doc: Improve documentation about MI thread output
I noticed that the documentation on how the info about threads is output
in MI is duplicated and not up to date.  The duplication is between the
"GDB/MI Thread Information" page and the -thread-info result
description.

I improved the "GDB/MI Thread Information" page a bit and referred to it
in the -thread-info doc.  This way, the -thread-info doc is more precise
(it did not mention the "threads" and "current-thread-id" attributes)
and concise.

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Thread Information): Add missing
	fields, re-word some things.
	(GDB/MI Thread Commands): Describe fields found in the output of
	-thread-info, remove description of fields in the
	thread output tuple, replace with a cross-reference to "GDB/MI
	Thread Information".
2017-04-21 21:50:22 -04:00