Commit Graph

37433 Commits

Author SHA1 Message Date
Jonas Hahnfeld dc36518224 GDB SIGSEGV opening a Fortran program compiled with ifort
This patch fixes a SIGSEGV when trying to open a Fortran program
compiled with ifort (reproduced using version using version 16.0.1.150).
The error can be reproduce with most, if not any program. For instance,
a single file only containing "end", compiled with no additional flag,
suffices.

gdb/ChangeLog:

       PR gdb/19208
       * dwarf2read.c (read_partial_die): Do not call set_objfile_main_name
       if the function has no name.
2016-01-17 10:11:02 +04:00
Sandra Loosemore f74f61cbf7 Fix phony_iconv wide character support.
2016-01-15  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/
	* charset.c [PHONY_ICONV] (GDB_DEFAULT_HOST_CHARSET):
	Conditionalize for Windows host.
	(GDB_DEFAULT_TARGET_CHARSET): Match GDB_DEFAULT_HOST_CHARSET.
	(GDB_DEFAULT_TARGET_WIDE_CHARSET): Use UTF-32.
	(phony_iconv_open): Handle both UTF-32 endiannesses.
	(phony_iconv): Likewise.  Check for output overflow and clean up
	out-of-input cases.  Correct adjustment to input buffer pointer.
	(set_be_le_names) [PHONY_ICONV]: Use hard-wired names to match
	phony_iconv_open.
2016-01-15 14:45:19 -08:00
Pedro Alves 71ef29a86b Star wildcard ranges (e.g., "info thread 2.*")
Add support for specifying "all threads of inferior N", by writing "*"
as thread number/range in thread ID lists.

E.g., "info threads 2.*" or "thread apply 2.* bt".

gdb/ChangeLog:
2016-01-15  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention star wildcard ranges.
	* cli/cli-utils.c (get_number_or_range): Check state->in_range first.
	(number_range_setup_range): New function.
	* cli/cli-utils.h (number_range_setup_range): New declaration.
	* thread.c (thread_apply_command): Support star TID ranges.
	* tid-parse.c (tid_range_parser_finished)
	(tid_range_parser_string, tid_range_parser_skip)
	(get_tid_or_range, get_tid_or_range): Handle
	TID_RANGE_STATE_STAR_RANGE.
	(tid_range_parser_star_range): New function.
	* tid-parse.h (enum tid_range_state) <TID_RANGE_STATE_STAR_RANGE>:
	New value.
	(tid_range_parser_star_range): New declaration.

gdb/doc/ChangeLog:
2016-01-15  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Threads) <thread ID lists>: Document star ranges.

gdb/testsuite/ChangeLog:
2016-01-15  Pedro Alves  <palves@redhat.com>

	* gdb.multi/tids.exp: Test star wildcard ranges.
2016-01-15 21:46:23 +00:00
Pedro Alves 3f5b759880 Fix "thread apply $conv_var" and misc other related problems
This fixes a few bugs in "thread apply".

While this works:

 (gdb) thread apply 1 p 1234

 Thread 1 (Thread 0x7ffff7fc1740 (LWP 14048)):
 $1 = 1234

This doesn't:

 (gdb) thread apply $thr p 1234

 Thread 1 (Thread 0x7ffff7fc1740 (LWP 12039)):
 Invalid thread ID: p 1234
 (gdb)

~~~~

Also, while this works:
 (gdb) thread apply 1
 Please specify a command following the thread ID list

This doesn't:
 (gdb) thread apply $thr
 Thread 1 (Thread 0x7ffff7fc1740 (LWP 12039)):
 [Current thread is 1 (Thread 0x7ffff7fc1740 (LWP 12039))]
 (gdb)

~~~~

And, while this works:
 (gdb) thread apply
 Please specify a thread ID list

This obviously bogus invocation is just silent:
 (gdb) thread apply bt
 (gdb)

gdb/ChangeLog:
2016-01-15  Pedro Alves  <palves@redhat.com>

	* thread.c (thread_apply_command): Use the tid range parser to
	advance past the thread ID list.
	* tid-parse.c (get_positive_number_trailer): New function.
	(parse_thread_id): Use it.
	(get_tid_or_range): Use it.  Return 0 instead of throwing invalid
	thread ID error.
	(get_tid_or_range): Detect negative values.  Return 0 instead of
	throwing invalid thread ID error.

gdb/testsuite/ChangeLog:
2016-01-15  Pedro Alves  <palves@redhat.com>

	* gdb.multi/tids.exp (thr_apply_info_thr_error): Remove "p 1234"
	command from "thread apply" invocation.
	(thr_apply_info_thr_invalid): Default the expected output to the
	input tid list.
	(top level): Add tests that use convenience variables.  Add tests
	for "thread apply" with a valid TID list, but missing the command.
2016-01-15 21:46:22 +00:00
Yao Qi e7cf25a8ab [ARM] Remove field syscall_next_pc in struct gdbarch_tdep
Field syscall_next_pc in struct gdbarch_tdep was to calculate the
next pc of syscall instruction.  On linux target, syscall_next_pc
is set to arm_linux_syscall_next_pc, to do linux specific things.
However, after we have struct arm_get_next_pcs_ops, we can do the
same thing in struct arm_get_next_pcs_ops field syscall_next_pc,
so syscall_next_pc in struct gdbarch_tdep is not needed any more.

gdb:

2016-01-14  Yao Qi  <yao.qi@linaro.org>

	* arm-linux-tdep.c (arm_linux_get_next_pcs_syscall_next_pc):
	Declare.
	(arm_linux_get_next_pcs_ops): Install
	arm_linux_get_next_pcs_syscall_next_pc.
	(arm_linux_syscall_next_pc): Change to ...
	(arm_linux_get_next_pcs_syscall_next_pc): ... it.
	(arm_linux_init_abi): Don't set tdep->syscall_next_pc.
	* arm-tdep.c (arm_get_next_pcs_syscall_next_pc): Declare.
	(arm_get_next_pcs_syscall_next_pc): Make it static.  Don't
	call tdep->syscall_next_pc.
	* arm-tdep.h (struct gdbarch_tdep) <syscall_next_pc>: Remove.
	(arm_get_next_pcs_syscall_next_pc): Remove.
2016-01-14 14:54:24 +00:00
Yao Qi c0518081f0 Fix C++ build error by casting void *
Two recent patches breaks GDB C++ mode build,

  https://sourceware.org/ml/gdb-patches/2016-01/msg00150.html
  https://sourceware.org/ml/gdb-patches/2016-01/msg00086.html

gdb/remote.c: In function 'int remote_set_syscall_catchpoint(target_ops*, int, int, int, int, int*)':
gdb/remote.c:2036:39: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
       catch_packet = xmalloc (maxpktsz);
                                       ^

gdb/thread.c: In function 'int do_captured_thread_select(ui_out*, void*)':
gdb/git/gdb/thread.c:1999:24: error: invalid conversion from 'void*' to 'const char*' [-fpermissive]
   const char *tidstr = tidstr_v;
                        ^

this patch fixes them by casting void * to the right type.

gdb:

2016-01-14  Yao Qi  <yao.qi@linaro.org>

	* remote.c (remote_set_syscall_catchpoint): Cast to char *.
	* thread.c (do_captured_thread_select): Cast to const char *.
2016-01-14 12:28:02 +00:00
Yao Qi 1b451dda5f [ARM] Make thumb2_breakpoint static again
This patch makes thumb2_breakpoint static.  When writing this patch,
I find the only reason we keep thumb2_breakpoint extern is that it
is used as an argument passed to arm_gdbserver_get_next_pcs.  However,
field arm_thumb2_breakpoint is only used in a null check in
thumb_get_next_pcs_raw, so I wonder why do need to pass thumb2_breakpoint
to arm_gdbserver_get_next_pcs.

