Commit Graph

35816 Commits

Author SHA1 Message Date
Doug Evans 013d031916 completer.c (completion_list_add_name): Fix memory leak.
gdb/ChangeLog:

	* completer.c (completion_list_add_name): Fix memory leak.
2015-02-12 13:32:36 -08:00
David Taylor fa3f8d5ac6 Fix documentation of the QTDV packet
gdb/doc/ChangeLog
2015-02-12  David Taylor  <dtaylor@emc.com>

	* gdb.texinfo (Tracepoint Packets): Document the builtin and name
	fields of the QTDV packet.
2015-02-12 22:38:28 +02:00
Doug Evans 9a7e538ee1 completer.c (complete_line): Remove incorrect comment.
gdb/ChangeLog:

	* completer.c (complete_line): Remove incorrect comment.
2015-02-12 12:20:37 -08:00
Jan Kratochvil 63cc30e93a framefilter quit: New test
It definitely does not test all the RETURN_MASK_ERROR cases.  But it tests at
least two of them.

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

	* gdb.python/py-framefilter.exp (pagination quit - *): New tests.
2015-02-11 14:53:14 +01:00
Jan Kratochvil e1fcd5757b framefilter quit: Use RETURN_MASK_ERROR
Now when the code is exception safe we can let RETURN_QUIT to pass through as
all the installed cleanups with handle that.

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

	* python/py-framefilter.c (py_print_single_arg, enumerate_locals)
	(py_print_frame): Use RETURN_MASK_ERROR.
2015-02-11 14:50:09 +01:00
Jan Kratochvil b99bf4e352 framefilter quit: Make it exception safe
gdb/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python/py-framefilter.c (py_print_frame): Mention RETURN_QUIT in
	function comment.  Wrap all function that can throw in cleanups.
	(gdbpy_apply_frame_filter): Wrap all function that can throw in
	cleanups.
2015-02-11 14:44:00 +01:00
Jan Kratochvil 800eb1cebe framefilter quit: Code cleanup: Avoid gotos
goto error patters are sometimes AFAIK used in C for the cases like:
	int retval=-1;
	if (!(a=malloc())) goto error;
	if (!(b=malloc())) goto error_a;
	if (!(c=malloc())) goto error_b;
	retval=0;
	error_c: free(c);
	error_b: free(b);
	error_a: free(a);
	error: return retval;

But here there is single error label with one do_cleanups() which I do not find
it worth the goto complication.  Without goto one can then furher merge code in
the exit paths in the next patches and ... after all it is all the same, just
without a goto.

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

	* python/py-framefilter.c (py_print_frame): Substitute goto error.
	Remove the error label.
2015-02-11 14:40:14 +01:00
Jan Kratochvil 34019068f0 framefilter quit: Code cleanup: Reindentation
Nothing significant but I find code more clear with less deep indentation.

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

	* python/py-framefilter.c (py_print_frame): Put conditional code paths
	with goto first, indent the former else codepath left.  Put variable
	'elided' to a new inner block.
