Commit Graph

21517 Commits

Author SHA1 Message Date
Tristan Gingold d4ccb5e05c darwin: handle recent version of dyld
gdb/
	* solib-darwin.c (DYLD_VERSION_MAX): Increase value.
	(darwin_solib_create_inferior_hook): Emit a warning if version
	is unhandled.
2014-03-17 14:10:06 +01:00
Ulrich Weigand 49840f2a66 Fix Python 2.4 build break
This fixes a build failure against Python 2.4 by casting away "const"
on the second argument to PyObject_GetAttrString.  Similar casts to
support Python 2.4 were already present in a number of other places.

gdb/
2014-03-16  Ulrich Weigand  <uweigand@de.ibm.com>

	* python/py-value.c (get_field_flag): Cast flag_name argument to
	PyObject_GetAttrString to support Python 2.4.
2014-03-16 15:04:38 +01:00
Jan Kratochvil ed4123e58e Step down from being global maintainer.
gdb/
2014-03-14  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* MAINTAINERS (The Official FSF-appointed GDB Maintainers)
	(Global Maintainers): Remove Jan Kratochvil.
2014-03-14 19:54:08 +01:00
Pedro Alves d6b6434614 Rename native-only terminal related functions.
Looking at target_terminal_inferior etc. in async mode, I realized
that the naming of the terminal_inferior, terminal_ours,
etc. functions doesn't really give a clue that they're meant for the
native target only.  This patch renames them.  There's already
child_terminal_info using the child_ prefix, and, they're most
prominently installed by inf-child.c, so I went with the child_
prefix.  I dropped "inferior" from a couple to make the name match the
corresponding target method.

Tested on x86_64 Fedora 17, and cross built for mingw.  I didn't test
gnu-nat.c, but I think the change is as obvious as it gets.  I grepped
the tree looking for other potential spots that would need adjustment
but this is all I found.  If something breaks, it should be trivial to
fix.

gdb/
2014-03-14  Pedro Alves  <palves@redhat.com>

	* inferior.h (terminal_ours_for_output): Rename to ...
	(child_terminal_ours_for_output): ... this.
	(terminal_save_ours): Rename to ...
	(child_terminal_save_ours): ... this.
	(terminal_ours): Rename to ...
	(child_terminal_ours): ... this.
	(terminal_inferior): Rename to ...
	(child_terminal_inferior): ... this.
	(terminal_init_inferior): Rename to ...
	(child_terminal_init_inferior): ... this.
	(terminal_init_inferior_with_pgrp): Rename to ...
	(child_terminal_init_inferior_with_pgrp): ... this.
	* inflow.c (terminal_init_inferior_with_pgrp): Rename to ...
	(child_terminal_init_with_pgrp): ... this.
	(terminal_save_ours): Rename to ...
	(child_terminal_save_ours): ... this.
	(terminal_init_inferior): Rename to ...
	(child_terminal_init): ... this.  Adjust.
	(terminal_inferior): Rename to ...
	(child_terminal_inferior): ... this.
	(terminal_ours_for_output): Rename to ...
	(child_terminal_ours_for_output): ... this.  Adjust.
	(terminal_ours): Rename to ...
	(child_terminal_ours): ... this.
	(terminal_ours_1): Rename to ...
	(child_terminal_ours_1): ... this.  Adjust.
	* linux-nat.c (linux_nat_terminal_inferior): Adjust.
	* windows-nat.c (do_initial_windows_stuff): Adjust.
	* gnu-nat.c (gnu_terminal_init_inferior): Rename to ...
	(gnu_terminal_init): ... this.  Adjust.
	(gnu_target): Adjust.
	* inf-child.c (inf_child_target): Adjust.
2014-03-14 00:06:45 +00:00
Doug Evans 5a1e8c7a83 Fix pr 16612.
* guile/scm-type.c (tyscm_copy_type_recursive): Move type to its
	new eq?-hashtab.

	testsuite/
	* gdb.guile/scm-value.ep (test_value_after_death): Do a garbage
	collect after discarding symbols.
2014-03-13 09:55:12 -07:00
Doug Evans 350e1a768c Fix segv when referencing a value added to history after a Guile garbage collect.
* value.c (record_latest_value): Call release_value_or_incref
	instead of release_value.

	testsuite/
	* gdb.guile/scm-value.exp (test_value_in_inferior): Verify value added
	to history survives a gc.
2014-03-13 09:24:19 -07:00
Pedro Alves a69900ae4e Rename Solaris's target to "target child" like most other ports.
Note that "target procfs" is used by QNX, but the test must be failing
there, as nto-procfs.c overrides to_open with a method that doesn't
throw the error being tested.  So I'm just removing the test
completely.