thumb2_breakpoint was added by Daniel Jacobowitz in order to support
single-step IT block
https://sourceware.org/ml/gdb-patches/2010-01/msg00624.html  the logic
there was if we have 32-bit thumb-2 breakpoint defined, we can safely
single-step IT block, otherwise, we can't.  Daniel didn't want to use
16-bit thumb BKPT instruction, because it triggers even on instruction
which should be executed.  Secondly, using 16-bit thumb illegal
instruction on top of 32-bit thumb instruction may break the meaning of
original IT blocks, because the other 16-bit can be regarded as an
instruction.  See more explanations from Daniel's kernel patch
http://www.spinics.net/lists/arm-kernel/msg80476.html

Let us back to this patch, GDB/GDBserver can safely single step
IT block if thumb2_breakpoint is defined, but the single step logic
doesn't have to know the thumb-2 breakpoint instruction.  Only
breakpoint insertion mechanism decides to use which breakpoint
instruction.  In the software single step code, instead of pass
thumb2_breakpoint, we can pass a boolean variable
has_thumb2_breakpoint indicate whether the target has thumb-2
breakpoint defined, which is equivalent to the original code.

Regression tested on arm-linux.  No regression.

gdb:

2016-01-14  Yao Qi  <yao.qi@linaro.org>

	* arch/arm-get-next-pcs.c (arm_get_next_pcs_ctor): Change
	argument arm_thumb2_breakpoint to has_thumb2_breakpoint.
	(thumb_get_next_pcs_raw): Check has_thumb2_breakpoint
	instead.
	* arch/arm-get-next-pcs.h (struct arm_get_next_pcs)
	<arm_thumb2_breakpoint>: Remove.
	<has_thumb2_breakpoint>: New field.
	(arm_get_next_pcs_ctor): Update declaration.
	* arm-linux-tdep.c (arm_linux_software_single_step): Pass
	1 to arm_get_next_pcs_ctor.
	* arm-tdep.c (arm_software_single_step): Pass 0 to
	arm_get_next_pcs_ctor.

gdb/gdbserver:

2016-01-14  Yao Qi  <yao.qi@linaro.org>

	* linux-aarch32-low.c (thumb2_breakpoint): Make it static.
	* linux-aarch32-low.h (thumb2_breakpoint): Remove declaration.
	* linux-arm-low.c (arm_gdbserver_get_next_pcs): Pass 1 to
	arm_get_next_pcs_ctor.
2016-01-14 09:36:43 +00:00
Ulrich Weigand bc06e0b148 MAINTAINERS: Add Andreas Arnez as s390 target maintainer.
gdb/ChangeLog:

	* MAINTAINERS: Add Andreas Arnez as s390 target maintainer.
2016-01-13 18:57:59 +01:00
Yao Qi 4e7b8beaa3 Read instruction with byte_order_for_code
When reading instruction, we should use byte_order_for_code instead
of byte_order.

gdb:

2016-01-13  Yao Qi  <yao.qi@linaro.org>

	* arch/arm-get-next-pcs.c (arm_get_next_pcs_raw): Use
	byte_order_for_code to read instruction.
2016-01-13 16:15:31 +00:00
Pedro Alves 663f6d42f4 Add $_gthread convenience variable
This commit adds a new $_gthread convenience variable, that is like
$_thread, but holds the current thread's global thread id.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention $_gthread.
	* gdbthread.h (struct thread_info) <global_num>: Mention
	$_gthread.
	* thread.c (thread_num_make_value_helper): New function.
	(thread_id_make_value): Delete.
	(thread_id_per_inf_num_make_value, global_thread_id_make_value):
	New.
	(thread_funcs): Adjust.
	(gthread_funcs): New.
	(_initialize_thread): Register $_gthread variable.

gdb/testsuite/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/default.exp: Expect $_gthread as well.
	* gdb.multi/tids.exp: Test $_gthread.
	* gdb.threads/thread-specific.exp: Test $_gthread.

gdb/doc/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Threads): Document the $_gthread convenience
	variable.
	(Convenience Vars): Likewise.
2016-01-13 11:03:19 +00:00
Pedro Alves c84f6bbfe5 Implement "info threads -gid"
This commit makes global thread IDs optionaly visible in "info
threads", with the new "-gid" switch:

 (gdb) info threads -gid
   Id   GId  Target Id         Frame
   1.1  1    Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
   1.2  3    Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
   1.3  4    Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
   2.1  2    Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
   2.2  5    Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
 * 2.3  6    Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)

 (gdb) info threads
   Id   Target Id         Frame
   1.1  Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
   1.2  Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
   1.3  Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
   2.1  Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
   2.2  Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
 * 2.3  Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)

No regressions on x86_64 Fedora 20.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention "info threads -gid".
	* gdbthread.h (struct thread_info) <global_num>: Mention "info
	threads -gid".
	* thread.c (info_threads_command): Handle "-gid".
	(_initialize_thread): Adjust "info threads" help string to mention
	-gid.

gdb/testsuite/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.multi/tids.exp: Test "info threads -gid".

gdb/doc/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Threads): Document "info threads -gid".
2016-01-13 11:02:05 +00:00
Pedro Alves 22a0232400 Add Python InferiorThread.global_num attribute
This commit adds a new Python InferiorThread.global_num attribute.
This can be used to pass the correct thread ID to Breakpoint.thread,
which takes a global thread ID, not a per-inferior thread number.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention InferiorThread.global_num.
	* python/py-infthread.c (thpy_get_global_num): New function.
	(thread_object_getset): Register "global_num".

gdb/testsuite/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.multi/tids.exp: Test InferiorThread.global_num and
	Breakpoint.thread.
	* gdb.python/py-infthread.exp: Test InferiorThread.global_num.

gdb/doc/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* python.texi (Breakpoints In Python) <Breakpoint.thread>: Add
	anchor.
	(Threads In Python): Document new InferiorThread.global_num
	attribute.
2016-01-13 11:00:54 +00:00
Pedro Alves 5d5658a1d3 Per-inferior/Inferior-qualified thread IDs
This commit changes GDB to track thread numbers per-inferior.  Then,
if you're debugging multiple inferiors, GDB displays
"inferior-num.thread-num" instead of just "thread-num" whenever it
needs to display a thread:

 (gdb) info inferiors
   Num  Description       Executable
   1    process 6022     /home/pedro/gdb/tests/threads
 * 2    process 6037     /home/pedro/gdb/tests/threads
 (gdb) info threads
   Id   Target Id         Frame
   1.1  Thread 0x7ffff7fc2740 (LWP 6022) "threads" (running)
   1.2  Thread 0x7ffff77c0700 (LWP 6028) "threads" (running)
   1.3  Thread 0x7ffff7fc2740 (LWP 6032) "threads" (running)
   2.1  Thread 0x7ffff7fc1700 (LWP 6037) "threads" (running)
   2.2  Thread 0x7ffff77c0700 (LWP 6038) "threads" (running)
 * 2.3  Thread 0x7ffff7fc2740 (LWP 6039) "threads" (running)
 (gdb)
...
 (gdb) thread 1.1
 [Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]
 (gdb)
...

etc.

You can still use "thread NUM", in which case GDB infers you're
referring to thread NUM of the current inferior.

The $_thread convenience var and Python's InferiorThread.num attribute
are remapped to the new per-inferior thread number.  It's a backward
compatibility break, but since it only matters when debugging multiple
inferiors, I think it's worth doing.

Because MI thread IDs need to be a single integer, we keep giving
threads a global identifier, _in addition_ to the per-inferior number,
and make MI always refer to the global thread IDs.  IOW, nothing
changes from a MI frontend's perspective.

