Commit Graph

36660 Commits

Author SHA1 Message Date
Andrew Burgess 150375dc7a gdb/tui: Define tui window names once.
Don't duplicate the window names inside the completion function.
Instead make use of the existing defines, and the tui_win_name function
to obtain the window names.

gdb/ChangeLog:

	* tui/tui-win.c (focus_completer): Don't duplicate the tui window
	names in this function.
2015-07-10 12:38:38 +01:00
Andrew Burgess 6dce28e413 gdb: Convert TUI windows names to lower case.
This commit converts the window names for the TUI windows to lower case.
The windows names are already lower case in the documentation, and are
shown as lower case in some of the command completion results.

Given that all the commands that take a window name currently accept
upper or lower case, this commit just changes the window names to lower
case in the remaining places they are displayed by gdb.

gdb/ChangeLog:

	* tui/tui-data.h (SRC_NAME): Convert to lower case.
	(CMD_NAME): Likewise.
	(DATA_NAME): Likewise.
	(DISASSEM_NAME): Likewise.
	* tui/tui-win.c (tui_set_focus): Window names are now lower case.
	(tui_set_win_height): Likewise.
	(parse_scrolling_args): Likewise.
2015-07-10 12:37:57 +01:00
Andreas Arnez e03ed3c64a gnu_vector.exp: Skip infcall tests on x86/x86_64
Since the new KFAILs/KPASSs for the infcall tests on x86 and x86_64
targets generated unnecessary noise, this change skips them with
UNSUPPORTED instead.

gdb/testsuite/ChangeLog:

	* gdb.base/gnu_vector.exp: On x86 and x86_64 targets, skip the
	infcall tests instead of setting up for KFAIL.
2015-07-10 10:36:02 +02:00
Markus Metzger 485668e5b3 record: set stop_pc in "record goto" command
When navigating in the recorded execution trace via "record goto", we do not
set stop_pc.  This may trigger an internal error in infrun.c when stepping
from that location.  Set it.

(gdb) rec full
(gdb) c
Continuing.

Breakpoint 1, foo (void) at foo.c:42
42             x = y
(gdb) rn
foo (void)
    at foo.c:41
41             y = x
(gdb) rec go end
Go forward to insn number 98724
    at foo.c:42
42             x = y
(gdb) n
infrun.c:2382: internal-error: resume: Assertion `sig != GDB_SIGNAL_0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

This happens because there's a breakpoint at PC when the "next"
is issued, so that breapoint should be immediately stepped over.
That should have been detected/done by proceed, here:

  if (addr == (CORE_ADDR) -1)
    {
      if (pc == stop_pc
	  && breakpoint_here_p (aspace, pc) == ordinary_breakpoint_here
	  && execution_direction != EXEC_REVERSE)
	/* There is a breakpoint at the address we will resume at,
	   step one instruction before inserting breakpoints so that
	   we do not stop right away (and report a second hit at this
	   breakpoint).

	   Note, we don't do this in reverse, because we won't
	   actually be executing the breakpoint insn anyway.
	   We'll be (un-)executing the previous instruction.  */
	tp->stepping_over_breakpoint = 1;

But since stop_pc was stale, the pc == stop_pc check failed, and left the
breakpont at PC inserted.

gdb/
	* record-btrace.c (record_btrace_goto_begin, record_btrace_goto_end)
	record_btrace_goto): Move call to print_stack_frame ...
	(record_btrace_set_replay): ... here.  Set stop_pc.
	* record-full.c (record_full_goto_entry): Set stop_pc.

testsuite/
	* gdb.btrace/record_goto-step.exp: New.
2015-07-10 09:19:27 +02:00
Pierre Langlois 58d2eda55c Add NEWS entry for tracepoints support on aarch64-linux
gdb/ChangeLog:

	* NEWS: Mention support for tracepoints on aarch64-linux.
2015-07-09 16:35:11 +01:00
Pierre Langlois 7671bf47fc [GDBServer][AArch64] Enable support for tracepoints
gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (aarch64_supports_tracepoints): New
	function.  Return 1.
	(the_low_target): Install it.
2015-07-09 16:35:11 +01:00
Pierre Langlois 7890fb4566 [testsuite][AArch64] Port gdb.trace
This patch adds support for AArch64 to the gdb.trace testsuite.

Note that it does not add support for testing fast tracepoint as it
isn't supported.  Therefore the test cases with inline assembly are not
ported in this patch, as we do not know what the conditions for
inserting a fast tracepoint on AArch64 would be.

gdb/testsuite/ChangeLog:

	* gdb.trace/backtrace.exp: Set registers for aarch64 target.
	* gdb.trace/collection.exp: Likewise.
	* gdb.trace/mi-trace-frame-collected.exp: Likewise.
	* gdb.trace/mi-trace-unavailable.exp: Likewise.
	* gdb.trace/report.exp: Likewise.
	* gdb.trace/trace-break.exp: Likewise.
	* gdb.trace/unavailable.exp: Likewise.
	* gdb.trace/while-dyn.exp: Likewise.
2015-07-09 16:35:11 +01:00
Pierre Langlois ea873d8ea6 [AArch64] Implement gdbarch_gen_return_address gdbarch method
This patch implements the 'collect $_ret' command to collect the return
address of a function in a tracepoint.  It marks the LR register for
collection.

gdb/ChangeLog:

	* aarch64-tdep.c: Add ax.h and ax-gdb.h includes.
	(aarch64_gen_return_address): New function.
	(aarch64_gdbarch_init): Hook it.
2015-07-09 16:35:11 +01:00
Pierre Langlois 02a2a705aa [AArch64] Teach stub unwinder to terminate gracefully
The stub unwinder is used on AArch64 if the target's memory is not
readable at the current PC.  For example, the user could try to call at
an invalid address such as 0x0, as covered in the gdb.base/signull.exp
test case.  Many GDB ports use a similar unwinder to handle this case
too.

If we purposely kill the inferior before examining the trace then we get
the following issue:

~~~
...
(gdb) trace f
Tracepoint 3 at 0x7fb7fc28c0
(gdb) tstart
(gdb) continue
...
(gdb) tstop
(gdb) tsave /tmp/trace
(gdb) kill
...
(gdb) target tfile /tmp/trace
...
(gdb) tfind
Register 31 is not available.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Found trace frame 0, tracepoint 3
#-1 0x0000007fb7fc28c0 in f () ...
^^^
~~~

This patch teaches the stub unwinder to report to the core frame code
with UNWIND_UNAVAILABLE when either the stack pointer of the return
address are unavailable to read from the target.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_make_stub_cache): Set available_p and
	swallow NOT_AVAILABLE_ERROR.
	(aarch64_stub_this_id): Call frame_id_build_unavailable_stack if
	available_p is not set.
	(aarch64_stub_frame_unwind_stop_reason): New function.
	(aarch64_stub_unwind): Install it.
2015-07-09 16:35:11 +01:00
Pierre Langlois 7dfa3edc03 [AArch64] Teach prologue unwinder to terminate gracefully
Without debugging information, we have the following issue when
examining a trace buffer:

~~~
...
(gdb) trace f
Tracepoint 3 at 0x7fb7fc28c0
(gdb) tstart
(gdb) continue
...
(gdb) tstop
(gdb) tfind start
Register 31 is not available.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Found trace frame 0, tracepoint 3
#-1 0x0000007fb7fc28c0 in f () ...
^^^
~~~

The reason for this is that the target's stack pointer is unavailable
when examining the trace buffer.  What we are seeing is due to the
'tfind' command creating a sentinel frame and unwinding it.  If an
exception is thrown, we are left with the sentinel frame being displayed
at level #-1.  The exception is thrown when the prologue unwinder tries
to read the stack pointer to construct an ID for the frame.

This patch fixes this by making the prologue unwinder catch
NOT_AVAILABLE_ERROR exceptions when either registers or memory is
unreadable and report back to the frame core code with
UNWIND_UNAVAILABLE.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_prologue_cache) <available_p>: New
	field.
	(aarch64_make_prologue_cache_1): New function, factored out from
	aarch64_make_prologue_cache.  Do not allocate cache.  Set
	available_p.
	(aarch64_make_prologue_cache): Reimplement wrapping
	aarch64_make_prologue_cache_1, and swallowing
	NOT_AVAILABLE_ERROR.
	(aarch64_prologue_frame_unwind_stop_reason): New function.
	Return UNWIND_UNAVAILABLE if available_p is not set.
	(aarch64_prologue_unwind): Install it.
	(aarch64_prologue_this_id): Move prev_pc and prev_sp limit
	checks into aarch64_prologue_frame_unwind_stop_reason.  Call
	frame_id_build_unavailable_stack if available_p is not set.
2015-07-09 16:35:11 +01:00
Pierre Langlois db63414322 [AArch64] Only access inferior registers when creating a frame cache
This patch moves the address of the start of a function (func) and the
address from which it was called (prev_pc) into aarch64_prologue_cache.
The idea is to keep accesses to the inferior's registers into
aarch64_make_prologue_cache and aarch64_make_stub_cache.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_prologue_cache) <func, prev_pc>: New
	fields.
	(aarch64_scan_prologue): Set prev_pc.
	(aarch64_make_prologue_cache): Set func.
	(aarch64_make_stub_cache): Set prev_pc.
	(aarch64_prologue_this_id): Remove local variables id, pc and
	func.  Read prev_pc and func from cache.
	(aarch64_stub_this_id): Read prev_pc from cache.
2015-07-09 16:35:11 +01:00
Pierre Langlois 8b61f75db5 [AArch64] Refactor aarch64_make_stub_cache
We would previously have to make sure the frame cache was not already
created before calling aarch64_make_stub_cache.  This patch makes this
function check it so the caller does not need to do so.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_make_stub_cache): Update comment.  New
	argument this_cache.  Remove unused local variables reg and
	unwound_fp.  Return early if this_cache is already set.  Set
	this_cache.
	(aarch64_stub_this_id): Update call to aarch64_make_stub_cache.
2015-07-09 16:35:10 +01:00
Pierre Langlois 7c8edfae86 [AArch64] Refactor aarch64_make_prologue_cache
We would previously have to make sure the frame cache was not already
created before calling aarch64_make_prologue_cache.  This patch makes
this function check it so that the caller does not need to do so.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_make_prologue_cache): Update comment.
	New argument this_cache.  Return early if this_cache is already
	set.  Set this_cache.
	(aarch64_prologue_this_id): Update call to
	aarch64_make_prologue_cache.
	(aarch64_prologue_prev_register): Likewise.
	(aarch64_normal_frame_base): Likewise.
2015-07-09 16:35:10 +01:00
Simon Marchi 938c69a118 Factor out memberptr printing code from c_val_print
gdb/ChangeLog:

	* c-valprint.c (c_val_print): Factor out memberptr printing code
	from c_val_print to ...
	(c_val_print_memberptr): ... this new function.
2015-07-09 11:24:57 -04:00
Simon Marchi 49f7fe2880 Factor out int printing code from c_val_print
gdb/ChangeLog:

	* c-valprint.c (c_val_print): Factor out int printing code to ...
	(c_val_print_int): ... this new function.
2015-07-09 11:24:57 -04:00
Simon Marchi 9e4f353ca9 Factor out struct and union printing code from c_val_print
gdb/ChangeLog:

	* c-valprint.c (c_val_print): Factor out struct and union
	printing code to ...
	(c_val_print_struct): ... this new function ...
	(c_val_print_union): ... and this new function.
2015-07-09 11:24:56 -04:00
Simon Marchi 1c67f03263 Factor out pointer printing code from c_val_print
gdb/ChangeLog:

	* c-valprint.c (c_val_print): Factor out pointer printing code
	to ...
	(c_val_print_ptr): ... this new function.
2015-07-09 11:24:56 -04:00
Simon Marchi 0b6ef777bd Factor out array printing code from c_val_print
gdb/ChangeLog:

	* c-valprint.c (c_valprint): Factor our array printing code from
	c_val_print to ...
	(c_val_print_array): ... this new function.
2015-07-09 11:24:56 -04:00
Simon Marchi 1033c33c36 Factor out print_unpacked_pointer from c_val_print
Turn this code into a function, instead of a goto.

gdb/ChangeLog:

	* c-valprint.c (c_val_print): Factor out pointer printing code
	to ...
	(print_unpacked_pointer): ... this new function.
2015-07-09 11:24:56 -04:00
Simon Marchi f6b93c3463 Remove unneeded variable assignment
The assignment to i in the TYPE_CODE_PTR section is not useful.
Removing it allows to move i in a narrower scope, which will help
things somewhere in the next patches.

gdb/ChangeLog:

	* c-valprint.c (c_val_print): Remove an assignment to i and move
	its declaration.
2015-07-09 11:24:56 -04:00
Yao Qi 0f4576e358 Pass ptid to aarch64_linux_get_debug_reg_capacity
This patch is to pass ptid to aarch64_linux_get_debug_reg_capacity,
and stop using global variable inferior_ptid.

gdb:

2015-07-09  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_get_debug_reg_capacity): Add
	argument ptid.  Update comments.  Caller update.
2015-07-09 12:55:45 +01:00
Yao Qi c2d65f389a [gdbserver, aarch64] Set usrregs to NULL in regs_info
Hi,
I happen to read the comments in regs_info below,

struct regs_info
{
  ...
  /* Info used when accessing registers with PTRACE_PEEKUSER /
     PTRACE_POKEUSER.  This can be NULL if all registers are
     transferred with regsets  .*/
  struct usrregs_info *usrregs;

that usrregs can be NULL if all registers are transferred with
regsets, which is exactly what aarch64-linux does.  This patch
is to set usrregs to NULL in regs_info and remove
aarch64_usrregs_info and aarch64_regmap.

gdb/gdbserver:

2015-07-09  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch64-low.c (aarch64_regmap): Remove.
	(aarch64_usrregs_info): Remove.
	(regs_info): Set field usrregs to NULL.
2015-07-09 12:48:09 +01:00
Markus Metzger 37fdfe4c00 btrace, pt: support new packets
Add support for dumping new Intel(R) Processor Trace packets in the
"maint btrace packet-history" command.

gdb/
	* btrace.c (pt_print_packet): Print stop, vmcs, tma, mtc, cyc, and
	mnt packets.
2015-07-09 08:03:10 +02:00
Markus Metzger 80a2b330f7 btrace: fix build fail with 32-bit BFD
When compiling GDB with 32-bit BFD, the build fails with:

In file included from btrace.h:33:0,
                 from btrace.c:23:
/usr/include/intel-pt.h:1643:51: note: expected 'int (*)(uint8_t *, size_t,
 const struct pt_asid *, uint64_t, void *)' but argument is of type 'int
 (*)(gdb_byte *, size_t, const struct pt_asid *, CORE_ADDR, void *)' extern
 pt_export int pt_image_set_callback(struct pt_image *image, ^

gdb/
	* btrace.c (btrace_pt_readmem_callback): Change type of PC argument.
2015-07-09 08:01:44 +02:00
Simon Marchi 4ab31498e4 Add missing spaces in previous patch
gdb/ChangeLog:

	* progspace.c (delete_program_space): Add missing spaces.
2015-07-08 15:48:02 -04:00
Simon Marchi 7a41607e01 Delete program spaces directly when removing inferiors
When deleting an inferior, delete the associated program space as well
if it becomes unused. This replaces the "pruning" approach, with which
you could forget to call prune_program_spaces (as seen, with the
-remove-inferior command, see [1]).

This allows to remove the prune_program_spaces function. At the same
time, I was able to clean up the delete_inferior* family:

 - delete_inferior is unused
 - delete_inferior_silent is only used in monitor_close, but is replaced
   with discard_all_inferiors [2], so it becomes unused
 - All remaining calls to delete_inferior_1 are with silent=1, so the
   parameter is removed
 - delete_inferior_1 is renamed to delete_inferior

I renamed pspace_empty_p to program_space_empty_p. I prefer if the
"exported" functions have a more explicit and standard name.

Tested on Ubuntu 14.10.

[1] https://sourceware.org/ml/gdb-patches/2014-09/msg00717.html
[2] See https://sourceware.org/ml/gdb-patches/2015-07/msg00228.html and
    follow-ups for details.

gdb/Changelog:

	* inferior.c (delete_inferior_1): Rename to ...
	(delete_inferior): ..., remove 'silent' parameter, delete
	program space when unused and remove call to prune_program_spaces.
	Remove the old, unused, delete_inferior.
	(delete_inferior_silent): Remove.
	(prune_inferiors): Change call from delete_inferior_1 to
	delete_inferior and remove 'silent' parameter. Remove call to
	prune_program_spaces.
	(remove_inferior_command): Idem.
	* inferior.h (delete_inferior_1): Rename to...
	(delete_inferior): ..., remove 'silent' parameter and remove the
	original delete_inferior.
	(delete_inferior_silent): Remove.
	* mi/mi-main.c (mi_cmd_remove_inferior): Change call from
	delete_inferior_1 to delete_inferior and remove 'silent'
	parameter.
	* progspace.c (prune_program_spaces): Remove.
	(pspace_empty_p): Rename to...
	(program_space_empty_p): ... and make non-static.
	(delete_program_space): New.
	* progspace.h (prune_program_spaces): Remove declaration.
	(program_space_empty_p): New declaration.
	(delete_program_space): New declaration.
	* monitor.c (monitor_close): Replace call to
	delete_thread_silent and delete_inferior_silent with
	discard_all_inferiors.
2015-07-08 15:41:01 -04:00
Patrick Palka a9bd710f87 tui: replace deprecated_register_changed_hook with observer
This is a straightforward replacement of the TUI's use of the
aforementioned hook with the register_changed observer.  Since this was
the only user of the hook, this patch also removes the hook.

gdb/ChangeLog:

	* defs.h (deprecated_register_changed_hook): Remove prototype.
	* interps.c (clear_iterpreter_hooks): Remove reference to
	deprecated_register_changed_hook.
	* top.c (deprecated_register_changed_hook): Remove prototype.
	* valops.c (value_assign): Remove reference to
	deprecated_register_changed_hook.
	* tui/tui-hooks.c (tui_register_changed): Add parameter "frame".
	Add comment documenting the function.
	(tui_register_changed_observer): Define.
	(tui_install_hooks): Remove reference to
	deprecated_register_changed_hook.  Set
	tui_register_changed_observer.
	(tui_remove_hooks): Remove reference to
	deprecated_register_changed_hook.  Unset
	tui_register_changed_observer.
2015-07-08 14:44:30 -04:00
Andrew Burgess 7c7f93f6e5 gdb/doc: Update 'frame' command documentation.
The documentation for the 'frame' command has gotten a little out of
date, it still mentions architecturally specific details that are no
longer relevant.

This commit removes the old details that no longer apply, and tries to
expand the existing text a little to make the usage clearer for some
cases.

gdb/doc/ChangeLog:

	* gdb.texinfo (Selection): Update documentation for 'frame'
	command.
2015-07-08 17:39:35 +01:00
Simon Marchi ef3f321b39 Revert "Delete program spaces directly when removing inferiors"
Reverted, since it causes a build failure.  It turns out that
delete_inferior_silent wasn't actually unused.

This reverts commit 0560c645c0.
2015-07-08 11:40:35 -04:00
Simon Marchi 0560c645c0 Delete program spaces directly when removing inferiors
When deleting an inferior, delete the associated program space as well
if it becomes unused. This replaces the "pruning" approach, with which
you could forget to call prune_program_spaces (as seen, with the
-remove-inferior command, see [1]).

This allows to remove the prune_program_spaces function. At the same
time, I was able to clean up the delete_inferior* family.
delete_inferior_silent and delete_inferior were unused, which allowed
renaming delete_inferior_1 to delete_inferior. Also, since all calls to
it were with silent=1, I removed that parameter completely.

I renamed pspace_empty_p to program_space_empty_p. I prefer if the
"exported" functions have a more explicit and standard name.

Tested on Ubuntu 14.10.

This obsoletes my previous patch "Add call to prune_program_spaces in
mi_cmd_remove_inferior" [1].

[1] https://sourceware.org/ml/gdb-patches/2014-09/msg00717.html

gdb/Changelog:

	* inferior.c (delete_inferior_1): Rename to ...
	(delete_inferior): ..., remove 'silent' parameter, delete
	program space when unused and remove call to prune_program_spaces.
	Remove the old, unused, delete_inferior.
	(delete_inferior_silent): Remove.
	(prune_inferiors): Change call from delete_inferior_1 to
	delete_inferior and remove 'silent' parameter. Remove call to
	prune_program_spaces.
	(remove_inferior_command): Idem.
	* inferior.h (delete_inferior_1): Rename to...
	(delete_inferior): ..., remove 'silent' parameter and remove the
	original delete_inferior.
	(delete_inferior_silent): Remove.
	* mi/mi-main.c (mi_cmd_remove_inferior): Change call from
	delete_inferior_1 to delete_inferior and remove 'silent'
	parameter.
	* progspace.c (prune_program_spaces): Remove.
	(pspace_empty_p): Rename to...
	(program_space_empty_p): ... and make non-static.
	(delete_program_space): New.
	* progspace.h (prune_program_spaces): Remove declaration.
	(program_space_empty_p): New declaration.
	(delete_program_space): New declaration.
2015-07-08 11:26:32 -04:00
Jan Kratochvil 084641963d compile: Warn for old GCC on cv-qualified self-reference
GDB could:

compile code struct_object.selffield = &struct_object
./compile/compile-c-types.c:83: internal-error: insert_type: Assertion `add == NULL || add->gcc_type == gcc_type' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) FAIL: gdb.compile/compile.exp: compile code struct_object.selffield = &struct_object (GDB internal
error)