2015-02-11 14:37:40 +01:00
Jan Kratochvil 8d4a54e2fb framefilter quit: Obvious whitespacing fixes
gdb/ChangeLog
2015-02-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* python/py-framefilter.c (py_print_frame): Whitespacing fixes.
2015-02-11 14:33:48 +01:00
Pedro Alves 18ad82c163 xcoffread.c: delete 'within_function' definition
Linking GDB as a C++ program, we get:

  src/gdb/buildsym.c:226: multiple definition of `within_function'
  xcoffread.o:src/gdb/xcoffread.c:181: first defined here

gdb/
2015-02-11  Pedro Alves  <palves@redhat.com>

	* xcoffread.c (within_function): Delete.
2015-02-11 11:32:38 +00:00
Tom Tromey e36122e9d7 Fix redefinition errors in C++ mode
In C, we can forward declare static structure instances.  That doesn't
work in C++ though.  C++ treats these as definitions.  So then the
compiler complains about symbol redefinition, like:

 src/gdb/elfread.c:1569:29: error: redefinition of ‘const sym_fns elf_sym_fns_lazy_psyms’
 src/gdb/elfread.c:53:29: error: ‘const sym_fns elf_sym_fns_lazy_psyms’ previously declared here

The intent of static here is naturally to avoid making these objects
visible outside the compilation unit.  The equivalent in C++ would be
to instead define the objects in the anonymous namespace.  But given
that it's desirable to leave the codebase compiling as both C and C++
for a while, this just makes the objects extern.

(base_breakpoint_ops is already declared in breakpoint.h, so we can
just remove the forward declare from breakpoint.c)

gdb/ChangeLog:
2015-02-11  Tom Tromey  <tromey@redhat.com>
	    Pedro Alves <palves@redhat.com>

	* breakpoint.c (base_breakpoint_ops): Delete.
	* dwarf2loc.c (dwarf_expr_ctx_funcs): Make extern.
	* elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_lazy_psyms): Make extern.
	* guile/guile.c (guile_extension_script_ops, guile_extension_ops): Make extern.
	* ppcnbsd-tdep.c (ppcnbsd2_sigtramp): Make extern.
	* python/py-arch.c (arch_object_type): Make extern.
	* python/py-block.c (block_syms_iterator_object_type): Make extern.
	* python/py-bpevent.c (breakpoint_event_object_type): Make extern.
	* python/py-cmd.c (cmdpy_object_type): Make extern.
	* python/py-continueevent.c (continue_event_object_type)
	* python/py-event.h (GDBPY_NEW_EVENT_TYPE): Remove 'qual'
	parameter.  Update all callers.
	* python/py-evtregistry.c (eventregistry_object_type): Make extern.
	* python/py-exitedevent.c (exited_event_object_type): Make extern.
	* python/py-finishbreakpoint.c (finish_breakpoint_object_type): Make extern.
	* python/py-function.c (fnpy_object_type): Make extern.
	* python/py-inferior.c (inferior_object_type, membuf_object_type): Make extern.
	* python/py-infevents.c (call_pre_event_object_type)
	(inferior_call_post_event_object_type).
	(memory_changed_event_object_type): Make extern.
	* python/py-infthread.c (thread_object_type): Make extern.
	* python/py-lazy-string.c (lazy_string_object_type): Make extern.
	* python/py-linetable.c (linetable_entry_object_type)
	(linetable_object_type, ltpy_iterator_object_type): Make extern.
	* python/py-newobjfileevent.c (new_objfile_event_object_type)
	(clear_objfiles_event_object_type): Make extern.
	* python/py-objfile.c (objfile_object_type): Make extern.
	* python/py-param.c (parmpy_object_type): Make extern.
	* python/py-progspace.c (pspace_object_type): Make extern.
	* python/py-signalevent.c (signal_event_object_type): Make extern.
	* python/py-symtab.c (symtab_object_type, sal_object_type): Make extern.
	* python/py-type.c (type_object_type, field_object_type)
	(type_iterator_object_type): Make extern.
	* python/python.c (python_extension_script_ops)
	(python_extension_ops): Make extern.
	* stap-probe.c (stap_probe_ops): Make extern.
2015-02-11 11:20:21 +00:00
Pedro Alves 0703599a49 Fix adjust_pc_after_break, remove still current thread check
On decr_pc_after_break targets, GDB adjusts the PC incorrectly if a
background single-step stops somewhere where PC-$decr_pc has a
breakpoint, and the thread that finishes the step is not the current
thread, like:

   ADDR1 nop <-- breakpoint here
   ADDR2 jmp PC

IOW, say thread A is stepping ADDR2's line in the background (an
infinite loop), and the user switches focus to thread B.  GDB's
adjust_pc_after_break logic confuses the single-step stop of thread A
for a hit of the breakpoint at ADDR1, and thus adjusts thread A's PC
to point at ADDR1 when it should not, and reports a breakpoint hit,
when thread A did not execute the instruction at ADDR1 at all.

The test added by this patch exercises exactly that.

I can't find any reason we'd need the "thread to be examined is still
the current thread" condition in adjust_pc_after_break, at least
nowadays; it might have made sense in the past.  Best just remove it,
and rely on currently_stepping().

Here's the test's log of a run with an unpatched GDB:

 35        while (1);
 (gdb) PASS: gdb.threads/step-bg-decr-pc-switch-thread.exp: next over nop
 next&
 (gdb) PASS: gdb.threads/step-bg-decr-pc-switch-thread.exp: next& over inf loop
 thread 1
 [Switching to thread 1 (Thread 0x7ffff7fc2740 (LWP 29027))](running)
 (gdb)
 PASS: gdb.threads/step-bg-decr-pc-switch-thread.exp: switch to main thread
 Breakpoint 2, thread_function (arg=0x0) at ...src/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.c:34
 34        NOP; /* set breakpoint here */
 FAIL: gdb.threads/step-bg-decr-pc-switch-thread.exp: no output while stepping

gdb/ChangeLog:
2015-02-11  Pedro Alves  <pedro@codesourcery.com>

	* infrun.c (adjust_pc_after_break): Don't adjust the PC just
	because the event thread is not the current thread.

gdb/testsuite/ChangeLog:
2015-02-11  Pedro Alves  <pedro@codesourcery.com>

	* gdb.threads/step-bg-decr-pc-switch-thread.c: New file.
	* gdb.threads/step-bg-decr-pc-switch-thread.exp: New file.
2015-02-11 09:45:41 +00:00
Doug Evans 7e60a48ee0 lib/gdb.exp (gdb_load): Always return a result.
gdb/testsuite/ChangeLog:

	* lib/gdb.exp (gdb_load): Always return a result.
2015-02-10 22:07:06 -08:00
Doug Evans eaaf76abdc internal_type_self_type: Handle TYPE_SPECIFIC_NONE.
gdb/ChangeLog:

	* gdbtypes.c (internal_type_self_type): If TYPE_SPECIFIC_FIELD hasn't
	been initialized yet, return NULL.
2015-02-10 21:18:59 -08:00
Doug Evans e7d52ed304 Rename new_symfile_objfile, make static.
gdb/ChangeLog:

	* symfile.h (new_symfile_objfile): Delete.
	* symfile.c (finish_new_objfile): Renamed from new_symfile_objfile.
	All callers updated.
2015-02-10 17:01:37 -08:00
Patrick Palka fc6b1256ee Fix a pair of screen-resizing issues in TUI
This patch fixes a pair of TUI issues related to screen resizing:

1. In tui_handle_resize_during_io(), when the TUI screen gets resized,
we fail to update GDB's idea about the height of the output window.

You can see this bug by doing:

  a. Enter TUI mode.
  b. "show height"
  c. Resize the terminal.
  d. "show height"

And observe that despite resizing the terminal, the reported height
remains unchanged.  Note that a similar issue exists in the CLI.

The fix for this is simple: call tui_update_gdb_sizes() after performing
a resize, so that the "height" variable remains consistent with the
height of TUI's output window.

2. In tui_enable(), the call to tui_update_gdb_sizes() may clobber
readline's idea of the actual screen dimensions, and a subsequent
pending resize will use bogus terminal dimensions.

You can see this bug by doing:

  a. Enter TUI mode.
  b. Exit TUI mode.
  c. Resize the terminal.
  d. Enter TUI mode.
  e. Press a key to resize the screen.

And observe that the terminal gets incorrectly resized to the wrong
dimensions.  To fix this issue, we should oppurtunistically resize the
screen in tui_enable().  That way we eliminate the possibility of a
pending resize triggering right after we call tui_update_gdb_sizes().

gdb/ChangeLog:

	* tui/tui-io.c (tui_handle_resize_during_io): Call
	tui_update_gdb_sizes() after resizing the screen.
	* tui/tui.c (tui_enable): Resize the terminal before
	calling tui_update_gdb_sizes().
2015-02-10 19:06:49 -05:00
Patrick Palka d908067812 Fix truncation of TUI command history
If we submit a command while the prompt cursor is somewhere other than
at the end of the command line, the command line gets truncated as the
command window gets shifted one line up.  This happens because we fail
to properly move the cursor to the end of the command line before
transmitting the newline to ncurses.  We need to move the cursor because
when ncurses outputs a newline it truncates any text that appears
past the end of the cursor.

The fix is generic enough to work properly even in multi-line secondary
prompts like the quit prompt.

gdb/ChangeLog:

	* tui/tui-io.c (tui_getc): Move cursor to the end of the command
	line before printing a newline.
2015-02-10 19:06:49 -05:00
Mark Wielaard 9f615e3af0 gdb producer_is_gcc fix bool return value.
gdb/ChangeLog:

	* utils.c (producer_is_gcc): Return true or false.
2015-02-11 00:45:39 +01:00
Mark Wielaard b1ffba5a7f Change producer_is_gcc function return type to bool.
gdb/ChangeLog:

        * utils.h (producer_is_gcc): Change return type to bool. Add major
        argument.
        * utils.c (producer_is_gcc): Likewise.
        (producer_is_gcc_ge_4): Adjust producer_is_gcc call.
        * dwarf2read.c (check_producer): Likewise.
2015-02-10 21:20:38 +01:00
Pedro Alves 01b088bc51 Add "signal SIGTRAP" test
Some local changes I was working on related to SIGTRAP handling
resulted in "signal SIGTRAP" no longer passing the SIGTRAP to the
inferior.

Surprisingly, only annota1.exp catches this.  This commit adds a test
that doesn't rely on annotations, so that at the point annotations are
finaly dropped, we still have this use case covered ...

This is a multi-threaded test to also exercise the case of first
needing to do a step-over before delivering the signal.

Tested on x86_64 Fedora 20, native, remote/extended-remote gdbserver.

gdb/testsuite/
2015-02-10  Pedro Alves  <palves@redhat.com>

	* gdb.threads/signal-sigtrap.c: New file.
	* gdb.threads/signal-sigtrap.exp: New file.
2015-02-10 19:30:55 +00:00
Pedro Alves b052c4fbf5 displaced_step_fixup may access memory from the wrong inferior/thread
displaced_step_fixup takes an thread to work with, as argument.  OTOH,
gdbarch_displaced_step_fixup fixes up the current thread.  The former
calls the latter without making sure the current thread is the one
that was passed in.  If it is not, then gdbarch_displaced_step_fixup
may e.g., try reading from a running thread, which doesn't work on
some targets, or worse, read memory from the wrong inferior and
succeed.

This is mostly a latent problem currently, as non-stop switches the
current thread to the event thread early in fetch_inferior_event.

Tested on x86_64 Fedora 20.

gdb/
2015-02-10  Pedro Alves  <palves@redhat.com>

	* infrun.c (displaced_step_fixup): Switch to the event thread
	before calling gdbarch_displaced_step_fixup.
2015-02-10 19:13:31 +00:00
Antoine Tremblay b05ec7a53f gdbserver: Fix crash when QTinit is handled with no inferior process attached
When gdbserver is called with --multi and attach has not been called yet
and tstart is called on the gdb client, gdbserver would crash.
This patch fixes gdbserver so that it returns E01 to the gdb client.

Also this patch adds a testcase to verify this bug named no-attach-trace.exp

gdb/gdbserver/ChangeLog:
	PR breakpoints/15956
	* tracepoint.c (cmd_qtinit): Add check for current_thread.

gdb/testsuite/ChangeLog:
	* gdb.trace/no-attach-trace.c: New file.
	* gdb.trace/no-attach-trace.exp: New file.
2015-02-10 13:49:41 -05:00
Antoine Tremblay 3ac240d438 Add myself as write-after-approval GDB maintainer
gdb/ChangeLog:
	* MAINTAINERS (Write After Approval): Add Antoine Tremblay.
2015-02-10 13:38:57 -05:00
Simon Marchi c1cc615262 Finish constification of varobj interface
This completes the constification of the struct varobj pointers in the
lang_varobj_ops interface partially done in
b09e2c591f. As suggested by Pedro,
varobj_get_path_expr casts away the const to assign the "mutable" struct
member.

gdb/ChangeLog:

	* ada-varobj.c (ada_name_of_child): Constify parent.
	(ada_path_expr_of_child): Same.
	(ada_value_of_child): Same.
	(ada_type_of_child): Same.
	* c-varobj.c (c_is_path_expr_parent): Same.
	(c_describe_child): Same.
	(c_name_of_child): Same.
	(c_value_of_child): Same.
	(c_type_of_child): Same.
	(cplus_number_of_children): Same.
	(cplus_describe_child): Constify var.
	(cplus_name_of_child): Constify parent.
	(cplus_value_of_child): Same.
	(cplus_type_of_child): Same.
	* jv-varobj.c (java_name_of_child): Same.
	(java_value_of_child): Same.
	(java_type_of_child): Same.
	* varobj.c (value_of_child): Same.
	(varobj_default_is_path_expr_parent): Constify var, parent and return
	value.
	(varobj_get_path_expr): Constify var, modify path_expr through
	mutable_var.
	(install_new_value): Constify parent.
	(value_of_child): Constify parent.
	* varobj.h (struct varobj): Constify parent.
	(struct lang_varobj_ops): Constify name_of_child, value_of_child and
	type_of_child.
	(varobj_get_path_expr): Constify var.
	(varobj_get_path_expr_parent): Constify var and return value.
2015-02-10 12:57:47 -05:00
Luis Machado c1ee941477 Relax ARM prologue unwinder assumption
Modify the ARM prologue unwinder to use the stop_reason hook instead of
returning imprecise frame id's through the arm prologue this_id hook.

gdb/
2015-02-10  Luis Machado  <lgustavo@codesourcery.com>

	* arm-tdep.c (arm_prologue_unwind_stop_reason): New function.
	(arm_prologue_this_id): Move PC and SP limit checks to
	arm_prologue_unwind_stop_reason.
	(arm_prologue_unwind) <stop_reason> : Set to
	arm_prologue_unwind_stop_reason.
2015-02-10 09:46:11 -02:00
Mark Wielaard f7de9aab90 Recognize new DWARF5/GCC5 DW_LANG Fortran 2003 and Fortran 2008 standards.
DWARFv5 defines and GCC5 may output two new DW_LANG constants for the
Fortran 2003 and Fortran 2008 standards. Recognize both as variants of
language_fortran.

gdb/ChangeLog:

	* dwarf2read.c (set_cu_language): Recognize DW_LANG_Fortran03 and
	DW_LANG_Fortran08 as language_fortran.

http://dwarfstd.org/ShowIssue.php?issue=141121.1
2015-02-10 10:15:04 +01:00
Sergio Durigan Junior 0b24eb2de5 PR remote/17946: Fix wrong comparison of pointer against char
We were comparing a pointer against a char on remote.c.  'dcb' filed a
bug to inform us about that.  I pushed the following patch under the
obvious rule.

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

	PR remote/17946
	* gdb/remote.c (remote_parse_stop_reply): Fix wrong comparison
	of pointer against char.
2015-02-09 19:00:55 -05:00
Mark Wielaard a2c2acaf15 GCC5/DWARFv5 Handle DW_TAG_atomic_type for C11 _Atomic type qualifier.
gdb/ChangeLog

	* c-typeprint.c (cp_type_print_method_args): Handle '_Atomic'.
	(c_type_print_modifier): Likewise.
	* dwarf2read.c (read_tag_atomic_type): New function.
	(read_type_die_1): Handle DW_TAG_atomic_type.
	* gdbtypes.c (make_atomic_type): New function.
	(recursive_dump_type): Handle TYPE_ATOMIC.
	* gdbtypes.h (enum type_flag_values): Renumber.
	(enum type_instance_flag_value): Add TYPE_INSTANCE_FLAG_ATOMIC.
	(TYPE_ATOMIC): New macro.
	(make_atomic_type): Declare.

gdb/testsuite/ChangeLog

	* gdb.dwarf2/atomic.c: New file.
	* gdb.dwarf2/atomic-type.exp: Likewise.

include/ChangeLog

	* dwarf2.def: Add DW_TAG_atomic_type.
2015-02-09 15:09:22 +01:00
Markus Metzger 31fd9caad9 record-btrace: indicate gaps
Indicate gaps in the trace due to decode errors.  Internally, a gap is
represented as a btrace function segment without instructions and with a
non-zero format-specific error code.

Show the gap when traversing the instruction or function call history.
Also indicate gaps in "info record".

It looks like this:

  (gdb) info record
  Active record target: record-btrace
  Recording format: Branch Trace Store.
  Buffer size: 64KB.
  Recorded 32 instructions in 5 functions (1 gaps) for thread 1 (process 7182).
  (gdb) record function-call-history /cli
  1	fib	inst 1,9	at src/fib.c:9,14
  2	  fib	inst 10,20	at src/fib.c:6,14
  3	[decode error (1): instruction overflow]
  4	fib	inst 21,28	at src/fib.c:11,14
  5	  fib	inst 29,33	at src/fib.c:6,9
  (gdb) record instruction-history 20,22
  20	   0x000000000040062f <fib+47>:	sub    $0x1,%rax
  [decode error (1): instruction overflow]
  21	   0x0000000000400613 <fib+19>:	add    $0x1,%rax
  22	   0x0000000000400617 <fib+23>:	mov    %rax,0x200a3a(%rip)
  (gdb)

Gaps are ignored during reverse execution and replay.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c (ftrace_find_call): Skip gaps.
	(ftrace_new_function): Initialize level.
	(ftrace_new_call, ftrace_new_tailcall, ftrace_new_return)
	(ftrace_new_switch): Update
	level computation.
	(ftrace_new_gap): New.
	(ftrace_update_function): Create new function after gap.
	(btrace_compute_ftrace_bts): Create gap on error.
	(btrace_stitch_bts): Update parameters.  Clear trace if it
	becomes empty.
	(btrace_stitch_trace): Update parameters.  Update callers.
	(btrace_clear): Reset the number of gaps.
	(btrace_insn_get): Return NULL if the iterator points to a gap.
	(btrace_insn_number): Return zero if the iterator points to a gap.
	(btrace_insn_end): Allow gaps at the end.
	(btrace_insn_next, btrace_insn_prev, btrace_insn_cmp): Handle gaps.
	(btrace_find_insn_by_number): Assert that the found iterator does
	not point to a gap.
	(btrace_call_next, btrace_call_prev): Assert that the last function
	is not a gap.
	* btrace.h (btrace_bts_error): New.
	(btrace_function): Update comment.
	(btrace_function) <insn, insn_offset, number>: Update comment.
	(btrace_function) <errcode>: New.
	(btrace_thread_info) <ngaps>: New.
	(btrace_thread_info) <replay>: Update comment.
	(btrace_insn_get): Update comment.
	* record-btrace.c (btrace_ui_out_decode_error): New.
	(record_btrace_info): Print number of gaps.
	(btrace_insn_history, btrace_call_history): Call
	btrace_ui_out_decode_error for gaps.
	(record_btrace_step_thread, record_btrace_start_replaying): Skip gaps.

testsuite/
	* gdb.btrace/buffer-size.exp: Update "info record" output.
	* gdb.btrace/delta.exp: Update "info record" output.
	* gdb.btrace/enable.exp: Update "info record" output.
	* gdb.btrace/finish.exp: Update "info record" output.
	* gdb.btrace/instruction_history.exp: Update "info record" output.
	* gdb.btrace/next.exp: Update "info record" output.
	* gdb.btrace/nexti.exp: Update "info record" output.
	* gdb.btrace/step.exp: Update "info record" output.
	* gdb.btrace/stepi.exp: Update "info record" output.
	* gdb.btrace/nohist.exp: Update "info record" output.
2015-02-09 09:52:10 +01:00
Markus Metzger afb778a2a8 btrace: identify cpu
Add a struct for identifying a processor and use it in linux-btrace.c when
identifying the processor we're running on.

We will need this feature for the new btrace format.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* common/btrace-common.h (btrace_cpu_vendor, btrace_cpu): New.
	* nat/linux-btrace.c: (btrace_this_cpu): New.
	(cpu_supports_bts): Call btrace_this_cpu.
	(intel_supports_bts): Add cpu parameter.
2015-02-09 09:49:15 +01:00
Markus Metzger 7d5c24b3ae btrace: extend struct btrace_insn
Add the instruction's size as well as a coarse classification to struct
btrace_insn.  Use the information in ftrace_update_function and
ftrace_find_call.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.h (btrace_insn_class): New.
	(btrace_insn) <size, iclass>: New.
	* btrace.c (ftrace_find_call): Update parameters.  Update users.
	Use instruction classification.
	(ftrace_new_return): Update parameters.  Update users.
	(ftrace_update_function): Update parameters.  Update users.  Use
	instruction classification.
	(ftrace_update_insns): Update parameters.  Update users.
	(ftrace_classify_insn): New.
	(btrace_compute_ftrace_bts): Fill in new btrace_insn fields.  Add
	TRY_CATCH around call to gdb_insn_length.
2015-02-09 09:46:49 +01:00
Markus Metzger 76235df10b btrace: update btrace_compute_ftrace parameters
Pass thread_info instead of btrace_thread_info to btrace_compute_ftrace.
We will need the thread_info in subsequent patches.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c (btrace_compute_ftrace_bts, btrace_compute_ftrace):
	Update parameters.  Update users.
2015-02-09 09:45:00 +01:00
Markus Metzger d33501a51f record-btrace: add bts buffer size configuration option
Allow the size of the branch trace ring buffer to be defined by the
user.  The specified buffer size will be used when BTS tracing is
enabled for new threads.

The obtained buffer size may differ from the requested size.  The
actual buffer size for the current thread is shown in the "info record"
command.

Bigger buffers mean longer traces, but also longer processing time.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c (parse_xml_btrace_conf_bts): Add size.
	(btrace_conf_bts_attributes): New.
	(btrace_conf_children): Add attributes.
	* common/btrace-common.h (btrace_config_bts): New.
	(btrace_config)<bts>: New.
	(btrace_config): Update comment.
	* nat/linux-btrace.c (linux_enable_btrace, linux_enable_bts):
	Use config.
	* features/btrace-conf.dtd: Increment version.  Add size
	attribute to bts element.
	* record-btrace.c (set_record_btrace_bts_cmdlist,
	show_record_btrace_bts_cmdlist): New.
	(record_btrace_adjust_size, record_btrace_print_bts_conf,
	record_btrace_print_conf, cmd_set_record_btrace_bts,
	cmd_show_record_btrace_bts): New.
	(record_btrace_info): Call record_btrace_print_conf.
	(_initialize_record_btrace): Add commands.
	* remote.c: Add PACKET_Qbtrace_conf_bts_size enum.
	(remote_protocol_features): Add Qbtrace-conf:bts:size packet.
	(btrace_sync_conf): Synchronize bts size.
	(_initialize_remote): Add Qbtrace-conf:bts:size packet.
	* NEWS: Announce new commands and new packets.

doc/
	* gdb.texinfo (Branch Trace Configuration Format): Add size.
	(Process Record and Replay): Describe new set|show commands.
	(General Query Packets): Describe Qbtrace-conf:bts:size packet.

testsuite/
	* gdb.btrace/buffer-size: New.

gdbserver/
	* linux-low.c (linux_low_btrace_conf): Print size.
	* server.c (handle_btrace_conf_general_set): New.
	(hanle_general_set): Call handle_btrace_conf_general_set.
	(handle_query): Report Qbtrace-conf:bts:size as supported.
2015-02-09 09:42:28 +01:00
Markus Metzger f4abbc1682 record btrace: add configuration struct
Add a struct to describe the branch trace configuration and use it for
enabling branch tracing.

The user will be able to set configuration fields for each tracing format
to be used for new threads.

The actual configuration that is active for a given thread will be shown
in the "info record" command.

At the moment, the configuration struct only contains a format field
that is set to the only available format.

The format is the only configuration option that can not be set via set
commands.  It is given as argument to the "record btrace" command when
starting recording.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* Makefile.in (XMLFILES): Add btrace-conf.dtd.
	* x86-linux-nat.c (x86_linux_enable_btrace): Update parameters.
	(x86_linux_btrace_conf): New.
	(x86_linux_create_target): Initialize to_btrace_conf.
	* nat/linux-btrace.c (linux_enable_btrace): Update parameters.
	Check format.  Split into this and ...
	(linux_enable_bts): ... this.
	(linux_btrace_conf): New.
	(perf_event_skip_record): Renamed into ...
	(perf_event_skip_bts_record): ... this.  Updated users.
	(linux_disable_btrace): Split into this and ...
	(linux_disable_bts): ... this.
	(linux_read_btrace): Check format.
	* nat/linux-btrace.h (linux_enable_btrace): Update parameters.
	(linux_btrace_conf): New.
	(btrace_target_info)<ptid>: Moved.
	(btrace_target_info)<conf>: New.
	(btrace_target_info): Split into this and ...
	(btrace_tinfo_bts): ... this.  Updated users.
	* btrace.c (btrace_enable): Update parameters.
	(btrace_conf, parse_xml_btrace_conf_bts, parse_xml_btrace_conf)
	(btrace_conf_children, btrace_conf_attributes)
	(btrace_conf_elements): New.
	* btrace.h (btrace_enable): Update parameters.
	(btrace_conf, parse_xml_btrace_conf): New.
	* common/btrace-common.h (btrace_config): New.
	* feature/btrace-conf.dtd: New.
	* record-btrace.c (record_btrace_conf): New.
	(record_btrace_cmdlist): New.
	(record_btrace_enable_warn, record_btrace_open): Pass
	&record_btrace_conf.
	(record_btrace_info): Print recording format.
	(cmd_record_btrace_bts_start): New.
	(cmd_record_btrace_start): Call cmd_record_btrace_bts_start.
	(_initialize_record_btrace): Add "record btrace bts" subcommand.
	Add "record bts" alias command.
	* remote.c (remote_state)<btrace_config>: New.
	(remote_btrace_reset, PACKET_qXfer_btrace_conf): New.
	(remote_protocol_features): Add qXfer:btrace-conf:read.
	(remote_open_1): Call remote_btrace_reset.
	(remote_xfer_partial): Handle TARGET_OBJECT_BTRACE_CONF.
	(btrace_target_info)<conf>: New.
	(btrace_sync_conf, btrace_read_config): New.
	(remote_enable_btrace): Update parameters.  Call btrace_sync_conf and
	btrace_read_conf.
	(remote_btrace_conf): New.
	(init_remote_ops): Initialize to_btrace_conf.
	(_initialize_remote): Add qXfer:btrace-conf packet.
	* target.c (target_enable_btrace): Update parameters.
	(target_btrace_conf): New.
	* target.h (target_enable_btrace): Update parameters.
	(target_btrace_conf): New.
	(target_object)<TARGET_OBJECT_BTRACE_CONF>: New.
	(target_ops)<to_enable_btrace>: Update parameters and comment.
	(target_ops)<to_btrace_conf>: New.
	* target-delegates: Regenerate.
	* target-debug.h (target_debug_print_const_struct_btrace_config_p)
	(target_debug_print_const_struct_btrace_target_info_p): New.
	NEWS: Announce new command and new packet.

doc/
	* gdb.texinfo (Process Record and Replay): Describe the "record
	btrace bts" command.
	(General Query Packets): Describe qXfer:btrace-conf:read packet.
	(Branch Trace Configuration Format): New.

gdbserver/
	* linux-low.c (linux_low_enable_btrace): Update parameters.
	(linux_low_btrace_conf): New.
	(linux_target_ops)<to_btrace_conf>: Initialize.
	* server.c (current_btrace_conf): New.
	(handle_btrace_enable): Rename to ...
	(handle_btrace_enable_bts): ... this.  Pass &current_btrace_conf
	to target_enable_btrace.  Update comment.  Update users.
	(handle_qxfer_btrace_conf): New.
    (qxfer_packets): Add btrace-conf entry.
	(handle_query): Report qXfer:btrace-conf:read as supported packet.
	* target.h (target_ops)<enable_btrace>: Update parameters and comment.
	(target_ops)<read_btrace_conf>: New.
	(target_enable_btrace): Update parameters.
	(target_read_btrace_conf): New.

testsuite/
	* gdb.btrace/delta.exp: Update "info record" output.
	* gdb.btrace/enable.exp: Update "info record" output.
	* gdb.btrace/finish.exp: Update "info record" output.
	* gdb.btrace/instruction_history.exp: Update "info record" output.
	* gdb.btrace/next.exp: Update "info record" output.
	* gdb.btrace/nexti.exp: Update "info record" output.
	* gdb.btrace/step.exp: Update "info record" output.
	* gdb.btrace/stepi.exp: Update "info record" output.
	* gdb.btrace/nohist.exp: Update "info record" output.
2015-02-09 09:38:55 +01:00
Markus Metzger aadf7753fd btrace, linux: add perf event buffer abstraction
Collect perf event buffer related fields from btrace_target_info into
a new struct perf_event_buffer.  Update functions that operated on the
buffer to take a struct perf_event_buffer pointer rather than a
btrace_target_info pointer.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* nat/linux-btrace.h (perf_event_buffer): New.
	(btrace_target_info) <buffer, size, data_head>: Replace with ...
	<bts>: ... this.
	* nat/linux-btrace.c (perf_event_header, perf_event_mmap_size)
	(perf_event_buffer_size, perf_event_buffer_begin)
	(perf_event_buffer_end, linux_btrace_has_changed): Removed.
	Updated users.
	(perf_event_new_data): New.
2015-02-09 09:33:59 +01:00
Markus Metzger 043c357797 btrace: add format argument to supports_btrace
Add a format argument to the various supports_btrace functions to check
for support of a specific btrace format.  This is to prepare for a new
format.

Removed two redundant calls.  The check will be made in the subsequent
btrace_enable call.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* btrace.c (btrace_enable): Pass BTRACE_FORMAT_BTS.
	* record-btrace.c (record_btrace_open): Remove call to
	target_supports_btrace.
	* remote.c (remote_supports_btrace): Update parameters.
	* target.c (target_supports_btrace): Update parameters.
	* target.h (to_supports_btrace, target_supports_btrace): Update
	parameters.
	* target-delegates.c: Regenerate.
	* target-debug.h (target_debug_print_enum_btrace_format): New.
	* nat/linux-btrace.c
	(kernel_supports_btrace): Rename into ...
	(kernel_supports_bts): ... this.  Update users.  Update warning text.
	(intel_supports_btrace): Rename into ...
	(intel_supports_bts): ... this.  Update users.
	(cpu_supports_btrace): Rename into ...
	(cpu_supports_bts): ... this.  Update users.
	(linux_supports_btrace): Update parameters.  Split into this and ...
	(linux_supports_bts): ... this.
	* nat/linux-btrace.h (linux_supports_btrace): Update parameters.

gdbserver/
	* server.c (handle_btrace_general_set): Remove call to
	target_supports_btrace.
	(supported_btrace_packets): New.
	(handle_query): Call supported_btrace_packets.
	* target.h: include btrace-common.h.
	(btrace_target_info): Removed.
	(supports_btrace, target_supports_btrace): Update parameters.
2015-02-09 09:31:14 +01:00
Markus Metzger 734b0e4bda btrace: add struct btrace_data
Add a structure to hold the branch trace data and an enum to describe
the format of that data.  So far, only BTS is supported.  Also added
a NONE format to indicate that no branch trace data is available.

This will make it easier to support different branch trace formats in
the future.

2015-02-09  Markus Metzger  <markus.t.metzger@intel.com>

	* Makefile.in (SFILES): Add common/btrace-common.c.
	(COMMON_OBS): Add common/btrace-common.o.
	(btrace-common.o): Add build rules.
	* btrace.c (parse_xml_btrace): Update parameters.
	(parse_xml_btrace_block): Set format field.
	(btrace_add_pc, btrace_fetch): Use struct btrace_data.
	(do_btrace_data_cleanup, make_cleanup_btrace_data): New.
	(btrace_compute_ftrace): Split into this and...
	(btrace_compute_ftrace_bts): ...this.
	(btrace_stitch_trace): Split into this and...
	(btrace_stitch_bts): ...this.
	* btrace.h (parse_xml_btrace): Update parameters.
	(make_cleanup_btrace_data): New.
	* common/btrace-common.c: New.
	* common/btrace-common.h: Include common-defs.h.
	(btrace_block_s): Update comment.
	(btrace_format): New.
	(btrace_format_string): New.
	(btrace_data_bts): New.
	(btrace_data): New.
	(btrace_data_init, btrace_data_fini, btrace_data_empty): New.
	* remote.c (remote_read_btrace): Update parameters.
	* target.c (target_read_btrace): Update parameters.
	* target.h (target_read_btrace): Update parameters.
	(target_ops)<to_read_btrace>: Update parameters.
	* x86-linux-nat.c (x86_linux_read_btrace): Update parameters.
	* target-delegates.c: Regenerate.
	* target-debug (target_debug_print_struct_btrace_data_p): New.
	* nat/linux-btrace.c (linux_read_btrace): Split into this and...
	(linux_read_bts): ...this.
	* nat/linux-btrace.h (linux_read_btrace): Update parameters.

gdbserver/
	* Makefile.in (SFILES): Add common/btrace-common.c.
	(OBS): Add common/btrace-common.o.
	(btrace-common.o): Add build rules.
	* linux-low: Include btrace-common.h.
	(linux_low_read_btrace): Use struct btrace_data.  Call
	btrace_data_init and btrace_data_fini.
2015-02-09 09:21:44 +01:00
Doug Evans bd2e0e9e9a remote-m32r-sdi.c: Include symfile.h.
gdb/ChangeLog:

	* remote-m32r-sdi.c: Include symfile.h.
2015-02-06 12:17:21 -08:00
Doug Evans f176c4b57f Move clear_symtab_users, deduce_language_from_filename decls to better place.
gdb/ChangeLog:

	* symtab.h (clear_symtab_users, deduce_language_from_filename): Move
	* symfile.h (clear_symtab_users, deduce_language_from_filename): ...
	to here.
2015-02-06 11:32:01 -08:00
Pedro Alves d6c146e9ea libthread_db: attaching to terminated/joined threads, debug output
Add a bit of debug output that made things a bit easier for me before.

gdb/
2015-02-06  Pedro Alves  <palves@redhat.com>

	* linux-thread-db.c (find_new_threads_callback): Add debug output.

gdb/gdbserver/
2015-02-06  Pedro Alves  <palves@redhat.com>

	* thread-db.c (find_new_threads_callback): Add debug output.
2015-02-06 15:57:06 +00:00
Simon Marchi b9d6130764 "enable count" user input error handling (PR gdb/15678)
Typing "enable count" by itself crashes GDB. Also, if you omit the
breakpoint number/range, the error message is not very clear:

(gdb) enable count 2
warning: bad breakpoint number at or near ''
(gdb) enable count
Segmentation fault (core dumped)

With this patch, the error messages are slightly more helpful:

(gdb) enable count 2
Argument required (one or more breakpoint numbers).
(gdb) enable count
Argument required (hit count).

gdb/ChangeLog:

	PR gdb/15678
	* breakpoint.c (map_breakpoint_numbers): Check for empty args
	string.
	(enable_count_command): Check args for NULL value.

gdb/testsuite/ChangeLog:

	PR gdb/15678
	* gdb.base/ena-dis-br.exp: Test "enable count" for bad user input.
2015-02-06 10:27:01 -05:00
Pedro Alves e584fdbc6a Improve gdb.threads/attach-many-short-lived-threads.exp timeout handling
The buildbot shows that this test is still racy, and occasionally
fails with time outs on some machines.  I'd like to get major issues
with load out of the way.

The test currently exits after 180s, which is just a random number,
that has no relation to what the .exp file considers a time out.  This
commit makes the program wait a bit longer than what the .exp file
considers a time out, and, resets the timer for each iteration.

Tested on x86_64 Fedora 20, native and extended-remote gdbserver.

gdb/testsuite/
2015-02-06  Pedro Alves  <palves@redhat.com>

	* gdb.threads/attach-many-short-lived-threads.c (SECONDS): New
	macro.
	(seconds_left, again): New globals.
	(main): Wait seconds_left in a 1-second sleep loop instead of
	sleeping 180 seconds.  If 'again' is set, reset the seconds
	counter.
	* gdb.threads/attach-many-short-lived-threads.exp (test): Set
	'again' in the inferior before detaching.  Print the seconds left.
	(options): New global.
	(top level): Build program with	-DTIMEOUT=$timeout.
2015-02-06 13:24:32 +01:00
Pedro Alves 77f4176143 gdb.base/gdb-sigterm.exp: Fix spurious FAILs
The buildbot shows that some machines FAIL this test frequently.
E.g.: https://sourceware.org/ml/gdb-testers/2015-q1/msg00997.html

If I stress my machine, I can sometimes see it fail too.

Bumping the 200 limit and tweaking the test to show the step count, I
get:

     ...
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 12 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 8 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 13 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 7 times
-->  FAIL: gdb.base/gdb-sigterm.exp: SIGTERM stepped 228 times <--
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 11 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 13 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 12 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 8 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 9 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 7 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 11 times
     PASS: gdb.base/gdb-sigterm.exp: SIGTERM stepped 8 times
     ...

Thinking that this might be a problem of SIGTERM reaching GDB, but
then the event loop taking too long to handle it, I hacked GDB to
print a debug log whenever the SIGTERM handler was called, and,
whenever the event loop finally calls the async SIGTERM handler.
Here's what I see:

     infrun:   30011 [Thread 30011],
     infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
     infrun: TARGET_WAITKIND_STOPPED
     infrun: stop_pc = 0x4005de
-->  infrun: got SIGTERM                                       <--
     infrun: stepping inside range [0x4005de-0x4005e0]
     infrun: resume (step=1, signal=GDB_SIGNAL_0), ...
     infrun: prepare_to_wait
-->  infrun: handling async SIGTERM                            <--
     Cannot execute this command while the target is running.
     Use the "interrupt" command to stop the target
     and then try again.
     gdb.base/gdb-sigterm.exp: expect eof #27
     FAIL: gdb.base/gdb-sigterm.exp: SIGTERM stepped 228 times

So, no delay on the GDB side.  It just happens that occasionally it
takes more than 200 single-steps before SIGTERM even reaches GDB.
This just looks like a kernel/scheduling issue --- some extra usage
spike in the system (e.g., an I/O spike) might cause it for me.  For
the build slaves, I'm guessing they're frequently busy enough to trip
on this often.  Particularly more so now that we're having them run
tests in parallel mode.

The fix is to detect failure by timeout instead of counting single
steps.  This should be more reliable.  Indeed for me, after this
commit, I couldn't trigger a FAIL anymore, even after letting the test
run for an hour.

By timeout is also nicer in that a board file for a slow host/target
can increase it (like, e.g., an embedded GNU/Linux board).

Tested on x86_64 Fedora 20, native, gdbserver, and extended-remote
gdbserver.

gdb/testsuite/
2015-02-06  Pedro Alves  <palves@redhat.com>

	* gdb.base/gdb-sigterm.c (main): Use the TIMEOUT define to
	determine how many seconds to pass to 'alarm'.
	* gdb.base/gdb-sigterm.exp (top level): Build program with
	-DTIMEOUT=$timeout.
	(do_test): Return success/failure indication.  Add more verbose
	logging.  Don't fail if 200 single steps are seen.  Instead, fail
	when the test times out.
	(passes): New global.
	(top level): Break the testing loop if testing fails on any
	iteration.  Use gdb_assert.
2015-02-06 11:09:42 +01:00
Doug Evans e9fbd0432f guile/scm-frame.c: Fix spelling errors in a comment.
gdb/ChangeLog:

	* guile/scm-frame.c: Fix spelling errors in a comment.
2015-02-05 23:31:05 -08:00
Don Breazeal b9394193d0 Clean up System V IPC objects allocated by test.
This commit modifies the test program gdb.base/info-os.c so that
it cleans up all allocated System V IPC objects when a fatal
error occurs.  Without this, it was possible for the program
to leave IPC objects on the system, and such objects persist
until they are manually deleted or the system reboots.

I looked at changing the SysV IPC key for allocating the IPC objects to
IPC_PRIVATE.  That would prevent errors due to namespace conflicts with the
key.  However, the test needs to read the actual key number from the 'info
os' command output, and IPC_PRIVATE won't work for that.

gdb/testsuite/ChangeLog:
2015-02-04  Don Breazeal  <donb@codesourcery.com>

        * gdb.base/info-os.c (shmid, semid, msqid): Make variables static
        and initialize them.
        (ipc_cleanup): New function.
        (main): Don't declare shmid, semid, and msqid.  Add a call to
        atexit so that we call ipc_cleanup on exit.
2015-02-04 13:24:35 -08:00
Jan Kratochvil 881d5d5db0 Fix Python 3 build error on 32-bit hosts
on Fedora Rawhide (==22) i686 using --with-python=/usr/bin/python3 one gets:

./python/py-value.c:1696:3: error: initialization from incompatible pointer type [-Werror]
   valpy_hash,            /*tp_hash*/
   ^
./python/py-value.c:1696:3: error: (near initialization for ‘value_object_type.tp_hash’) [-Werror]
cc1: all warnings being treated as errors
Makefile:2628: recipe for target 'py-value.o' failed

This is because in Python 2 tp_hash was:
	typedef long (*hashfunc)(PyObject *);
while in Python 3 tp_hash is:
	typedef Py_hash_t (*hashfunc)(PyObject *);

Py_hash_t is int for 32-bit hosts and long for 64-bit hosts.  While on 32-bit
hosts sizeof(long)==sizeof(int) still the hashfunc type is formally
incompatible.  As this patch should have no compiled code change it is not
really necessary for gdb-7.9, it would fix there just this non-fatal
compilation warning:
	./python/py-value.c:1696:3: warning: initialization from incompatible pointer type
	   valpy_hash,            /*tp_hash*/
	   ^
	./python/py-value.c:1696:3: warning: (near initialization for ‘value_object_type.tp_hash’)

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

	* python/python-internal.h (Py_hash_t): Define it for Python <3.2.
	* python/py-value.c (valpy_fetch_lazy): Use it.  Remove cast to the
	return type.
2015-02-04 20:31:17 +01:00
Pedro Alves 20ba1ce66d Linux: don't resume new LWPs until we've pulled all events out of the kernel
Since the starvation avoidance series
(https://sourceware.org/ml/gdb-patches/2014-12/msg00631.html), both
GDB and GDBserver pull all events out of ptrace before deciding which
event to process.

There's one problem with that though.  Because we resume new threads
immediately when we see a PTRACE_EVENT_CLONE event, if the program
constantly spawns threads fast enough, new threads can spawn threads
faster we can pull events out of the kernel, and thus we'd get stuck
in an infinite loop, never returning any event to the core to process.
I occasionally see this happen with the
attach-many-short-lived-threads.exp test against gdbserver.

The fix is to delay resuming new threads until we've pulled out all
events out of the kernel.

On native, we already have the resume_stopped_resumed_lwps function
that knows to resume LWPs that are stopped with no event to report to
the core.  So the patch just adds another use.  GDBserver didn't have
the equivalent yet, so the patch adds one.

Tested on x86_64 Fedora 20, native and gdbserver (remote and
extended-remote).

gdb/gdbserver/ChangeLog:
2015-02-04  Pedro Alves  <palves@redhat.com>

	* linux-low.c (handle_extended_wait): Don't resume LWPs here.
	(resume_stopped_resumed_lwps): New function.
	(linux_wait_for_event_filtered): Use it.

gdb/ChangeLog:
2015-02-04  Pedro Alves  <palves@redhat.com>

	* linux-nat.c (handle_extended_wait): Don't resume LWPs here.
	(wait_lwp): Don't call wait_lwp if linux_handle_extended_wait
	returns true.
	(resume_stopped_resumed_lwps): Don't check whether the thread is
	marked as executing.
	(linux_nat_wait_1): Use resume_stopped_resumed_lwps.
2015-02-04 19:13:28 +01:00
Pedro Alves 42d9e5288b Fix '--target_board=native-extended-gdbserver/-m32'
Running the testsuite with the native-extended-gdbserver.exp board and
passing a variant spec, like

  make check RUNTESTFLAGS="--target_board=native-extended-gdbserver/-m32"

results in dejagnu trying to open a rsh connection to
"native-extended-gdbserver", which of course is wrong.  The point of
this board is running things locally.

The issue is that the native-extended-gdbserver board does not clear
the "isremote" flag properly.

Reported by Sergio at:
  https://sourceware.org/ml/gdb-patches/2015-02/msg00067.html

testsuite/
2015-02-04  Pedro Alves  <palves@redhat.com>

	* boards/native-extended-gdbserver.exp: Remove any target variant
	specifications from the board name before clearing the isremote
	flag from board_info.
2015-02-04 14:53:24 +01:00
Andreas Arnez f962539ad2 Warn if core file register section is larger than expected
When reading a core file register section which is larger than
expected, emit a warning.  Assume that a register section usually has
exactly the size specified by the regset section iterator.  In some
special cases this assumption is wrong, or at least does not match the
regset supply function's logic.  Thus also add a way to suppress the
warning in those cases, using a new flag REGSET_VARIABLE_SIZE.

gdb/ChangeLog:

	* regset.h (struct regset): Add flags field.
	(REGSET_VARIABLE_SIZE): New value for a regset's flags field.
	* corelow.c (get_core_register_section): Add warning if the size
	exceeds the requested size and the regset does not have the
	REGSET_VARIABLE_SIZE flag set.
	* alphanbsd-tdep.c (alphanbsd_gregset): Add REGSET_VARIABLE_SIZE
	flag.
	* armbsd-tdep.c (armbsd_gregset): Likewise.
	* hppa-hpux-tdep.c (hppa_hpux_regset): Likewise.
	* hppaobsd-tdep.c (hppaobsd_gregset): Likewise.
	* m68kbsd-tdep.c (m68kbsd_gregset): Likewise.
	* mipsnbsd-tdep.c (mipsnbsd_gregset): Likewise.
2015-02-04 14:14:32 +01:00
Andreas Arnez dde9acd693 x86: Use correct .reg-xstate section size
When reading the XSAVE extended state from an i386 or AMD64 core file,
the respective regset iterator requests a minimum section size of
zero.  Since the respective regset supply function does not check the
size either, this may lead to accessing data out of range if the
section is too short.

In write mode, the iterator always uses the maximum supported size for
the XSAVE extended state.

This is now changed such that the iterator always requests the
expected size of this section based on xcr0, both for reading and
writing.

gdb/ChangeLog:

	* amd64-linux-tdep.c (amd64_linux_iterate_over_regset_sections):
	For ".reg-xstate", explicitly specify the requested section size
	via X86_XSTATE_SIZE instead of just 0 on input and
	X86_XSTATE_MAX_SIZE on output.
	* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections):
	Likewise.
2015-02-04 14:14:31 +01:00