Similarly, since Python's Breakpoint.thread and Guile's
breakpoint-thread/set-breakpoint-thread breakpoint methods need to
work with integers, those are adjusted to work with global thread IDs
too.  Follow up patches will provide convenient means to access
threads' global IDs.

To avoid potencially confusing users (which also avoids updating much
of the testsuite), if there's only one inferior and its ID is "1",
IOW, the user hasn't done anything multi-process/inferior related,
then the "INF." part of thread IDs is not shown.  E.g,.:

 (gdb) info inferiors
   Num  Description       Executable
 * 1    process 15275     /home/pedro/gdb/tests/threads
 (gdb) info threads
   Id   Target Id         Frame
 * 1    Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
 (gdb) add-inferior
 Added inferior 2
 (gdb) info threads
   Id   Target Id         Frame
 * 1.1  Thread 0x7ffff7fc1740 (LWP 15275) "threads" main () at threads.c:40
 (gdb)

No regressions on x86_64 Fedora 20.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention that thread IDs are now per inferior and global
	thread IDs.
	* Makefile.in (SFILES): Add tid-parse.c.
	(COMMON_OBS): Add tid-parse.o.
	(HFILES_NO_SRCDIR): Add tid-parse.h.
	* ada-tasks.c: Adjust to use ptid_to_global_thread_id.
	* breakpoint.c (insert_breakpoint_locations)
	(remove_threaded_breakpoints, bpstat_check_breakpoint_conditions)
	(print_one_breakpoint_location, set_longjmp_breakpoint)
	(check_longjmp_breakpoint_for_call_dummy)
	(set_momentary_breakpoint): Adjust to use global IDs.
	(find_condition_and_thread, watch_command_1): Use parse_thread_id.
	(until_break_command, longjmp_bkpt_dtor)
	(breakpoint_re_set_thread, insert_single_step_breakpoint): Adjust
	to use global IDs.
	* dummy-frame.c (pop_dummy_frame_bpt): Adjust to use
	ptid_to_global_thread_id.
	* elfread.c (elf_gnu_ifunc_resolver_stop): Likewise.
	* gdbthread.h (struct thread_info): Rename field 'num' to
	'global_num.  Add new fields 'per_inf_num' and 'inf'.
	(thread_id_to_pid): Rename thread_id_to_pid to
	global_thread_id_to_ptid.
	(pid_to_thread_id): Rename to ...
	(ptid_to_global_thread_id): ... this.
	(valid_thread_id): Rename to ...
	(valid_global_thread_id): ... this.
	(find_thread_id): Rename to ...
	(find_thread_global_id): ... this.
	(ALL_THREADS, ALL_THREADS_BY_INFERIOR): Declare.
	(print_thread_info): Add comment.
	* tid-parse.h: New file.
	* tid-parse.c: New file.
	* infcmd.c (step_command_fsm_prepare)
	(step_command_fsm_should_stop): Adjust to use the global thread
	ID.
	(until_next_command, until_next_command)
	(finish_command_fsm_should_stop): Adjust to use the global thread
	ID.
	(attach_post_wait): Adjust to check the inferior number too.
	* inferior.h (struct inferior) <highest_thread_num>: New field.
	* infrun.c (handle_signal_stop)
	(insert_exception_resume_breakpoint)
	(insert_exception_resume_from_probe): Adjust to use the global
	thread ID.
	* record-btrace.c (record_btrace_open): Use global thread IDs.
	* remote.c (process_initial_stop_replies): Also consider the
	inferior number.
	* target.c (target_pre_inferior): Clear the inferior's highest
	thread num.
	* thread.c (clear_thread_inferior_resources): Adjust to use the
	global thread ID.
	(new_thread): New inferior parameter.  Adjust to use it.  Set both
	the thread's global ID and the thread's per-inferior ID.
	(add_thread_silent): Adjust.
	(find_thread_global_id): New.
	(find_thread_id): Make static.  Adjust to rename.
	(valid_thread_id): Rename to ...
	(valid_global_thread_id): ... this.
	(pid_to_thread_id): Rename to ...
	(ptid_to_global_thread_id): ... this.
	(thread_id_to_pid): Rename to ...
	(global_thread_id_to_ptid): ... this.  Adjust.
	(first_thread_of_process): Adjust.
	(do_captured_list_thread_ids): Adjust to use global thread IDs.
	(should_print_thread): New function.
	(print_thread_info): Rename to ...
	(print_thread_info_1): ... this, and add new show_global_ids
	parameter.  Handle it.  Iterate over inferiors.
	(print_thread_info): Reimplement as wrapper around
	print_thread_info_1.
	(show_inferior_qualified_tids): New function.
	(print_thread_id): Use it.
	(tp_array_compar): Compare inferior numbers too.
	(thread_apply_command): Use tid_range_parser.
	(do_captured_thread_select): Use parse_thread_id.
	(thread_id_make_value): Adjust.
	(_initialize_thread): Adjust "info threads" help string.
	* varobj.c (struct varobj_root): Update comment.
	(varobj_create): Adjust to use global thread IDs.
	(value_of_root_1): Adjust to use global_thread_id_to_ptid.
	* windows-tdep.c (display_tib): No longer accept an argument.
	* cli/cli-utils.c (get_number_trailer): Make extern.
	* cli/cli-utils.h (get_number_trailer): Declare.
	(get_number_const): Adjust documentation.
	* mi/mi-cmd-var.c (mi_cmd_var_update_iter): Adjust to use global
	thread IDs.
	* mi/mi-interp.c (mi_new_thread, mi_thread_exit)
	(mi_on_normal_stop, mi_output_running_pid, mi_on_resume):
	* mi/mi-main.c (mi_execute_command, mi_cmd_execute): Likewise.
	* guile/scm-breakpoint.c (gdbscm_set_breakpoint_thread_x):
	Likewise.
	* python/py-breakpoint.c (bppy_set_thread): Likewise.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Likewise.
	* python/py-infthread.c (thpy_get_num): Add comment and return the
	per-inferior thread ID.
	(thread_object_getset): Update comment of "num".

gdb/testsuite/ChangeLog:
2016-01-07  Pedro Alves  <palves@redhat.com>

	* gdb.base/break.exp: Adjust to output changes.
	* gdb.base/hbreak2.exp: Likewise.
	* gdb.base/sepdebug.exp: Likewise.
	* gdb.base/watch_thread_num.exp: Likewise.
	* gdb.linespec/keywords.exp: Likewise.
	* gdb.multi/info-threads.exp: Likewise.
	* gdb.threads/thread-find.exp: Likewise.
	* gdb.multi/tids.c: New file.
	* gdb.multi/tids.exp: New file.

gdb/doc/ChangeLog:
2016-01-07  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Threads): Document per-inferior thread IDs,
	qualified thread IDs, global thread IDs and thread ID lists.
	(Set Watchpoints, Thread-Specific Breakpoints): Adjust to refer to
	thread IDs.
	(Convenience Vars): Document the $_thread convenience variable.
	(Ada Tasks): Adjust to refer to thread IDs.
	(GDB/MI Async Records, GDB/MI Thread Commands, GDB/MI Ada Tasking
	Commands, GDB/MI Variable Objects): Update to mention global
	thread IDs.
	* guile.texi (Breakpoints In Guile)
	<breakpoint-thread/set-breakpoint-thread breakpoint>: Mention
	global thread IDs instead of thread IDs.
	* python.texi (Threads In Python): Adjust documentation of
	InferiorThread.num.
	(Breakpoint.thread): Mention global thread IDs instead of thread
	IDs.
2016-01-13 10:59:43 +00:00
Pedro Alves 43792cf0de Centralize thread ID printing
Add a new function to print a thread ID, in the style of paddress,
plongest, etc. and adjust all CLI-reachable paths to use it.