The bug was not in GDB but in the GCC part interfacing with GDB.

Alexandre Oliva has fixed it the right way:
	https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=commitdiff;h=072dfdba0ea62abb65514cb3a90cdf3868efe286
	git://gcc.gnu.org/git/gcc.git
	aoliva/libcp1

Attaching this GDB testsuite update + info to user s/he should upgrade GCC.
After Alex upstreams the fix I can update the message to contain the specific
GCC release.

gdb/ChangeLog
2015-07-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR compile/18484
	* compile/compile-c-types.c (insert_type): Change gdb_assert to error.

gdb/testsuite/ChangeLog
2015-07-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR compile/18484
	* gdb.compile/compile.c (struct struct_type): Add volatile to
	selffield's type.
	* gdb.compile/compile.exp
	(compile code struct_object.selffield = &struct_object): Skip further
	struct_object tests if this one xfails.
2015-07-08 14:42:19 +02:00
Robert O'Callahan bcf5c1d96b PR18617 - Incorrect expression bytecode generated for narrowing conversions
The existing code preserves 'from' bits, which is incorrect.  E.g.

 (gdb) maint agent-eval (char)255L
 Scope: 0x4008d6
 Reg mask: 00
   0  const16 255
   3  ext 64
   5  end

'ext 64' should be 'ext 8'; this bytecode evaluates to 255 instead of
the correct result of -1.  The fix is simple.  I ran the entire test
suite on x86-64 and there were no new test failures.

gdb/ChangeLog:
2015-07-08  Robert O'Callahan  <robert@ocallahan.org>

	PR exp/18617
	* ax-gdb.c (gen_conversion): Extend to 'to' bits, not 'from'.

gdb/testsuite/ChangeLog:
2015-07-08  Robert O'Callahan  <robert@ocallahan.org>

	PR exp/18617
	* gdb.trace/ax.exp: Add test.
2015-07-08 10:53:36 +01:00
Markus Metzger e8643a4533 add myself to write-after-approval list
gdb/
	* MAINTAINERS (Write After Approval): Add Markus T. Metzger.
2015-07-08 09:59:07 +02:00
Markus Metzger 76fb6829cd ari: fix strerror() use
Do not use strerror(), instead use safe_strerror().

gdb/
	* nat/linux-btrace.c (kernel_supports_bts, kernel_supports_pt):
	Use safe_strerror() instead of strerror().
2015-07-08 09:57:55 +02:00
Yao Qi 4931af25b8 New proc is_aarch64_target
Some tests expect the the target is aarch64, but checking target
triplet is not accurate, because target triplet can be aarch64 but
the program is in arm (or aarch32) state.

This patch addes a new proc is_aarch64_target which returns true
if the target is on aarch64 state.

gdb/testsuite:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* gdb.arch/aarch64-atomic-inst.exp: Check is_aarch64_target
	instead of istarget "aarch64*-*-*".
	* gdb.arch/aarch64-fp.exp: Likewise.
	* gdb.base/float.exp: Likewise.
	* gdb.reverse/aarch64.exp: Likewise.
	* lib/gdb.exp (is_aarch64_target): New proc.
2015-07-07 16:58:20 +01:00
Yao Qi 9fcf688e80 New proc is_aarch32_target
GDB tests running on arm target should be also run on aarch32
(32-bit mode on aarch64).  There should be no difference.  It is not
precise to check target triplet to decide which tests should be run,
because if I compiler all the test binary in 32-bit (arm program),
but target triplet is still aarch64, so that these arm specific tests
are skipped.

This patch is to add a new proc is_aarch32_target which return true
if target triplet is arm or the test binary is compiled for arm.

gdb/testsuite:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* lib/gdb.exp (is_aarch32_target): New proc.
	* gdb.arch/arm-bl-branch-dest.exp: Check is_aarch32_target
	instead of "istarget "arm*-*-*"".
	* gdb.arch/arm-disp-step.exp: Likewise.
	* gdb.arch/thumb-bx-pc.exp: Likewise.
	* gdb.arch/thumb-prologue.exp: Likewise.
	* gdb.arch/thumb-singlestep.exp: Likewise.
	* gdb.base/disp-step-syscall.exp: Likewise.
	* gdb.base/float.exp: Likewise.
2015-07-07 16:58:19 +01:00
Yao Qi fbd8d50de2 Enable multi-arch test in catch-syscall.exp on aarch64
This patch is to enable test_catch_syscall_multi_arch on aarch64.

gdb/testsuite:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* gdb.base/catch-syscall.exp (test_catch_syscall_multi_arch):
	Set arch1, arch2, syscall1_name, syscall2_name and syscall_number.
2015-07-07 16:58:19 +01:00
Yao Qi 71be1fdc36 Adjust gdb.multi tests for aarch64
Multi-arch related tests under gdb.multi are to compile programs with
the same compiler but different compiler options (-m64 vs -m32).  However,
different compilers are needed to compile both aarch64 program and
arm (aarch32) program.  This patch is to adjust these test cases to
compile programs in different modes with different compiler.

When we use gcc for arm-linux target, its file name can be different,
arm-linux-gnueabihf-gcc, arm-linux-gnueabi-gcc, or arm-none-linux-gnueabi-gcc,
so I add a variable ARM_CC_FOR_TARGET, so that user can set the name
of gcc for arm-linux target on aarch64, like:

 $ make check RUNTESTFLAGS='ARM_CC_FOR_TARGET=arm-linux-gnueabihf-gcc multi-arch.exp'

gdb/testsuite:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* gdb.multi/multi-arch-exec.exp: Set march1 and march2 to "" if target
	is aarch64.  If target is aarch64, set compiler=${ARM_CC_FOR_TARGET}
	if it exists.
	* gdb.multi/multi-arch.exp: Likewise.
2015-07-07 16:58:19 +01:00
Yao Qi 82c40d4b1d Set architecture to arm in arm-*.xml files
This patch is to add the following line to various arm target description
xml files,

<architecture>arm</architecture>

in order to fix problems I've seen on aarch64 multi-arch debugging,

 detach^M
 Detaching from program: build-gdb/gdb/testsuite/gdb.base/attach, process 17145^M
 (gdb) PASS: gdb.base/attach.exp: attach1 detach file^M
 No executable file now.^M
 Architecture of file not recognized.^M
 (gdb) FAIL: gdb.base/attach.exp: attach1, purging symbols after detach

Without this patch, struct target_desc *tdesc_* are not initialised
properly, that is, fields arch and osabi in 'struct target_desc' are
not set properly.  This doesn't cause any problems on single arch
debugging, because arch-utils.c:gdbarch_info_fill will guess correctly.
However, in multi-arch debugging, gdbarch_info_fill gets the aarch64
arch, but the target description is for arm (because the current
inferior is 32-bit arm).