gdb/
2014-03-13  Pedro Alves  <palves@redhat.com>

	* procfs.c (procfs_target): Don't override to_shortname,
	to_longname or to_doc.

gdb/testsuite/
2014-03-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/default.exp: Don't test "target procfs".
2014-03-13 12:30:38 +00:00
Pedro Alves 5db9f0bdb5 Don't mention "Unix" in native target name.
I find the mention of "Unix" unnecessary (and really slightly a lie)
on GNU/Linux in a couple of places:

 (gdb) maint print target-stack
 The current target stack is:
  - multi-thread (multi-threaded child process.)
  - child (Unix child process)
  - exec (Local exec file)
  - None (None)

 (gdb) help target child
 Unix child process (started by the "run" command).

 (gdb) target child
 Use the "run" command to start a Unix child process.

It's also odd that e.g., the Windows port says "Unix" in reaction to
"target child" (it was already that way before Windows used
inf-child.c):

 (gdb) target child
 Use the "run" command to start a Unix child process.
 (gdb)

So drop "Unix", going in the direction of saying mostly the same on
all native targets:

  (gdb) maint print target-stack
  The current target stack is:
   - multi-thread (multi-threaded child process.)
 - - child (Unix child process)
 + - child (Child process)
   - exec (Local exec file)
   - None (None)

  (gdb) help target child
 - Unix child process (started by the "run" command).
 + Child process (started by the "run" command).

 (gdb) target child
 -Use the "run" command to start a Unix child process.
 +Use the "run" command to start a child process.

gdb/
2014-03-13  Pedro Alves  <palves@redhat.com>

	* inf-child.c (inf_child_open, inf_child_target): Don't mention
	Unix in user visible strings.

gdb/testsuite/
2014-03-13  Pedro Alves  <palves@redhat.com>

	* gdb.base/default.exp: Update "target child" and "target procfs"
	tests to not expect "Unix".
2014-03-13 12:02:24 +00:00
Stan Shebs 5e3a2c38d7 Doxygenate gdbtypes.h 2014-03-12 19:36:45 -07:00
Pedro Alves 8bc2fe4889 Factor out foreground/background execution command preparation.
All execution commands currently have this pattern:

  /* If we must run in the background, but the target can't do it,
     error out.  */
  if (async_exec && !target_can_async_p ())
    error (_("Asynchronous execution not supported on this target."));

  /* If we are not asked to run in the bg, then prepare to run in the
     foreground, synchronously.  */
  if (!async_exec && target_can_async_p ())
    {
      /* Simulate synchronous execution.  */
      async_disable_stdin ();
    }

This patch factors that into a shared function.

attach_command installs a cleanup to re-enable stdin, but that's not
necessary, as per the comment in prepare_execution_command.  In any
case, if someday it turns out necessary, we have a single place to
install it now.

Tested on x86_64 Fedora 17, sync and async modes.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

	* infcmd.c (prepare_execution_command): New function, factored out
	from several execution commands.
	(run_command_1, continue_command, step_1, jump_command)
	(signal_command, until_command, advance_command, finish_command)
	(attach_command): Use prepare_execution_command.
2014-03-12 20:32:53 +00:00
Omair Javaid 638c5f4962 Support for HWbreak/watchpoint across fork/vfork on arm-native
This patch updates arm native support for hwbreak-/watchpoints to enable
support for hwbreak-/watchpoints across fork/vfork. This involves changes to
hwbreak-/watchpoint insertion mechanism to the modern way, by marking debug
registers as needing update, but only really updating them on resume, which is
necessary for supporting watchpoints in non-stop mode. This also updates a
previously maintained per thread hwbreak-/watchpoint cache to a per process
cache which allows target specific code to come in sync with gdb-linux calls to
threads create/destroy and process fork/exit hooks.
2014-03-13 01:23:55 +05:00
Pedro Alves 6d03af93d2 Make 'make check TESTS="..."' work from GDB's build dir.
I noticed 'make check TESTS="..."' works when ran from gdb/testsuite/,
but TESTS is ignored when "make check" is ran from gdb/.

The issue is that TESTS isn't being passed to the testsuite subdir
make invocation.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

	* Makefile.in (TARGET_FLAGS_TO_PASS): Add TESTS.
2014-03-12 19:52:00 +00:00
Tom Tromey b3ccfe11d3 fix regressions with target-async
A patch in the target cleanup series caused a regression when using
record with target-async.  Version 4 of the patch is here:

    https://sourceware.org/ml/gdb-patches/2014-03/msg00159.html

The immediate problem is that record supplies to_can_async_p and
to_is_async_p methods, but does not supply a to_async method.  So,
when target-async is set, record claims to support async -- but if the
underlying target does not support async, then the to_async method
call will end up in that method's default implementation, namely
tcomplain.