This gives us a single place to tweak to print inferior-qualified
thread IDs later:

 - [Switching to thread 1 (Thread 0x7ffff7fc2740 (LWP 8155))]
 + [Switching to thread 1.1 (Thread 0x7ffff7fc2740 (LWP 8155))]

etc., though for now, this has no user-visible change.

No regressions on x86_64 Fedora 20.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (remove_threaded_breakpoints)
	(print_one_breakpoint_location): Use print_thread_id.
	* btrace.c (btrace_enable, btrace_disable, btrace_teardown)
	(btrace_fetch, btrace_clear): Use print_thread_id.
	* common/print-utils.c (CELLSIZE): Delete.
	(get_cell): Rename to ...
	(get_print_cell): ... this and made extern.  Adjust call callers.
	Adjust to use PRINT_CELL_SIZE.
	* common/print-utils.h (get_print_cell): Declare.
	(PRINT_CELL_SIZE): New.
	* gdbthread.h (print_thread_id): Declare.
	* infcmd.c (signal_command): Use print_thread_id.
	* inferior.c (print_inferior): Use print_thread_id.
	* infrun.c (handle_signal_stop)
	(insert_exception_resume_breakpoint)
	(insert_exception_resume_from_probe)
	(print_signal_received_reason): Use print_thread_id.
	* record-btrace.c (record_btrace_info)
	(record_btrace_resume_thread, record_btrace_cancel_resume)
	(record_btrace_step_thread, record_btrace_wait): Use
	print_thread_id.
	* thread.c (thread_apply_all_command): Use print_thread_id.
	(print_thread_id): New function.
	(thread_apply_command): Use print_thread_id.
	(thread_command, thread_find_command, do_captured_thread_select):
	Use print_thread_id.
2016-01-13 10:59:14 +00:00
Pedro Alves 8465445732 Add Python InferiorThread.inferior attribute
So a script can easily get at a thread's inferior and its number.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention InferiorThread.inferior.
	* python/py-infthread.c (thpy_get_inferior): New.
	(thread_object_getset): Register "inferior".

gdb/testsuite/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.python/py-infthread.exp: Test InferiorThread.inferior.

gdb/doc/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* python.texi (Threads In Python): Document
	InferiorThread.inferior.
2016-01-13 10:58:03 +00:00
Pedro Alves e3940304fe Add a new $_inferior convenience variable
Like $_thread, but holds the current inferior number.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention $_inferior.
	* inferior.c (inferior_id_make_value): New.
	(inferior_funcs): New.
	(_initialize_inferior): Create $_inferior variable.

gdb/testsuite/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/default.exp: Expect $_inferior as well.
	* gdb.multi/base.exp: Test $_inferior.

gdb/doc/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Inferiors and Programs): Document the $_inferior
	convenience variable.
	(Convenience Vars): Likewise.
2016-01-13 10:56:05 +00:00
Pedro Alves a911d87ad7 Fix PR19388: Can't access $_siginfo in breakpoint (catch signal) condition
This commit merges both the registers and $_siginfo "thread
running/executing" checks into a single function.

Accessing $_siginfo from a "catch signal" breakpoint condition doesn't
work.  The condition always fails with "Selected thread is running":

 (gdb) catch signal
 Catchpoint 3 (standard signals)
 (gdb)
 condition $bpnum $_siginfo.si_signo == 5
 (gdb) continue
 Continuing.
 Error in testing breakpoint condition:
 Selected thread is running.

 Catchpoint 3 (signal SIGUSR1), 0x0000003615e35877 in __GI_raise (sig=10) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
 (gdb)

When accessing the $_siginfo object, we check whether the thread is
marked running (external/public) state and refuse the access if so.
This is so "print $_siginfo" at the prompt fails nicelly when the
current thread is running.  While evaluating breakpoint conditionals,
we haven't decided yet whether the thread is going to stop, so
is_running still returns true, and we thus always error out.

Evaluating an expression that requires registers access is really
conceptually the same -- we could think of $_siginfo as a pseudo
register.  However, in that case we check whether the thread is marked
executing (internal/private state), not running (external/public
state).  Changing the $_siginfo validation to check is_executing as
well fixes the bug in question.

Note that checking is_executing is not fully correct, not even for
registers.  See PR 19389.  However, I think this is the lesser of two
evils and ends up as an improvement.  We at least now have a single
place to fix.

Tested on x86_64 GNU/Linux.

gdb/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	PR breakpoints/19388
	* frame.c (get_current_frame): Use validate_registers_access.
	* gdbthread.h (validate_registers_access): Declare.
	* infrun.c (validate_siginfo_access): Delete.
	(siginfo_value_read, siginfo_value_write): Use
	validate_registers_access.
	* thread.c (validate_registers_access): New function.

gdb/testsuite/ChangeLog:
2016-01-13  Pedro Alves  <palves@redhat.com>

	PR breakpoints/19388
	* gdb.base/catch-signal-siginfo-cond.c: New file.
	* gdb.base/catch-signal-siginfo-cond.exp: New file.
2016-01-13 10:40:33 +00:00
Josh Stone 82075af2c1 Implement 'catch syscall' for gdbserver
This adds a new QCatchSyscalls packet to enable 'catch syscall', and new
stop reasons "syscall_entry" and "syscall_return" for those events.  It
is currently only supported on Linux x86 and x86_64.

gdb/ChangeLog:

2016-01-12  Josh Stone  <jistone@redhat.com>
	    Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the
	syscall_entry and syscall_return stop reasons.  Mention GDB
	support for remote catch syscall.
	* remote.c (PACKET_QCatchSyscalls): New enum.
	(remote_set_syscall_catchpoint): New function.
	(remote_protocol_features): New element for QCatchSyscalls.
	(remote_parse_stop_reply): Parse syscall_entry/return stops.
	(init_remote_ops): Install remote_set_syscall_catchpoint.
	(_initialize_remote): Config QCatchSyscalls.
	* linux-nat.h (struct lwp_info) <syscall_state>: Comment typo.

gdb/doc/ChangeLog:

2016-01-12  Josh Stone  <jistone@redhat.com>
	    Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet.
	(Stop Reply Packets): List the syscall entry and return stop reasons.
	(General Query Packets): Describe QCatchSyscalls, and add it to the
	table and the detailed list of stub features.

gdb/gdbserver/ChangeLog:

2016-01-12  Josh Stone  <jistone@redhat.com>
	    Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* inferiors.h: Include "gdb_vecs.h".
	(struct process_info): Add syscalls_to_catch.
	* inferiors.c (remove_process): Free syscalls_to_catch.
	* remote-utils.c (prepare_resume_reply): Report syscall_entry and
	syscall_return stops.
	* server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define.
	* server.c (handle_general_set): Handle QCatchSyscalls.
	(handle_query): Report support for QCatchSyscalls.
	* target.h (struct target_ops): Add supports_catch_syscall.
	(target_supports_catch_syscall): New macro.
	* linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo.
	(struct lwp_info): Add syscall_state.
	* linux-low.c (handle_extended_wait): Mark syscall_state as an entry.
	Maintain syscall_state and syscalls_to_catch across exec.
	(get_syscall_trapinfo): New function, proxy to the_low_target.
	(linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD.
	(linux_low_filter_event): Toggle syscall_state entry/return for
	syscall traps, and set it ignored for all others.
	(gdb_catching_syscalls_p): New function.
	(gdb_catch_this_syscall_p): New function.
	(linux_wait_1): Handle SYSCALL_SIGTRAP.
	(linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility.
	(linux_supports_catch_syscall): New function.
	(linux_target_ops): Install it.
	* linux-x86-low.c (x86_get_syscall_trapinfo): New function.
	(the_low_target): Install it.

gdb/testsuite/ChangeLog:

2016-01-12  Josh Stone  <jistone@redhat.com>
	    Philippe Waroquiers  <philippe.waroquiers@skynet.be>

	* gdb.base/catch-syscall.c (do_execve): New variable.
	(main): Conditionally trigger an execve.
	* gdb.base/catch-syscall.exp: Enable testing for remote targets.
	(test_catch_syscall_execve): New, check entry/return across execve.
	(do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 12:27:27 -08:00
Yao Qi d18547d8b0 Fix invalid conversion from void * to gdb_byte *
This patch fixes the following GDB build error in C++ mode.

gdb/nat/linux-ptrace.c: In function 'int linux_child_function(void*)':
gdb/nat/linux-ptrace.c:323:65: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
   linux_fork_to_function (child_stack, linux_grandchild_function);
                                                                 ^

gdb:

2016-01-12  Yao Qi  <yao.qi@linaro.org>

	* nat/linux-ptrace.c (linux_child_function): Cast child_stack
	to gdb_byte * and pass to linux_fork_to_function.
2016-01-12 16:29:30 +00:00
Mike Frysinger 8f13a3ce8a gdbserver: use the new gdb warning helpers
We need to use -Wno-missing-prototypes for now as much of the code
sticks externs in local files and not in common headers.

2016-01-11  Mike Frysinger  <vapier@gentoo.org>

	* acinclude.m4: Include new ../warning.m4 file.
	* configure: Regenerated.
	* configure.ac: Replace all warning logic with AM_GDB_WARNINGS.
2016-01-12 10:34:57 -05:00
Mike Frysinger 5b3da067f0 gdbserver: fix various warnings
Delete unused funcs, update old prototypes, and mark local funcs
as static.  This doesn't cover all missing prototype warnings.
2016-01-12 10:34:17 -05:00
Yao Qi ba4dd7c4a1 Change function signature passed to clone
I see the following compile error with an old bfin-uclinux gcc to
build GDBserver,

 cc1: warnings being treated as errors
 gdb/gdbserver/../nat/linux-ptrace.c: In function 'linux_fork_to_function':
 gdb/gdbserver/../nat/linux-ptrace.c:283: error: passing argument 1 of 'clone' from incompatible pointer type

in glibc, clone's prototype is like this, and in uClibc, it is the same,

       int clone(int (*fn)(void *), void *child_stack,
                 int flags, void *arg, ...
                 /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ );

so this patch changes function signature from 'void (*function) (gdb_byte *)'
to 'int (*function) (void *)'.

Note that I find Pedro advised to change argument type from 'void *'
to 'gdb_byte *' during the patch review
https://sourceware.org/ml/gdb-patches/2013-08/msg00611.html  however,
I think fix compile error can justify the change back to 'void *'.

gdb:

2016-01-12  Yao Qi  <yao.qi@linaro.org>

	* nat/linux-ptrace.c (linux_fork_to_function): Change type
	of argument 'function'.
	(linux_grandchild_function): Change return type to 'int'.
	Change child_stack's type to 'void *'.
	(linux_child_function): Likewise.
2016-01-12 15:18:09 +00:00
Pedro Alves bc504a3117 Remove trademark acknowledgements throughout
The GNU Coding Standards say:

  "Please do not include any trademark acknowledgements in GNU
  software packages or documentation."

gdb/ChangeLog:
2016-01-12  Pedro Alves  <palves@redhat.com>

	Remove use of the registered trademark symbol throughout.

gdb/gdbserver/ChangeLog:
2016-01-12  Pedro Alves  <palves@redhat.com>

	Remove use of the registered trademark symbol throughout.

gdb/doc/ChangeLog:
2016-01-12  Pedro Alves  <palves@redhat.com>

	Remove use of the registered trademark symbol throughout.
2016-01-12 15:03:11 +00:00
Yao Qi cde67b27d6 [DOC] Interrupt when program is stopped
This patch changes the document that interrupt (ctrl-c) is not ignored
when the program is stopped.

When the interrupt was supported in remote target, people thought interrupt
is meaningless when the program is stopped.  See

  https://www.sourceware.org/ml/gdb/2005-11/msg00349.html
  https://www.sourceware.org/ml/gdb-patches/2005-11/msg00307.html

recently we find it is hard to preserve this feature "ignore interrupt
while program is stopped" when we fix some other bugs.  See
https://sourceware.org/ml/gdb-patches/2016-01/msg00039.html

so we think we can go to the simpler approach "not ignoring ctrl-c when
program is stopped".  As a result, we tweak the documentation here.

gdb/doc:

2016-01-12  Yao Qi  <yao.qi@linaro.org>

	* gdb.texinfo (Interrupts): Update the document on handling
	interrupt when program is stopped.
2016-01-12 14:59:45 +00:00
Pedro Alves e46eeeddfb Test gdb.base/random-signal.exp with "attach"
This exposes the issued fixed by 2f99e8fc9cb8:

  https://sourceware.org/ml/gdb-patches/2015-12/msg00423.html

to native debugging as well.

gdb/testsuite/ChangeLog:
2016-01-12  Pedro Alves  <palves@redhat.com>

	* gdb.base/random-signal.exp (do_test): New procedure, with body
	of testcase moved in.
	(top level) Call it twice, once with "run" and once with "attach".
2016-01-12 12:30:33 +00:00
Thomas Schwinge 5eddd57823 Hurd: Make gdb/reply_mig_hack.awk script compatible to "mawk"
The "mawk" AWK implementation did't like that regular expression:

    mawk: [...]/gdb/reply_mig_hack.awk: line 98: regular expression compile failed (missing operand)

	gdb/
	* reply_mig_hack.awk: Rewrite one regular expression.
2016-01-12 12:53:09 +01:00
Pedro Alves b05b120205 Reapply: List inferiors/threads/pspaces in ascending order
[This reapplies a change that was accidentally reverted with c0ecb95f3d.]

Before:
  (gdb) info threads
    Id   Target Id         Frame
    3    Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30
    2    Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60
  * 1    Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92

After:
  (gdb) info threads
    Id   Target Id         Frame
  * 1    Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92
    2    Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60
    3    Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30

gdb/doc/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

	PR 17539
	* gdb.texinfo (Inferiors and Programs): Adjust "maint info
	program-spaces" example to ascending order listing.
	(Threads): Adjust "info threads" example to ascending order
	listing.
	(Forks): Adjust "info inferiors" example to ascending order
	listing.

gdb/ChangeLog:
2015-11-24  Pedro Alves  <palves@redhat.com>

	PR 17539
	* inferior.c (add_inferior_silent): Append the new inferior to the
	end of the list.
	* progspace.c (add_program_space): Append the new pspace to the
	end of the list.
	* thread.c (new_thread): Append the new thread to the end of the
	list.

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

	PR 17539
	* gdb.base/foll-exec-mode.exp: Adjust to GDB listing inferiors and
	threads in ascending order.
	* gdb.base/foll-fork.exp: Likewise.
	* gdb.base/foll-vfork.exp: Likewise.
	* gdb.base/multi-forks.exp: Likewise.
	* gdb.mi/mi-nonstop.exp: Likewise.
	* gdb.mi/mi-nsintrall.exp: Likewise.
	* gdb.multi/base.exp: Likewise.
	* gdb.multi/multi-arch.exp: Likewise.
	* gdb.python/py-inferior.exp: Likewise.
	* gdb.threads/break-while-running.exp: Likewise.
	* gdb.threads/execl.exp: Likewise.
	* gdb.threads/gcore-thread.exp: Likewise.
	* gdb.threads/info-threads-cur-sal.exp: Likewise.
	* gdb.threads/kill.exp: Likewise.
	* gdb.threads/linux-dp.exp: Likewise.
	* gdb.threads/multiple-step-overs.exp: Likewise.
	* gdb.threads/next-bp-other-thread.exp: Likewise.
	* gdb.threads/step-bg-decr-pc-switch-thread.exp: Likewise.
	* gdb.threads/step-over-lands-on-breakpoint.exp: Likewise.
	* gdb.threads/step-over-trips-on-watchpoint.exp: Likewise.
	* gdb.threads/thread-find.exp: Likewise.
	* gdb.threads/tls.exp: Likewise.
	* lib/mi-support.exp (mi_reverse_list): Delete.
	(mi_check_thread_states): No longer reverse list.
2016-01-12 01:12:38 +00:00
Jan Kratochvil 01d8c27e4f testsuite: i386 regression for funcargs.exp
3ca22649a6 is the first bad commit
commit 3ca22649a6
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Mon Dec 21 12:51:54 2015 -0500
    Remove HP-UX references fom testsuite
@@ -1013,13 +1013,6 @@ proc localvars_in_indirect_call { } {
     #

     gdb_test_multiple "finish" "finish from indirectly called function" {
-       -re "\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*First.*$gdb_prompt $" {
-           #On hppa2.0w-hp-hpux11.00, gdb finishes at one line earlier than
-           #hppa1.1-hp-hpux11.00. Therefore, an extra "step" is necessary
-           #to continue the test.
-           send_gdb "step\n"
-           exp_continue
-	}
        -re ".*\\(\\*pointer_to_call0a\\) \\(c, s, i, l\\);.*Second.*$gdb_prompt $" {
            pass "finish from indirectly called function"
       	}

->

 finish^M
 Run till exit from #0  call0a (c=97 'a', s=1, i=2, l=3) at ./gdb.base/funcargs.c:82^M
 0x0804a189 in main () at ./gdb.base/funcargs.c:583^M
 583	  (*pointer_to_call0a) (c, s, i, l);    /* First step into call0a.  */^M
-(gdb) step^M
-584	  (*pointer_to_call0a) (c, s, i, l);    /* Second step into call0a.  */^M
-(gdb) PASS: gdb.base/funcargs.exp: finish from indirectly called function
+(gdb) FAIL: gdb.base/funcargs.exp: finish from indirectly called function
 step^M
-call0a (c=97 'a', s=1, i=2, l=3) at ./gdb.base/funcargs.c:82^M
-82	  c = 'a';^M
-(gdb) PASS: gdb.base/funcargs.exp: stepping into indirectly called function
+584	  (*pointer_to_call0a) (c, s, i, l);    /* Second step into call0a.  */^M
+(gdb) FAIL: gdb.base/funcargs.exp: stepping into indirectly called function

At least on x86_64 with testsuite in -m32 (expecting native i386 would be the
same).

Pedro Alves:

The difference is that with newer GCC there's an extra instruction
after the call which is still assigned to line 583:

$ diff -up /tmp/4.8.3 /tmp/6.0.0 -U 1000
--- /tmp/4.8.3  2016-01-11 12:37:39.611089156 +0000
+++ /tmp/6.0.0  2016-01-11 13:21:00.021127976 +0000
@@ -1,27 +1,30 @@
 583       (*pointer_to_call0a) (c, s, i, l);    /* First step into call0a.  */
    mov    0x804d060,%ebx
    mov    0x804d050,%ecx
    movzwl 0x804d040,%eax
    movswl %ax,%edx
    movzbl 0x804d030,%eax
    movsbl %al,%eax
-   mov    %ebx,0xc(%esp)
-   mov    %ecx,0x8(%esp)
-   mov    %edx,0x4(%esp)
-   mov    %eax,(%esp)
-   mov    0x7c(%esp),%eax
+   push   %ebx
+   push   %ecx
+   push   %edx
+   push   %eax
+   mov    -0x1c(%ebp),%eax
    call   *%eax
+   add    $0x10,%esp

 584	   (*pointer_to_call0a) (c, s, i, l);    /* Second step into call0a.  */
    mov    0x804d060,%ebx
    mov    0x804d050,%ecx
    movzwl 0x804d040,%eax
    movswl %ax,%edx
    movzbl 0x804d030,%eax
    movsbl %al,%eax
-   mov    %ebx,0xc(%esp)
-   mov    %ecx,0x8(%esp)
-   mov    %edx,0x4(%esp)
-   mov    %eax,(%esp)
-   mov    0x7c(%esp),%eax
+   push   %ebx
+   push   %ecx
+   push   %edx
+   push   %eax
+   mov    -0x1c(%ebp),%eax
    call   *%eax
+   add    $0x10,%esp
+

I don't know why -m32 changed to push/add instead of mov while 64-bit hasn't.

This is most likely needed on non-x86 ports as well.

gdb/testsuite/ChangeLog
2016-01-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.base/funcargs.exp (finish from indirectly called function):
	Reintroduce the case for 'First'.
2016-01-11 22:27:15 +01:00
Jan Kratochvil 9a70630256 testsuite: Regression for foll-vfork.exp
fe33faff35 is the first bad commit
commit fe33faff35
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Tue Dec 22 10:52:31 2015 -0500
    Remove HP-UX reference in foll-vfork.exp

FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork
FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork
FAIL: gdb.base/foll-vfork.exp: exit: vfork parent follow, finish after tcatch vfork: continue to vfork
FAIL: gdb.base/foll-vfork.exp: exit: vfork child follow, finish after tcatch vfork: continue to vfork

It happens for plain gdb.base/foll-vfork.exp runtest on Fedora 23 x86_64.

-Temporary catchpoint 2 (vforked process 24562), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M
+Temporary catchpoint 2 (vforked process 25345), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M
 52             pushq   %rdi^M
 Current language:  auto^M
 The current source language is "auto; currently asm".^M
-(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork
+(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork parent follow, finish after tcatch vfork: continue to vfork

-Temporary catchpoint 2 (vforked process 24629), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M
+Temporary catchpoint 2 (vforked process 25411), vfork () at ../sysdeps/unix/sysv/linux/x86_64/vfork.S:52^M
 52             pushq   %rdi^M
 Current language:  auto^M
 The current source language is "auto; currently asm".^M
-(gdb) PASS: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork
+(gdb) FAIL: gdb.base/foll-vfork.exp: exec: vfork child follow, finish after tcatch vfork: continue to vfork

So I have reverted it and just simplified the comment.

The third case is not necessary during testing but I have changed back all the
3 cases.

Pedro Alves:
I know it was that way before, but would you mind moving this to a helper
proc.

gdb/testsuite/ChangeLog
2016-01-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* gdb.base/foll-vfork.exp (tcatch_vfork_then_parent_follow)
	(tcatch_vfork_then_child_follow_exec)
	(tcatch_vfork_then_child_follow_exit): Revert back DWARF vfork
	identification.
2016-01-11 22:20:16 +01:00
Jan Kratochvil c0ecb95f3d testsuite: Fix false FAILs on too long base directory
I was getting

gu (print arg0)^M
= 0x7fffffffdafb
"/unsafebuild-x86_64-redhat-linux-gnu/gdb/testsuite.unix.-m64/outputs/gdb.guile/scm-value/scm-"...^M
(gdb) FAIL: gdb.guile/scm-value.exp: verify dereferenced value
python print (arg0)^M
0x7fffffffdafd
"/unsafebuild-x86_64-redhat-linux-gnu/gdb/testsuite.unix.-m64/outputs/gdb.python/py-value/py-v"...^M
(gdb) FAIL: gdb.python/py-value.exp: verify dereferenced value

and also:

(gdb) p argv[0]^M
$2 = 0x7fffffffd832 "/home/jkratoch/redhat/gdb-test-", 'x' <repeats 169
times>...^M
(gdb) FAIL: gdb.guile/scm-value.exp: argv[0] should be available on this
target

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

	* gdb.guile/scm-value.exp (test_value_in_inferior): Set print elements
	and repeats to unlimited.
	* gdb.python/py-value.exp: Likewise.
	* lib/gdb.exp (gdb_has_argv0): Save and temporarily set print elements
	and repeats to unlimited.
2016-01-11 22:12:16 +01:00
Mike Frysinger b835bb5265 gdb: split out warnings helpers
This will allow the sim tree to use the same set of warnings.
The new code in warning.m4 is exactly the same (other than the
AC_DEFUN wrapping).
2016-01-11 14:09:46 -05:00
Jan Kratochvil 6cfc1fcb51 Fix gdb.multi/base.exp testsuite regression
Regressed by:

commit 762f774785
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Dec 10 16:21:06 2015 +0000
    Stop using nowarnings in gdb/testsuite/gdb.multi/

+gdb compile failed, gdb/testsuite/gdb.multi/hello.c: In function 'commonfun':
+gdb/testsuite/gdb.multi/hello.c:24:19: warning: implicit declaration of function 'bar' [-Wimplicit-function-declaration]
+ int commonfun() { bar(); } /* from hello */
+                   ^
+gdb/testsuite/gdb.multi/hello.c: At top level:
+gdb/testsuite/gdb.multi/hello.c:26:1: warning: return type defaults to 'int' [-Wimplicit-int]
+ bar()
+ ^
+gdb/testsuite/gdb.multi/hello.c:32:1: warning: return type defaults to 'int' [-Wimplicit-int]
+ hello(int x)
+ ^
+gdb/testsuite/gdb.multi/hello.c:38:1: warning: return type defaults to 'int' [-Wimplicit-int]
+ main()
+ ^
+UNTESTED: gdb.multi/base.exp: base.exp

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

	* gdb.multi/goodbye.c: Fix compilation warnings by adding return types
	and reordering the functions.
	* gdb.multi/hangout.c: Likewise.
	* gdb.multi/hello.c: Likewise.
2016-01-08 20:07:02 +01:00
Simon Marchi 582a1b0064 perf testsuite: python 3 fixes
There are a few errors when trying to run the performance testsuite with
Python 3.  This commit fixes them.

In Python 2, it was possible to use relative imports (importing a module
relative to the current one).  In Python 3 it isn't.  So I use
absolute_import from the __future__ module, which allows Python 2 to
behave like Python 3, and use the Python 3 syntax.

In Python 3, dict.iterkeys doesn't exist anymore.  Using dict.keys is a
good compromise in this case.

gdb/testsuite/ChangeLog:

	* gdb.perf/lib/perftest/perftest.py: Change relative imports to
	absolute.
	(SingleStatisticTestResult.report): Use dict.keys instead of
	dict.iterkeys.
2016-01-08 10:22:17 -05:00
Yao Qi 2f99e8fc9c Change SIGINT handler for extension languages only when target terminal is ours
I see a timeout in gdb.base/random-signal.exp,

 Continuing.^M
 PASS: gdb.base/random-signal.exp: continue
 ^CPython Exception <type 'exceptions.KeyboardInterrupt'> <type
 exceptions.KeyboardInterrupt'>: ^M
 FAIL: gdb.base/random-signal.exp: stop with control-c (timeout)

it can be reproduced by running random-signal.exp with native-gdbserver
in a loop, like this, and the fail will be shown in about 20 runs,

$ (set -e; while true; do make check RUNTESTFLAGS="--target_board=native-gdbserver random-signal.exp"; done)

In the test, the program is being single-stepped for software watchpoint,
and in each internal stop, python unwinder sniffer is used,

 #0  pyuw_sniffer (self=<optimised out>, this_frame=<optimised out>, cache_ptr=0xd554f8) at /home/yao/SourceCode/gnu/gdb/git/gdb/python/py-unwind.c:608
 #1  0x00000000006a10ae in frame_unwind_try_unwinder (this_frame=this_frame@entry=0xd554e0, this_cache=this_cache@entry=0xd554f8, unwinder=0xecd540)
     at /home/yao/SourceCode/gnu/gdb/git/gdb/frame-unwind.c:107
 #2  0x00000000006a143f in frame_unwind_find_by_frame (this_frame=this_frame@entry=0xd554e0, this_cache=this_cache@entry=0xd554f8)
     at /home/yao/SourceCode/gnu/gdb/git/gdb/frame-unwind.c:163
 #3  0x000000000069dc6b in compute_frame_id (fi=0xd554e0) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:454
 #4  get_prev_frame_if_no_cycle (this_frame=this_frame@entry=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1781
 #5  0x000000000069fdb9 in get_prev_frame_always_1 (this_frame=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1955
 #6  get_prev_frame_always (this_frame=this_frame@entry=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1971
 #7  0x00000000006a04b1 in get_prev_frame (this_frame=this_frame@entry=0xd55410) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:2213

when GDB goes to python extension, or other language extension, the
SIGINT handler is changed, and is restored when GDB leaves extension
language.  GDB only stays in extension language for a very short period
in this case, but if ctrl-c is pressed at that moment, python extension
will handle the SIGINT, and exceptions.KeyboardInterrupt is shown.

Language extension is used in GDB side rather than inferior side,
so GDB should only change SIGINT handler for extension language when
the terminal is ours (not inferior's).  This is what this patch does.
With this patch applied, I run random-signal.exp in a loop for 18
hours, and no fail is shown.

gdb:

2016-01-08  Yao Qi  <yao.qi@linaro.org>

	* extension.c: Include target.h.
	(set_active_ext_lang): Only call install_gdb_sigint_handler,
	check_quit_flag, and set_quit_flag if target_terminal_is_ours
	returns false.
	(restore_active_ext_lang): Likewise.
	* target.c (target_terminal_is_ours): New function.
	* target.h (target_terminal_is_ours): Declare.
2016-01-08 11:06:00 +00:00
Yao Qi 5a0dd67a45 Check input interrupt first when reading packet
Hi,
I see timeout in one of several runs of random-signal.exp like this,

 $ (set -e; while true; do make check RUNTESTFLAGS="--target_board=native-gdbserver random-signal.exp"; done)

In about every five runs, we can see a fail,

PASS: gdb.base/random-signal.exp: continue
^CFAIL: gdb.base/random-signal.exp: stop with control-c (timeout)

after some investigation, I find '\003' may be discarded by GDBserver when
it is expecting '$'.  In GDB side, both normal packets and '\003' are sent
via function send, but GDBserver may receive them at any time, that is to
say, in the receive buffer in GDBserver, '\003' may appear before or after
normal packet.  However, current GDBserver doesn't handle this case.

With this patch applied, I don't see this fail in multiple runs.
Although there is still timeout fail, that is a different problem, the
next patch will fix it.

gdb/gdbserver:

2016-01-08  Yao Qi  <yao.qi@linaro.org>

	* remote-utils.c (getpkt): If c is '\003', call target hook
	request_interrupt.
2016-01-08 11:06:00 +00:00
Maciej W. Rozycki 5dd0563088 MIPS: Complete `status' to `err' renaming in `mips_breakpoint_from_pc'
Complement commit d09f2c3f [target_read_memory&co: no longer return
target_xfer_status] and apply the same change made to the big-endian leg
of the function to the little-endian leg as well.

	gdb/
	* mips-tdep.c (mips_breakpoint_from_pc): Rename local `status'
	to `err' in the little-endian leg.
2016-01-07 19:12:44 +00:00
Yao Qi f5aa306929 Make {arm,thumb}_get_next_pcs_raw static
This patch makes arm_get_next_pcs_raw and thumb_get_next_pcs_raw
static.

gdb:

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

	* arch/arm-get-next-pcs.c (arm_get_next_pcs): Move it to some
	lines below.
	(thumb_get_next_pcs_raw): Make it static.
	(arm_get_next_pcs_raw): Likewise.
	* arch/arm-get-next-pcs.h (thumb_get_next_pcs_raw): Remove the
	declaration.
	(arm_get_next_pcs_raw): Likewise.
2016-01-06 15:03:41 +00:00
Yao Qi b2ca446f68 [ARM/AArch64] Fix -Werror=unused-const-variable warnings in GDBserver
This patch fixes gcc warning when build ARM GDBserver and AArch64
GDBserver,

AArch64 GDBserver:

gdb/gdbserver/linux-aarch32-low.h:36:29: error: 'thumb2_breakpoint' defined but not used [-Werror=unused-const-variable]
 static const unsigned short thumb2_breakpoint[] = { 0xf7f0, 0xa000 };
                             ^
gdb/gdbserver/linux-aarch32-low.h:34:29: error: 'thumb_breakpoint' defined but not used [-Werror=unused-const-variable]
 static const unsigned short thumb_breakpoint = 0xde01;
                             ^
gdb/gdbserver/linux-aarch32-low.h:28:28: error: 'arm_breakpoint' defined but not used [-Werror=unused-const-variable]
 static const unsigned long arm_breakpoint = arm_eabi_breakpoint;
                            ^
cc1: all warnings being treated as errors

ARM GDBserver:

gdb/gdbserver/linux-aarch32-low.h:34:29: error: 'thumb_breakpoint' defined but not used [-Werror=unused-const-variable]
 static const unsigned short thumb_breakpoint = 0xde01;
                             ^~~~~~~~~~~~~~~~

gdb/gdbserver/linux-aarch32-low.h:28:28: error: 'arm_breakpoint' defined but not used [-Werror=unused-const-variable]
 static const unsigned long arm_breakpoint = arm_eabi_breakpoint;
                            ^~~~~~~~~~~~~~

by simply moving these macros and variables to
linux-aarch32-low.c and only declare thumb2_breakpoint in
linux-aarch32-low.h, which is not perfect, and reveals some issues
in recent arm GDBserver software single step changes.  I'll post
follow-up patches.

gdb/gdbserver:

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

	* linux-aarch32-low.h (arm_abi_breakpoint): Move to
	linux-aarch32-low.c.
	(arm_eabi_breakpoint, arm_breakpoint): Likewise.
	(arm_breakpoint_len, thumb_breakpoint_len): Likewise.
	(thumb2_breakpoint, thumb2_breakpoint_len): Likewise.
	(thumb2_breakpoint): Declare.
	* linux-aarch32-low.c (arm_abi_breakpoint): Moved from
	linux-aarch32-low.h.
	(arm_eabi_breakpoint, arm_breakpoint): Likewise.
	(arm_breakpoint_len, thumb_breakpoint_len): Likewise.
	(thumb2_breakpoint, thumb2_breakpoint_len): Likewise.
2016-01-06 15:00:58 +00:00
Pedro Alves 79bc59cb34 Fix gdb.python/py-infthread.exp test message typo
gdb/testsuite/ChangeLog:
2016-01-06  Pedro Alves  <palves@redhat.com>

	* gdb.python/py-infthread.exp: Fix typo.  Expect t0.num to be 1.
2016-01-06 11:31:52 +00:00
Mike Frysinger bf69ad5a18 gdb: change version stamp to git 2016-01-05 23:23:52 -05:00
Mike Frysinger 6675033211 gdb: score: drop sim file check
There has never been a GNU/sim port for the S+Core architecture.
It was added to support private code that has (and most likely
never will) see the light of day [1].  Punt this as we don't do
this for other people.  If you want to maintain a proprietary
internal build, then that's not really our problem.

[1] https://sourceware.org/ml/gdb-patches/2009-03/msg00390.html
2016-01-05 14:46:57 -05:00
Pedro Alves fa89c1268f Add missing ChangeLog entry bit
gdb/ChangeLog:

 	PR sim/13418
	* rs6000-tdep.c (init_sim_regno_table): Check WITH_PPC_SIM instead
	of WITH_SIM.
2016-01-05 11:12:31 +00:00
Pedro Alves 976102cd17 Fix PR sim/13418: building with --enable-targets=all fails
Multitarget builds currently fail when:

 (1) simulator support is enabled (the main --target supports target sim)
 (2) powerpc is included in the --enable-targets list
 (3) powerpc is not the main/default target (--target)

This is because the powerpc sim provides a non-standard API function
sim_spr_register_name which gdb/rs6000-tdep.c utilizes.  Since the sim
does not yet support multitarget, only the sim (if one exists) for the
main target is built.  When that target isn't powerpc, this function
is not available leading to linking errors:

	rs6000-tdep.c:(.text+0x1e34d): undefined reference to
	`sim_spr_register_name'

Fix this by only using that API if the sim linked in is the powerpc
sim.

gdb/ChangeLog:
2016-01-05  Pedro Alves  <palves@redhat.com>

	PR sim/13418
	* configure.ac: Define WITH_PPC_SIM when linking in the sim and
	the target is powerpc*.
	* configure: Regenerate.
	* config.in: Regenerate.
2016-01-05 11:03:40 +00:00
Markus Metzger 43368e1d9a btrace: do not return out of TRY/CATCH
In btrace_pt_readmem_callback, we read memory inside TRY/CATCH and return in
case of an error return value.  This corrupts the cleanup chain, which
eventually results in a SEGV when doing or discarding cleanups later on.

gdb/
	* btrace.c (btrace_pt_readmem_callback): Do not return in TRY/CATCH.

testsuite/
	* gdb.btrace/dlopen.exp: New.
	* gdb.btrace/dlopen.c: New.
	* gdb.btrace/dlopen-dso.c: New.
2016-01-04 09:43:39 +01:00
Mike Frysinger 32273fe68f gdb: ppc: drop unnecessary sim file check
We don't do this for other ppc targets in this file (we assume the sim
subdir exists), and it has existed for over a decade at this point.
2016-01-02 03:40:32 -05:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Joel Brobecker edd8878834 update copyright year printed by GDB, GDBserver and gdbreplay.
gdb/ChangeLog:

        * top.c (print_gdb_version): Change copyright year in version
        message.

gdb/gdbserver/ChangeLog:

        * gdbreplay.c (gdbreplay_version): Change copyright year in
        version message.
        * server.c (gdbserver_version): Likewise.
2016-01-01 08:26:14 +04:00
Joel Brobecker 0f7b3ef4dc Rotate the GDB ChangeLog
Per GDB the "Start of New Year Procedure", this patch
  - renames the current ChangeLog into ChangeLog-2015;
  - starts a new ChangeLog file.

gdb/ChangeLog:

        * config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2015.
2016-01-01 08:19:16 +04:00
Patrick Palka 65da7f144f Use libiberty's crc32 implementation in gdbserver
Tested on x86_64-pc-linux-gnu native-gdbserver, no new regressions.

gdb/gdbserver/ChangeLog:

	* server.c (crc32_table): Delete.
	(crc32): Use libiberty's xcrc32 function.
2015-12-28 11:17:57 -05:00
Sandra Loosemore 79fad5b803 Document that the PATTERN argument to gdb_test is optional.
2015-12-25  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* lib/gdb.exp (gdb_test): Update comments to clarify that the
	PATTERN argument is optional.
2015-12-25 11:36:52 -08:00