It is a surprise to me we didn't set architecture to "arm" before in *.xml
files, and I didn't find out why didn't do so.  AFAICS,
gdb/features/arm-with-iwmmxt.xml was added firstly (in patch
https://sourceware.org/ml/gdb-patches/2007-01/msg00593.html)
which had <architecture>iwmmxt</architecture>, however, afterwards,
architecture isn't set anymore in features/arm-*.xml files (in patches
https://sourceware.org/ml/gdb-patches/2009-07/msg00689.html and
https://sourceware.org/ml/gdb-patches/2010-08/msg00225.html).

gdb:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* features/arm-with-m-fpa-layout.xml: Set architecture to arm.
	* features/arm-with-m-fpa-layout.c: Regenerated.
	* features/arm-with-m-vfp-d16.xml: Likewise.
	* features/arm-with-m-vfp-d16.c: Regenerated.
	* features/arm-with-m.xml: Likewise.
	* features/arm-with-m.c: Regenerated.
	* features/arm-with-neon.xml: Likewise.
	* features/arm-with-neon.c: Regenerated.
	* features/arm-with-vfpv2.xml: Likewise.
	* features/arm-with-vfpv2.c: Regenerated.
	* features/arm-with-vfpv3.xml: Likewise.
	* features/arm-with-vfpv3.c: Regenerated.
2015-07-07 16:58:19 +01:00
Yao Qi 607685ecee Native debug arm program by aarch64 GDB
This patch is to let aarch64 GDB debug 32-bit arm program natively.  In
each function for fetching and storing registers, GDB will check
gdbarch_bfd_arch_info (gdbarch)->bits_per_word, if it is 32, call
the corresponding aarch32 functions in aarch32-linux-nat.c, otherwise
fall back to aarch64 code to fetch and store registers.

aarch64_linux_read_description has to return the right target description,
but we don't have gdbarch available there, so GDB fetches auxv and gets
AT_PHENT, in order to determine whether the target is 32-bit or 64-bit.
I learned this trick from solib-svr4.c.

gdb:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* aarch32-linux-nat.h (VFP_REGS_SIZE): New macro, moved from
	arm-linux-nat.c.
	* aarch64-linux-nat.c: Include aarch32-linux-nat.h and
	elf/external.h.
	(fetch_gregs_from_thread): Call aarch32_gp_regcache_supply
	if target is 32-bit.
	(store_gregs_to_thread): Call aarch32_gp_regcache_collect
	if target is 32-bit.
	(fetch_fpregs_from_thread): Call aarch32_vfp_regcache_supply
	if target is 32-bit.
	(store_fpregs_to_thread): Call aarch32_vfp_regcache_collect
	if target is 32-bit.
	(tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare.
	(aarch64_linux_read_description): Return the right target
	description.
	* arm-linux-nat.c (VFP_REGS_SIZE): Moved to aarch32-linux-nat.h.
	* config/aarch64/linux.mh (NATDEPFILES): Add aarch32-linux-nat.o.
	* configure.tgt (aarch64*-*-linux*): Add arm-tdep.o and
	arm-linux-tdep.o
2015-07-07 16:58:19 +01:00
Yao Qi f1b6788884 New aarch32-linux-nat.c
This patch is to move all the code about transferring
regcache <-> byte buffer for arm (aarch32) to a separate file
aarch32-linux-nat.c.  Then, in the following patch, aarch64 code
can use it to do multi-arch debugging.  This is a refactory patch.

gdb:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* aarch32-linux-nat.c: New file.
	* aarch32-linux-nat.h: New file.
	* arm-linux-nat.c: Include aarch32-linux-nat.h.
	(fetch_regs): Move code to aarch32-linux-nat.c.  Call
	aarch32_gp_regcache_supply.
	(store_regs): Move code to aarch32-linux-nat.c.  Call
	aarch32_gp_regcache_collect.
	(fetch_vfp_regs): Move code to aarch32-linux-nat.c.  Call
	aarch32_vfp_regcache_supply.
	(store_vfp_regs): Move code to aarch32-linux-nat.c.  Call
	aarch32_vfp_regcache_collect.
	* config/arm/linux.mh (NATDEPFILES): Add aarch32-linux-nat.o.
2015-07-07 16:58:19 +01:00
Yao Qi 179bfe826b Remove {fetch,store}_fpregister and {fetch,store}_register
This patch is to remove fetch_fpregister, fech_register,
store_fpregister and store_register, and use fetch_fpregs,
fetch_regs, store_regs, and store_fpregs instead.

gdb:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (store_fpregister): Remove.
	(store_register): Likewise.
	(fetch_fpregister): Likewise.
	(fetch_register): Likewise.
	(arm_linux_store_inferior_registers): Call store_regs and
	store_fpregs instead.
	(arm_linux_fetch_inferior_registers): Call fetch_fpregs and
	fetch_regs instead.
2015-07-07 16:58:19 +01:00
Simon Marchi 3e221d361f Fix test for Python 3
gdb/testsuite/ChangeLog:

	* gdb.python/py-lazy-string.exp: Add missing parentheses to
	print.
2015-07-07 11:39:06 -04:00
Yao Qi d441430b75 [arm] Fix regression by Do not skip prologue for asm (.S) files
Patch "Do not skip prologue for asm (.S) files" [1] changes GDB's
behaviour on which test gdb.arch/thumb-singlestep.exp depends, so
it causes the fail below:

 (gdb) si^M
 37              blx     foo^M
 (gdb) FAIL: gdb.arch/thumb-singlestep.exp: step into foo

the test assumes the program will stop at the instruction after "push"
but it doesn't.  The fix to this fail is to do one more single step.

[1] https://sourceware.org/ml/gdb-patches/2015-06/msg00561.html

gdb/testsuite:

2015-07-07  Yao Qi  <yao.qi@linaro.org>

	* gdb.arch/thumb-singlestep.exp: Do one more single step.
2015-07-07 10:40:30 +01:00
Andrew Burgess 6008fc5fcd gdb: Rewrite documentation for layout and focus commands.
Changes the documentation for the layout and focus commands.

Instead of documenting each layout (or focus) sub-command as a separate
command, document a single layout (and focus) command which takes a
parameter, then list the possible parameters in a table nested under
each command.

The documentation for the layout command has been extended little to
make it clearer which windows are shown in each layout.

gdb/ChangeLog:

	* doc/gdb.texinfo (TUI): Restructure documentation on TUI layout
	and focus commands.
2015-07-06 22:39:21 +01:00
Joel Brobecker 7c79d316af Update NEWS post GDB 7.10 branch creation.
gdb/ChangeLog:

	* NEWS: Create a new section for the next release branch.
	Rename the section of the current branch, now that it has
	been cut.
2015-07-06 13:02:47 -07:00
Joel Brobecker f2232bea32 Bump version to 7.10.50.DATE-cvs.
Now that the GDB 7.10 branch has been created, we can
bump the version number.

gdb/ChangeLog:

	GDB 7.10 branch created (66c4b3e8a6):
	* version.in: Bump version to 7.10.50.DATE-cvs.
2015-07-06 12:58:29 -07:00
Luis Machado 66c4b3e8a6 Fix problems with finishing a dummy function call on simulators.
This fixes regressions introduced with the original change to not
consider permanent breakpoints always inserted:

  6ae8866180 is the first bad commit
  commit 6ae8866180
  Author: Luis Machado <lgustavo@codesourcery.com>
  Date:   Wed Jun 17 16:50:57 2015 -0300

      Fix problems with finishing a dummy function call on simulators.

Some checks were mistakenly left out of the original patch, which
caused the following failures:

-PASS: gdb.base/shlib-call.exp: print mainshr1(1)
-PASS: gdb.base/shlib-call.exp: step into mainshr1
+FAIL: gdb.base/shlib-call.exp: print mainshr1(1)
+FAIL: gdb.base/shlib-call.exp: step into mainshr1

-PASS: gdb.cp/chained-calls.exp: q(p())
+FAIL: gdb.cp/chained-calls.exp: q(p())

-PASS: gdb.cp/chained-calls.exp: q(p() + r())
+FAIL: gdb.cp/chained-calls.exp: q(p() + r())

-PASS: gdb.cp/chained-calls.exp: g(f(g(f() + f())) + f())
+FAIL: gdb.cp/chained-calls.exp: g(f(g(f() + f())) + f())

-PASS: gdb.cp/chained-calls.exp: *c
-PASS: gdb.cp/chained-calls.exp: *c + *c
-PASS: gdb.cp/chained-calls.exp: q(*c + *c)
+FAIL: gdb.cp/chained-calls.exp: *c
+FAIL: gdb.cp/chained-calls.exp: *c + *c
+FAIL: gdb.cp/chained-calls.exp: q(*c + *c)

-PASS: gdb.cp/classes.exp: calling method for small class
+FAIL: gdb.cp/classes.exp: calling method for small class

The above is likely caused by GDB not removing the permanent
breakpoints from the target, leading to the inferior executing
the breakpoint instruction and tripping on a SIGSEGV.

gdb/ChangeLog:
2015-07-06  Luis Machado  <lgustavo@codesourcery.com>

	* breakpoint.c (remove_breakpoint_1): Don't handle permanent
	breakpoints in a special way.
	(remove_breakpoint): Likewise.
	(mark_breakpoints_out): Likewise.
2015-07-06 16:09:21 -03:00
Andrew Burgess bcd8537ce1 gdb/doc: Fix incorrect use of @xref.
All uses of @xref must be followed by either '.' or ','.  In commit
a4ea0946c an incorrect use of @xref was introduced.  This commit
adds a comma after the use of @xref.

gdb/ChangeLog:

	* doc/gdb.texinfo (TUI): Add comma after @xref.
2015-07-06 19:18:15 +01:00
Andrew Burgess 10e9aaa3b8 gdb/tui: Don't cast between window types.
Instead of casting between structure types to get the 'tui_gen_win_info'
info from a 'tui_win_info' access the generic member variable.  This is
inline with what is done throughout the rest of the tui code.

gdb/ChangeLog:

	* tui/tui-win.c (tui_set_focus): Use structure member 'generic'
	instead of casting the structure type.
2015-07-06 19:13:02 +01:00
Simon Marchi 8a13d42d99 search_struct_field: remove OFFSET parameter
I was trying to understand what the OFFSET parameter was for, and
realized it was set to 0 in every call to search_struct_field.  I
assume that it was used at some point, but some subsequent changes
made it useless.

gdb/ChangeLog:

	* valops.c (search_struct_field): Remove OFFSET parameter.
	(value_cast_structs): Adjust calls to search_struct_field.
	(value_struct_elt): Same.
	(find_overload_match): Same.
2015-07-06 13:10:56 -04:00
Simon Marchi a844296a98 Cleanup value_fetch_lazy's comment and return value
The comment for value_fetch_lazy seems outdated. It says that it's only
called from the value_contents and value_contents_all (macros!), which
is not true.  Also, the return value seems useless now, despite what the
comment says.

gdb/ChangeLog:

	* value.c (value_fetch_lazy): Update comment, change return
	value to void.
	* value.h (value_fetch_lazy): Change return value to void.
2015-07-06 13:04:11 -04:00
Andrew Burgess f41cbf58f4 gdb: tui_win_name: Make parameter and result const.
This commit makes the parameter and the result for 'tui_win_name'
constant.  There's one place in the code that is then updated as a
result of this change.

gdb/ChangeLog:

	* tui/tui-data.c (tui_partial_win_by_name): Window name is const.
	(tui_win_name): Make parameter and result const.
	* tui/tui-data.h (tui_win_name): Make parameter and result const.
2015-07-06 15:54:21 +01:00
Patrick Palka 118ca22445 Don't throw an error in "show mpx bound" implementation
"show" functions should not throw an exception in part because it causes
the output of the commands "info set" and "show" to get truncated.

This fixes the following fails:

    FAIL: gdb.base/default.exp: info set
    FAIL: gdb.base/default.exp: show

gdb/ChangeLog:

	* i386-tdep.c (i386_mpx_info_bounds): Don't call error, instead
	use printf_unfiltered.
	(set_mpx_cmd): Add missing trailing space to command string
	literal.
	(_initialize_i386_tdep): Give the "mpx" prefix command its
	correct name.
2015-07-06 08:07:32 -04:00
Kevin Buettner 1b485e6778 Add support for backtracing through Renesas RX exception frames.
This change adds support for backtracing through Renesas RX exception
frames.

Determination about the type of frame is made by scanning the
remainder of the function for a return instruction and then looking at
which, if any, return instruction is found.  A normal RTS instruction
indicates that the frame is a normal frame.  An RTFI instruction
indicates that it's a fast interrupt, and an RTE instruction indicates
that the frame is a (normal) exception frame.  If no return instruction
is found within the scanned region - which can happen when the end of
the function cannot be found - it is assumed to be a normal frame.

I was able to test that normal prologue scanning still works by
disabling the dwarf2 sniffer.  I've tested this code for normal
interrupts.  The fast interrupt case has not been tested.

gdb/ChangeLog:

	* rx-tdep.c (RX_USP_REGNUM, RX_BPC_REGNUM): New constants.
	(enum rx_frame_type): New.
	(struct rx_prologue): Add new field `frame_type'.
	(rx_analyze_prologue): Add `frame_type' parameter. Cache this
	parameter in the prologue struct.  Add code for recording
	locations of PC and PSW for fast interrupt and exception frames.
	(rx_skip_prologue): Adjust call to rx_analyze_prologue.
	(rx_analyze_frame_prologue): Add `frame_type' parameter.
	(rx_frame_type): New function.
	(rx_frame_base): Fetch frame type and pass it to rx_analyze_prologue.
	(rx_frame_this_id): Rename parameter `this_prologue_cache' to
	`this_cache'.
	(rx_frame_prev_register): Rename parameter `this_prologue_cache' to
	`this_cache'.  Add cases for RX_FRAME_TYPE_EXCEPTION and
	RX_FRAME_TYPE_FAST_INTERRUPT.
	(normal_frame_p, exception_frame_p, rx_frame_sniffer_common)
	(rx_frame_sniffer, rx_exception_sniffer): New functions.
	(rx_frame_unwind): Use rx_frame_sniffer instead of
	default_frame_sniffer.
	(rx_frame_unwind): New unwinder.
	(rx_gdbarch_init): Register new unwinder.
2015-07-02 17:21:18 -07:00
Kevin Buettner 0561fea48c rx: Create and use flags types for psw, bpsw, and fpsw registers.
This change adds two flags types for the (Renesas RX) psw, bpsw, and
fpsw registers.  As a result, symbolic flags are displayed for these
registers in the output of GDB's "info registers" command as well as
in output from other commands, such as "print".

gdb/ChangeLog:

	* rx-tdep.c (RX_BPSW_REGNUM, RX_FPSW_REGNUM): New constants.
	(struct gdbarch_tdep): Add fields rx_psw_type and rx_fpsw_type.
	(rx_register_type): Add cases for RX_PSW_REGNUM, RX_BPSW_REGNUM,
	and RX_FPSW_REGNUM.
	(rx_gdbarch_init): Initialize PSW, BPSW, and FPSW flags types.
2015-07-02 15:26:51 -07:00
Jan Kratochvil decf8d9a5f Fix GCC false warning
At least on
	gcc-4.4.7-11.el6.i686
	./configure --enable-64-bit-bfd --enable-targets=all
GDB does not build due to:
	cc1: warnings being treated as errors
	s390-linux-tdep.c: In function ‘s390_handle_arg’:
	s390-linux-tdep.c:2575: error: ‘val’ may be used uninitialized in this function

gdb/ChangeLog
2015-07-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix GCC false warning.
	* s390-linux-tdep.c (s390_handle_arg): Initialize VAL.
2015-07-02 22:39:57 +02:00
Yao Qi 2fd0f80d57 Fix typo in aarch64_linux_insert_hw_breakpoint
It should be "insert_hw_breakpoint" rather than "insert_hw_watchpoint".

gdb:

2015-07-02  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-nat.c (aarch64_linux_insert_hw_breakpoint): Fix
	typo in the debugging message.
2015-07-02 17:02:05 +01:00
Markus Metzger b0627500e8 btrace: maintenance commands
Add maintenance commands that help debugging the btrace record target.
The following new commands are added:

maint info btrace
  Print information about branch tracing internals.

maint btrace packet-history
  Print the raw branch tracing data.

maint btrace clear-packet-history
  Discard the stored raw branch tracing data.

maint btrace clear
  Discard all branch tracing data.  It will be fetched and processed
  anew by the next "record" command.

maint set|show btrace pt skip-pad
  Set and show whether PAD packets are skipped when computing the
  packet history.

gdb/
	* btrace.c: Include gdbcmd.h, cli/cli-utils.h, and ctype.h.
	(maint_btrace_cmdlist, maint_btrace_set_cmdlist)
	(maint_btrace_show_cmdlist, maint_btrace_pt_set_cmdlist)
	(maint_btrace_pt_show_cmdlist, maint_btrace_pt_skip_pad)
	(btrace_maint_clear): New.
	(btrace_fetch, btrace_clear): Call btrace_maint_clear.
	(pt_print_packet, btrace_maint_decode_pt)
	(btrace_maint_update_pt_packets, btrace_maint_update_packets)
	(btrace_maint_print_packets, get_uint, get_context_size, no_chunk)
	(maint_btrace_packet_history_cmd)
	(maint_btrace_clear_packet_history_cmd, maint_btrace_clear_cmd)
	(maint_btrace_cmd, maint_btrace_set_cmd, maint_btrace_show_cmd)
	(maint_btrace_pt_set_cmd, maint_btrace_pt_show_cmd)
	(maint_info_btrace_cmd, _initialize_btrace): New.
	* btrace.h (btrace_pt_packet, btrace_pt_packet_s)
	(btrace_maint_packet_history, btrace_maint_info): New.
	(btrace_thread_info) <maint>: New.
	* NEWS: Announce it.

doc/
	* gdb.texinfo (Maintenance Commands): Document "maint btrace"
	commands.
2015-07-02 12:56:29 +02:00
Markus Metzger 9be54cae43 btrace: store raw btrace data
Store the raw branch trace data that has been read from the target.

This data can be used for maintenance commands as well as for generating
a core file for the "record save" command.

gdb/
	* btrace.c (btrace_fetch): Append the new trace data.
	(btrace_clear): Clear the stored trace data.
	* btrace.h (btrace_thread_info) <data>: New.
	* common/btrace-common.h (btrace_data_clear)
	(btrace_data_append): New.
	* common/btrace-common.c (btrace_data_clear)
	(btrace_data_append): New.
2015-07-02 12:54:20 +02:00
Markus Metzger 010a18a1b1 btrace, linux: use data_size and data_offset
In struct perf_event_mmap_page there are new fields data_size and data_offset
that give the location of the perf_event data buffer relative to the mmap
page.  Use them if they are present.

gdb/
	* nat/linux-btrace.c (linux_enable_bts): Check for
	PERF_ATTR_SIZE_VER5.
	Check for data_offset and data_size fields.  Use them.
2015-07-02 12:52:19 +02:00
Markus Metzger b20a652466 btrace: support Intel(R) Processor Trace
Adds a new command "record btrace pt" to configure the kernel to use
Intel(R) Processor Trace instead of Branch Trace Strore.

The "record btrace" command chooses the tracing format automatically.

Intel(R) Processor Trace support requires Linux 4.1 and libipt.

gdb/
	* NEWS: Announce new commands "record btrace pt" and "record pt".
	Announce new options "set|show record btrace pt buffer-size".
	* btrace.c: Include "rsp-low.h".
	Include "inttypes.h".
	(btrace_add_pc): Add forward declaration.
	(pt_reclassify_insn, ftrace_add_pt, btrace_pt_readmem_callback)
	(pt_translate_cpu_vendor, btrace_finalize_ftrace_pt)
	(btrace_compute_ftrace_pt): New.
	(btrace_compute_ftrace): Support BTRACE_FORMAT_PT.
	(check_xml_btrace_version): Update version check.
	(parse_xml_raw, parse_xml_btrace_pt_config_cpu)
	(parse_xml_btrace_pt_raw, parse_xml_btrace_pt)
	(btrace_pt_config_cpu_attributes, btrace_pt_config_children)
	(btrace_pt_children): New.
	(btrace_children): Add support for "pt".
	(parse_xml_btrace_conf_pt, btrace_conf_pt_attributes): New.
	(btrace_conf_children): Add support for "pt".
	* btrace.h: Include "intel-pt.h".
	(btrace_pt_error): New.
	* common/btrace-common.c (btrace_format_string, btrace_data_fini)
	(btrace_data_empty): Support BTRACE_FORMAT_PT.
	* common/btrace-common.h (btrace_format): Add BTRACE_FORMAT_PT.
	(struct btrace_config_pt): New.
	(struct btrace_config)<pt>: New.
	(struct btrace_data_pt_config, struct btrace_data_pt): New.
	(struct btrace_data)<pt>: New.
	* features/btrace-conf.dtd (btrace-conf)<pt>: New.
	(pt): New.
	* features/btrace.dtd (btrace)<pt>: New.
	(pt, pt-config, cpu): New.
	* nat/linux-btrace.c (perf_event_read, perf_event_read_all)
	(perf_event_pt_event_type, kernel_supports_pt)
	(linux_supports_pt): New.
	(linux_supports_btrace): Support BTRACE_FORMAT_PT.
	(linux_enable_bts): Free tinfo on error.
	(linux_enable_pt): New.
	(linux_enable_btrace): Support BTRACE_FORMAT_PT.
	(linux_disable_pt): New.
	(linux_disable_btrace): Support BTRACE_FORMAT_PT.
	(linux_fill_btrace_pt_config, linux_read_pt): New.
	(linux_read_btrace): Support BTRACE_FORMAT_PT.
	* nat/linux-btrace.h (struct btrace_tinfo_pt): New.
	(struct btrace_target_info)<pt>: New.
	* record-btrace.c (set_record_btrace_pt_cmdlist)
	(show_record_btrace_pt_cmdlist): New.
	(record_btrace_print_pt_conf): New.
	(record_btrace_print_conf): Support BTRACE_FORMAT_PT.
	(btrace_ui_out_decode_error): Support BTRACE_FORMAT_PT.
	(cmd_record_btrace_pt_start): New.
	(cmd_record_btrace_start): Support BTRACE_FORMAT_PT.
	(cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): New.
	(_initialize_record_btrace): Add new commands.
	* remote.c (PACKET_Qbtrace_pt, PACKET_Qbtrace_conf_pt_size): New.
	(remote_protocol_features): Add "Qbtrace:pt".
	Add "Qbtrace-conf:pt:size".
	(remote_supports_btrace): Support BTRACE_FORMAT_PT.
	(btrace_sync_conf): Support PACKET_Qbtrace_conf_pt_size.
	(remote_enable_btrace): Support BTRACE_FORMAT_PT.
	(_initialize_remote): Add new commands.

gdbserver/
	* linux-low.c: Include "rsp-low.h"
	(linux_low_encode_pt_config, linux_low_encode_raw): New.
	(linux_low_read_btrace): Support BTRACE_FORMAT_PT.
	(linux_low_btrace_conf): Support BTRACE_FORMAT_PT.
	(handle_btrace_enable_pt): New.
	(handle_btrace_general_set): Support "pt".
	(handle_btrace_conf_general_set): Support "pt:size".

doc/
	* gdb.texinfo (Process Record and Replay): Spell out that variables
	and registers are not available during btrace replay.
	Describe the new "record btrace pt" command.
	Describe the new "set|show record btrace pt buffer-size" options.
	(General Query Packets): Describe the new Qbtrace:pt and
	Qbtrace-conf:pt:size packets.
	Expand "bts" to "Branch Trace Store".
	Update the branch trace DTD.
2015-07-02 12:49:32 +02:00
Markus Metzger 58bfce9343 configure: check for libipt
Check for libipt, an Intel(R) Processor Trace decoder library.  The sources
can be found on github at:

    https://github.com/01org/processor-trace

gdb/
	* configure.ac: Check for libipt
	* configure: Regenerate.
	* config.in: Regenerate.
	* Makefile.in (LIBIPT): New.
	(CLIBS): Add $LIBIPT.
	* NEWS: document new configure options
2015-07-02 12:45:50 +02:00
Jan Kratochvil b0fd6b3037 debug compile: Replace confusing debug message
It was found that from

(gdb) set debug compile 1
(gdb) compile code 1
[...]
allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
lookup undefined ELF symbol "_GLOBAL_OFFSET_TABLE_"
allocated 0x10 bytes at 0x7ffff7ff7000 for registers
(gdb) _

the message 'lookup undefined ELF symbol' looks as an error to people,
including to myself once.

Change it to:

allocated 0x7f bytes at 0x7ffff7ff9000 prot 5
allocated 0x38 bytes at 0x7ffff7ff8000 prot 1
ELF symbol "_GLOBAL_OFFSET_TABLE_" relocated to zero
allocated 0x10 bytes at 0x7ffff7ff7000 for registers
(gdb) _

gdb/ChangeLog
2015-07-02  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* compile/compile-object-load.c (compile_object_load): Replace debug
	message "lookup undefined ELF symbol" by 3 more specific messages.
2015-07-02 08:01:35 +02:00
Kevin Buettner 78ab7e9d38 Tabify my ChangeLog entry for 2015-06-29. 2015-07-01 17:46:23 -07:00
Kevin Buettner e62803699d rl78: Create a flags type for the psw register.
For the Renesas rl78 architecture, associate a flags type with the PSW
register. This will cause symbolic flags to be printed when using
the "info registers" command.

gdb/ChangeLog:

	* rl78-tdep.c (struct gdbarch_tdep): Add new field, rl78_psw_type.
	(rl78_register_type): Add case for RL78_PSW_REGNUM.
	(rl78_gdbarch_init): Initialize rl78_psw_type.
2015-07-01 17:36:36 -07:00
Patrick Palka bbcbf914a6 TUI: Make sure to update registers if frame information has changed
When I replaced TUI's frame_changed hook to fix PR tui/13378 I assumed
that there's no reason to refresh register information following a call
to "up", "down" or "frame".  This assumption was made to fix the problem
of refreshing frame information twice following a sync-execution normal
stop (once in tui_normal_stop and then in tui_before_prompt) -- the
second refresh removing any highlights made by the first.

I was wrong about that -- GDB's snapshot of register information is
per-frame, and when the frame changes, registers do too (most
prominently the %rip and %rsp registers).  So e.g. GDB 7.8 would
highlight such register changes after invoking "up", "down" or "frame",
and current GDB does not.

To fix this regression, this patch adds another (sufficient) condition
for refreshing register information: in
tui_refresh_frame_and_register_information, always refresh register
information if frame information has changed.  This makes register
information get refreshed following a call to "up", "down" or "frame"
while still avoiding the "double refresh" issue following a normal stop.

This condition may seem to obsolete the existing registers_too_p
parameter, but it does not: following a normal stop, it is possible that
registers may have changed while frame information had not.  We could be
on the exact same PC with different register values.  The new condition
would not catch such a case, but the registers_too_p condition will.  So
both conditions seem necessary (and either one is sufficient).

gdb/ChangeLog:

	* tui/tui-hooks.c (tui_refresh_frame_and_register_information):
	Update commentary.  Always refresh the registers when frame
	information has changed.
	* tui/tui-stack.c (tui_show_frame_info): Update commentary.
	Change return type to int.  Return 1 if frame information has
	changed, 1 otherwise.
	(tui_before_prompt): Update commentary.
	* tui/tui-stack.h (tui_show_frame_info): Change return type to
	int.
2015-07-01 12:13:57 -04:00
Martin Galvan 06f810bd8e Remove the unneeded escaping of '[' and ']' characters in test_class_help
As these characters don't need to be escaped for strings
wrapped inside {} braces, we can remove the unneeded backslashes.

gdb/testsuite/ChangeLog:

	* lib/gdb.exp (test_class_help): Remove the unneeded escaping of
	'[' and ']' characters.
2015-06-30 18:24:13 -03:00
Iain Buclaw 5e61e7c039 Sync dlang demangling tests from upstream libiberty testsuite
gdb/testsuite/ChangeLog:

	* gdb.dlang/demangle.exp: Sync tests from libiberty testsuite.
2015-06-30 20:11:09 +02:00
Patrick Palka 0986c744df Replace TUI's select_frame hook (PR tui/13378)
The select_frame hook is used by TUI to update TUI's frame and register
information following changes to the selected frame.  The problem with
this hook is that it gets called after every single frame change, even
if the frame change is only temporary or internal.  This is the primary
cause of flickering and slowdown when running the inferior under TUI
with conditional breakpoints set.  Internal GDB events are the source of
many calls to select_frame and these internal events are triggered
frequently, especially when a few conditional breakpoints are set.

This patch removes the select_frame hook altogether and instead makes
the frame and register information get updated in two key places (using
observers): after an inferior stops, and right before displaying a
prompt.  The latter hook covers the case when frame information must be
updated following a call to "up", "down" or "frame", and the former
covers the case when frame and register information must be updated
after a call to "continue", "step", etc. or after the inferior stops in
async execution mode.  Together these hooks should cover all the cases
when frame information ought to be refreshed (and when the relevant
windows ought to be subsequently updated).

The print_frame_info_listing hook is also effectively obsolete now, but
it still must be set while the TUI is active because its caller
print_frame_info will otherwise assume that the CLI is active, and will
print the frame informaion accordingly.  So this patch also sets the
print_frame_info_listing hook to a dummy callback, in lieu of outright
removing it yet.

Effectively, with this patch, frame/PC changes that do not immediately
precede an inferior-stop event or a prompt display event no longer cause
TUI's frame and register information to be updated.

And as a result of this change and of the previous change to
tui_show_frame_info, the TUI is much more disciplined about updating the
screen, and so the flicker as described in the PR is totally gone.

gdb/ChangeLog:

	PR tui/13378
	* frame.c (select_frame): Remove reference to
	deprecated_selected_frame_level_changed_hook.
	* frame.h (deprecated_selected_frame_level_changed_hook): Remove
	declaration.
	* stack.c (deprecated_selected_frame_level_changed_hook):
	Likewise.
	* tui/tui-hooks.c (tui_selected_frame_level_changed_hook):
	Rename to ...
	(tui_refresh_frame_and_register_information): ... this.  Bail
	out if there is no stack.  Don't update register information
	unless registers_too_p is true.
	(tui_print_frame_info_listing_hook): Rename to ...
	(tui_dummy_print_frame_info_listing_hook): ... this.
	(tui_before_prompt): New function.
	(tui_normal_stop): New function.
	(tui_before_prompt_observer): New observer.
	(tui_normal_stop_observer): New observer.
	(tui_install_hooks): Set
	deprecated_print_frame_info_listing_hook to
	tui_dummy_print_frame_info_listing_hook.  Register
	tui_before_prompt_observer to call tui_before_prompt and
	tui_normal_stop_observer to call tui_normal_stop.  Remove
	reference to deprecated_selected_frame_level_changed_hook.
	(tui_remove_hooks): Detach and unset tui_before_prompt_observer
	and tui_normal_stop_observer.  Remove reference to
	deprecated_selected_frame_level_changed_hook.
2015-06-30 13:56:49 -04:00
Patrick Palka b5fca6d728 Be lazy about refreshing the windows in tui_show_frame_info (PR tui/13378)
tui_show_frame_info is responsible for updating the visible windows
following a change in frame information (that being the currently
selected frame, PC, line number, etc).  Currently it always redraws and
refreshes each window even if frame information has not changed.  This
behavior is inefficient and helps contribute to the occassional
flickering of the TUI as described in the mentioned PR.

This patch makes tui_show_frame_info refresh the windows only if frame
information has changed.  Determining whether frame information has
changed is done indirectly by determining whether the locator has
changed.  This approach is convenient and yet sensible because the
locator contains all the relevant info we need to check anyway: the
current PC, the line number, the name of the executable and the name of
the current function.  Probably only the PC is really necessary to
check, but it doesn't hurt to check every field.

Effectively, with this patch, consecutive calls to select_frame with the
same frame/PC no longer cause TUI's frame information to be updated
multiple times.

gdb/ChangeLog:

	PR tui/13378
	* tui/tui-stack.c (tui_set_locator_info): Change prototype to
	return an int instead of void.  Return whether the locator
	window has changed.
	(tui_show_frame_info): If the locator info has not changed, then
	bail out early to avoid refreshing the windows.
2015-06-30 13:56:17 -04:00
Patrick Palka c45613e33d Correctly initialize the TUI locator window
The call to tui_alloc_content in tui_set_locator_info passes
locator->type as the type of the window whose content is being
allocated.  This may seem correct but it's actually not because when
this code path actually get executed locator->type has not yet been to
set LOCATOR_WIN so it defaults to 0 i.e. SRC_WIN.  Thus we allocate the
content of the locator window as if it was the source window.  This
oversight turns out not to be a big deal in practice but the patch that
follows depends on the locator's proc_name and full_name arrays to be
initialized to the empty string which is done by tui_alloc_content if
we pass to it LOCATOR_WIN.

This patch fixes this bug by explicitly passing LOCATOR_WIN to
tui_alloc_content.

gdb/ChangeLog:

	* tui/tui-stack.c (tui_set_locator_info): Explicitly pass
	LOCATOR_WIN to tui_alloc_content.
2015-06-30 13:44:25 -04:00
Yao Qi 7b9be803fe Handle media instructions in arm software single step.
This patch fixes PR 18605 which is about incorrectly decoding media
instructions in software single step.

gdb:

2015-06-30  Yao Qi  <yao.qi@linaro.org>

	PR tdep/18605
	* arm-tdep.c (arm_get_next_pc_raw): Break for media
	instructions.
2015-06-30 09:24:43 +01:00
Kevin Buettner fd6e021d8c Turn on dwarf2 unwinding for Renesas RX architecture
This change turns on dwarf2 unwinding in rx-tdep.c.  I found it
necessary to add rx_dwarf_reg_to_regnum in order to cause PC to be
mapped correctly.

gdb/ChangeLog:

	* rx-tdep.c (RX_PSW_REGNUM): New enum constant.
	(rx_dwarf_reg_to_regnum): New function.
	(rx_gdbarch_init): Register rx_dwarf_reg_to_regnum.  Use dwarf2
	unwinding.
2015-06-29 17:50:43 -07:00
Pedro Alves 28bf096c62 PR threads/18127 - threads spawned by infcall end up stuck in "running" state
Refs:
 https://sourceware.org/ml/gdb/2015-03/msg00024.html
 https://sourceware.org/ml/gdb/2015-06/msg00005.html

On GNU/Linux, if an infcall spawns a thread, that thread ends up with
stuck running state.  This happens because:

 - when linux-nat.c detects a new thread, it marks them as running,
   and does not report anything to the core.

 - we skip finish_thread_state when the thread that is running the
   infcall stops.

As result, that new thread ends up with stuck "running" state, even
though it really is stopped.

On Windows, _all_ threads end up stuck in running state, not just the
one that was spawned.  That happens because when a new thread is
detected, unlike linux-nat.c, windows-nat.c reports
TARGET_WAITKIND_SPURIOUS to infrun.  It's the fact that that event
does not cause a user-visible stop that triggers the problem.  When
the target is re-resumed, we call set_running with a wildcard ptid,
which marks all thread as running.  That set_running is not suppressed
because the (leader) thread being resumed does not have in_infcall
set.  Later, when the infcall finally finishes successfully, nothing
marks all threads back to stopped.

We can trigger the same problem on all targets by having a thread
other than the one that is running the infcall report a breakpoint hit
to infrun, and then have that breakpoint not cause a stop.  That's
what the included test does.

The fix is to stop GDB from suppressing the set_running calls while
doing an infcall, and then set the threads back to stopped when the
call finishes, iff they were originally stopped before the infcall
started.  (Note the MI *running/*stopped event suppression isn't
affected.)

Tested on x86_64 GNU/Linux.

gdb/ChangeLog:
2015-06-29  Pedro Alves  <palves@redhat.com>

	PR threads/18127
	* infcall.c (run_inferior_call): On infcall success, if the thread
	was marked stopped before, reset it back to stopped.
	* infrun.c (resume): Don't suppress the set_running calls when
	doing an infcall.
	(normal_stop): Only discard the finish_thread_state cleanup if the
	infcall succeeded.

gdb/testsuite/ChangeLog:
2015-06-29  Pedro Alves  <palves@redhat.com>

	PR threads/18127
	* gdb.threads/hand-call-new-thread.c: New file.
	* gdb.threads/hand-call-new-thread.c: New file.
2015-06-29 16:07:57 +01:00
Pierre Langlois 2880b51c25 Fix email in ChangeLog entry. 2015-06-29 10:48:56 +01:00
Pierre Langlois 96c9746122 [GDBServer][AArch64] Enable support for Z0 packets
This patch lets GDBServer handle software breakpoints instead of relying
on GDB.

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c (aarch64_supports_z_point_type): Enable for
	Z_PACKET_SW_BP.
2015-06-29 10:37:09 +01:00
Pierre Langlois 37d669427f [GDBServer][AArch64] Use the same break instruction as GDB
GDB uses a "brk #0" instruction to perform a software breakpoint while
GDBServer uses an illegal instruction.  Both instructions should match.

When enabling support for the 'Z0' packet, we let GDBServer insert the
breakpoint instruction instead of GDB.  And in case of permanent
breakpoints for example, GDB will check if a breakpoint is inserted in the
inferior with `program_breakpoint_here_p (gdbarch, address)', and
compare the instruction read from the inferior with the breakpoint
instruction.

On AArch64, instructions are always little endian so we need to
represent it as an array of bytes, as done in aarch64-tdep.c.

gdb/gdbserver/ChangeLog:

	* linux-aarch64-low.c: Remove comment about endianness.
	(aarch64_breakpoint): Change type to gdb_byte[].  Set to "brk #0".
	(aarch64_breakpoint_at): Change type of insn to gdb_byte[].  Use
	memcmp.
2015-06-29 10:34:42 +01:00
Pierre Langlois 1451ea7da4 Update my email address
gdb/ChangeLog:

	* MAINTAINERS (Write After Approval): Update my email address.
2015-06-29 10:28:16 +01:00
Keith Seitz ee93cd5e1e PR 16253 revisited
Last year a patch was submitted/approved/commited to eliminate
symbol_matches_domain which was causing this problem.  It was later reverted
because it introduced a (severe) performance regression.

Recap:

(gdb) list
1	enum e {A,B,C} e;
2	int main (void) { return 0; }
3
(gdb) p e
Attempt to use a type name as an expression

The parser attempts to find a symbol named "e" of VAR_DOMAIN.
This gets passed down through lookup_symbol and (eventually) into
block_lookup_symbol_primary, which iterates over the block's dictionary
of symbols:

  for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
       sym != NULL;
       sym = dict_iter_name_next (name, &dict_iter))
    {
      if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
                                 SYMBOL_DOMAIN (sym), domain))
        return sym;
    }