This worked previously because the record target used to provide a
to_async method; one that (erroneously, only at push time) checked the
other members of the target stack, and then simply dropped to_async
calls in the "does not implement async" case.

My first thought was to simply drop tcomplain as the default for
to_async.  This works, but Pedro pointed out that the only reason
record has to supply to_can_async_p and to_is_async_p is that these
default to using the find_default_run_target machinery -- and these
defaults are only needed by "run" and "attach".

So, a nicer solution presents itself: change run and attach to
explicitly call into the default run target when needed; and change
to_is_async_p and to_can_async_p to default to "return 0".  This makes
the target stack simpler to use and lets us remove the method
implementations from record.  This is also in harmony with other plans
for the target stack; namely trying to reduce the impact of
find_default_run_target.  This approach makes it clear that
find_default_is_async_p is not needed -- it is asking whether a target
that may not even be pushed is actually async, which seems like a
nonsensical question.

While an improvement, this approach proved to introduce the same bug
when using the core target.  Looking a bit deeper, the issue is that
code in "attach" and "run" may need to use either the current target
stack or the default run target -- but different calls into the target
API in those functions could wind up querying different targets.

This new patch makes the target to use more explicit in "run" and
"attach".  Then these commands explicitly make the needed calls
against that target.  This ensures that a single target is used for
all relevant operations.  This lets us remove a couple find_default_*
functions from various targets, including the dummy target.  I think
this is a decent understandability improvement.

One issue I see with this patch is that the new calls in "run" and
"attach" are not very much like the rest of the target API.  I think
fundamentally this is due to bad factoring in the target API, which
may need to be fixed for multi-target.  Tackling that seemed ambitious
for a regression fix.

While working on this I noticed that there don't seem to be any test
cases that involve both target-async and record, so this patch changes
break-precsave.exp to add some.  It also changes corefile.exp to add
some target-async tests; these pass with current trunk and with this
patch applied, but fail with the v1 patch.

This patch differs from v4 in that it moves initialization of
to_can_async_p and to_supports_non_stop into inf-child, adds some
assertions to complete_target_initialization, and adds some comments
to target.h.

Built and regtested on x86-64 Fedora 20.

2014-03-12  Tom Tromey  <tromey@redhat.com>

	* inf-child.c (return_zero): New function.
	(inf_child_target): Set to_can_async_p, to_supports_non_stop.
	* aix-thread.c (aix_thread_inferior_created): New function.
	(aix_thread_attach): Remove.
	(init_aix_thread_ops): Don't set to_attach.
	(_initialize_aix_thread): Register inferior_created observer.
	* corelow.c (init_core_ops): Don't set to_attach or
	to_create_inferior.
	* exec.c (init_exec_ops): Don't set to_attach or
	to_create_inferior.
	* infcmd.c (run_command_1): Use find_run_target.  Make direct
	target calls.
	(attach_command): Use find_attach_target.  Make direct target
	calls.
	* record-btrace.c (init_record_btrace_ops): Don't set
	to_create_inferior.
	* record-full.c (record_full_can_async_p, record_full_is_async_p):
	Remove.
	(init_record_full_ops, init_record_full_core_ops): Update.  Don't
	set to_create_inferior.
	* target.c (complete_target_initialization): Add assertion.
	(target_create_inferior): Remove.
	(find_default_attach, find_default_create_inferior): Remove.
	(find_attach_target, find_run_target): New functions.
	(find_default_is_async_p, find_default_can_async_p)
	(target_supports_non_stop, target_attach): Remove.
	(init_dummy_target): Don't set to_create_inferior or
	to_supports_non_stop.
	* target.h (struct target_ops) <to_attach>: Add comment.  Remove
	TARGET_DEFAULT_FUNC.
	<to_create_inferior>: Add comment.
	<to_can_async_p, to_is_async_p, to_supports_non_stop>: Use
	TARGET_DEFAULT_RETURN.
	<to_can_async_p, to_supports_non_stop, to_can_run>: Add comments.
	(find_attach_target, find_run_target): Declare.
	(target_create_inferior): Remove.
	(target_has_execution_1): Update comment.
	(target_supports_non_stop): Remove.
	* target-delegates.c: Rebuild.

2014-03-12  Tom Tromey  <tromey@redhat.com>

	* gdb.base/corefile.exp (corefile_test_run, corefile_test_attach):
	New procs.  Add target-async tests.
	* gdb.reverse/break-precsave.exp (precsave_tests): New proc.
	Add target-async tests.
2014-03-12 13:05:58 -06:00
Pedro Alves 91f83b0228 inf-child.h: Update comment.
Like inf-child.c, this file is no longer used exclusively by Unix
targets anymore.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

        * inf-child.h: Update comment to not mention Unix.