The problem here is that we have a symbol named "e" in both STRUCT_DOMAIN
and VAR_DOMAIN, and for languages like C++, Java, and Ada, where a tag name
may be used as an implicit typedef of the type, symbol_matches_domain ignores
the difference between VAR_DOMAIN and STRUCT_DOMAIN.  As it happens, the
STRUCT_DOMAIN symbol is found first, considered a match, and that symbol is
returned to the parser, eliciting the (now dreaded) error message.

Since this bug exists specifically because we have both STRUCT and VAR_DOMAIN
symbols in a given block/CU, this patch rather simply/naively changes
block_lookup_symbol_primary so that it continues to search for an exact
domain match on the symbol if symbol_matches_domain returns a symbol
which does not exactly match the requested domain.

This "fixes" the immediate problem, but admittedly might uncover other,
related bugs.  [Paranoia?] However, it causes no regressions (functional
or performance) in the test suite.  A similar change has been made
to block_lookup_symbol for other cases in which this bug might appear.

The tests from the previous submission have been resurrected and updated.
However since we can still be given a matching symbol with a different domain
than requested, we cannot say that a symbol "was not found."  The error
messages today will still be the (dreaded) "Attempt to use a type name..."

ChangeLog

	PR 16253
	* block.c (block_lookup_symbol): For non-function blocks,
	continue to search for a symbol with an exact domain match
	Otherwise, return any previously found "best domain" symbol.
	(block_lookup_symbol_primary): Likewise.

testsuite/ChangeLog

	PR 16253
	* gdb.cp/var-tag-2.cc: New file.
	* gdb.cp/var-tag-3.cc: New file.
	* gdb.cp/var-tag-4.cc: New file.
	* gdb.cp/var-tag.cc: New file.
	* gdb.cp/var-tag.exp: New file.
2015-06-26 10:27:45 -07:00
Patrick Palka fc637f04c7 Add option to remove duplicate command history entries
This patch implements the new option "history remove-duplicates", which
controls the removal of duplicate history entries ("off" by default).

The motivation for this option is to be able to reduce the prevalence of
basic commands such as "up" and "down" in the history file.  These
common commands crowd out more unique commands in the history file (when
the history file has a fixed size), and they make navigation of the
history file via ^P, ^N and ^R more inconvenient.

The option takes an integer denoting the number of history entries to
look back at for a history entry that is a duplicate of the latest one.
"history remove-duplicates 1" is equivalent to bash's ignoredups option,
and "history remove-duplicates unlimited" is equivalent to bash's
erasedups option.

[ I decided to go with this integer approach instead of a tri-state enum
  because it's slightly more flexible and seemingly more intuitive than
  leave/erase/ignore.  ]

gdb/ChangeLog:

	* NEWS: Mention the new option "history remove-duplicates".
	* top.c (history_remove_duplicates): New static variable.
	(show_history_remove_duplicates): New static function.
	(gdb_add_history): Conditionally remove duplicate history
	entries.
	(init_main): Add "history remove-duplicates" option.

gdb/doc/ChangeLog:

	* gdb.texinfo (Command History): Document the new option
	"history remove-duplicates".

gdb/testsuite/ChangeLog:

	* gdb.base/history-duplicates.exp: New test.
2015-06-26 11:05:56 -04:00
Patrick Palka 2e52ae68e7 Add tab completion for TUI's "focus" command
The implementation is pretty straightforward, with the only caveat being
that the "src", "cmd", "next" and "prev" entries get delibrately added
to the completion list even when the TUI has not yet been initialized
(i.e. has never been enabled during the session), since invoking the
"focus" command with these arguments already works when the TUI has not
yet been initialized.

gdb/ChangeLog:

	* tui/tui-win.c (focus_completer): New static function.
	(_initialize_tui_win): Set the completion function of the
	"focus" command to focus_completer.

gdb/testsuite/ChangeLog:

	* gdb.base/completion.exp: Test the completion of the "focus"
	command.
2015-06-26 10:11:28 -04:00
Jan Kratochvil 6e22494e50 Do not skip prologue for asm (.S) files
GDB tries to skip prologue for .S files according to .debug_line but it then
places the breakpoint to a location where it is never hit.

This is because #defines in .S files cause prologue skipping which is
completely inappropriate, for s390x:

glibc/sysdeps/unix/syscall-template.S
78:/* This is a "normal" system call stub: if there is an error,
79:   it returns -1 and sets errno.  */
80:
81:T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
82:     ret

00000000000f4210 T __select
 Line Number Statements:
  Extended opcode 2: set Address to 0xf41c8
  Advance Line by 80 to 81
  Copy
  Advance PC by 102 to 0xf422e
  Special opcode 6: advance Address by 0 to 0xf422e and Line by 1 to 82
  Special opcode 34: advance Address by 2 to 0xf4230 and Line by 1 to 83
  Advance PC by 38 to 0xf4256
  Extended opcode 1: End of Sequence
  Compilation Unit @ offset 0x28b3e0:
 <0><28b3eb>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <28b3ec>   DW_AT_stmt_list   : 0x7b439
    <28b3f0>   DW_AT_low_pc	 : 0xf41c8
    <28b3f8>   DW_AT_high_pc     : 0xf4256
    <28b400>   DW_AT_name        : ../sysdeps/unix/syscall-template.S
    <28b423>   DW_AT_comp_dir    : /usr/src/debug////////glibc-2.17-c758a686/misc
    <28b452>   DW_AT_producer    : GNU AS 2.23.52.0.1
    <28b465>   DW_AT_language    : 32769        (MIPS assembler)

without debuginfo or with debuginfo and the fix - correct address:
(gdb) b select
Breakpoint 1 at 0xf4210

It is also where .dynsym+.symtab point to:
00000000000f4210 T __select
00000000000f4210 W select

with debuginfo, without the fix:
(gdb) b select
Breakpoint 1 at 0xf41c8: file ../sysdeps/unix/syscall-template.S, line 81.

One part is to behave for asm files similar way like for 'locations_valid':
  /* Symtab has been compiled with both optimizations and debug info so that
     GDB may stop skipping prologues as variables locations are valid already
     at function entry points.  */
  unsigned int locations_valid : 1;

The other part is to extend the 'locations_valid'-like functionality more.

Both minsym_found and find_function_start_sal need to be patched, otherwise
their addresses do not match and GDB regresses on ppc64:

gdb/ChangeLog
2015-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linespec.c (minsym_found): Reset sal.PC for COMPUNIT_LOCATIONS_VALID
	and language_asm..
	* symtab.c (find_function_start_sal): Likewise.

gdb/testsuite/ChangeLog
2015-06-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.arch/amd64-prologue-skip.S: New file.
	* gdb.arch/amd64-prologue-skip.exp: New file.
2015-06-26 15:11:14 +02:00
Simon Marchi bf7b9cd9aa py-prettyprint.exp: Add is_address_zero_readable check
gdb/testsuite/ChangeLog:

	* gdb.python/py-prettyprint.exp (run_lang_tests): Add
	is_address_zero_readable check.
2015-06-25 13:33:14 -04:00
Gary Benson f8773be1be Correctly notice empty sysroots in solib_find_1
Some parts of solib_find_1 should only operate if the sysroot
is nonempty after processing, but the logic that checked this
happened before trailing slashes were stripped so empty but
non-NULL sysroots were possible.  This commit moves the logic
so it correctly notices all empty sysroots.

gdb/ChangeLog:

	* solib.c (solib_find_1): Set local variable sysroot to NULL if
	it is the empty string after trailing slashes have been stripped.
2015-06-25 09:54:12 +01:00
Gary Benson a3be80c3c5 Remove gdb_sysroot NULL checks
Since fed040c6a5 gdb_sysroot is
never NULL.  This commit removes all gdb_sysroot NULL checks.

gdb/ChangeLog:

	* exec.c (exec_file_locate_attach): Remove gdb_sysroot NULL check.
	* infrun.c (follow_exec): Likewise.
	* remote.c (remote_filesystem_is_local): Likewise.
	* solib.c (solib_find_1): Likewise.
2015-06-25 09:31:07 +01:00
Keith Seitz 32fad71f9e Fix lrealpath memory leak in build_id_to_debug_bfd
Valgrind reports memory leaking from build_id_to_debug_bfd:
==7261== 88 bytes in 2 blocks are definitely lost in loss record 31,319 of 35,132
==7261==    at 0x4A06BCF: malloc (vg_replace_malloc.c:296)
==7261==    by 0x32CA88A9B9: strdup (strdup.c:42)
==7261==    by 0xFE62AB: lrealpath (lrealpath.c:88)
==7261==    by 0x7F7AD6: build_id_to_debug_bfd (build-id.c:116)
==7261==    by 0x7F7BB5: find_separate_debug_file_by_buildid (build-id.c:149)
==7261==    by 0x6D9382: elf_symfile_read (elfread.c:1348)
==7261==    by 0x777F02: read_symbols (symfile.c:875)
==7261==    by 0x778505: syms_from_objfile_1 (symfile.c:1078)
==7261==    by 0x778548: syms_from_objfile (symfile.c:1094)
==7261==    by 0x778746: symbol_file_add_with_addrs (symfile.c:1191)
==7261==    by 0x77893B: symbol_file_add_from_bfd (symfile.c:1280)
==7261==    by 0x8E51E3: solib_read_symbols (solib.c:706)
==7261==    by 0x8E58AF: solib_add (solib.c:1029)

This occurs because commit 1be5090b in bfd, addressing PR 11983, started
taking a copy of the input filename instead of directly caching it.  It
appears that this code was never updated to reflect that API change.

This simple patch creates a cleanup to free the return value for lrealpath.

gdb/ChangeLog

	* build-id.c (build_id_to_debug_bfd): Add cleanup to free
	return value from lrealpath.
2015-06-24 14:09:19 -07:00
Mike Frysinger 87d1b30944 gdb: sim: merge the sysroot update logic together
Initialize the local sysroot fully before we start using it.
This keeps it all a bit simpler.
2015-06-24 10:25:38 -04:00
Peter Bergner 201e8dfdc8 Add missing ChangeLog entries for yesterday's commmit below.
gdb/testsuite/
	* gdb.arch/powerpc-power.exp <rfebb>: Fixup test results.
	* gdb.arch/powerpc-power.s <rfebb>: Likewise.
2015-06-24 09:15:29 -05:00
Mike Frysinger 23bf70af12 gdb: sim: handle target sysroot prefix
The default gdb sysroot now sets itself to "target:".  This works for
most remote targets, but when using the simulator, this causes problems
as the sim will attempt to search for that path.

Update the remote-sim logic to skip this leading prefix when it is found
so that the sysroot isn't passed in as an invalid value.
2015-06-24 09:59:17 -04:00
Yao Qi 5cd867b414 Call set_gdbarch_get_siginfo_type in linux_init_abi
linux_get_siginfo_type is installed to many linux gdbarch.  This patch
is to move this to a common area linux-tdep.c:linux_init_abi, so that
linux_get_siginfo_type is installed to every linux gdbarch.  If some
linux gdbarch needs its own version, please override it in
$ARCH_linux_init_abi.  In the testsuite, we enable siginfo related
tests for all linux targets.

gdb:

2015-06-24  Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-tdep.c (aarch64_linux_init_abi): Don't call
	set_gdbarch_get_siginfo_type.
	* amd64-linux-tdep.c (amd64_linux_init_abi_common): Likewise.
	* arm-linux-tdep.c (arm_linux_init_abi): Likewise.
	* i386-linux-tdep.c (i386_linux_init_abi): Likewise.
	* m68klinux-tdep.c (m68k_linux_init_abi): Likewise.
	* ppc-linux-tdep.c (ppc_linux_init_abi): Likewise.
	* s390-linux-tdep.c (s390_gdbarch_init): Likewise.
	* tilegx-linux-tdep.c (tilegx_linux_init_abi): Likewise.
	* linux-tdep.c (linux_get_siginfo_type): Change it to static.
	(linux_init_abi): Call set_gdbarch_get_siginfo_type.
	* linux-tdep.h (linux_get_siginfo_type): Remove the declaration.

gdb/testsuite:

2015-06-24  Yao Qi  <yao.qi@linaro.org>

	* lib/gdb.exp (supports_get_siginfo_type): Return 1 for all
	linux targets.
2015-06-24 14:53:03 +01:00
Yao Qi 4d7be0075a New proc supports_get_siginfo_type
Both siginfo-obj.exp and siginfo-thread.exp have the same code
checking the support of geting a type of siginfo for a given arch.
This patch is to move these code into a proc supports_get_siginfo_type.

gdb/testsuite:

2015-06-24  Yao Qi  <yao.qi@linaro.org>

	* lib/gdb.exp (supports_get_siginfo_type): New proc.
	* gdb.base/siginfo-obj.exp: Invoke supports_get_siginfo_type.
	* gdb.base/siginfo-thread.exp: Likewise.
2015-06-24 14:53:03 +01:00
Gary Benson dc06243f6f Remove redundant include directives.
stdint.h was added to common-defs.h some months ago and should
no longer be included directly by any file.

gdb_assert.h was added to common-defs.h nearly a year ago, but
three includes have crept in since then.

This commit removes all such redundant include directives.

gdb/ChangeLog:

	* common/buffer.c (stdint.h): Do not include.
	* common/print-utils.c (stdint.h): Likewise.
	* compile/compile-c-symbols.c (gdb_assert.h): Likewise.
	* compile/compile-c-types.c (gdb_assert.h): Likewise.
	* ft32-tdep.c (gdb_assert.h): Likewise.
	* guile/scm-utils.c (stdint.h): Likewise.
	* i386-linux-tdep.c (stdint.h): Likewise.
	* i386-tdep.c (stdint.h): Likewise.
	* nat/linux-btrace.c (stdint.h): Likewise.
	* nat/linux-btrace.h (stdint.h): Likewise.
	* nat/linux-ptrace.c (stdint.h): Likewise.
	* nat/mips-linux-watch.h (stdint.h): Likewise.
	* ppc-linux-nat.c (stdint.h): Likewise.
	* python/python-internal.h (stdint.h): Likewise.
	* stub-termcap.c (stdlib.h): Likewise.
	* target/target.h (stdint.h): Likewise.
	* xtensa-linux-nat.c (stdint.h): Likewise.

gdb/gdbserver/ChangeLog:

	* linux-i386-ipa.c (stdint.h): Do not include.
	* lynx-i386-low.c (stdint.h): Likewise.
	* lynx-ppc-low.c (stdint.h): Likewise.
	* mem-break.c (stdint.h): Likewise.
	* thread-db.c (stdint.h): Likewise.
	* tracepoint.c (stdint.h): Likewise.
	* win32-low.c (stdint.h): Likewise.
2015-06-24 13:52:29 +01:00
Patrick Palka 0fc26cafac Fix GDBHISTSIZE test failure on i686
The test

  test_histsize_history_setting "99999999999999999999999999999999999" "unlimited"

was failing on i686 because the condition in init_history() for
determining whether to map a large GDBHISTSIZE value to infinity was

  long var = strtol (tmpenv);
  if (var > INT_MAX)
    history_size = unlimited;

but this condition is never true on i686 because INT_MAX == LONG_MAX.
So in order to properly map large out-of-range values of GDBHISTSIZE to
infinity on targets where LONG_MAX > INT_MAX as well as on i686, we have
to instead change the above condition to

  if (var > INT_MAX
      || (var == INT_MAX && errno == ERANGE))
    history_size = unlimited;

gdb/ChangeLog:

	* top.c (init_history): Look at errno after calling strtol to
	properly map large GDBHISTSIZE values to infinity.
2015-06-23 16:32:36 -04:00
Doug Evans a38fe4fedd inferior.h (struct inferior_suspend_state): Delete, unused.
gdb/ChangeLog:

	* inferior.h (struct inferior_suspend_state): Delete, unused.
	All references deleted.
2015-06-23 11:36:49 -07:00
Peter Bergner 8e6500c55e Fix rfebb gdb test cases.
The following patch fixed the assembly / disassembly of the rfebb instruction:

    https://sourceware.org/ml/binutils/2015-06/msg00190.html

This patch updates the gdb testsuite to match the new disassembly behavior.

gdb/testsuite/
	* gdb.arch/powerpc-power.exp <rfebb>: Fixup test results.
	* gdb.arch/powerpc-power.s <rfebb>: Likewise.
2015-06-23 13:33:05 -05:00
Mike Frysinger 7564fe458c gdb: microblaze: delete useless stubs
These don't accomplish anything the common core doesn't already, so
punt them as they purely waste code.
2015-06-23 09:41:31 -04:00
Yao Qi 0bdb2f7849 Convert have_ptrace_getregset to a tri-state boolean
have_ptrace_getregset is a tri-state variable (-1, 0, 1), and we have
some conditions like "if (have_ptrace_getregset)", which is not correct.
I'll explain why it is not correct in the following example.  This fix
to this problem to replace the test (have_ptrace_getregset) to test
(have_ptrace_getregset == 1) or (have_ptrace_getregset == -1) etc.
However Doug thinks it hinders readability
https://sourceware.org/ml/gdb-patches/2015-05/msg00692.html so I decide
to add a new enum tribool and change have_ptrace_getregset to it, in
order to make these tests more readable.

have_ptrace_getregset is initialised to -1, and is adjusted to 0 or 1 in
$ARCH_linux_read_description according to the capability of the kernel.
However, it is possible that have_ptrace_getregset is used before it is
set to 0 or 1, which means it is still -1.  This is shown below.