2014-03-12 11:55:02 +00:00
Pedro Alves f1aea813c8 inf-child.c: Update comments.
This file is no longer used exclusively by Unix targets anymore.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

	* inf-child.c: Update top comment to not mention Unix.  Add
	generic comment describing how this target is meant to be used.
	(inf_child_post_attach, inf_child_post_startup_inferior)
	(inf_child_follow_fork, inf_child_pid_to_exec_file): Don't mention
	Unix in comment.
2014-03-12 11:33:59 +00:00
Pedro Alves ee8e9165af Make the nto-procfs.c target inherit inf-child.c.
So that all native targets inherit a single "superclass".

Target methods that are set to or do the same as inf-child.c's are
removed.

Not tested.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

	* nto-procfs.c: Include inf-child.h.
	(procfs_ops): Delete global.
	(procfs_can_run): Delete method.
	(procfs_detach, procfs_mourn_inferior): Unpush the passed in
	target pointer instead of referencing procfs_ops.
	(procfs_prepare_to_store): Delete.
	(init_procfs_ops): Delete function.
	(procfs_target): New function, based on init_procfs_ops, but
	inherit inf_child_target.
	(_initialize_procfs): Use procfs_target.
2014-03-12 11:24:41 +00:00
Pedro Alves 51a9c8c5f8 Make the windows-nat.c target inherit inf-child.c.
So that all native targets inherit a single "superclass".

Target methods that are set to or do the same as inf-child.c's are
removed.

Tested by cross building on Fedora 17, and then confirming that

./gdb.exe ./gdb.exe -ex "set pagination off" -ex "start"

under Wine still works.

Also, Joel tested this with Adacore's internal testsuite.

gdb/
2014-03-12  Pedro Alves  <palves@redhat.com>

	* windows-nat.c: Include inf-child.h.
	(windows_ops): Delete global.
	(windows_open, windows_prepare_to_store, windows_can_run): Delete
	methods.
	(init_windows_ops): Delete function.
	(windows_target): New function, based on init_windows_ops, but
	inherit inf_child_target.
	(_initialize_windows_nat): Use windows_target.  Install x86
	specific target methods here.
2014-03-12 11:21:47 +00:00
Doug Evans c1966e261a * guile/guile.c (call_initialize_gdb_module): New function.
(initialize_guile): Replace call to scm_init_guile with call to
	scm_with_guile.
2014-03-11 00:04:53 -04:00
Joel Brobecker 023db19c6b Missing space before '(' in ada-lang.c::ada_evaluate_subexp
gdb/ChangeLog:

        * ada-lang.c (ada_evaluate_subexp): Add missing space before '('
        in call to TYPE_CODE macro.
2014-03-10 14:46:55 +01:00
Joel Brobecker 8668be63cf Minor style change in the previous commits' ChangeLog entry. 2014-03-10 14:44:30 +01:00
Jerome Guitton 5ec18f2b48 [Ada] Full view of tagged type with ptype
When evaluating an expression, if it is of a tagged type, GDB reads
the tag in memory and deduces the full view. At parsing time, however,
this operation is done only in the case of OP_VAR_VALUE. ptype does
not go through a full evaluation of expressions so it may return some
odd results:

 (gdb) print c.menu_name
 $1 = 0x0
 (gdb) ptype $
 type = system.strings.string_access
 (gdb) ptype c.menu_name
 type = <void>

This change removes this peculiarity by extending the tag resolution
to UNOP_IND and STRUCTOP_STRUCT. As in the case of OP_VAR_VALUE, this
implies switching from EVAL_AVOID_SIDE_EFFECTS to EVAL_NORMAL when a
tagged type is dereferenced.

gdb/
	* ada-lang.c (ada_evaluate_subexp): Resolve tagged types to
	full view in the case of UNOP_IND and STRUCTOP_STRUCT.

gdb/testsuite/

	* gdb.ada/tagged_access: New testcase.
2014-03-10 14:40:35 +01:00
Hui Zhu 7d03f2eb64 Remove "hardware" from comments of "target_insert_breakpoint"
This function is for simple breakpoint.  So I post a patch to remove "hardware".

Thanks,
Hui

2014-03-10  Hui Zhu  <hui@codesourcery.com>

	* target.h (target_insert_breakpoint): Remove "hardware" from its
	comments.
2014-03-10 15:42:26 +08:00
Doug Evans c5164cbc32 * dwarf2read.c (read_str_index): Rename local dwo_name to objf_name. 2014-03-07 17:33:12 -08:00
Doug Evans c4a3fee29d read_cutu_die_from_dwo: Misc minor cleanups.
* dwarf2read.c (read_cutu_die_from_dwo): Fix function comment.
	Remove unused local comp_dir_attr.  Assert exactly one of
	stub_comp_unit_die, stub_comp_dir is non-NULL.
2014-03-07 16:38:26 -08:00
Joel Brobecker 3156469ca8 target.h: Expands complete_target_initialization and add_target comments.
Expand a bit the comments to answer some questions I had when looking
at why a target of mine would not have some default methods set.

gdb/ChangeLog:

        * target.h (complete_target_initialization, add_target):
        Add comment.
2014-03-07 16:26:35 -08:00
Pedro Alves c1a7b7c6f8 Make the go32-nat.c target inherit inf-child.c.
So that all native targets inherit a single "superclass".

Target methods that are set to or do the same as inf-child.c's are
removed.

Tested by cross building on Fedora 17.

gdb/
2014-03-07  Pedro Alves  <palves@redhat.com>

	* go32-nat.c: Include inf-child.h.
	(go32_ops): Delete global.
	(go32_close, go32_detach, go32_prepare_to_store, go32_can_run):
	Delete methods.
	(go32_create_inferior): Push the passed in target pointer instead
	of referencing go32_ops.
	(init_go32_ops): Delete function.  Moved parts to _initialize_go32_nat.
	(go32_target): New function, based on init_go32_ops, but inherit
	inf_child_target.
	(_initialize_go32_nat): Use go32_target.  Move parts of
	init_go32_ops here.
2014-03-07 15:36:50 +00:00
Joel Brobecker d3c1a85fda Fix sol-thread.c build failure.
Some updates where needed after the minimal symbol handling got changed
a little. This patch makes those changes.

gdb/ChangeLog:

        * sol-thread.c: #include "symtab.h", "minsym.h" and "objfiles.h".
        (ps_pglobal_lookup): Use BMSYMBOL_VALUE_ADDRESS instead of
        SYMBOL_VALUE_ADDRESS.
        (info_cb): MSYMBOL_PRINT_NAME instead of SYMBOL_PRINT_NAME.
2014-03-06 08:04:58 -08:00
Yao Qi 5fa1d40e97 Remove argument optional_p from get_tracepoint_by_number
This patch is to remove parameter optional_p as it is always true,
in order to simplify get_tracepoint_by_number.

'optional_p' was added by this change,

1999-11-18  Tom Tromey  <tromey@cygnus.com>

	* tracepoint.h (get_tracepoint_by_number): Updated
	declaration.
	* tracepoint.c (trace_pass_command): Better error message.
	Fixed logic when `all' not specified.
	(get_tracepoint_by_number): Added `optional_p' argument.  Fixed
	all callers.