(gdb) run
Starting program: gdb/testsuite/gdb.base/break

Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128	{
top?p have_ptrace_getregset
$1 = TRIBOOL_UNKNOWN
top?c
Continuing.

Breakpoint 2, amd64_linux_fetch_inferior_registers (ops=0xceaa80, regcache=0xe72000, regnum=16) at git/gdb/amd64-linux-nat.c:128
128	{
top?c
Continuing.

Breakpoint 1, x86_linux_read_description (ops=0xceaa80) at git/gdb/x86-linux-nat.c:117
117	{

PTRACE_GETREGSET command is used even GDB doesn't know whether
PTRACE_GETREGSET is supported or not.  It is wrong, but works on x86.
However it doesn't work on arm-linux if the kernel doesn't support
PTRACE_GETREGSET at all.  We'll get:

(gdb) run
Starting program: gdb/testsuite/gdb.base/break
warning: Unable to fetch general register.
PC register is not available

gdb:

2015-06-23  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers):
	Check whether have_ptrace_getregset is TRIBOOL_TRUE explicitly.
	(amd64_linux_store_inferior_registers): Likewise.
	* arm-linux-nat.c (fetch_fpregister): Likewise.
	(fetch_fpregs, store_fpregister): Likewise.
	(store_fpregister, store_fpregs): Likewise.
	(fetch_register, fetch_regs): Likewise.
	(store_register, store_regs): Likewise.
	(fetch_vfp_regs, store_vfp_regs): Likewise.
	(arm_linux_read_description): Check have_ptrace_getregset is
	TRIBOOL_UNKNOWN.  Set have_ptrace_getregset to TRIBOOL_TRUE
	or TRIBOOL_FALSE.
	* i386-linux-nat.c (fetch_xstateregs): Check
	have_ptrace_getregset is not TRIBOOL_TRUE.
	(store_xstateregs): Likewise.
	* linux-nat.c (have_ptrace_getregset): Change its type to
	enum tribool.
	* linux-nat.h (tribool): New enum.
	* x86-linux-nat.c (x86_linux_read_description): Use enum tribool.
	Check whether have_ptrace_getregset is TRIBOOL_TRUE.
2015-06-23 14:03:11 +01:00
Yao Qi 07fcd30112 Add comments on using board file remote-gdbserver-on-localhost.exp
This commit is to add comments on using this board file and the
requirements on localhost.

gdb/testsuite:

2015-06-22  Yao Qi  <yao.qi@linaro.org>

	* boards/remote-gdbserver-on-localhost.exp: Add comments.
2015-06-22 14:01:20 +01:00
Yao Qi 52042a003f Don't skip hw breakpoint/watchpoint tests for aarch64 target
This patch is to let skip_hw_breakpoint_tests and skip_hw_watchpoint_tests
return 0 for aarch64 target, since aarch64 has HW watchpoint and
breakpoint registers.

With this patch applied, about 1560 watchpoint/breakpoint related tests
become enabled on aarch64-linux native testing.

gdb/testsuite:

2015-06-22  Yao Qi  <yao.qi@linaro.org>

	* lib/gdb.exp (skip_hw_breakpoint_tests): Return 0 for target
	aarch64*-*-*.
	(skip_hw_watchpoint_tests): Likewise.
2015-06-22 13:43:30 +01:00
Doug Evans 18a94d75a0 Remove special support in gdb for Sun's version of stabs.
Discussion:
https://sourceware.org/ml/gdb-patches/2015-05/msg00169.html

gdb/ChangeLog:

	* NEWS: Mention Sun's version of stabs is no longer supported.
	* elfread.c (free_elfinfo): Delete.  All uses updated.
	(elfstab_offset_sections): Delete.  All uses updated.
	* gdb-stabs.h (stab_section_info): Delete.  All uses updated.
	* psympriv.h (partial_symtab) <section_offsets>: Delete.
	All uses updated.
	* psymtab.c (start_psymtab_common): Delete arg section_offsets.
	All callers updated.

gdb/doc/ChangeLog:

	* stabs.texinfo (ELF Linker Relocation): Mention Sun stabs is no
	longer supported.
2015-06-19 11:34:43 -07:00
Simon Marchi 124e13d9e7 remote: consider addressable unit size when reading/writing memory
Adapt code in remote.c to take into account addressable unit size when
reading/writing memory.

A few variables are renamed and suffixed with _bytes or _units. This
way, it's more obvious if there is any place where we add or compare
values of different kinds (which would be a mistake).

gdb/ChangeLog:

	* common/rsp-low.c (needs_escaping): New.
	(remote_escape_output): Add unit_size parameter. Refactor to
	support multi-byte addressable units.  Rename parameters.
	* common/rsp-low.h (remote_escape_output): Add unit_size
	parameter and rename others. Update doc.
	* remote.c (align_for_efficient_write): New.
	(remote_write_bytes_aux): Add unit_size parameter and use it.
	Rename some variables.  Update doc.
	(remote_xfer_partial): Get unit size and use it.
	(remote_read_bytes_1): Add unit_size parameter and use it.
	Rename some variables. Update doc.
	(remote_write_bytes): Same.
	(remote_xfer_live_readonly_partial): Same.
	(remote_read_bytes): Same.
	(remote_flash_write): Update call to remote_write_bytes_aux.
	(remote_write_qxfer): Update call to remote_escape_output.
	(remote_search_memory): Same.
	(remote_hostio_pwrite): Same.

gdb/gdbserver/ChangeLog:

	* server.c (write_qxfer_response): Update call to
	remote_escape_output.
2015-06-18 13:12:39 -04:00
Patrick Palka 74bd41ce65 Test the interaction between GDBHISTSIZE and .gdbinit
The value inside the GDBHISTSIZE environment variable, only if valid,
should override setting the history size through one's .gdbinit file.

gdb/testsuite/ChangeLog:

	* gdb.base/gdbinit-history.exp: Test the interaction between
	setting GDBHISTSIZE and setting the history size via .gdbinit.
2015-06-18 11:51:19 -04:00
Luis Machado 6ae8866180 Fix problems with finishing a dummy function call on simulators.
Some simulators don't handle permanent breakpoints properly and will
sometimes terminate when hitting such a breakpoint instruction or have
unwanted effects.

When a permanent breakpoint is inserted, GDB will not attempt to insert
other breakpoint locations on top of it, leading to the problem described
above.

By not marking permanent breakpoint locations as inserted, we allow the
insertion of breakpoint locations on top of the permanent ones, preventing
the simulators from running into that situation.

gdb/ChangeLog:

2015-06-17  Luis Machado  <lgustavo@codesourcery.com>

	* breakpoint.c (add_location_to_breakpoint): Don't mark permanent
	locations as inserted.
	Update and expand comment about permanent locations.
	(bp_loc_is_permanent): Don't return 0 for bp_call_dummy.
	Move comment to add_location_to_breakpoint.
	(update_global_location_list): Don't error out if a permanent
	breakpoint is not marked inserted.
	Don't error out if a non-permanent breakpoint location is inserted on
	top of a permanent breakpoint.
2015-06-17 16:50:57 -03:00
Luis Machado da4616f69f Remove unused function make_breakpoint_permanent.
make_breakpoint_permanent is no longer used anywhere and can be
safely removed.

gdb/ChangeLog:

2015-06-17  Luis Machado  <lgustavo@codesourcery.com>

	* breakpoint.c (make_breakpoint_permanent): Remove unused
	function.
	* breakpoint.h (make_breakpoint_permanent): Remove declaration.
2015-06-17 16:09:24 -03:00
Patrick Palka 0eacb2983d Make NEWS entry and manual regarding GDBHISTSIZE more consistent
... by mentioning in the manual that setting GDBHISTSIZE to the empty
string disables truncation, like the NEWS entry does.

gdb/doc/ChangeLog:

	* gdb.texinfo (Command History): Mention that setting
	GDBHISTSIZE to the empty string disables history truncation.
2015-06-17 14:52:09 -04:00
Patrick Palka bc460514b9 Tweak the handling of $GDBHISTSIZE edge cases [PR gdb/16999]
When GDB reads a nonsensical value for the GDBHISTSIZE environment
variable, i.e. one that is non-numeric or negative, GDB then sets its
history size to 0.  This behavior is annoying and also inconsistent
with the behavior of bash.

This patch makes the behavior of invalid GDBHISTSIZE consistent with how
bash handles HISTSIZE.  When we encounter a null or out-of-range
GDBHISTSIZE (outside of [0, INT_MAX]) we now set the history size to
unlimited instead of 0.  When we encounter a non-numeric GDBHISTSIZE we
do nothing.

gdb/ChangeLog:

	PR gdb/16999
	* NEWS: Mention new GDBHISTSIZE behavior.
	* top.c (init_history): For null or out-of-range GDBHISTSIZE,
	set history size to unlimited.  Ignore non-numeric GDBHISTSIZE.

gdb/doc/ChangeLog:

	PR gdb/16999
	* gdb.texinfo (Command History): Mention new GDBHISTSIZE
	behavior.

gdb/testsuite/ChangeLog:

	PR gdb/16999
	* gdb.base/gdbhistsize-history.exp: New test.
2015-06-17 14:12:19 -04:00
Patrick Palka b58c513b79 Read $GDBHISTSIZE instead of $HISTSIZE
The HISTSIZE environment variable is generally expected to be read by
shells, not by applications.  Some distros for example globally export
HISTSIZE in /etc/profile -- with the intention that it only affects
shells -- and by doing so it renders useless GDB's own mechanism for
setting the history size via .gdbinit.  Also, annoyances may arise when
HISTSIZE is not interpreted the same way by the shell and by GDB, e.g.
PR gdb/16999.  That can always be fixed on a shell-by-shell basis but it
may be impossible to be consistent with the behavior of all shells at
once.  Finally it just makes sense to not confound shell environment
variables with application environment variables.

gdb/ChangeLog:

	* NEWS: Mention that GDBHISTSIZE is read instead of HISTSIZE.
	* top.c (init_history): Read from GDBHISTSIZE instead of
	HISTSIZE.
	(init_main): Refer to GDBHISTSIZE instead of HISTSIZE.

gdb/doc/ChangeLog:

	* gdb.texinfo (Command History): Replace occurrences of HISTSIZE
	with GDBHISTSIZE.

gdb/testsuite/ChangeLog:

	* gdb.base/gdbinit-history.exp: Replace occurrences of HISTSIZE
	with GDBHISTSIZE.
	* gdb.base/readline.exp: Likewise.
2015-06-17 14:03:50 -04:00
Yao Qi 920467912a Fix tcl error
This patch fixes the following tcl error

Running ../../../binutils-gdb/gdb/testsuite/gdb.base/break-interp.exp ...
ERROR: (DejaGnu) proc "else" does not exist.
The error code is NONE
The info on the error is:
invalid command name "else"
    while executing
"::tcl_unknown else"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 ::tcl_unknown $args"

gdb/testsuite:

2015-06-17  Yao Qi  <yao.qi@linaro.org>

	* lib/gdb.exp (get_build_id): Move braces and "else" to the same
	line.
2015-06-17 17:16:00 +01:00
Patrick Palka 2093d2d314 Don't truncate the history file when history size is unlimited
We still do not handle "set history size unlimited" correctly.  In
particular, after writing to the history file, we truncate the history
even if it is unlimited.

This patch makes sure that we do not call history_truncate_file() if the
history is not stifled (i.e. if it's unlimited).  This bug causes the
history file to be truncated to zero on exit when one has "set history
size unlimited" in their gdbinit file.  Although this code exists in GDB
7.8, the bug is masked by a pre-existing bug that's been only fixed in
GDB 7.9 (PR gdb/17820).

gdb/ChangeLog:

	* top.c (gdb_safe_append_history): Do not call
	history_truncate_file if the history is not stifled.

gdb/testsuite/ChangeLog:

	* gdb.base/gdbinit-history.exp: Add test case to check that
	an unlimited history file does not get truncated on exit.
2015-06-17 09:41:58 -04:00
Andreas Arnez fc24848555 S390: Add syscall info for syscalls from 344 up to 354
Represent new Linux syscalls for s390 and s390x in GDB's syscall info.
Add the syscalls from 344 (finit_module) up to 354 (execveat).

gdb/ChangeLog:

	* syscalls/s390-linux.xml: Add syscalls 344 through 354.
	* syscalls/s390x-linux.xml: Likewise.
2015-06-17 11:17:08 +02:00
Andreas Arnez e6c693af14 Add vector ABI tests to gnu_vector.exp
So far the gnu_vector test was limited to "static" aspects of GDB's
vector support, like evaluating vector-valued expressions.  This patch
enriches the test and adds checks for GDB's vector ABI support as well.
The new checks particularly verify inferior function calls with vector
arguments and GDB's handling of vector return values.

The test now attempts to compile for the target's "native" architecture,
such that a hardware vector ABI is used if available.

Since GDB has no vector ABI support for x86 and x86_64 targets, most of
the new checks are KFAILed there.

gdb/testsuite/ChangeLog:

	* gdb.base/gnu_vector.c: Include stdarg.h and stdio.h.
	(VECTOR): New macro.  Use it...
	(int4, uint4, char4, float4, int2, longlong2, float2, double2):
	...for these typedefs.
	(int8, char1, int1, double1): New typedefs.
	(struct just_int2, struct two_int2): New structures.
	(add_some_intvecs, add_many_charvecs, add_various_floatvecs)
	(add_structvecs, add_singlevecs): New functions.
	(main): Call add_some_intvecs twice.
	* gdb.base/gnu_vector.exp: Drop GCC version check; just attempt
	the compile and exit upon failure.  Try compiling for the "native"
	architecture.  Test inferior function calls with vector arguments
	and vector return value handling with "finish" and "return".
2015-06-17 11:17:07 +02:00
Michael Eager 4da680addb GDB Namespaces - Define MSG_CMSG_CLOEXEC if not defined.
2015-06-16  Michael Eager  <eager@eagercon.com>

	* nat/linux-namespaces.c (MSG_CMSG_CLOEXEC): Define if not defined.
2015-06-16 07:18:03 -07:00
Patrick Palka 0a75489fab Call target_terminal_ours_for_output() before refreshing TUI's frame info
In some cases tui_show_frame_info() may get called while the inferior's
terminal settings are still in effect.  But when we call this function
we absolutely need to have our terminal settings in effect because the
function is responsible for redrawing TUI's windows following a change
in the selected frame or a change in the PC.  If our terminal settings
are not in effect, the screen does not get redrawn properly, causing
temporary display artifacts (which can be fixed via ^L).

This scenario happens most prominently when stepping through a program
in TUI while a watchpoint is in effect.

Here is an example backtrace for when tui_show_frame_info() gets called
while target_terminal_is_inferior() == 1:

  #1  0x00000000004988ee in tui_selected_frame_level_changed_hook (level=0)
  #2  0x0000000000617b99 in select_frame (fi=0x18c9820)
  #3  0x0000000000617c3f in get_selected_frame (message=message@entry=0x0)
  #4  0x00000000004ce534 in update_watchpoint (b=b@entry=0x2d9a760,
      reparse=reparse@entry=0)
  #5  0x00000000004d625e in insert_breakpoints ()
  #6  0x0000000000531cfe in keep_going (ecs=ecs@entry=0x7ffea7884ac0)
  #7  0x00000000005326d7 in process_event_stop_test (ecs=ecs@entry=0x7ffea7884ac0)
  #8  0x000000000053596e in handle_inferior_event_1 (ecs=0x7ffea7884ac0)

The fix is simple: call target_terminal_ours_for_output() before calling
tui_show_frame_info() in TUI's frame-changed hook, making sure to
restore the original terminal settings afterwards.

gdb/ChangeLog:

	* tui/tui-hooks.c (tui_selected_frame_level_changed_hook): Call
	target_terminal_ours_for_output() before calling
	tui_show_frame_info(), and restore the original terminal
	settings afterwards.
2015-06-16 09:31:05 -04:00
Martin Simmons 95855ca82e Fix compilation of gdb/arm-linux-nat.c on Raspbian GNU/Linux 7
GDB trunk fails to compile on Raspbian GNU/Linux 7 because
PTRACE_GETREGSET and PTRACE_SETREGSET are not defined in sys/ptrace.h.

gcc -g -O2   -I. -I. -I./common -I./config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode -I./../opcodes/.. -I./../readline/.. -I./../zlib -I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  -I./gnulib/import -Ibuild-gnulib/import   -DTUI=1  -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wpointer-sign -Wmissing-prototypes -Wdeclaration-after-statement -Wmissing-parameter-type -Wold-style-declaration -Wold-style-definition -Wformat-nonliteral -Werror -c -o arm-linux-nat.o -MT arm-linux-nat.o -MMD -MP -MF .deps/arm-linux-nat.Tpo arm-linux-nat.c
arm-linux-nat.c: In function 'fetch_fpregister':
arm-linux-nat.c:103:21: error: 'PTRACE_GETREGSET' undeclared (first use in this function)
arm-linux-nat.c:103:21: note: each undeclared identifier is reported only once for each function it appears in
arm-linux-nat.c: In function 'fetch_fpregs':
arm-linux-nat.c:144:21: error: 'PTRACE_GETREGSET' undeclared (first use in this function)
arm-linux-nat.c: In function 'store_fpregister':
arm-linux-nat.c:184:21: error: 'PTRACE_GETREGSET' undeclared (first use in this function)
arm-linux-nat.c:211:21: error: 'PTRACE_SETREGSET' undeclared (first use in this function)
...

This patch includes the gdb header file nat/linux-ptrace.h, which provides
fallback definitions.

2015-06-16  Martin Simmons  <martin@lispworks.com>  (tiny patch)

	* arm-linux-nat.c: Include nat/linux-ptrace.h.
2015-06-16 09:42:53 +01:00
Simon Marchi cfc32360af MI: consider addressable unit size when reading/writing memory
As a user of the target memory read/write interface, the MI code must
adjust its memory allocations to take into account the addressable memory
unitsize of the target.

gdb/ChangeLog:

	mi/mi-main.c (mi_cmd_data_read_memory_bytes): Consider byte
	size.
	(mi_cmd_data_write_memory_bytes): Same.
2015-06-15 15:50:31 -04:00
Simon Marchi a86c90e6ba Clarify doc about memory read/write and non-8-bits addressable memory unit sizes
New in v3:

 * Change RSP documentation as well. The m, M and X packets now use
 lengths in addressable memory units.

New in v2:

 * Change wording: use byte for 8-bits chunks and addressable memory unit
   for the unit of data associated to a single address.
 * Introduce definition of addressable memory unit in the Memory
   section.

This patch modifies the manual to clarify the MI, RSP and Python APIs in
regard to reading/writing memory on architectures with addressable
memory unit that are not 8 bits.

Care is taken to use the word "addressable memory unit" or "memory unit"
when referring to one piece of the smallest addressable size on the
current architecture and the word "byte" when referring to an 8-bits
data piece.

For MI, -data-{read,write}-memory are not modified, since they are
deprecated.

gdb/doc/ChangeLog:

	* gdb.texinfo (GDB/MI Data Manipulation): Clarify usage of
	bytes and memory units for -data-{read,write}-memory-bytes.
	(Packets): Same for m, M and X packets.
	* python.texi (Inferiors In Python): Same for read_memory and
	write_memory.
2015-06-15 15:31:00 -04:00
Simon Marchi cb6f16cf4f Cleanup write_memory doc
This doc about write_memory seems outdated.

gdb/ChangeLog:

	* corefile.c (write_memory): Update doc.
	* gdbcore.h (write_memory): Same.
2015-06-15 13:34:47 -04:00
Jan Kratochvil 31b7833d20 Code cleanup: Rename enum -> enum filterflags
Bit mask ints are better to make enums as GDB already has support to
automatically decode them:

before this patch:
	(gdb) p filterflags
	$1 = 51
	(gdb) p/x filterflags
	$2 = 0x33

after this patch:
	(gdb) p filterflags
	$1 = (COREFILTER_ANON_PRIVATE | COREFILTER_ANON_SHARED | COREFILTER_ELF_HEADERS | COREFILTER_HUGETLB_PRIVATE)

gdb/ChangeLog
2015-06-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linux-tdep.c (enum filterflags): Make it from anonymous enum.
	(dump_mapping_p): Use it for parameter filterflags.
	(linux_find_memory_regions_full): Use it for variable filterflags.
2015-06-15 17:10:44 +02:00
Jan Kratochvil 909c2cdaa7 Merge multiple hex conversions
gdb/ChangeLog
2015-06-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Merge multiple hex conversions.
	* monitor.c: Include rsp-low.h.
	(fromhex): Remove definition.

gdb/gdbserver/ChangeLog
2015-06-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Merge multiple hex conversions.
	* gdbreplay.c (tohex): Rename to 'fromhex'.
	(logchar): Use fromhex.
2015-06-15 17:08:49 +02:00
Jan Kratochvil 03aef70fec Move utility functions to common/
gdb/ChangeLog
2015-06-15  Aleksandar Ristovski  <aristovski@qnx.com
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	Move utility functions to common/.
	* cli/cli-utils.c (skip_spaces, skip_spaces_const, skip_to_space_const):
	Move defs to common/common-utils.c.
	* cli/cli-utils.h (skip_spaces, skip_spaces_const, skip_to_space)
	(skip_to_space_const): Move decls to common/common-utils.h.
	* common/common-defs.h: Move include of common-types.h before
	common-utils.h.
	* common/common-utils.c: Include host-defs.h and ctype.h.
	(HIGH_BYTE_POSN, is_digit_in_base, digit_to_int, strtoulst): Move
	from utils.c.
	(skip_spaces, skip_spaces_const, skip_to_space_const): Move from
	cli/cli-utils.c.
	* common/common-utils.h (strtoulst): Move decl from utils.h.
	(skip_spaces, skip_spaces_const, skip_to_space, skip_to_space_const):
	Move from cli/cli-utils.h.
	* common/host-defs.h: Include limits.h.
	(TARGET_CHAR_BIT, HOST_CHAR_BIT): Moved from defs.h.
	(skip_spaces, skip_spaces_const): Move decls from cli/cli-utils.h.
	* defs.h (TARGET_CHAR_BIT, HOST_CHAR_BIT): Move to
	common/common-utils.h.
	* utils.c (HIGH_BYTE_POSN, is_digit_in_base, digit_to_int)
	(strtoulst): Move to common/common-utils.c.
	* utils.h (strtoulst): Moved decl to common/common-utils.h.
2015-06-15 17:04:56 +02:00
Yao Qi d1168cc1a9 Copy aarch64-linux.xml to build tree.
This patch fixes a bug that aarch64-linux.xml isn't copied to the
build tree, so that some tests catch-syscall.exp fail.

gdb:

2015-06-15  Yao Qi  <yao.qi@linaro.org>

	* data-directory/Makefile.in (SYSCALLS_FILES): Add aarch64-linux.xml.
2015-06-15 13:38:21 +01:00
Ulrich Weigand 1e5338b6e7 Fix ChangeLog entry. 2015-06-15 13:49:43 +02:00
Jon Turney c74f7d1c6c Allow gdb to find debug symbols file by build-id for PE file format also
This promotes BFD's struct elf_build_id to the generic struct bfd_build_id,
populated when an ELF or PE BFD is read.

gdb is updated to use that, and to use the build-id to find symbols for PE files
also.

There is currently no generic way to extract the build-id from an object file,
perhaps an option to objdump to do this might make sense?

On x86_64-pc-cygwin, gdb's sepdebug.exp changes:

-# of unsupported tests          1
+# of expected passes            90

I don't seem to get consistent testsuite runs on i686-linux-gnu, but there
don't appear to be any regressions.

bfd/ChangeLog:

2015-06-10  Jon Turney  <jon.turney@dronecode.org.uk>

	* elf-bfd.h : Remove struct elf_build_id.
	* bfd.c : Add struct bfd_build_id.
	* bfd-in2.h: Regenerate.
	* elf.c (elfobj_grok_gnu_build_id): Update to use bfd_build_id.
	* libpei.h: Add protoype and macros for
	bfd_XXi_slurp_codeview_record.
	* peXXigen.c (_bfd_XXi_slurp_codeview_record): Make public
	* peicode.h (pe_bfd_read_buildid): Add.
	(pe_bfd_object_p): Use pe_bfd_read_buildid().

gdb/ChangeLog:

2015-06-10  Jon Turney  <jon.turney@dronecode.org.uk>

	* build-id.c: Don't include elf-bfd.h.
	(build_id_bfd_get): Use bfd_build_id.
	(build_id_verify): Ditto.
	* build-id.h: Ditto.
	(find_separate_debug_file_by_buildid): Ditto.
	* python/py-objfile.c: Don't include elf-bfd.h.
	(objfpy_get_build_id) Use bfd_build_id.
	(objfpy_build_id_matches, objfpy_lookup_objfile_by_build_id): Ditto.
	* coffread.c: Include build-id.h.
	(coff_symfile_read): Try find_separate_debug_file_by_buildid.

gdb/doc/ChangeLog:

2015-06-10  Jon Turney  <jon.turney@dronecode.org.uk>

	* gdb.texinfo (Separate Debug Files): Document that PE is also
	supported.

gdb/testsuite/ChangeLog:

2015-06-10  Jon Turney  <jon.turney@dronecode.org.uk>

	* gdb.base/sepdebug.exp: Add EXEEXT where needed.
	* lib/gdb.exp (get_build_id): Teach how to extract build-id from a
	PE file.
	* lib/future.exp (gdb_find_objdump): Add gdb_find_objdump.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2015-06-15 12:10:55 +01:00
Jon Turney f20c58f51f windows-nat: Replace __COPY_CONTEXT_SIZE conditional with __CYGWIN__
Replace __COPY_CONTEXT_SIZE conditional with __CYGWIN__

__COPY_CONTEXT_SIZE was added to Cygwin's headers in 2006.

Versions of Cygwin which don't define __COPY_CONTEXT_SIZE are long obsolete.

Also see the thread starting at
https://sourceware.org/ml/gdb-patches/2015-03/msg00989.html for some discussion

Note that __COPY_CONTEXT_SIZE should just be sizeof(CONTEXT) (which is a
platform constant), but isn't due to historical mistakes in Cygwin headers.

gdb/ChangeLog:

2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>

	* windows-nat.c (do_windows_fetch_inferior_registers)
	(handle_output_debug_string): Replace __COPY_CONTEXT_SIZE
	conditional with __CYGWIN__.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2015-06-15 12:08:15 +01:00
Andrew Burgess 51f0e40d65 gdb: Rework command completion on 'tui reg'.
We previously specified a few known register groups for the 'tui reg'
command.  Other register groups could be accessed, but only by using the
'tui reg next' command and cycling through all the groups.

This commit removes the hard coded sub-commands of 'tui reg' and instead
adds dynamic completion of sub-commands based on the architecturally
defined register groups, giving immediate access to all available
register groups.

There is still the 'next' and 'prev' commands for cycling through the
register groups if that's wanted.

The new code maintains the ability to only enter partial names for
register groups, which is something we got for free when using the
standard sub-command mechanism.

The register (and register group) completer has been changed to use
get_current_arch rather than using the architecture of the currently
selected frame.  When the target is running, this is equivalent,
however, when the target is not running, using get_current_arch will
provide results from the default architecture.

gdb/ChangeLog:

	* completer.c: Add arch-utils.h include.
	(enum reg_completer_targets): New enum.
	(reg_or_group_completer_1): New function containing old
	reg_or_group_completer, add and use new parameter to control what
	is completed on.  Use get_current_arch rather than architecture of
	currently selected frame.
	(reg_or_group_completer): Call new reg_or_group_completer_1.
	(reggroup_completer): Call new reg_or_group_completer_1.
	* completer.h (reggroup_completer): Add declaration.
	* tui/tui-regs.c: Add 'completer.h' include.
	(tui_reg_next_command): Renamed to...
	(tui_reg_next): ...this.  Adjust parameters and return rather than
	display new group.
	(tui_reg_prev_command): Renamed to...
	(tui_reg_prev): ...this.  Adjust parameters and return rather than
	display new group.
	(tui_reg_float_command): Delete.
	(tui_reg_general_command): Delete.
	(tui_reg_system_command): Delete.
	(tui_reg_command): Rewrite to perform switching of register group.
	Add header comment.
	(tuireglist): Remove.
	(tui_reggroup_completer): New function.
	(_initialize_tui_regs): Remove 'tui reg' sub-commands, update
	creation of 'tui reg' command.
	* NEWS: Add comment about 'tui reg' changes.

gdb/doc/ChangeLog:

	* gdb.texinfo (TUI Commands): Bring all 'tui reg' commands into a
	single table entry.
2015-06-13 21:28:53 +01:00
Simon Marchi d309493c38 target: consider addressable unit size when reading/writing memory
If we are reading/writing from a memory object, the length represents
the number of "addresses" to read/write, so the addressable unit size
needs to be taken into account when allocating memory on gdb's side.

gdb/ChangeLog:

	* target.c (target_read): Consider addressable unit size when
	reading from a memory object.
	(read_memory_robust): Same.
	(read_whatever_is_readable): Same.
	(target_write_with_progress): Consider addressable unit size
	when writing to a memory object.
	* target.h (target_read): Update documentation.
	(target_write): Add documentation.
2015-06-12 17:03:19 -04:00
Simon Marchi 3374165f51 gdbarch: add addressable_memory_unit_size method
Add a new gdbarch method to get the length of an addressable memory unit
for a given architecture. The default implementation returns 1.

gdb/ChangeLog:

	* arch-utils.h (default_addressable_memory_unit_size): New.
	* arch-utils.c (default_addressable_memory_unit_size): New.
	* gdbarch.sh (addressable_memory_unit_size): New.
	* gdbarch.h: Re-generate.
	* gdbarch.c: Re-generate.
2015-06-12 16:51:51 -04:00
Simon Marchi 279a6fed95 Various cleanups in target read/write code
This contains various cleanups in the target memory read and write code.
They are not directly related to the non-8-bits changes, but they
clarify things a bit down the line.

gdb/ChangeLog:

	* target.c (target_read): Rename variables and use
	TARGET_XFER_E_IO.
	(target_read_with_progress): Same.
	(read_memory_robust): Constify parameters and rename
	variables.
	(read_whatever_is_readable): Constify parameters,
	rename variables, adjust formatting.
	* target.h (read_memory_robust): Constify parameters.
2015-06-12 13:08:12 -04:00
Ulrich Weigand a1da2672bd ppc64: Handle short vectors as function return types
Short synthetic vector types (i.e. those defined using GCC's
attribute ((vector_size)) instead of AltiVec vector types)
are returned in r3.  Fix ppc64_sysv_abi_return_value to
correctly handle this.

gdb/ChangeLog:

	* ppc-sysv-tdep.c (ppc64_sysv_abi_return_value_base): Handle short
	synthetic (non-AltiVec) vector types.
	(ppc64_sysv_abi_return_value): Likewise.
2015-06-12 17:43:48 +02:00
Antoine Tremblay 98aa42ee02 Fix MI dprintf-insert not printing on a resolved pending location.
This patch fixes the "Format string required" error when trying to print
a dprintf on a now resolved, pending location when set via the MI interface
even if the format string is entered correctly.

This patch also adds a test case to check that issue called
mi-dprintf-pending.exp.

gdb/ChangeLog:

	PR breakpoints/16465
	* breakpoint.c (create_breakpoint): Save extra_string for
	pending breakpoints.

gdb/testsuite/ChangeLog:

	PR breakpoints/16465
	* gdb.mi/mi-dprintf-pending.c: New file.
	* gdb.mi/mi-dprintf-pending.exp: New test.
	* gdb.mi/mi-dprintf-pendshr.c: New file.
2015-06-12 08:43:17 -04:00
Walfred Tedeschi 966f0aefa6 Fix broken GDB build after adding Bound table support for i386.
Types used for some variables could not be used for 32 bits, causing a
compilation failure.
This patch adds a cast to force a quite compilation, but at the same
time it bails out in the case that the cast performed is not safe, i.e.
in the case where the debuggee is 64bit and debugger is 32bit.

Documentation was also affected, once a different version of texinfo the
docs could not be build.

2015-06-10  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* i386-tdep.c (i386_mpx_get_bt_entry): Add a cast for mpx_bd_mask
	and bt_mask to CORE_ADDR.

doc:
	* gdb.textinfo (i386): Fix "@end table" end and "@table" placement.
2015-06-12 09:42:16 +02:00
Gary Benson 6449ed0d3a Use pulongest for printing ssize_t
This commit changes the debug printing code in linux-namespaces.c
to use pulongest instead of "%ld".

gdb/ChangeLog:

	* nat/linux-namespaces.c (mnsh_send_message): Use pulongest.
	(mnsh_recv_message): Likewise.
2015-06-11 13:38:15 +01:00
Walfred Tedeschi 34f8ac9f49 Fix ARI new warnings introduced in i386-tdep.c.
1. gdb/i386-tdep.c:8720: Do not use 'long long', instead use LONGEST
gdb/i386-tdep.c:8720:  long long int size;

2. gdb/i386-tdep.c:8755: Do not use printf(%ll), instead use printf(%s,phex()) to dump a 'long long' value
gdb/i386-tdep.c:8755: ui_out_field_fmt (uiout, "size", "%lld", size);

2015-06-11  Walfred Tedeschi  <walfred.tedeschi@intel.com>

	* i386-tdep.c (i386_mpx_print_bounds): use of LONGEST instead of
	long long int and plongest instead of %ll.

Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2015-06-11 13:48:26 +02:00
Gary Benson 198c808c87 Fix ARI warning in linux-namespaces.c
This commit fixes the following ARI warning:

  gdb/nat/linux-namespaces.c:28: regression: Do not include
  wait.h or sys/wait.h, instead include gdb_wait.h

gdb/ChangeLog:

	* nat/linux-namespaces.c (gdb_wait.h): New include.
	(sys/wait.h): Do not include.
2015-06-11 10:58:41 +01:00
Simon Marchi e815d2d271 dwarf2read: call dwarf_finish_line when ending a sequence
Commit d9b3de22f3 introduced a behaviour
change where dwarf_finish_line was not called anymore when ending a
sequence of machine instructions. This patch restores the original
behaviour.

gdb/ChangeLog:

	* dwarf2read.c (dwarf_record_line): Call dwarf_record_line if
	 end_sequence is true.
2015-06-10 16:34:16 -04:00
Jan Kratochvil 8847cac2f7 Code cleanup: Use explicit NULL comparison
gdb/ChangeLog
2015-06-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Code cleanup.
	* solib-target.c (library_list_start_list): Use explicit NULL
	comparison.
2015-06-10 19:37:19 +02:00
Jan Kratochvil 24c05f4605 Fix gdbserver <library-list> and its #FIXED version="1.0"
While reimplementing <library-list/> I found from expat-2.0.1-11.fc15.x86_64:

warning: while parsing target library list (at line 1): Required attribute "version" of <library-list-svr4> not specified

I believe the same bug has to apply for existing FSF gdbserver but I do not
have any <library-list/> platform to test it (I did not try to build MinGW).

features/library-list.dtd:
<!ATTLIST library-list  version CDATA   #FIXED  "1.0">

http://www.xml.com/pub/a/98/10/guide0.html?page=3 says:

	In this case, the attribute is not required, but if it occurs, it must
	have the specified value.

Which would suggest gdbserver is right but solib-target.c is wrong.  One could
also make gdbserver explicit for the version (if those 14 bytes are not of
a concern).

gdb/ChangeLog
2015-06-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* solib-target.c (library_list_start_list): Do not dereference
	variable version in its initialization.  Make the VERSION check handle
	NULL.
	(library_list_attributes): Make "version" GDB_XML_AF_OPTIONAL.

gdb/gdbserver/ChangeLog
2015-06-10  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* server.c (handle_qxfer_libraries): Set `version' attribute for
	<library-list>.
2015-06-10 18:30:10 +02:00
Gary Benson 51aad7cc44 Announce new container-awareness features for GNU/Linux systems
This commit announces the newly added ability to directly access
executable and shared library files when attaching to processes
running in containers on GNU/Linux systems.

gdb/ChangeLog:

	* NEWS: Announce support for direct access of executable and
	shared library files when attaching to inferiors in containers
	on GNU/Linux systems.
2015-06-10 14:28:44 +01:00
Gary Benson 14d2069a32 Implement vFile:setfs in gdbserver
This commit implements the "vFile:setfs" packet in gdbserver.

gdb/gdbserver/ChangeLog:

	* target.h (struct target_ops) <multifs_open>: New field.
	<multifs_unlink>: Likewise.
	<multifs_readlink>: Likewise.
	* linux-low.c (nat/linux-namespaces.h): New include.
	(linux_target_ops): Initialize the_target->multifs_open,
	the_target->multifs_unlink and the_target->multifs_readlink.
	* hostio.h (hostio_handle_new_gdb_connection): New declaration.
	* hostio.c (hostio_fs_pid): New static variable.
	(hostio_handle_new_gdb_connection): New function.
	(handle_setfs): Likewise.
	(handle_open): Use the_target->multifs_open as appropriate.
	(handle_unlink): Use the_target->multifs_unlink as appropriate.
	(handle_readlink): Use the_target->multifs_readlink as
	appropriate.
	(handle_vFile): Handle vFile:setfs packets.
	* server.c (handle_query): Call hostio_handle_new_gdb_connection
	after target_handle_new_gdb_connection.
2015-06-10 14:28:44 +01:00
Gary Benson 15a201c844 Implement multiple-filesystem support for remote targets
This commit allows GDB to access executables and shared libraries
on remote targets where the remote stub does not share a common
filesystem with the inferior(s).  A new packet "vFile:setfs" is
added to the remote protocol and the three remote hostio functions
with filename arguments are modified to send "vFile:setfs" packets
as necessary.

gdb/ChangeLog:

	* remote.c (struct remote_state) <fs_pid>: New field.
	(new_remote_state): Initialize the above.
	(PACKET_vFile_setfs): New enum value.
	(remote_hostio_set_filesystem): New function.
	(remote_hostio_open): Call the above.
	(remote_hostio_unlink): Likewise.
	(remote_hostio_readlink): Likewise.
	(_initialize_remote): Register new "set/show remote
	hostio-setfs-packet" command.
	* NEWS: Announce new vFile:setfs packet.

gdb/doc/ChangeLog:

	* gdb.texinfo (Remote Configuration): Document the
	"set/show remote hostio-setfs-packet" command.
	(Host I/O Packets): Document the vFile:setfs packet.
2015-06-10 14:28:44 +01:00
Gary Benson 7a6a173129 Implement mount namespace support for native Linux targets
This commit allows GDB to access executables and shared libraries
on native Linux targets where GDB and the inferior have different
mount namespaces.

gdb/ChangeLog:

	* linux-nat.c (nat/linux-namespaces.h): New include.
	(fileio.h): Likewise.
	(linux_nat_filesystem_is_local): New function.
	(linux_nat_fileio_pid_of): Likewise.
	(linux_nat_fileio_open): Likewise.
	(linux_nat_fileio_readlink): Likewise.
	(linux_nat_fileio_unlink): Likewise.
	(linux_nat_add_target): Initialize to_filesystem_is_local,
	to_fileio_open, to_fileio_readlink and to_fileio_unlink.
	(_initialize_linux_nat): New "set/show debug linux-namespaces"
	commands.
	* NEWS: Mention new "set/show debug linux-namespaces" commands.

gdb/doc/ChangeLog:

	* gdb.texinfo (Debugging Output): Document the "set/show debug
	linux-namespaces" command.
2015-06-10 14:28:43 +01:00
Gary Benson 07c138c8ae Add "inferior" argument to some target_fileio functions
This commit adds a new argument to all target_fileio functions with
filename arguments to allow the desired inferior to be specified.
This allows GDB to support systems where processes do not necessarily
share a common filesystem.

gdb/ChangeLog:

	* target.h (struct inferior): New forward declaration.
	(struct target_ops) <to_filesystem_is_local>: Update comment.
	(struct target_ops) <to_fileio_open>: New argument inf.
	Update comment.  All implementations updated.
	(struct target_ops) <to_fileio_unlink>: Likewise.
	(struct target_ops) <to_fileio_readlink>: Likewise.
	(target_filesystem_is_local): Update comment.
	(target_fileio_open): New argument inf.  Update comment.
	(target_fileio_unlink): Likewise.
	(target_fileio_readlink): Likewise.
	(target_fileio_read_alloc): Likewise.
	(target_fileio_read_stralloc): Likewise.
	* target.c (target_fileio_open): New argument inf.
	Pass inf to implementation.  Update debug printing.
	(target_fileio_unlink): Likewise.
	(target_fileio_readlink): Likewise.
	(target_fileio_read_alloc_1): New argument inf. Pass inf
	to target_fileio_open.
	(target_fileio_read_alloc): New argument inf. Pass inf to
	target_fileio_read_alloc_1.
	(target_fileio_read_stralloc): Likewise.
	* gdb_bfd.c (inferior.h): New include.
	(gdb_bfd_iovec_fileio_open): Replace unused "open_closure"
	argument with new argument "inferior".  Pass inferior to
	target_fileio_open.
	(gdb_bfd_open): Supply inferior argument to
	gdb_bfd_iovec_fileio_open.
	* linux-tdep.c (linux_info_proc): Supply inf argument to
	relevant target_fileio calls.
	(linux_find_memory_regions_full): Likewise.
	(linux_fill_prpsinfo): Likewise.
	* remote.c (remote_filesystem_is_local): Supply inf
	argument to remote_hostio_open.
	(remote_file_put): Likewise.
	(remote_file_get): Likewise.
	(remote_file_delete): Supply inf argument to
	remote_hostio_unlink.
2015-06-10 14:28:43 +01:00
Gary Benson 12e2a5fdcc Comment and whitespace changes
Comments on the various implementations of target fileio functions
duplicate information documented in target.h.  This commit replaces
the duplicated documentation with breadcrumbs, and inserts blank
lines to separate comments from the functions they describe where
necessary.

gdb/ChangeLog:

	* inf-child.c (inf_child_fileio_open): Replace comment.
	(inf_child_fileio_pwrite): Likewise.
	(inf_child_fileio_pread): Likewise.
	(inf_child_fileio_fstat): Insert blank line before comment.
	(inf_child_fileio_close): Replace comment.
	(inf_child_fileio_unlink): Likewise.
	(inf_child_fileio_readlink): Likewise.
	* remote.c (remote_hostio_open): Likewise.
	(remote_hostio_pread): Likewise.
	(remote_hostio_pwrite): Likewise.
	(remote_hostio_close): Likewise.
	(remote_hostio_unlink): Likewise.
	(remote_hostio_readlink): Likewise.
	(remote_hostio_fstat): Likewise.
	(remote_filesystem_is_local): Likewise.
	* target.c (target_fileio_open): Likewise.
	(target_fileio_pwrite): Likewise.
	(target_fileio_pread): Likewise.
	(target_fileio_fstat): Insert blank line before comment.
	(target_fileio_close): Replace comment.
	(target_fileio_unlink): Likewise.
	(target_fileio_readlink): Likewise.
	(target_fileio_read_alloc): Likewise.
	(target_fileio_read_stralloc): Likewise.
2015-06-10 14:28:43 +01:00
Gary Benson 9bc3a9760b Remove linux_proc_pid_get_ns
This commit removes linux_proc_pid_get_ns, and updates its only
caller to use linux_ns_same instead.

gdb/ChangeLog:

	* linux-thread-db.c (nat/linux-namespaces.h): New include.
	(check_pid_namespace_match): Use linux_ns_same rather than
	linux_proc_pid_get_ns to spot PID namespace mismatches.
	* nat/linux-procfs.h (linux_proc_pid_get_ns): Remove.
	* nat/linux-procfs.c (linux_proc_pid_get_ns): Likewise.
2015-06-10 14:28:43 +01:00
Gary Benson 4b8b5e7245 Introduce nat/linux-namespaces.[ch]
This commit introduces new shared files nat/linux-namespaces.[ch]
containing code to support Linux namespaces that will be used by
both GDB and gdbserver.

gdb/ChangeLog:

	* configure.ac (AC_CHECK_FUNCS): Add setns.
	* config.in: Regenerate.
	* configure: Likewise.
	* nat/linux-namespaces.h: New file.
	* nat/linux-namespaces.c: Likewise.
	* Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-namespaces.h.
	(linux-namespaces.o): New rule.
	* config/aarch64/linux.mh (NATDEPFILES): Add linux-namespaces.o.
	* config/alpha/alpha-linux.mh (NATDEPFILES): Likewise.
	* config/arm/linux.mh (NATDEPFILES): Likewise.
	* config/i386/linux.mh (NATDEPFILES): Likewise.
	* config/i386/linux64.mh (NATDEPFILES): Likewise.
	* config/ia64/linux.mh (NATDEPFILES): Likewise.
	* config/m32r/linux.mh (NATDEPFILES): Likewise.
	* config/m68k/linux.mh (NATDEPFILES): Likewise.
	* config/mips/linux.mh (NATDEPFILES): Likewise.
	* config/pa/linux.mh (NATDEPFILES): Likewise.
	* config/powerpc/linux.mh (NATDEPFILES): Likewise.
	* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
	* config/powerpc/spu-linux.mh (NATDEPFILES): Likewise.
	* config/s390/linux.mh (NATDEPFILES): Likewise.
	* config/sparc/linux.mh (NATDEPFILES): Likewise.
	* config/sparc/linux64.mh (NATDEPFILES): Likewise.
	* config/tilegx/linux.mh (NATDEPFILES): Likewise.
	* config/xtensa/linux.mh (NATDEPFILES): Likewise.

gdb/gdbserver/ChangeLog:

	* configure.ac (AC_CHECK_FUNCS): Add setns.
	* config.in: Regenerate.
	* configure: Likewise.
	* Makefile.in (SFILES): Add nat/linux-namespaces.c.
	(linux-namespaces.o): New rule.
	* configure.srv (srv_linux_obj): Add linux-namespaces.o.
2015-06-10 14:28:43 +01:00
Gary Benson ca09583623 Move make_cleanup_close to common code
This commit moves the function make_cleanup_close from gdb/utils.[ch]
to gdb/common/filestuff.[ch] to make it usable from common code.

gdb/ChangeLog:

	* utils.h (make_cleanup_close): Moved to common/filestuff.h.
	* utils.c (do_close_cleanup): Moved to common/filestuff.c.
	(make_cleanup_close): Likewise.
	* common/filestuff.h (make_cleanup_close): Moved from utils.h.
	* common/filestuff.c (do_close_cleanup): Moved from utils.c.
	(make_cleanup_close): Likewise.
2015-06-10 14:28:43 +01:00
Jon Turney 5d9c55d355 windows-nat: Also ignore ERROR_INVALID_HANDLE from SuspendThread()
Discussed somewhat in the thread at
https://cygwin.com/ml/gdb-patches/2013-06/msg00680.html

This is pretty straightforward to demonstrate on Cygwin currently:

$ cat main.c

int main()
{
  return 0;
}

$ gcc -g -O0 main.c -o main

$ ./gdb ./main
[...]
(gdb) r
Starting program: /wip/binutils-gdb/build.x86_64/gdb/main
warning: SuspendThread (tid=0x1cf0) failed. (winerr 6)
[Inferior 1 (process 976) exited normally]

with this patch applied:

$ ./gdb ./main
[...]
(gdb) r
Starting program: /wip/binutils-gdb/build.x86_64/gdb/main
[Inferior 1 (process 4852) exited normally]

gdb/ChangeLog:

2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>

	* windows-nat.c (thread_rec): Also ignore ERROR_INVALID_HANDLE
	from SuspendThread().

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2015-06-10 13:28:19 +01:00
Jon Turney 040ea00bb0 windows-nat: Trim a trailing '\n' from OutputDebugString before echoing it
For cosmetic purposes, trim a trailing '\n' from OutputDebugString before
echoing it, as warning() will add a '\n', anyhow.

gdb/ChangeLog:

2015-06-03  Jon Turney  <jon.turney@dronecode.org.uk>

	* windows-nat.c (handle_output_debug_string): Trim trailing '\n'
	from OutputDebugString.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2015-06-10 13:24:13 +01:00
Walfred Tedeschi 7d73c23c4d Missing Changelogs for last commits
Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
2015-06-10 10:52:12 +02:00
Walfred Tedeschi 29c1c24429 Add support for bound table in the Intel MPX context.
Intel(R) Memory protection bound information are located in register
to be tested using the MPX new instructions. Since the number of
bound registers are limited a table is used to provide storage for
bounds during run-time.

In order to investigate the contents of the MPX bound table two new
commands are added to GDB.  "show mpx bound" and "set mpx bound" are
used to display and set values on the MPX bound table.

2015-04-20  Walfred Tedeschi  <walfred.tedeschi@intel.com>
            Mircea Gherzan  <mircea.gherzan@intel.com>

	* i386-tdep.c (MPX_BASE_MASK, MPX_BD_MASK, MPX_BT_MASK, MPX_BD_MASK_32,
	MPX_BT_MASK_32): New macros.
	(i386_mpx_set_bounds): New function that implements
	the command "set-mpx-bound".
	(i386_mpx_enabled) Helper function to test MPX availability.
	(i386_mpx_bd_base) Helper function to calculate the base directory
	address. (i386_mpx_get_bt_entry) Helper function to access a bound
	table entry. (i386_mpx_print_bounds) Effectively display bound
	information. (_initialize_i386_tdep): Qdd new commands
	to commands "set mpx" and "show mpx". (_initialize_i386_tdep):
	Add "bound" to the commands "show mpx" and "set mpx" commands.
	(mpx_set_cmdlist and mpx_show_cmdlist):
	list for the new prefixed "set mpx" and "show mpx" commands.
	* NEWS: List new commands for MPX support.

testsuite:

	* gdb.arch/i386-mpx-map.c: New file.
	* gdb.arch/i386-mpx-map.exp: New File.

doc:
	* gdb.texinfo (i386): Add documentation about "show mpx bound"
	and "set mpx bound".
2015-06-10 09:58:06 +02:00
Walfred Tedeschi 422d944b03 Obvious indentation fixes on test sample and test file for MPX registers.
2015-06-08  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testsuite:

	* gdb.arch/i386-mpx.c (have_mpx): Indentation fixed.
	* gdb.arch/i386-mpx.exp: Indentation fixed.
2015-06-10 09:58:05 +02:00
Walfred Tedeschi 547a646d67 Improve test for processor feature om MPX registers test.
Skips the MPX register test in case target is not Intel.
Improves the test for MPX feature making MPX and AVX512
tests more similar in terms of initialization.
Indentation was improved on sample file and final return added
to have_mpx.  On test file identation was improved and
gdb_send was exchanged by gdb_test_multiple.

2015-06-08  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testsuite
	* gdb.arch/i386-mpx.c: Added final return to the have_mpx
	function and improved indentation.
	* gdb.arch/i386-mpx.exp: Exchanging gdb_send and gdb_expect for
	gdb_test_multiple. Added additional tests to skip the test.
2015-06-10 09:58:05 +02:00
Walfred Tedeschi 8b600ba2b4 Fix MPX and AVX512 tests for path changes.
Changes on the path for i386-cpuid.h file lead to failure in compiling
tests for AVX512 and MPX.

2015-06-08  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/testsuite
	* gdb.arch/i386-avx512.c: Change path in include file.
	* gdb.arch/i386-avx512.exp: Change include dir path
	compilation flag.
	* gdb.arch/i386-mpx.c: Change path in include file.
	* gdb.arch/i386-mpx.exp: Change include dir path compilation
	flag.
2015-06-10 09:58:05 +02:00
Gary Benson 3ac2e371a1 Don't assume File-I/O mode bits match the host's format
inf_child_fileio_open and its gdbserver equivalent both assume that
the mode_t bits defined in gdb/fileio.h are the same as those used
by the open system call, but there is no mechanism to ensure this is
the case.  This commit adds a conversion function to handle systems
where the File-I/O definitions do not align with the host's.

gdb/ChangeLog:

	* common/fileio.h (fileio_to_host_mode): New declaration.
	* common/fileio.c (fileio_to_host_mode): New Function.
	* inf-child.c (inf_child_fileio_open): Process mode argument
	with fileio_to_host_mode.

gdb/gdbserver/ChangeLog:

	* hostio.c (handle_open): Process mode argument with
	fileio_to_host_mode.
2015-06-09 13:24:46 +01:00
Gary Benson ecef18c564 Fix preprocessor conditional
This commit fixes a typo in common/fileio.c where S_IWGRP was
misspelled as S_IWRGRP in a preprocessor conditional, causing
Host-I/O "vFile:fstat:" and File-I/O "Fstat" and "Ffstat"
responses to always indicate files were not group-writable
regardless of their actual status.
2015-06-09 10:12:11 +01:00
Gary Benson e3dd7556ad Move vgdb special case into remote_filesystem_is_local
Valgrind GDB (vgdb) presents itself as a remote target but works on
the local filesystem.  gdb_bfd_open contained a special case to make
vgdb work with "target:" sysroots, but the implementation meant that
GDB would fall back to the local filesystem if *any* to_fileio_open
method failed with ENOSYS for *any* reason.  This commit moves the
vgdb special case to remote_filesystem_is_local to allow the fallback
to be restricted only to the specific case that remote file transfer
is unsupported.  This commit also adds a warning which is displayed
the first time the fallback is used.

gdb/ChangeLog:

	* gdb_bfd.c (gdb_bfd_open): Move vgdb special case to...
	* remote.c (remote_filesystem_is_local): ...here.
2015-06-05 16:08:05 +01:00
Jan Kratochvil d5eba19a65 compile-print.exp: xfail->kfail for '@' GDB array operator
Patch implementing '@' GDB array operator in GCC has been rejected:
	https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00414.html
and so there is now a GDB tracker to implement it just in GDB:
	https://sourceware.org/bugzilla/show_bug.cgi?id=18489

gdb/testsuite/ChangeLog
2015-06-04  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.compile/compile-print.exp (compile print *vararray@3)
	(compile print *vararrayp@3): Change xfail to kfail compile/18489.
2015-06-04 21:35:43 +02:00
Yao Qi 5b74bf7d63 Regenerate gdbarch.c to sync with gdbarch.sh
When I do something else, I find that gdbarch.c isn't sync'ed with
gdbarch.sh.  This patch just move some statements on
stack_frame_destroyed_p some lines below.

gdb:

2015-06-04  Yao Qi  <yao.qi@linaro.org>

	* gdbarch.c: Regenerate it.
2015-06-04 17:31:16 +01:00
Jan Kratochvil 7f36105668 compile: Use also inferior munmap
Currently inferior memory is allocated by inferior mmap() but it is never
deallocated; despite the injected objfile incl. its symbols is freed.  This was
intentional so that one can do for example:
inferior:
	char *str = "foo";
GDB:
	(gdb) compile code str = "bar";

I believe later patches will be needed to introduce full control over keeping
vs. discarding the injected module as being discussed in:
	compile: objfiles lifetime UI
	https://sourceware.org/ml/gdb/2015-04/msg00051.html
	Message-ID: <20150429135735.GA16974@host1.jankratochvil.net>
	https://sourceware.org/ml/gdb/2015-05/msg00007.html

As decided by Phil it is better not to leak inferior pages as users can
workaround the issue above for example by:
	(gdb) compile code str = strdup ("bar");

I have checked that in fact gdb/doc/ (written by Phil) already expects the
injected code will be unmapped so that does not need to be changed:
	compile code int ff = 5; p = &ff;
	In this example, @code{p} would point to @code{ff} when the
	@code{compile} command is executing the source code provided to it.
	However, as variables in the (example) program persist with their
	assigned values, the variable @code{p} would point to an invalid
	location when the command exists.

gdb/ChangeLog
2015-04-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* arch-utils.c (default_infcall_munmap): New.
	* arch-utils.h (default_infcall_munmap): New declaration.
	* compile/compile-object-load.c (struct munmap_list, munmap_list_add)
	(munmap_list_free, munmap_listp_free_cleanup): New.
	(struct setup_sections_data): Add field munmap_list_headp.
	(setup_sections): Call munmap_list_add.
	(compile_object_load): New variable munmap_list_head, initialize
	setup_sections_data.munmap_list_headp, return munmap_list_head.
	* compile/compile-object-load.h (struct munmap_list): New declaration.
	(struct compile_module): Add field munmap_list_head.
	(munmap_list_free): New declaration.
	* compile/compile-object-run.c (struct do_module_cleanup): Add field
	munmap_list_head.
	(do_module_cleanup): Call munmap_list_free.
	(compile_object_run): Pass munmap_list_head to do_module_cleanup.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (infcall_munmap): New.
	* linux-tdep.c (linux_infcall_munmap): New.
	(linux_init_abi): Install it.

gdb/testsuite/ChangeLog
2015-04-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.compile/compile.exp (keep jit in memory): Rename to ...
	(do not keep jit in memory): ... this.
	(expect 5): Change it to ...
	(expect no 5): ... this.
2015-06-03 21:26:04 +02:00
Simon Marchi 3b462ec2be Fix =thread-exited not showing up when detaching (PR 15564)
I sent a patch in 2013 for this (incorrectly named =thread-created):

  https://cygwin.com/ml/gdb-patches/2013-06/msg00129.html

Tom Tromey was ok with the change, but suggested to add a test as well.
Then I forgot about this patch until today. So here it is again, with the
corresponding test.

The problem is that the =thread-exited event does not appear when detaching
from a local process. It does appear with remote though. It's not a really
big deal, but I'd like it to be consistent.

Tested with local and remote Linux on my Ubuntu 14.04.

gdb/ChangeLog:

	PR gdb/15564
	* inferior.c (detach_inferior): Call exit_inferior_1 with silent = 0.

gdb/testsuite/ChangeLog:

	PR gdb/15564
	* gdb.mi/mi-detach.exp: New file.
2015-06-02 15:32:57 -04:00
Yao Qi 8d683210f1 Include linux-nat.h in i386-linux-nat.c
This commit fixes a build failure on i386-linux.

gdb:

2015-06-02  Yao Qi  <yao.qi@linaro.org>

	* i386-linux-nat.c: Include linux-nat.h.
2015-06-02 10:28:03 +01:00
Jan Kratochvil e0619de699 PR symtab/18392
Initially there is some chain (let's say the longest one
but that doe snot matter).  Consequently its elements from the middle are
being removed and there remains only some few unambiguous top and bottom ones.

The original idea why the comparison should be sharp ("<") was that if there
are multiple chains like (0xaddr show jmp instruction address):
        main(0x100) -> a(0x200) -> d(0x400)
        main(0x100) -> a(0x200) -> c(0x300) -> d(0x400)
then - such situation cannot exist - if two jmp instructions in "a" have the
same address they must also jump to the same address (*).

(*) jump to a computed address would be never considered for the DWARF
    tail-call records.

So there could be:
        main(0x100) -> a(0x200) -> d(0x400)
        main(0x100) -> a(0x270) -> c(0x300) -> d(0x400)
But then "a" frame itself is ambiguous and it must not be displayed.

I did not realize that there can be self-tail-call:
        main(0x100) -> a(0x200) -> d(0x400)
        main(0x100) -> a(0x280) -> a(0x200) -> d(0x400)
which intersects to:
        main(0x100) -> <???>? -> a(0x200) -> d(0x400)
And so if the first chain was chosen the
        main(0x100) -> a(0x200) -> d(0x400)
then the final intersection has callers+callees==length.

> for example, if CALLERS is 3 and
> CALLEES is 2, what does the chain look like?

main(0x100) -> x(0x150) -> y(0x200) -> <???>? -> a(0x200) -> d(0x400)

And if LENGTH is 7 then:
        call_site[0] = main(0x100)
        call_site[1] = x(0x150)
        call_site[2] = y(0x200)
        call_site[3] = garbage
        call_site[4] = garbage
        call_site[5] = a(0x200)
        call_site[6] = d(0x400)

gdb/ChangeLog
2015-06-01  Andreas Schwab  <schwab@linux-m68k.org>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR symtab/18392
	* dwarf2-frame-tailcall.c (pretended_chain_levels): Correct
	assertion.
	* dwarf2loc.c (chain_candidate): Likewise.

gdb/testsuite/ChangeLog
2015-06-01  Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR symtab/18392
	* gdb.arch/amd64-tailcall-self.S: New file.
	* gdb.arch/amd64-tailcall-self.c: New file.
	* gdb.arch/amd64-tailcall-self.exp: New file.
2015-06-01 14:02:34 +02:00
Yao Qi bd16da5114 Fetch and store VFP registers by PTRACE_{G,S}ETREGSET
This patch is to use PTRACE_{G,S}ETREGSET to fetch and store VFP
registers if kernel supports.

gdb:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (fetch_vfp_regs): Use PTRACE_GETREGSET.
	(store_vfp_regs): Use PTRACE_SETREGSET.
2015-06-01 12:13:02 +01:00
Yao Qi df9d7ec9e7 Fetch and store FP registers by PTRACE_{G,S}ETREGSET
If kernel supports PTRACE_GETREGSET, GDB uses PTRACE_{G,S}ETREGSET
to fetch and store FP registers.

gdb:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (fetch_fpregister): Use PTRACE_GETREGSET.
	(fetch_fpregs): Likewise.
	* arm-linux-nat.c (store_fpregister): Use PTRACE_SETREGSET.
	(store_fpregs): Likewise.
2015-06-01 12:13:02 +01:00
Yao Qi 10766686b0 Fetch and store GP registers by PTRACE_{G,S}ETREGSET
If kernel supports PTRACE_GETREGSET, GDB uses PTRACE_{G,S}ETREGSET
to fetch and store GP registers.

gdb:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (fetch_register): Use PTRACE_GETREGSET.
	(fetch_regs): Likewise.
	(store_regs): Use PTRACE_SETREGSET.
	(store_register): Likewise.
2015-06-01 12:13:02 +01:00
Yao Qi 7efe48d196 Check whether kernel supports PTRACE_GETREGSET
gdb:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (arm_linux_read_description): Check whether
	kernel supports PTRACE_GETREGSET.
2015-06-01 12:13:02 +01:00
Yao Qi 433bbbf857 Move have_ptrace_getregset to linux-nat.c
I'll let arm-linux-nat.c to use PTRACE_GETREGSET if kernel supports,
so this patch is to move have_ptrace_getregset from x86-linux-nat.c
to linux-nat.c.

gdb:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* x86-linux-nat.c (have_ptrace_getregset): Move it to ...
	* linux-nat.c: ... here.
	* x86-linux-nat.h (have_ptrace_getregset): Move the declaration
	to ...
	* linux-nat.h: ... here.
2015-06-01 12:13:02 +01:00
Yao Qi ca9b78ce90 Move PTRACE_GETREGSET and PTRACE_SETREGSET to nat/linux-ptrace.h
Macros PTRACE_GETREGSET and PTRACE_SETREGSET are defined locally in
some places in GDB and GDBserver.  This patch is to move them to
nat/linux-ptrace.h to avoid duplication.

gdb:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* amd64-linux-nat.c: Include "nat/linux-ptrace.h".
	* i386-linux-nat.c: Likewise.
	* nat/linux-ptrace.h (PTRACE_GETREGSET, PTRACE_SETREGSET): Define.
	* s390-linux-nat.c: Include "nat/linux-ptrace.h".
	(PTRACE_GETREGSET, PTRACE_SETREGSET): Remove.
	* x86-linux-nat.c: Include "nat/linux-ptrace.h".
	* x86-linux-nat.h (PTRACE_GETREGSET, PTRACE_SETREGSET): Remove.

gdb/gdbserver:

2015-06-01  Yao Qi  <yao.qi@linaro.org>

	* linux-s390-low.c (PTRACE_GETREGSET, PTRACE_SETREGSET): Remove.
	* linux-x86-low.c: Likewise.
2015-06-01 12:13:02 +01:00
Eli Zaretskii 99cee7b71f Unbreak DJGPP build of GDB.
gdb/
	* go32-nat.c (go32_xfer_memory): Fix the return value to be
	compatible to what read_child and write_child return.  This
	unbreaks that DJGPP build of GDB which was broken since v7.7.
2015-05-30 13:05:53 +03:00
Martin Galvan 2147f5bd65 Add myself to the Write After Approval list. 2015-05-29 20:44:22 -03:00
Roland McGrath c8f6c93cb2 PR gdb/18464: Do not crash on unrecognized GNU .note.ABI-tag values
Diagnosis of unexpected input (in this case, in an executable file)
should not crash as if it were a bug in GDB.

gdb/
	PR gdb/18464
	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Use warning
	rather than internal_error for an unrecognized value.
2015-05-29 09:24:36 -07:00
Max Filippov 8c6a948dbe xtensa: fix access to the last pseudo register
Currently access to the last pseudo register is aliased to a1. This is
done by little snippets in the beginning of xtensa_pseudo_register_read
and xtensa_pseudo_register_write that used to do such aliasing for FP
register since bdb4c075a2, but then
FP_ALIAS was expanded into gdbarch_num_regs (current_gdbarch) +
gdbarch_num_pseudo_regs (current_gdbarch) (one register past the last
pseudo register) in 304fe2552d, which
then was changed to the last pseudo register in
94a0e87711.

Drop these snippets.

2015-05-29  Max Filippov  <jcmvbkbc@gmail.com>
gdb/
	* xtensa-tdep.c (xtensa_pseudo_register_read)
	(xtensa_pseudo_register_write): Don't alias last pseudo register
	to a1.
2015-05-29 13:33:30 +03:00
Don Breazeal e970cb3401 Disable exec-dependent follow vfork tests for remote
The native-extended-gdbserver target now supports fork events and
follow fork, but it does not yet support exec events.  Some of the
tests in gdb.base/foll-vfork.exp depend on exec events.  This patch
disables those tests for remote targets.  We can re-enable these
once the exec event support goes in.

gdb/testsuite/

	* gdb.base/foll-vfork.exp (main): Disable exec-dependent
	tests for remote targets by checking is_target_gdbserver.
2015-05-28 14:40:30 -07:00
Don Breazeal bfacd19d64 Initialize last_resume_kind for remote fork child
This patch fixes some intermittent test failures in
gdb.base/foll-vfork.exp where a vfork child would be (incorrectly)
resumed when handling the vfork event.  In this case the result
was a subsequent event reported to the client side as a SIGTRAP
delivered to the as-yet-unknown child thread.

The new thread was resumed (incorrectly) in linux-low.c when
resume_stopped_resumed_lwps was called from
linux_wait_for_event_filtered after the vfork event had been
handled in handle_extended_wait.

Gdbserver/linux-low.c's add_thread function creates threads with
last_resume_kind == resume_continue by default.  This field is
used by resume_stopped_resumed_lwps to decide whether to perform
the resume:

static void
resume_stopped_resumed_lwps (struct inferior_list_entry *entry) {
  struct thread_info *thread = (struct thread_info *) entry;
  struct lwp_info *lp = get_thread_lwp (thread);

  if (lp->stopped
      && !lp->status_pending_p
      && thread->last_resume_kind != resume_stop
      && thread->last_status.kind == TARGET_WAITKIND_IGNORE)
    {

So the fix is to make sure to set thread->last_resume_kind to
resume_stop.  Here we do that for new fork children in
gdbserver/linux-low.c:handle_extended_wait.

In addition, it seemed prudent to initialize lwp_info.status_pending_p
for the new fork child.  I also rearranged the initialization code
so that all of the lwp_info initialization was together, rather than
intermixed with thread_info and process_info initialization.

Tested native, native-gdbserver, native-extended-gdbserver on
x86_64 GNU/Linux.

gdb/gdbserver/

	* linux-low.c (handle_extended_wait): Initialize
	thread_info.last_resume_kind for new fork children.
2015-05-28 14:40:30 -07:00
Don Breazeal 8dd06f7a89 Make remote follow fork 'Detaching' message match native
This patch fixes a couple of failures in gdb.base/foll-vfork.exp for
extended-remote targets.  The failures were the result of the
verbose/debug "Detaching..." messages in infrun.c:follow_fork_inferior
not matching what was expected in the extended-remote case.

The path modifies the ptids used in the messages to ensure that they
print "process nnn" instead of (possibly) "Thread nnn.nnn".  The
detach is a process-wide operation, so we need to use a process-
style ptid regardless of what type of ptid target_pid_to_str returns.

Tested on x86_64 GNU/Linux, native, remote, extended-remote.

gdb/

	* infrun.c (follow_fork_inferior): Ensure the use of
	process-style ptids (pid,0,0) in verbose/debug "Detaching"
	messages.
2015-05-28 14:37:56 -07:00
Doug Evans a051152b64 * dwarf2read.c (record_line_ftype): Remove, duplicate.
gdb/Changelog:

	* dwarf2read.c (record_line_ftype): Remove, duplicate.
2015-05-28 09:42:02 -07:00
Yao Qi a56cc1ce22 Remove global variable arm_linux_has_wmmx_registers in arm-linux-nat.c
This patch is to remove the global variable arm_linux_has_wmmx_registers
in arm-linux-nat.c, and add a new field have_wmmx_registers in
'struct gdbarch_tdep'.

gdb:

2015-05-28  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (arm_linux_has_wmmx_registers): Remove.
	(arm_linux_fetch_inferior_registers): Use
	tdep->have_wmmx_registers instead of arm_linux_has_wmmx_registers.
	(arm_linux_store_inferior_registers): Likewise.
	(arm_linux_read_description): Don't set
	arm_linux_has_wmmx_registers.
	* arm-tdep.c (arm_gdbarch_init): Set
	tdep->have_wmmx_registers according target descriptions.
	* arm-tdep.h (struct gdbarch_tdep) <have_wmmx_registers>: New
	field.
2015-05-28 10:19:30 +01:00
Yao Qi 330c6ca9a0 Remove global variable arm_linux_vfp_register_count in arm-linux-nat.c
This patch is to remove the global variable arm_linux_vfp_register_count
from arm-linux-nat.c.  This global variable is set when native gdb
looks for the right target description according HWCAP.  However,
'struct gdbarch_tdep' has already had a field have_vfp_registers, which
is a boolean about whether target has vfp registers or not.  This
patch converts this boolean field to a numeric counter to replace
global variable arm_linux_vfp_register_count.

gdb:

2015-05-28  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-nat.c (arm_linux_vfp_register_count): Remove.
	(fetch_vfp_regs): Use vfp_register_count from gdbarch_tdep
	instead of arm_linux_vfp_register_count.
	(store_vfp_regs): Likewise.
	(arm_linux_fetch_inferior_registers): Likewise.
	(arm_linux_store_inferior_registers): Likewise.
	(arm_linux_read_description): Don't set
	arm_linux_vfp_register_count.
	* arm-linux-tdep.c (arm_linux_iterate_over_regset_sections):
	Adjust.
	* arm-tdep.c (arm_gdbarch_init): Add assert on
	vfp_register_count.
	* arm-tdep.h (struct gdbarch_tdep) <have_vfp_registers>: Rename
	field to vfp_register_count.  All users updated.
2015-05-28 10:19:30 +01:00
Kyle Huey d403db2720 Do arm_abi detection for ELFOSABI_GNU binaries
On ARM systems, gdb must determine which style of breakpoint to use
(see the comments at the beginning of gdb/arm-linux-tdep.c).  In
arm_gdbarch_init we only attempt to extract the eabi version from the
ELF binary if it is a ELFOSABI_NONE binary.  If the binary is
ELFOSABI_GNU instead, we end up defaulting to the old style OABI
syscall breakpoint instruction.  On a Linux kernel built without
CONFIG_OABI_COMPAT, this triggers a SIGILL in ld when attempting to
execute any ELFOSABI_GNU program.
(e.g. https://github.com/raspberrypi/linux/issues/766)

gdb/

2015-05-28  Kyle Huey  <me@kylehuey.com>  (tiny patch)

	* gdb/arm-tdep.c (arm_gdbarch_init): Perform arm_abi detection on
	ELFOSABI_GNU binaries.
2015-05-28 09:15:35 +01:00
Doug Evans d9b3de22f3 Add struct to record dwarf line number state machine.
gdb/ChangeLog:

	* dwarf2read.c (lnp_state_machine): New typedef.
	(lnp_reader_state): New typedef.
	(dwarf_record_line_1): Renamed from dwarf_record_line.
	All callers updated.
	(dwarf_record_line): New function.
	(init_lnp_state_machine): New function.
	(check_line_address): Replace p_record_line parameter with state.
	All callers updated.
	(dwarf_decode_lines_1): Call dwarf_record_line, init_lnp_state_machine.
	Update to record state in lnp_state_machine.
2015-05-27 14:44:29 -07:00
Doug Evans 924c2928ae dwarf2read.c code cleanup, split out check_line_address
gdb/ChangeLog:

	* dwarf2read.c (record_line_ftype): New typedef.
	(check_line_address): New function.
	(dwarf_decode_lines_1): Call it.
2015-05-27 13:22:02 -07:00
Doug Evans 27e0867f4d Add set/show debug dwarf-line.
gdb/ChangeLog:

	* NEWS: Mention "set debug dwarf-line".
	* dwarf2read.c (dwarf_line_debug): New static global.
	(add_include_dir): Add debug dwarf-line support.
	(add_file_name, dwarf_record_line, dwarf_finish_line): Ditto.
	(_initialize_dwarf2_read): New parameter "debug dwarf-line".

gdb/doc/ChangeLog:

	* gdb.texinfo (Debugging Output): Mention set/show debug dwarf-line.
2015-05-27 12:55:19 -07:00
Doug Evans 4dcabcc2b5 Don't ignore domain in nested lookups.
gdb/ChangeLog:

	* cp-namespace.c (cp_lookup_nested_symbol): New arg "domain".
	All callers updated.
	(cp_lookup_nested_symbol_1, find_symbol_in_baseclass): Ditto.
	* cp-support.h (cp_lookup_nested_symbol): Update.
2015-05-27 12:17:37 -07:00
Doug Evans b2e2f908b8 PR symtab/18258
gdb/ChangeLog:

	* block.c (block_find_symbol): New function.
	(block_find_non_opaque_type): Ditto.
	(block_find_non_opaque_type_preferred): Ditto.
	* block.h (block_symbol_matcher_ftype): New typedef.
	(block_find_symbol): Declare.
	(block_find_non_opaque_type): Ditto.
	(block_find_non_opaque_type_preferred): Ditto.
	* dwarf2read.c (dw2_lookup_symbol): Call block_find_symbol.
	* psymtab.c (psym_lookup_symbol): Ditto.
	* symtab.c (basic_lookup_transparent_type_1): New function.
	(basic_lookup_transparent_type): Call it.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/opaque-type-lookup-2.c: New file.
	* gdb.dwarf2/opaque-type-lookup.c: New file.
	* gdb.dwarf2/opaque-type-lookup.exp: New file.
2015-05-27 11:50:38 -07:00
Yao Qi f62fce356b [aarch64] Handle unknown instruction encoding
We see the following build error:

 gdb/aarch64-tdep.c: In function 'aarch64_process_record':
 gdb/aarch64-tdep.c:2823:17: error: 'record_buf[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                 memcpy(&REGS[0], &RECORD_BUF[0], sizeof(uint32_t)*LENGTH); \
                 ^
 gdb/aarch64-tdep.c:3529:12: note: 'record_buf[0]' was declared here
   uint32_t record_buf[2];

since record_buf[0] isn't initialized in some paths in which
instruction encodings doesn't exist in current ARMv8 reference manual.
This patch is to let the function return AARCH64_RECORD_UNKNOWN for
these paths.

gdb:

2015-05-27  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_record_data_proc_simd_fp): Return
	AARCH64_RECORD_UNKNOWN for unknown instruction encoding.
2015-05-27 17:16:45 +01:00
Yao Qi 5d98d3cd86 Fix ARI warnings in aarch64-tdep.c
This patch fixes some ARI warnings:

 $ bash ./gdb/contrib/ari/gdb_ari.sh -Wall -Werror -Wari gdb/aarch64-tdep.c
 gdb/aarch64-tdep.c:3009: code: Do not use &&, or || at the end of a line
 gdb/aarch64-tdep.c:3010: code: Do not use &&, or || at the end of a line
 gdb/aarch64-tdep.c:3413: code: Do not use &&, or || at the end of a line
 gdb/aarch64-tdep.c:3460: code: Do not use &&, or || at the end of a line

This patch moves && from the end of line to the start of the line.

gdb:

2015-05-27  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_record_branch_except_sys): Split lines
	before operator &&.
	(aarch64_record_load_store): Likewise.
2015-05-27 11:41:32 +01:00
Doug Evans 82c7be3106 PR c++/18141, c++/18417.
gdb/ChangeLog:

	* cp-support.c (cp_lookup_rtti_type): Handle the case of NAME being
	a typedef.

gdb/testsuite/ChangeLog:

	* gdb.cp/iostream.cc: New file.
	* gdb.cp/iostream.exp: New file.
2015-05-26 17:20:49 -07:00
Doug Evans b4f5498457 Rename dwarf2 to dwarf in "set debug" and maintenance commands.
gdb/ChangeLog:

	* NEWS: Add entries for command renamings.
	* dwarf2read.c (dwarf_read_debug): Renamed from dwarf2_read_debug.
	All uses updated.
	(dwarf_die_debug): Renamed from dwarf2_die_debug.  All uses updated.
	(dwarf_max_cache_age): Renamed from dwarf2_max_cache_age.
	All uses updated.
	(show_dwarf_max_cache_age): Renamed from show_dwarf2_max_cache_age.
	All callers updated.  Fix spelling of DWARF in help text.
	(set_dwarf_cmdlist): Renamed from set_dwarf2_cmdlist.
	All uses updated.
	(show_dwarf_cmdlist): Renamed from show_dwarf2_cmdlist.
	All uses updated.
	(set_dwarf_cmd): Renamed from set_dwarf2_cmd.  All callers updated.
	(show_dwarf_cmd): Renamed from show_dwarf2_cmd.  All callers updated.
	(dwarf_always_disassemble): Renamed from dwarf_always_disassemble.
	All uses updated.
	(show_dwarf_always_disassemble): Renamed from
	show_dwarf2_always_disassemble.  All callers updated.
	(_initialize_dwarf2_read): Rename "set/show dwarf2" prefix to
	"set/show dwarf".  Rename "set/show dwarf2 max-cache-age" to
	"set/show dwarf max-cache-age".  Rename
	"set/show dwarf2 always-disassemble" to
	"set/show dwarf always-disassemble".  Rename
	"set/show debug dwarf2-read" to "set/show debug dwarf-read".  Rename
	"set/show debug dwarf2-die" to "set/show debug dwarf-die".

gdb/doc/ChangeLog:

	* gdb.texinfo (Debugging Output): Update for DWARF "set debug"
	command renamings.
	(Maintenance Commands): Update for DWARF "set debug" command renamings.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-op-call.exp: Update.
	* gdb.dwarf2/dw4-sig-types.exp: Update.
	* gdb.dwarf2/implptr.exp: Update.
	* gdb.mi/mi-cmd-param-changed.exp: Update.
2015-05-26 16:50:57 -07:00
Doug Evans 4ea6efe936 PR python/18438
gdb/ChangeLog:

	* python/py-lazy-string.c (stpy_convert_to_value): Use
	gdbpy_gdb_memory_error not PyExc_MemoryError.
	(gdbpy_create_lazy_string_object): Ditto.

gdb/testsuite/ChangeLog:

	* gdb.python/py-lazy-string.c: New file.
	* gdb.python/py-lazy-string.exp: New file.
	* gdb.python/py-prettyprint.c (lazystring) <len>: New member.
	(main): Update.  Add estring3.
	* gdb.python/py-prettyprint.exp: Add tests for strings at address 0.
	* gdb.python/py-prettyprint.py (pp_ls): Handle length.
2015-05-26 16:13:04 -07:00
Andrew Burgess b93fd21dcc gdb: tui: Minor fix to compare against NULL.
Minor coding standard fix to compare against NULL.

gdb/ChangeLog:

	* tui/tui-regs.c (tui_reg_next_command): Compare against NULL.
2015-05-26 22:31:23 +01:00
Andrew Burgess 55b4002792 gdb: Add 'tui reg prev' command.
There is already a 'tui reg next' command, this adds a symmetric 'tui
reg prev' command.

gdb/ChangeLog:

	* tui/tui-regs.c (tui_reg_prev_command): New function.
	(_initialize_tui_regs): Add 'prev' command for 'tui reg'.
	* reggroups.c (reggroup_prev): New function.
	* reggroups.h (reggroup_prev): Add declaration.  Update comment.

gdb/doc/ChangeLog:

	* gdb.texinfo (TUI Commands): Add 'tui reg prev' details.
2015-05-26 22:18:50 +01:00
Yao Qi f6bb7db35d New gdb.reverse test case for aarch64 instructions
This patch adds a test case to test the process record for some of
aarch64 instructions.

In each function, GDB turns on process record, and single step until
program goes to the end of the function.  Then, single step backward.
In each of forward single step and backward single step, the contents
of registers are saved, and test compares them.  If there is any
differences, a FAIL is emitted.

The test is flexible, and we can test other instructions easily in the
future.

gdb/testsuite:

2015-05-26  Omair Javaid  <omair.javaid@linaro.org>
	    Yao Qi  <yao.qi@linaro.org>

	* gdb.reverse/aarch64.c: New.
	* gdb.reverse/aarch64.exp: New.
2015-05-26 12:42:21 +01:00
Omair Javaid a81bfbd06b Enables gdb.reverse testsuite for aarch64*-linux targets
This patch enable gdb.reverse tests for aarch64*-linux targets.

With this patch, there are 7 FAILs in gdb.reverse/ tests.

 FAIL: gdb.reverse/finish-reverse-bkpt.exp: reverse-finish from void_func trips breakpoint at entry
 FAIL: gdb.reverse/finish-reverse-bkpt.exp: no spurious proceed after breakpoint stop
 FAIL: gdb.reverse/next-reverse-bkpt-over-sr.exp: reverse-next over call trips user breakpoint at function entry
 FAIL: gdb.reverse/step-precsave.exp: reverse step into fn call
 FAIL: gdb.reverse/step-precsave.exp: reverse step out of called fn
 FAIL: gdb.reverse/step-reverse.exp: reverse step into fn call
 FAIL: gdb.reverse/step-reverse.exp: reverse step out of called fn

gdb/testsuite:

2015-05-26  Omair Javaid  <omair.javaid@linaro.org>

	* lib/gdb.exp (supports_process_record): Return true for aarch64*-linux*.
	(supports_reverse): Likewise.
2015-05-26 12:42:12 +01:00
Omair Javaid 99afc88b39 Implements aarch64 process record and reverse debugging support
This patch adds the support of aarch64-linux process record and reverse
debugging.  The implementation is similar to ARM's counterpart.

2015-05-26  Omair Javaid  <omair.javaid@linaro.org>
	    Yao Qi  <yao.qi@linaro.org>

	* aarch64-linux-tdep.c: Include linux-record.h and
	record-full.h.
	(struct linux_record_tdep aarch64_linux_record_tdep): Declare.
	(aarch64_syscall): New enum.
	(aarch64_canonicalize_syscall): New function.
	(aarch64_all_but_pc_registers_record): New function.
	(aarch64_linux_syscall_record): New function.
	(aarch64_linux_init_abi): Install AArch64 process record
	handler.  Update to handle syscall recording.
	* aarch64-tdep.c: Include record.h and record-full.h.
	(submask, bit, bits, REG_ALLOC, MEM_ALLOC): New macros.
	(struct aarch64_mem_r): Define.
	(aarch64_record_result): New enum.
	(struct insn_decode_record): Define.
	(insn_decode_record): New typedef.
	(aarch64_record_data_proc_reg): New function.
	(aarch64_record_data_proc_imm): New function.
	(aarch64_record_branch_except_sys): New function.
	(aarch64_record_load_store): New function.
	(aarch64_record_data_proc_simd_fp): New function.
	(aarch64_record_asimd_load_store): New function.
	(aarch64_record_decode_insn_handler): New function.
	(deallocate_reg_mem): New function.
	(aarch64_process_record): New function.
	* aarch64-tdep.h (struct gdbarch_tdep) <aarch64_syscall_record>:
	New field.
	(aarch64_process_record): New extern declaration.
	* configure.tgt: Add linux-record.o to gdb_target_obs.
	* linux-record.h (struct linux_record_tdep) <arg7>: New field.
2015-05-26 12:42:07 +01:00
Omair Javaid c16a3f522a NEWS entry about aarch64-linux record/replay support
This patch adds the NEWS entry for aarch64-linux record replay
support.

It has been reviewed and approved.

gdb:

2015-05-26  Omair Javaid  <omair.javaid@linaro.org>

	* NEWS: Add a note on process record-replay support on aarch64*-linux*
	targets.
2015-05-26 12:42:01 +01:00
Martin Galvan c9cf6e20c6 Rename in_function_epilogue_p to stack_frame_destroyed_p
We concluded that gdbarch_in_function_epilogue_p is misnamed, since it
returns true if the given PC is one instruction after the one that
destroyed the stack (which isn't necessarily inside an epilogue),
therefore it should be renamed to stack_frame_destroyed_p.

I also took the liberty of renaming the arch-specific implementations to
*_stack_frame_destroyed_p as well for consistency.

gdb:

2015-05-26  Martin Galvan  <martin.galvan@tallertechnologies.com>

	* amd64-tdep.c: Replace in_function_epilogue_p with
	stack_frame_destroyed_p throughout.
	* arch-utils.c: Ditto.
	* arch-utils.h: Ditto.
	* arm-tdep.c: Ditto.
	* breakpoint.c: Ditto.
	* gdbarch.sh: Ditto.
	* hppa-tdep.c: Ditto.
	* i386-tdep.c: Ditto.
	* mips-tdep.c: Ditto.
	* nios2-tdep.c: Ditto.
	* rs6000-tdep.c: Ditto.
	* s390-linux-tdep.c: Ditto.
	* score-tdep.c: Ditto.
	* sh-tdep.c: Ditto.
	* sparc-tdep.c: Ditto.
	* sparc-tdep.h: Ditto.
	* sparc64-tdep.c: Ditto.
	* spu-tdep.c: Ditto.
	* tic6x-tdep.c: Ditto.
	* tilegx-tdep.c: Ditto.
	* xstormy16-tdep.c: Ditto.
	* gdbarch.c, gdbarch.h: Re-generated.
2015-05-26 12:07:59 +01:00
Andrew Burgess a4ea0946c3 gdb: New 'tui enable' and 'tui disable' commands.
Add new commands to specifically enable and disable tui mode.  This is
in addition to the readline bindings, but might be easier for a user to
discover if they accidentally end up in tui mode.

gdb/ChangeLog:

	* NEWS: Mention 'tui enable' and 'tui disable'.
	* tui/tui.c (tui_enable_command): New function.
	(tui_disable_command): New function.
	(_initialize_tui): New function.

gdb/doc/ChangeLog:

	* gdb.texinfo (TUI): Include 'tui enable' in the introduction.
	(TUI Commands): Add 'tui enable' and 'tui disable' details.
2015-05-22 12:18:49 +02:00
Patrick Palka 158bf1b4aa Make sure test names are unique in gdb.base/gdbinit-history.exp
Use with_test_prefix to avoid duplicating test names when calling
the procedure test_gdbinit_history_setting multiple times.

gdb/testsuite/ChangeLog:

	* gdb.base/gdbinit-history.exp (test_gdbinit_history_setting):
	Use with_test_prefix.
2015-05-21 21:05:00 -04:00
Andrew Burgess b75c69bbf0 gdb: Use NULL not 0 in a tui function.
gdb/ChangeLog:

	* tui/tui-regs.c (tui_reg_next_command): Use NULL not 0.
2015-05-21 21:24:30 +02:00