but after this patch,

 FYI: remove `static's from cli-utils.c
 https://sourceware.org/ml/gdb-patches/2011-03/msg00636.html

'optional_p' passed to get_tracepoint_by_number become always true.

gdb:

2014-03-06  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c (get_tracepoint_by_number): Remove argument
	optional_p.  All callers updated.  Adjust comments.  Update
	output message.
	* breakpoint.h (get_tracepoint_by_number): Update declaration.
2014-03-06 15:03:38 +08:00
Yao Qi 0c13193f33 Handle parse number error in goto_bookmark_command
In GDB mainline, the error message for goto-bookmark
isn't perfect.

 (gdb) goto-bookmark 1.1
 goto-bookmark: no bookmark found for ''.

This patch tweaks the error message by checking the return value of
get_number.  With patch applied, it becomes:

 (gdb) goto-bookmark 1.1
 goto-bookmark: invalid bookmark number '1.1'.

gdb:

2014-03-06  Yao Qi  <yao@codesourcery.com>

	* reverse.c (goto_bookmark_command): Add local 'p'.  Emit error
	early if get_number returns zero.  Use 'p' instead of 'args'.
2014-03-06 15:03:30 +08:00
Yao Qi 2217da06d8 Add a newline in output messages
Hi,
GDB prints two warnings in one single line, as below:

 (gdb) p 1.2
 $1 = 1.2
 (gdb) enable $1.2
 History value must have integer type.Bad breakpoint number '$1'

This patch adds '\n' at the end of message.

gdb:

2014-03-06  Yao Qi  <yao@codesourcery.com>

	* cli/cli-utils.c (get_number_trailer): Add '\n' at the end of
	message.
2014-03-06 14:36:54 +08:00
Yao Qi cc3da68801 Fix PR16508
This patch fixes PR16508, which is about MI "-trace-find frame-number 0"
behaves differently from CLI "tfind 0".  In CLI, we check both
status->running and status->filename, but in MI, we only check
status->running, which looks wrong to me.  This patch moves the code
of checking to a new function check_trace_running, and use it in
both CLI and MI.

This patch also adds a test case pr16508.exp, which fails without this
fix, and passes with the fix applied.

  FAIL: gdb.trace/pr16508.exp: interpreter-exec mi "-trace-find frame-number 0"

gdb:

2014-03-06  Yao Qi  <yao@codesourcery.com>

	PR breakpoints/16508
	* tracepoint.c (check_trace_running): New function.
	(trace_find_command): Move code to check_trace_running and
	call check_trace_running.
	(trace_find_pc_command): Likewise.
	(trace_find_tracepoint_command): Likewise.
	(trace_find_line_command): Likewise.
	(trace_find_range_command): Likewise.
	* tracepoint.h (check_trace_running): Likewise.
	* mi/mi-main.c (mi_cmd_trace_find): Call check_trace_running.

gdb/testsuite:

2014-03-06  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/pr16508.exp: New file.
2014-03-06 11:33:06 +08:00
Yao Qi 6a5f844b29 Change the default implementation of to_traceframe_info to tcomplain
This patch is to change the default implementation of to_traceframe_info
from 'return NULL' to tcomplain, which is intended.  If new target
supports tracepoint, this method should be implemented, otherwise,
an error is thrown.

gdb:

2014-03-06  Yao Qi  <yao@codesourcery.com>

	* target.h (struct target_ops) <to_traceframe_info>: Use
	TARGET_DEFAULT_NORETURN (tcomplain ()).
	* target-delegates.c: Regenerated.
2014-03-06 09:39:50 +08:00
Pedro Alves 0f26cec1fd PR gdb/16575: stale breakpoint instructions in the code cache
In non-stop mode, or rather, breakpoints always-inserted mode, the
code cache can easily end up with stale breakpoint instructions:

All it takes is filling a cache line when breakpoints already exist in
that memory region, and then delete the breakpoint.

Vis. (from the new test):

 (gdb) set breakpoint always-inserted on
 (gdb) b 23
 Breakpoint 2 at 0x400540: file ../../../src/gdb/testsuite/gdb.base/breakpoint-shadow.c, line 23.
 (gdb) b 24
 Breakpoint 3 at 0x400547: file ../../../src/gdb/testsuite/gdb.base/breakpoint-shadow.c, line 24.
 disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     movl   $0x1,-0x4(%rbp)
    0x0000000000400547 <+11>:    movl   $0x2,-0x4(%rbp)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.

So far so good.  Now flush the code cache:

 (gdb) set code-cache off
 (gdb) set code-cache on

Requesting a disassembly works as expected, breakpoint shadowing is
applied:

 (gdb) disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     movl   $0x1,-0x4(%rbp)
    0x0000000000400547 <+11>:    movl   $0x2,-0x4(%rbp)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.

However, now delete the breakpoints:

 (gdb) delete
 Delete all breakpoints? (y or n) y

And disassembly shows the old breakpoint instructions:

 (gdb) disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     int3
    0x0000000000400541 <+5>:     rex.RB cld
    0x0000000000400543 <+7>:     add    %eax,(%rax)
    0x0000000000400545 <+9>:     add    %al,(%rax)
    0x0000000000400547 <+11>:    int3
    0x0000000000400548 <+12>:    rex.RB cld
    0x000000000040054a <+14>:    add    (%rax),%al
    0x000000000040054c <+16>:    add    %al,(%rax)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.

Those breakpoint instructions are no longer installed in target memory
they're stale in the code cache.  Easily confirmed by just disabling
the code cache:

 (gdb) set code-cache off
 (gdb) disass main
 Dump of assembler code for function main:
    0x000000000040053c <+0>:     push   %rbp
    0x000000000040053d <+1>:     mov    %rsp,%rbp
 => 0x0000000000400540 <+4>:     movl   $0x1,-0x4(%rbp)
    0x0000000000400547 <+11>:    movl   $0x2,-0x4(%rbp)
    0x000000000040054e <+18>:    mov    $0x0,%eax
    0x0000000000400553 <+23>:    pop    %rbp
    0x0000000000400554 <+24>:    retq
 End of assembler dump.


I stumbled upon this when writing a patch to infrun.c, that made
handle_inferior_event & co fill in the cache before breakpoints were
removed from the target.  Recall that wait_for_inferior flushes the
dcache for every event.  So in that case, always-inserted mode was not
necessary to trigger this.  It's just a convenient way to expose the
issue.

The dcache works at the raw memory level.  We need to update it
whenever memory is written, no matter what kind of target memory
object was originally passed down by the caller.  The issue is that
the dcache update code isn't reached when a caller explicitly writes
raw memory.  Breakpoint insertion/removal is one such case --
mem-break.c uses target_write_read_memory/target_write_raw_memory.

The fix is to move the dcache update code from memory_xfer_partial_1
to raw_memory_xfer_partial so that it's always reachable.

When we do that, we can actually simplify a series of things.
memory_xfer_partial_1 no longer needs to handle writes for any kind of
memory object, and therefore dcache_xfer_memory no longer needs to
handle writes either.  So the latter (dcache_xfer_memory) and its
callees can be simplified to only care about reads.  While we're
touching dcache_xfer_memory's prototype, might as well rename it to
reflect that fact that it only handles reads, and make it follow the
new target_xfer_status/xfered_len style.  This made me notice that
dcache_xfer_memory loses the real error status if a memory read fails:
we could have failed to read due to TARGET_XFER_E_UNAVAILABLE, for
instance, but we always return TARGET_XFER_E_IO, hence the FIXME note.
I felt that fixing that fell out of the scope of this patch.

Currently dcache_xfer_memory handles the case of a write failing.  The
whole cache line is invalidated when that happens.  However,
dcache_update, the sole mechanism for handling writes that will remain
after the patch, does not presently handle that scenario.  That's a
bug.  The patch makes it handle that, by passing down the
target_xfer_status status from the caller, so that it can better
decide what to do itself.  While I was changing the function's
prototype, I constified the myaddr parameter, getting rid of the need
for the cast as seen in its existing caller.

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/
2014-03-05  Pedro Alves  <palves@redhat.com>

	PR gdb/16575
	* dcache.c (dcache_poke_byte): Constify ptr parameter.  Return
	void.  Update comment.
	(dcache_xfer_memory): Delete.
	(dcache_read_memory_partial): New, based on the read bits of
	dcache_xfer_memory.
	(dcache_update): Add status parameter.  Use ULONGEST for len, and
	adjust.  Discard cache lines if the reason for the update was
	error.
	* dcache.h (dcache_xfer_memory): Delete declaration.
	(dcache_read_memory_partial): New declaration.
	(dcache_update): Update prototype.
	* target.c (raw_memory_xfer_partial): Update the dcache here.
	(memory_xfer_partial_1): Don't handle dcache writes here.

gdb/testsuite/
2014-03-05  Pedro Alves  <palves@redhat.com>

	PR gdb/16575
	* gdb.base/breakpoint-shadow.exp (compare_disassembly): New
	procedure.
	(top level): Adjust to use it.  Add tests that exercise breakpoint
	interaction with the code-cache.
2014-03-05 14:18:28 +00:00
Mike Frysinger b2b255bdf3 sim: constify prog_name
There's no need for the prog_name handed down to the core to be mutable,
so add const markings to it and all the related funcs.
2014-03-05 01:42:44 -05:00
Tom Tromey 5d9cf8a4d3 move probes to be per-bfd
This patch moves the probe data from the objfile to the per-BFD
object.  This lets the probes be shared between different inferiors
(and different objfiles when dlmopen is in use, should gdb ever handle
that).

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* elfread.c (probe_key): Change to bfd_data.
	(elf_get_probes, probe_key_free, _initialize_elfread): Probes are
	now per-BFD, not per-objfile.
	* stap-probe.c (stap_probe_destroy): Update comment.
	(handle_stap_probe): Allocate on the per-BFD obstack.
2014-03-03 12:47:25 -07:00
Tom Tromey 729662a522 change probes to be program-space-independent
This changes the probes to be independent of the program space.

After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.

This introduces a bound_probe object, similar to bound minimal
symbols.  Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.

This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.

This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address.  Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
	* breakpoint.c (create_longjmp_master_breakpoint): Use
	get_probe_address.
	(add_location_to_breakpoint, bkpt_probe_insert_location)
	(bkpt_probe_remove_location): Update.
	* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
	* elfread.c (elf_symfile_relocate_probe): Remove.
	(elf_probe_fns): Update.
	(insert_exception_resume_breakpoint): Change type of "probe"
	parameter to bound_probe.
	(check_exception_resume): Update.
	* objfiles.c (objfile_relocate1): Don't relocate probes.
	* probe.c (bound_probe_s): New typedef.
	(parse_probes): Use get_probe_address.  Set sal's objfile.
	(find_probe_by_pc): Return a bound_probe.
	(collect_probes): Return a VEC(bound_probe_s).
	(compare_probes): Update.
	(gen_ui_out_table_header_info): Change type of "probes"
	parameter.  Update.
	(info_probes_for_ops): Update.
	(get_probe_address): New function.
	(probe_safe_evaluate_at_pc): Update.
	* probe.h (struct probe_ops) <get_probe_address>: New field.
	<set_semaphore, clear_semaphore>: Add objfile parameter.
	(struct probe) <objfile>: Remove field.
	<arch>: New field.
	<address>: Update comment.
	(struct bound_probe): New.
	(find_probe_by_pc): Return a bound_probe.
	(get_probe_address): Declare.
	* solib-svr4.c (struct probe_and_action) <address>: New field.
	(hash_probe_and_action, equal_probe_and_action): Update.
	(register_solib_event_probe): Add address parameter.
	(solib_event_probe_at): Update.
	(svr4_create_probe_breakpoints): Add objfile parameter.  Use
	get_probe_address.
	* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
	(stap_get_probe_address): New function.
	(stap_can_evaluate_probe_arguments, compute_probe_arg)
	(compile_probe_arg): Update.
	(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
	address.
	(handle_stap_probe): Don't relocate the probe.
	(stap_relocate): Remove.
	(stap_gen_info_probes_table_values): Update.
	(stap_probe_ops): Remove stap_relocate.
	* symfile-debug.c (debug_sym_relocate_probe): Remove.
	(debug_sym_probe_fns): Update.
	* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
	* symtab.c (init_sal): Use memset.
	* symtab.h (struct symtab_and_line) <objfile>: New field.
	* tracepoint.c (start_tracing, stop_tracing): Update.
2014-03-03 12:47:20 -07:00
Tom Tromey ff8879201a comment fixes
This fixes up a few mildly erroneous comments in probe.h.

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* probe.h (parse_probes, find_probe_by_pc)
	(find_probes_in_objfile): Fix comments.
2014-03-03 12:36:43 -07:00
Doug Evans f0407826d9 * infrun.c (handle_signal_stop): Replace test for
TARGET_WAITKIND_STOPPED with an assert.
2014-03-02 16:51:35 -05:00
Doug Evans 35e6a7111e guile/scm-objfile.c (ofscm_mark_objfile_smob): Fix typo in comment. 2014-03-02 10:30:46 -08:00
Doug Evans 667f9d0bdd guile/lib/gdb/printing.scm (append-pretty-printer!): Fix thinko. 2014-03-02 09:17:46 -08:00
Mark Kettenis dc92ace053 Silence ARI warning.
gdb/ChangeLog:

        * obsd-nat.c: Include "gdb_wait.h" instead of <sys/wait.h>.
2014-03-01 17:13:47 +01:00
Mark Kettenis a900370fa1 Enable rhreads support on OpenBSD/i386.
gdb/ChangeLog:

        * i386obsd-nat.c: Include "obsd-nat.h".
        (_initialize_i386obsd_nat): Call obsd_add_target instead of
        add_target.
        * config/i386/obsd.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01 15:29:34 +01:00
Mark Kettenis b72a79813d Eliminate pointer signedness warning.
gdb/ChangeLog:

        * i386obsd-nat.c (i386obsd_supply_pcb): Cast 'sf' to 'gdb_byte *'.
2014-03-01 13:10:32 +01:00
Mark Kettenis 8fd408f130 Fix ChangeLog. 2014-03-01 12:03:30 +01:00
Mark Kettenis 96c70abaef Enable rthreads support on OpenBSD/mips64.
gdb/ChangeLog:

        * mips64obsd-nat.c: Include "obsd-nath".
        (_initialize_mips64obsd_nat): Call obsd_add_target instead of
        add_target
        * config/mips/obsd64.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01 12:00:19 +01:00
Mark Kettenis 874a80af9f Enable rthreads support on OpenBSD/amd64.
gdb/ChangeLog:

        * amd64obsd-nat.c (_initialize_amd64obsd_nat): Call
        obsd_add_target instead of add_target.
        * config/i386/obsd64.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01 11:49:58 +01:00
Siva Chandra 9cf953733a Remove the unnecesary argument METHOD to valops.c:find_oload_champ.
* valops.c (find_oload_champ): Remove unneccesary argument METHOD.
	(find_overload_match): Update call to find_oload_champ.
	(find_oload_champ_namespace_loop): Likewise
2014-02-28 15:03:22 -08:00
Mark Kettenis 025cac40e2 Add sparc64obsd-nat.c to ALLDEPFILES.
gdb/ChangeLog:

        * Makefile.in (ALLDEPFILES): Add sparc64obsd-nat.c.
2014-02-28 23:23:40 +01:00
Mark Kettenis 1ed586ce1d Enable rthreads supports on OpenBSD/sparc64.
gdb/ChangeLog:

        * configure.host (sparc64-*-openbsd*): Set gdb_host to obsd64.
        * config/sparc/obsd64.mh: New file.
        * sparc64obsd-nat.c: New file.
2014-02-28 23:07:55 +01:00
Mark Kettenis 863e4da4b6 Support rthreads on OpenBSD 5.2 and later.
OpenBSD 5.2 and later have a proper threads implementation based on
kernel threads.  Debugging support is provided through additional
ptrace(2) requests, so this diff extends the generic code in
inf-ptrace.c with OpenBSD-specific code to discover additional threads.

gdb/ChangeLog:

        * obsd-nat.h: New file.
        * obsd-nat.c: New file.
        * Makefile.in (HFILES_NO_SRCDIR): Add obsd-nat.h.
        (ALLDEPFILES): Add obsd-nat.c.
2014-02-28 22:45:51 +01:00